mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-25 03:34:05 +00:00
asset editor: added toolbar
This commit is contained in:
parent
c0eec49206
commit
60e527287e
@ -53,41 +53,17 @@ typedef enum { SND_START, SND_HIT, SND_COIN, SND_JUMP } SFXIndex;
|
|||||||
|
|
||||||
///// CHARS
|
///// CHARS
|
||||||
|
|
||||||
const byte CHAR_TABLE[8][8] = {
|
|
||||||
/*{w:8,h:8,brev:1,count:8}*/
|
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
|
||||||
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
|
|
||||||
{0xFF,0xBF,0xBF,0x00,0xFF,0xFB,0xFB,0x00},
|
|
||||||
{0x81,0xFF,0x81,0x81,0x81,0xFF,0x81,0x81},
|
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
|
||||||
};
|
|
||||||
|
|
||||||
const byte static_sprite_table[2][16*2] = {
|
|
||||||
/*{w:16,h:16,brev:1,remap:[4,0,1,2,3,5,6,7,8,9],count:4}*/
|
|
||||||
{
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x3F,
|
|
||||||
0x35, 0x2A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3F,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x40, 0xFC,
|
|
||||||
0x54, 0xAC, 0x04, 0x04, 0x04, 0x04, 0x04, 0xFC,
|
|
||||||
},{
|
|
||||||
0x00, 0x19, 0x1F, 0x0A, 0x05, 0x07, 0x0E, 0x1C,
|
|
||||||
0x3A, 0x2A, 0x3C, 0x2E, 0x1E, 0x18, 0x0E, 0x07,
|
|
||||||
0x00, 0x80, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0x38,
|
|
||||||
0xFC, 0xF4, 0x7C, 0xB4, 0xB8, 0x68, 0xF0, 0xE0,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const byte ITEM_CHARS[3][4] = {
|
const byte ITEM_CHARS[3][4] = {
|
||||||
{ 0xe9,0xe9,0x5f,0x69 },
|
{ 0xe9,0xe9,0x5f,0x69 },
|
||||||
{ 0x7f,0x7f,0x7f,0x7f },
|
{ 0x55,0x49,0x4a,0x4b },
|
||||||
{ 0x7f,0x7f,0x7f,0x7f },
|
{ 0x7f,0x7f,0x7f,0x7f },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*{w:12,h:21,bpp:2,brev:1,count:5,aspect:2}*/
|
#define NUM_SPRITE_PATTERNS 13
|
||||||
const char SPRITE_DATA[5][3*21] = {
|
|
||||||
|
/*{w:12,h:21,bpp:2,brev:1,count:13,aspect:2}*/
|
||||||
|
const char SPRITE_DATA[NUM_SPRITE_PATTERNS][3*21] = {
|
||||||
|
// left direction
|
||||||
{
|
{
|
||||||
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xEA,0x00,
|
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xEA,0x00,
|
||||||
0x02,0xEA,0x00,0x02,0xEA,0x00,0x02,0xEA,0x00,
|
0x02,0xEA,0x00,0x02,0xEA,0x00,0x02,0xEA,0x00,
|
||||||
@ -116,13 +92,13 @@ const char SPRITE_DATA[5][3*21] = {
|
|||||||
0x0A,0x02,0x94,0x15,0x00,0x94,0x15,0x00,0x04
|
0x0A,0x02,0x94,0x15,0x00,0x94,0x15,0x00,0x04
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xFE,0x00,
|
0x00,0x00,0x00,0x00,0x2A,0x00,0x00,0xBF,0x80,
|
||||||
0x02,0xBA,0x00,0x02,0xBA,0x00,0x02,0xBA,0x00,
|
0x00,0xAE,0x80,0x00,0xAE,0x80,0x00,0xAE,0x80,
|
||||||
0x00,0xA8,0x00,0x00,0x54,0x08,0x82,0xAA,0xA8,
|
0x00,0x2A,0x00,0x00,0x15,0x02,0x20,0xAA,0xAA,
|
||||||
0xAA,0xFE,0xA0,0x2A,0xAA,0x80,0x0A,0xFE,0x00,
|
0x2A,0xBF,0xA8,0x0A,0xAA,0xA0,0x02,0xBF,0x80,
|
||||||
0x02,0xAA,0x00,0x03,0xFF,0x00,0x02,0xAA,0x00,
|
0x00,0xAA,0x80,0x00,0xFF,0xC0,0x00,0xAA,0x80,
|
||||||
0x02,0xAA,0x00,0x0A,0x8A,0x80,0x0A,0x02,0x80,
|
0x00,0xAA,0x80,0x02,0xA2,0xA0,0x02,0x80,0xA0,
|
||||||
0x0A,0x02,0x80,0x05,0x01,0x40,0x15,0x01,0x50
|
0x02,0x80,0xA0,0x01,0x40,0x50,0x05,0x40,0x54
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xEA,0x00,
|
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xEA,0x00,
|
||||||
@ -133,11 +109,82 @@ const char SPRITE_DATA[5][3*21] = {
|
|||||||
0x00,0xA2,0x00,0x00,0xA8,0x80,0x00,0x2A,0x80,
|
0x00,0xA2,0x00,0x00,0xA8,0x80,0x00,0x2A,0x80,
|
||||||
0x02,0x8A,0x90,0x01,0x40,0x50,0x05,0x41,0x40
|
0x02,0x8A,0x90,0x01,0x40,0x50,0x05,0x41,0x40
|
||||||
},
|
},
|
||||||
|
// right direction
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x2A,0x00,0x00,0xAB,0x80,
|
||||||
|
0x00,0xAB,0x80,0x00,0xAB,0x80,0x00,0xAB,0x80,
|
||||||
|
0x05,0x2A,0x00,0x05,0x54,0x00,0x05,0xAA,0x00,
|
||||||
|
0x05,0xAA,0x00,0x05,0xAA,0x00,0x05,0xAA,0xA0,
|
||||||
|
0x05,0xAA,0x80,0x00,0xFF,0x00,0x00,0xAA,0x00,
|
||||||
|
0x00,0xAA,0x00,0x02,0x8A,0x00,0x02,0x8A,0x00,
|
||||||
|
0x02,0x88,0x00,0x01,0x45,0x40,0x01,0x45,0x40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0xAA,0x00,
|
||||||
|
0x02,0xAA,0x00,0x02,0xAA,0x20,0x02,0xAA,0x20,
|
||||||
|
0x00,0xA8,0x20,0x00,0x54,0xA0,0x0A,0x56,0xA0,
|
||||||
|
0x2A,0x56,0x80,0x2A,0x56,0x00,0x22,0x56,0x00,
|
||||||
|
0x22,0x56,0x00,0x23,0xFF,0x00,0x02,0xAA,0x00,
|
||||||
|
0x02,0x8A,0x00,0x02,0x8A,0x00,0x02,0x85,0x00,
|
||||||
|
0x02,0x85,0x40,0x01,0x40,0x00,0x05,0x40,0x00
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x2A,0x00,0x00,0xAB,0x80,
|
||||||
|
0x00,0xAB,0x80,0x00,0xAB,0x80,0x00,0xAB,0x80,
|
||||||
|
0x05,0x2A,0x00,0x05,0x54,0x00,0x05,0xAA,0x00,
|
||||||
|
0x05,0xAA,0x08,0x05,0xAA,0xA8,0x05,0xAA,0xA0,
|
||||||
|
0x05,0xAA,0x00,0x00,0xFF,0x00,0x00,0xAA,0x00,
|
||||||
|
0x00,0xAA,0x00,0x02,0x8A,0xA0,0x16,0x8A,0xA0,
|
||||||
|
0x16,0x80,0xA0,0x16,0x00,0x54,0x10,0x00,0x54
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x2A,0x00,0x00,0xBF,0x80,
|
||||||
|
0x00,0xAE,0x80,0x00,0xAE,0x80,0x00,0xAE,0x80,
|
||||||
|
0x00,0x2A,0x00,0x20,0x15,0x00,0x2A,0xAA,0x82,
|
||||||
|
0x0A,0xBF,0xAA,0x02,0xAA,0xA8,0x00,0xBF,0xA0,
|
||||||
|
0x00,0xAA,0x80,0x00,0xFF,0xC0,0x00,0xAA,0x80,
|
||||||
|
0x00,0xAA,0x80,0x02,0xA2,0xA0,0x02,0x80,0xA0,
|
||||||
|
0x02,0x80,0xA0,0x01,0x40,0x50,0x05,0x40,0x54
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x2A,0x00,0x00,0xAB,0x80,
|
||||||
|
0x00,0xAB,0x80,0x00,0xAB,0x80,0x00,0xAB,0x80,
|
||||||
|
0x05,0x2A,0x00,0x05,0x54,0x00,0x05,0xAA,0x00,
|
||||||
|
0x06,0xAA,0x20,0x0A,0xAA,0xA0,0x09,0xAA,0x80,
|
||||||
|
0x05,0xAA,0x00,0x00,0xFF,0x00,0x00,0xAA,0x00,
|
||||||
|
0x00,0x8A,0x00,0x02,0x2A,0x00,0x02,0xA8,0x00,
|
||||||
|
0x06,0xA2,0x80,0x05,0x01,0x40,0x01,0x41,0x50
|
||||||
|
},
|
||||||
|
// explosion
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,
|
||||||
|
0x00,0x20,0x00,0x08,0x20,0x80,0x02,0x02,0x00,
|
||||||
|
0x00,0x10,0x00,0x00,0x54,0x00,0x00,0x10,0x00,
|
||||||
|
0x02,0x02,0x00,0x08,0x20,0x80,0x00,0x20,0x00,
|
||||||
|
0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0x02,0x00,
|
||||||
|
0x08,0x00,0x80,0x20,0x00,0x20,0x20,0x54,0x20,
|
||||||
|
0x21,0x01,0x20,0x21,0x01,0x20,0x21,0x01,0x20,
|
||||||
|
0x20,0x54,0x20,0x20,0x00,0xA0,0x08,0x00,0x80,
|
||||||
|
0x02,0x02,0x00,0x00,0xA8,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0xA8,0x00,0x02,0x02,0x00,
|
||||||
|
0x08,0x10,0x80,0x08,0x54,0x80,0x08,0x10,0x80,
|
||||||
|
0x02,0x02,0x00,0x00,0xA8,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_SPRITE_PATTERNS 5
|
|
||||||
#define NUM_SPRITE_STATES 4
|
|
||||||
|
|
||||||
///// GLOBALS
|
///// GLOBALS
|
||||||
|
|
||||||
// random byte between (a ... b-1)
|
// random byte between (a ... b-1)
|
||||||
@ -230,7 +277,7 @@ void scroll_draw_row(byte row) {
|
|||||||
byte row_height; // rows above bottom of level
|
byte row_height; // rows above bottom of level
|
||||||
// set screen/color buffer addresses
|
// set screen/color buffer addresses
|
||||||
buf = hidbuf + row*COLS;
|
buf = hidbuf + row*COLS;
|
||||||
attrs = tempbuf + row*COLS;
|
attrs = colorbuf + row*COLS;
|
||||||
row_height = -(row + origin_y);
|
row_height = -(row + origin_y);
|
||||||
// loop over all floors
|
// loop over all floors
|
||||||
for (floor=0; floor<MAX_FLOORS; floor++) {
|
for (floor=0; floor<MAX_FLOORS; floor++) {
|
||||||
@ -292,7 +339,6 @@ void scroll_draw_row(byte row) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create actors on this floor, if needed
|
// create actors on this floor, if needed
|
||||||
// TODO: maybe this happens too early?
|
|
||||||
if (dy == 0 && (floor >= 2)) {
|
if (dy == 0 && (floor >= 2)) {
|
||||||
create_actors_on_floor(floor);
|
create_actors_on_floor(floor);
|
||||||
}
|
}
|
||||||
@ -313,6 +359,40 @@ void draw_entire_stage() {
|
|||||||
swap_needed = true;
|
swap_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// y = (256 - origin_y) - floor
|
||||||
|
void refresh_floor(byte floor) {
|
||||||
|
byte row = floors[floor].ypos; // get floor bottom coordinate
|
||||||
|
row = -origin_y - row;
|
||||||
|
scroll_draw_row(row-1); // redraw 2rd line
|
||||||
|
scroll_draw_row(row-2); // redraw 3th line
|
||||||
|
swap_needed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPLOSION
|
||||||
|
|
||||||
|
byte explode_timer = 0;
|
||||||
|
|
||||||
|
#define SPRITE_XPLODE 7
|
||||||
|
#define SHAPE_XPLODE0 (32+10)
|
||||||
|
#define NUM_XPLODE_SHAPES 3
|
||||||
|
|
||||||
|
void explode(int x, byte y) {
|
||||||
|
sprite_draw(SPRITE_XPLODE, x, y, SHAPE_XPLODE0+NUM_XPLODE_SHAPES-1);
|
||||||
|
sprshad.spr_color[SPRITE_XPLODE] = 10;
|
||||||
|
explode_timer = NUM_XPLODE_SHAPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
void animate_explosion(void) {
|
||||||
|
if (explode_timer) {
|
||||||
|
if (--explode_timer == 0) {
|
||||||
|
sprshad.spr_ena &= ~(1 << SPRITE_XPLODE);
|
||||||
|
} else {
|
||||||
|
sprshad.spr_ena |= (1 << SPRITE_XPLODE);
|
||||||
|
sprshad.spr_shapes[SPRITE_XPLODE] = SHAPE_XPLODE0-1+explode_timer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ACTORS
|
// ACTORS
|
||||||
|
|
||||||
word get_floor_yy(byte level) {
|
word get_floor_yy(byte level) {
|
||||||
@ -376,11 +456,11 @@ void draw_actor(byte i) {
|
|||||||
case WALKING:
|
case WALKING:
|
||||||
name += (a->x & 4);
|
name += (a->x & 4);
|
||||||
case JUMPING:
|
case JUMPING:
|
||||||
case FALLING:
|
if (!a->dir) name += 5;
|
||||||
//name = a->dir ? 16*4 : 0;
|
|
||||||
break;
|
break;
|
||||||
|
case FALLING:
|
||||||
case CLIMBING:
|
case CLIMBING:
|
||||||
//name += (a->yy & 4) ? 16*4 : 0;
|
if (a->yy & 4) name += 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sprite_draw(i, a->x + XOFS, screen_y, name);
|
sprite_draw(i, a->x + XOFS, screen_y, name);
|
||||||
@ -394,6 +474,7 @@ void refresh_actors() {
|
|||||||
sprite_clear();
|
sprite_clear();
|
||||||
for (i=0; i<MAX_ACTORS; i++)
|
for (i=0; i<MAX_ACTORS; i++)
|
||||||
draw_actor(i);
|
draw_actor(i);
|
||||||
|
animate_explosion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh_screen() {
|
void refresh_screen() {
|
||||||
@ -438,7 +519,8 @@ void check_scroll_up() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void check_scroll_down() {
|
void check_scroll_down() {
|
||||||
if (sprshad.spr_pos[0].y > BOTTOM_Y/2+32 && origin_y < START_ORIGIN_Y) {
|
if (sprshad.spr_pos[0].y > BOTTOM_Y/2+32
|
||||||
|
&& (origin_y < START_ORIGIN_Y || scroll_fine_y)) {
|
||||||
scroll_vert(-1);
|
scroll_vert(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,14 +610,30 @@ void move_actor(struct Actor* actor, byte joystick, bool scroll) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// should we pickup an object? only player does this
|
||||||
void pickup_object(Actor* actor) {
|
void pickup_object(Actor* actor) {
|
||||||
Floor* level = &floors[actor->level];
|
Floor* floor = &floors[actor->level];
|
||||||
byte objtype = level->objtype;
|
byte objtype = floor->objtype;
|
||||||
if (objtype && actor->state == WALKING) {
|
// only pick up if there's an object, and if we're walking or standing
|
||||||
byte objx = level->objpos * 16 + 16 - XOFS;
|
if (objtype && actor->state <= WALKING) {
|
||||||
|
byte objx = floor->objpos * 16 + 16 - XOFS;
|
||||||
|
// is the actor close to the object?
|
||||||
if (actor->x >= objx && actor->x < objx+16) {
|
if (actor->x >= objx && actor->x < objx+16) {
|
||||||
level->objtype = 0;
|
// clear the item from the floor and redraw
|
||||||
refresh_screen();
|
floor->objtype = 0;
|
||||||
|
refresh_floor(actor->level);
|
||||||
|
// show explosion
|
||||||
|
explode(objx + XOFS, yscroll - actor->yy);
|
||||||
|
// did we hit a mine?
|
||||||
|
if (objtype == ITEM_MINE) {
|
||||||
|
// we hit a mine, fall down
|
||||||
|
fall_down(actor);
|
||||||
|
//sfx_play(SND_HIT,0);
|
||||||
|
} else {
|
||||||
|
// we picked up an object, add to score
|
||||||
|
//score = bcd_add(score, 1);
|
||||||
|
//sfx_play(SND_COIN,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,8 +655,9 @@ bool check_collision(Actor* a) {
|
|||||||
// actors must be on same level
|
// actors must be on same level
|
||||||
// no need to apply XOFS because both sprites are offset
|
// no need to apply XOFS because both sprites are offset
|
||||||
if (a->level == b->level &&
|
if (a->level == b->level &&
|
||||||
iabs(a->yy - b->yy) < 8 &&
|
b->onscreen &&
|
||||||
iabs(a->x - b->x) < 8) {
|
iabs(a->yy - b->yy) < 16 &&
|
||||||
|
iabs(a->x - b->x) < 16) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,18 +666,6 @@ bool check_collision(Actor* a) {
|
|||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
void preview_stage() {
|
|
||||||
/*
|
|
||||||
scroll_y = floors[MAX_LEVELS-1].ypos;
|
|
||||||
while (scroll_y > 0) {
|
|
||||||
wait_vblank();
|
|
||||||
refresh_screen();
|
|
||||||
refresh_actors();
|
|
||||||
scroll_y--;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_blimp(struct cvu_sprite* sprite) {
|
void draw_blimp(struct cvu_sprite* sprite) {
|
||||||
/*
|
/*
|
||||||
sprite->name = 48;
|
sprite->name = 48;
|
||||||
@ -647,6 +734,7 @@ void play_scene() {
|
|||||||
fall_down(&actors[0]);
|
fall_down(&actors[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (swap_needed) sprite_update(hidbuf);
|
||||||
wait_vblank();
|
wait_vblank();
|
||||||
scroll_update();
|
scroll_update();
|
||||||
sprite_update(visbuf);
|
sprite_update(visbuf);
|
||||||
@ -655,8 +743,6 @@ void play_scene() {
|
|||||||
blimp_pickup_scene();
|
blimp_pickup_scene();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MAIN
|
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
byte i;
|
byte i;
|
||||||
@ -665,25 +751,22 @@ void main() {
|
|||||||
scroll_setup();
|
scroll_setup();
|
||||||
// set up sprites
|
// set up sprites
|
||||||
sprite_clear();
|
sprite_clear();
|
||||||
for (i=0; i<5; i++) {
|
for (i=0; i<NUM_SPRITE_PATTERNS; i++) {
|
||||||
sprite_shape(hidbuf, 32+i, SPRITE_DATA[i]);
|
sprite_shape(hidbuf, 32+i, SPRITE_DATA[i]);
|
||||||
}
|
}
|
||||||
sprshad.spr_mcolor = 0xff;
|
sprshad.spr_mcolor = 0xff;
|
||||||
sprshad.spr_mcolor0 = 0x0f;
|
sprshad.spr_mcolor0 = 0x0f;
|
||||||
sprshad.spr_mcolor1 = 0x00;
|
sprshad.spr_mcolor1 = 0x00;
|
||||||
// set up character set
|
// select character set 2
|
||||||
VIC.addr = 0x15;
|
VIC.addr = 0x15;
|
||||||
// start scrolling @ bottom of level
|
// start scrolling @ bottom of level
|
||||||
origin_y = START_ORIGIN_Y;
|
origin_y = START_ORIGIN_Y;
|
||||||
|
// install joystick
|
||||||
joy_install (joy_static_stddrv);
|
joy_install (joy_static_stddrv);
|
||||||
|
// main game loop
|
||||||
|
while (1) {
|
||||||
make_floors();
|
make_floors();
|
||||||
draw_entire_stage();
|
draw_entire_stage();
|
||||||
play_scene();
|
play_scene();
|
||||||
/*
|
|
||||||
while (1) {
|
|
||||||
scroll_vert(2);
|
|
||||||
scroll_update_regs();
|
|
||||||
wait_vblank();
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
144
presets/c64/multilines.c
Normal file
144
presets/c64/multilines.c
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <c64.h>
|
||||||
|
#include <peekpoke.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
//#link "common.c"
|
||||||
|
|
||||||
|
void setup_bitmap_multi() {
|
||||||
|
VIC.ctrl1 = 0x38;
|
||||||
|
VIC.ctrl2 = 0x18;
|
||||||
|
// set VIC bank ($4000-$7FFF)
|
||||||
|
// https://www.c64-wiki.com/wiki/VIC_bank
|
||||||
|
CIA2.pra = 0x02;
|
||||||
|
// set VIC screen to $6000
|
||||||
|
VIC.addr = 0x80;
|
||||||
|
// clear bitmap and screen RAM
|
||||||
|
memset((void*)0x4000, 0, 0x2000);
|
||||||
|
memset((void*)0xd800, 0, 40*25);
|
||||||
|
}
|
||||||
|
|
||||||
|
const byte PIXMASK[4] = { ~0xc0, ~0x30, ~0x0c, ~0x03 };
|
||||||
|
const byte PIXSHIFT[4] = { 6, 4, 2, 0 };
|
||||||
|
|
||||||
|
byte is_pixel(byte x, byte y) {
|
||||||
|
word ofs = ((x>>2)*8 + (y>>3)*320) | (y&7) | 0x4000;
|
||||||
|
return PEEK(ofs) & ~PIXMASK[x & 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_pixel(byte x, byte y, byte color) {
|
||||||
|
word ofs,b,cram,sram;
|
||||||
|
byte ccol,scol;
|
||||||
|
byte val;
|
||||||
|
|
||||||
|
if (x >= 160 || y >= 192) return;
|
||||||
|
|
||||||
|
color &= 0xf;
|
||||||
|
// equal to background color? (value 0)
|
||||||
|
if (color == VIC.bgcolor0) {
|
||||||
|
val = 0;
|
||||||
|
} else {
|
||||||
|
cram = ((x>>2) + (y>>3)*40);
|
||||||
|
sram = cram | 0x6000;
|
||||||
|
cram |= 0xd800;
|
||||||
|
ccol = PEEK(cram);
|
||||||
|
scol = PEEK(sram);
|
||||||
|
// color RAM contains unused bits (0x10 and 0x20)
|
||||||
|
// unused in lower nibble of screen RAM? (value 2)
|
||||||
|
if (color == (scol & 0xf) || !(ccol & 0x10)) {
|
||||||
|
val = 2;
|
||||||
|
scol = (scol & 0xf0) | color;
|
||||||
|
ccol |= 0x10;
|
||||||
|
POKE(sram, scol);
|
||||||
|
// unused in upper nibble of screen RAM? (value 1)
|
||||||
|
} else if (color == (scol >> 4) || !(ccol & 0x20)) {
|
||||||
|
val = 1;
|
||||||
|
scol = (scol & 0xf) | (color << 4);
|
||||||
|
ccol |= 0x20;
|
||||||
|
POKE(sram, scol);
|
||||||
|
// all other colors in use, use color RAM
|
||||||
|
} else {
|
||||||
|
val = 3;
|
||||||
|
ccol = 0x30 | color;
|
||||||
|
}
|
||||||
|
POKE(cram, ccol);
|
||||||
|
}
|
||||||
|
|
||||||
|
ofs = ((x>>2)*8 + (y>>3)*320) | (y&7) | 0x4000;
|
||||||
|
x &= 3;
|
||||||
|
b = PEEK(ofs) & PIXMASK[x];
|
||||||
|
if (val) {
|
||||||
|
b |= val << PIXSHIFT[x];
|
||||||
|
}
|
||||||
|
POKE(ofs, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_line(int x0, int y0, int x1, int y1, byte color) {
|
||||||
|
int dx = abs(x1-x0);
|
||||||
|
int sx = x0<x1 ? 1 : -1;
|
||||||
|
int dy = abs(y1-y0);
|
||||||
|
int sy = y0<y1 ? 1 : -1;
|
||||||
|
int err = (dx>dy ? dx : -dy)>>1;
|
||||||
|
int e2;
|
||||||
|
for(;;) {
|
||||||
|
set_pixel(x0, y0, color);
|
||||||
|
if (x0==x1 && y0==y1) break;
|
||||||
|
e2 = err;
|
||||||
|
if (e2 > -dx) { err -= dy; x0 += sx; }
|
||||||
|
if (e2 < dy) { err += dx; y0 += sy; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma static-locals(push,off)
|
||||||
|
byte flood_fill(byte x, byte y, byte color) {
|
||||||
|
register byte x1 = x;
|
||||||
|
register byte x2;
|
||||||
|
register byte i;
|
||||||
|
// find left edge
|
||||||
|
while (!is_pixel(x1, y))
|
||||||
|
--x1;
|
||||||
|
// exit if (x,y) is on a boundary
|
||||||
|
if (x1 == x)
|
||||||
|
return 1;
|
||||||
|
++x1;
|
||||||
|
// find right edge
|
||||||
|
x2 = x+1;
|
||||||
|
while (!is_pixel(x2, y))
|
||||||
|
++x2;
|
||||||
|
// fill scanline
|
||||||
|
for (i=x1; i<x2; i++) {
|
||||||
|
set_pixel(i, y, color);
|
||||||
|
}
|
||||||
|
// fill above and below scanline
|
||||||
|
for (i=x1; i<x2; ) {
|
||||||
|
i += flood_fill(i, y-1, color);
|
||||||
|
}
|
||||||
|
for (i=x1; i<x2; ) {
|
||||||
|
i += flood_fill(i, y+1, color);
|
||||||
|
}
|
||||||
|
return (x2-x1);
|
||||||
|
}
|
||||||
|
#pragma static-locals(pop)
|
||||||
|
|
||||||
|
#ifdef __MAIN__
|
||||||
|
|
||||||
|
word urand() {
|
||||||
|
return rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
setup_bitmap_multi();
|
||||||
|
draw_line(80, 10, 100, 100, 1);
|
||||||
|
draw_line(80, 10, 40, 80, 1);
|
||||||
|
draw_line(100, 100, 40, 80, 1);
|
||||||
|
draw_line(50, 0, 80, 60, 1);
|
||||||
|
draw_line(100, 0, 80, 60, 1);
|
||||||
|
flood_fill(80, 80, 2);
|
||||||
|
while(1) {
|
||||||
|
draw_line(urand()%160, urand()%192, urand()%160, urand()%192, rand()&15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -23,7 +23,7 @@ static void draw_cell(byte x, byte y) {
|
|||||||
byte ch = xx ^ yy;
|
byte ch = xx ^ yy;
|
||||||
word ofs = x+y*COLS;
|
word ofs = x+y*COLS;
|
||||||
hidbuf[ofs] = ch; // character
|
hidbuf[ofs] = ch; // character
|
||||||
tempbuf[ofs] = ch; // color
|
colorbuf[ofs] = ch; // color
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_draw_column(byte col) {
|
void scroll_draw_column(byte col) {
|
||||||
|
@ -9,7 +9,7 @@ byte origin_x;
|
|||||||
byte origin_y;
|
byte origin_y;
|
||||||
byte* hidbuf;
|
byte* hidbuf;
|
||||||
byte* visbuf;
|
byte* visbuf;
|
||||||
byte tempbuf[COLS*ROWS];
|
byte colorbuf[COLS*ROWS];
|
||||||
byte swap_needed;
|
byte swap_needed;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -26,7 +26,7 @@ void scroll_swap(void) {
|
|||||||
|
|
||||||
void scroll_copy(void) {
|
void scroll_copy(void) {
|
||||||
// copy temp buf to color ram
|
// copy temp buf to color ram
|
||||||
memcpy(COLOR_RAM, tempbuf, COLS*ROWS);
|
memcpy(COLOR_RAM, colorbuf, COLS*ROWS);
|
||||||
// copy visible buffer to hidden buffer
|
// copy visible buffer to hidden buffer
|
||||||
memcpy(hidbuf, visbuf, COLS*ROWS);
|
memcpy(hidbuf, visbuf, COLS*ROWS);
|
||||||
}
|
}
|
||||||
@ -41,36 +41,34 @@ void scroll_update(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: left and up can be faster, b/c we can copy color ram downward
|
|
||||||
|
|
||||||
void scroll_left(void) {
|
void scroll_left(void) {
|
||||||
memcpy(hidbuf, visbuf+1, COLS*ROWS-1);
|
memcpy(hidbuf, hidbuf+1, COLS*ROWS-1);
|
||||||
|
memcpy(colorbuf, colorbuf+1, COLS*ROWS-1);
|
||||||
++origin_x;
|
++origin_x;
|
||||||
memcpy(tempbuf, COLOR_RAM+1, COLS*ROWS-1);
|
|
||||||
scroll_draw_column(COLS-1);
|
scroll_draw_column(COLS-1);
|
||||||
swap_needed = true;
|
swap_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_up(void) {
|
void scroll_up(void) {
|
||||||
memcpy(hidbuf, visbuf+COLS, COLS*(ROWS-1));
|
memcpy(hidbuf, hidbuf+COLS, COLS*(ROWS-1));
|
||||||
|
memcpy(colorbuf, colorbuf+COLS, COLS*(ROWS-1));
|
||||||
++origin_y;
|
++origin_y;
|
||||||
memcpy(tempbuf, COLOR_RAM+COLS, COLS*(ROWS-1));
|
|
||||||
scroll_draw_row(ROWS-1);
|
scroll_draw_row(ROWS-1);
|
||||||
swap_needed = true;
|
swap_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_right(void) {
|
void scroll_right(void) {
|
||||||
memcpy(hidbuf+1, visbuf, COLS*ROWS-1);
|
memmove(hidbuf+1, hidbuf, COLS*ROWS-1);
|
||||||
|
memmove(colorbuf+1, colorbuf, COLS*ROWS-1);
|
||||||
--origin_x;
|
--origin_x;
|
||||||
memcpy(tempbuf+1, COLOR_RAM, COLS*ROWS-1);
|
|
||||||
scroll_draw_column(0);
|
scroll_draw_column(0);
|
||||||
swap_needed = true;
|
swap_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_down(void) {
|
void scroll_down(void) {
|
||||||
memcpy(hidbuf+COLS, visbuf, COLS*(ROWS-1));
|
memmove(hidbuf+COLS, hidbuf, COLS*(ROWS-1));
|
||||||
|
memmove(colorbuf+COLS, colorbuf, COLS*(ROWS-1));
|
||||||
--origin_y;
|
--origin_y;
|
||||||
memcpy(tempbuf+COLS, COLOR_RAM, COLS*(ROWS-1));
|
|
||||||
scroll_draw_row(0);
|
scroll_draw_row(0);
|
||||||
swap_needed = true;
|
swap_needed = true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ extern byte origin_x; // X scroll origin (columns)
|
|||||||
extern byte origin_y; // Y scroll origin (rows)
|
extern byte origin_y; // Y scroll origin (rows)
|
||||||
extern byte* hidbuf; // hidden screen buffer(s)
|
extern byte* hidbuf; // hidden screen buffer(s)
|
||||||
extern byte* visbuf; // visible screen buffer(s)
|
extern byte* visbuf; // visible screen buffer(s)
|
||||||
extern byte tempbuf[COLS*ROWS]; // temporary buffer
|
extern byte colorbuf[COLS*ROWS]; // color RAM buffer
|
||||||
extern byte swap_needed; // TRUE if scroll_update() swaps
|
extern byte swap_needed; // TRUE if scroll_update() swaps
|
||||||
|
|
||||||
// call this at start of program
|
// call this at start of program
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
SpriteShadow sprshad;
|
SpriteShadow sprshad;
|
||||||
|
|
||||||
void sprite_update(char* screenram) {
|
void sprite_update(char* vicbank) {
|
||||||
memcpy(screenram + 0x3f8, sprshad.spr_shapes, 8);
|
memcpy(vicbank + 0x3f8, sprshad.spr_shapes, 8);
|
||||||
VIC.spr_ena = sprshad.spr_ena;
|
VIC.spr_ena = sprshad.spr_ena;
|
||||||
VIC.spr_hi_x = sprshad.spr_hi_x;
|
VIC.spr_hi_x = sprshad.spr_hi_x;
|
||||||
memcpy(VIC.spr_pos, sprshad.spr_pos, 16);
|
memcpy(VIC.spr_pos, sprshad.spr_pos, 16);
|
||||||
@ -22,8 +22,12 @@ void sprite_shape(char* vicbank, byte index, const char* sprite_data) {
|
|||||||
memcpy(vicbank + index*64, sprite_data, 64);
|
memcpy(vicbank + index*64, sprite_data, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const byte BITS[8] = {
|
||||||
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
|
||||||
|
};
|
||||||
|
|
||||||
void sprite_draw(byte i, word x, byte y, byte shape) {
|
void sprite_draw(byte i, word x, byte y, byte shape) {
|
||||||
byte mask = 1 << i;
|
byte mask = BITS[i]; // 1 << i;
|
||||||
sprshad.spr_ena |= mask;
|
sprshad.spr_ena |= mask;
|
||||||
if (x >> 8)
|
if (x >> 8)
|
||||||
sprshad.spr_hi_x |= mask;
|
sprshad.spr_hi_x |= mask;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { hex, rgb2bgr, rle_unpack } from "../common/util";
|
import { hex, rgb2bgr, rle_unpack } from "../common/util";
|
||||||
import { ProjectWindows } from "./windows";
|
import { ProjectWindows } from "./windows";
|
||||||
|
import { Toolbar } from "../common/emu";
|
||||||
declare var Mousetrap;
|
declare var Mousetrap;
|
||||||
|
|
||||||
export type UintArray = number[] | Uint8Array | Uint16Array | Uint32Array; //{[i:number]:number};
|
export type UintArray = number[] | Uint8Array | Uint16Array | Uint32Array; //{[i:number]:number};
|
||||||
@ -991,18 +992,9 @@ class PixEditor extends Viewer {
|
|||||||
this.setPixel(pos.x, pos.y, dragcol);
|
this.setPixel(pos.x, pos.y, dragcol);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
Mousetrap.bind('ctrl+shift+h', this.flipX.bind(this));
|
|
||||||
Mousetrap.bind('ctrl+shift+v', this.flipY.bind(this));
|
|
||||||
Mousetrap.bind('ctrl+shift+9', this.rotate90.bind(this));
|
|
||||||
Mousetrap.bind('ctrl+shift+left', this.translate.bind(this, -1, 0));
|
|
||||||
Mousetrap.bind('ctrl+shift+right', this.translate.bind(this, 1, 0));
|
|
||||||
Mousetrap.bind('ctrl+shift+up', this.translate.bind(this, 0, -1));
|
|
||||||
Mousetrap.bind('ctrl+shift+down', this.translate.bind(this, 0, 1));
|
|
||||||
*/
|
|
||||||
// TODO: remove when unbound
|
|
||||||
|
|
||||||
aeditor.empty();
|
aeditor.empty();
|
||||||
|
this.createToolbarButtons(aeditor[0]);
|
||||||
aeditor.append(this.canvas);
|
aeditor.append(this.canvas);
|
||||||
aeditor.append(this.createPaletteButtons());
|
aeditor.append(this.createPaletteButtons());
|
||||||
this.setPaletteColor(1);
|
this.setPaletteColor(1);
|
||||||
@ -1050,6 +1042,18 @@ class PixEditor extends Viewer {
|
|||||||
return span;
|
return span;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createToolbarButtons(parent: HTMLElement) {
|
||||||
|
var toolbar = new Toolbar(parent, null);
|
||||||
|
toolbar.add('ctrl+shift+h', 'Flip X', 'glyphicon-resize-horizontal', this.flipX.bind(this));
|
||||||
|
toolbar.add('ctrl+shift+v', 'Flip Y', 'glyphicon-resize-vertical', this.flipY.bind(this));
|
||||||
|
toolbar.add('ctrl+shift+9', 'Rotate', 'glyphicon-repeat', this.rotate90.bind(this));
|
||||||
|
toolbar.add('ctrl+shift+left', 'Move Left', 'glyphicon-arrow-left', this.translate.bind(this, 1, 0));
|
||||||
|
toolbar.add('ctrl+shift+right', 'Move Right', 'glyphicon-arrow-right', this.translate.bind(this, -1, 0));
|
||||||
|
toolbar.add('ctrl+shift+up', 'Move Up', 'glyphicon-arrow-up', this.translate.bind(this, 0, 1));
|
||||||
|
toolbar.add('ctrl+shift+down', 'Move Down', 'glyphicon-arrow-down', this.translate.bind(this, 0, -1));
|
||||||
|
// TODO: destroy toolbar?
|
||||||
|
}
|
||||||
|
|
||||||
commit() {
|
commit() {
|
||||||
this.updateImage();
|
this.updateImage();
|
||||||
this.left.refreshLeft();
|
this.left.refreshLeft();
|
||||||
|
@ -10,11 +10,17 @@ const C64_PRESETS = [
|
|||||||
{id:'tgidemo.c', name:'TGI Graphics Demo (C)'},
|
{id:'tgidemo.c', name:'TGI Graphics Demo (C)'},
|
||||||
{id:'upandaway.c', name:'Up, Up and Away (C)'},
|
{id:'upandaway.c', name:'Up, Up and Away (C)'},
|
||||||
{id:'joymove.c', name:'Joystick Movement (C)'},
|
{id:'joymove.c', name:'Joystick Movement (C)'},
|
||||||
|
{id:'scroll1.c', name:'Scrolling 1 (C)'},
|
||||||
|
{id:'scroll2.c', name:'Scrolling 2 (C)'},
|
||||||
|
{id:'scroll3.c', name:'Scrolling 3 (C)'},
|
||||||
|
{id:'scroll4.c', name:'Scrolling 4 (C)'},
|
||||||
|
{id:'scroll5.c', name:'Scrolling 5 (C)'},
|
||||||
|
{id:'climber.c', name:'Climber Game (C)'},
|
||||||
];
|
];
|
||||||
|
|
||||||
const C64_MEMORY_MAP = { main:[
|
const C64_MEMORY_MAP = { main:[
|
||||||
{name:'6510 Registers',start:0x0, size:0x2,type:'io'},
|
{name:'6510 Registers',start:0x0, size:0x2,type:'io'},
|
||||||
{name:'RAM', start:0x2, size:0x7ffe,type:'ram'},
|
//{name:'RAM', start:0x2, size:0x7ffe,type:'ram'},
|
||||||
{name:'Cartridge ROM',start:0x8000,size:0x2000,type:'rom'},
|
{name:'Cartridge ROM',start:0x8000,size:0x2000,type:'rom'},
|
||||||
{name:'BASIC ROM', start:0xa000,size:0x2000,type:'rom'},
|
{name:'BASIC ROM', start:0xa000,size:0x2000,type:'rom'},
|
||||||
{name:'RAM', start:0xc000,size:0x1000,type:'ram'},
|
{name:'RAM', start:0xc000,size:0x1000,type:'ram'},
|
||||||
|
@ -1113,7 +1113,12 @@ function compileCC65(step:BuildStep) {
|
|||||||
'-I', '/share/include',
|
'-I', '/share/include',
|
||||||
'-I', '.',
|
'-I', '.',
|
||||||
];
|
];
|
||||||
if (params.define) params.define.forEach((x) => args.push('-D'+x));
|
if (params.define) {
|
||||||
|
params.define.forEach((x) => args.push('-D'+x));
|
||||||
|
}
|
||||||
|
if (step.mainfile) {
|
||||||
|
args.unshift.apply(args, ["-D", "__MAIN__"]);
|
||||||
|
}
|
||||||
args.push(step.path);
|
args.push(step.path);
|
||||||
//console.log(args);
|
//console.log(args);
|
||||||
execMain(step, CC65, args);
|
execMain(step, CC65, args);
|
||||||
|
Loading…
Reference in New Issue
Block a user