mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 23:32:55 +00:00
Working on Tetris. Implemented line removal. Fixed fragment error and added 2 missing fragments.
This commit is contained in:
parent
4724d7707c
commit
a79e318bcd
@ -0,0 +1,2 @@
|
|||||||
|
lda {c1},y
|
||||||
|
sta {c1},x
|
@ -0,0 +1,2 @@
|
|||||||
|
lda {c1},x
|
||||||
|
sta {c1},y
|
@ -1,2 +1,2 @@
|
|||||||
tya
|
tay
|
||||||
dey
|
dey
|
@ -20,7 +20,7 @@ public class CompileLog {
|
|||||||
/**
|
/**
|
||||||
* Should fragment synthesis be verbose.
|
* Should fragment synthesis be verbose.
|
||||||
*/
|
*/
|
||||||
private boolean verboseFragmentLog = false;
|
private boolean verboseFragmentLog = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should ASM optimization be verbose.
|
* Should ASM optimization be verbose.
|
||||||
@ -66,7 +66,7 @@ public class CompileLog {
|
|||||||
/**
|
/**
|
||||||
* Should the log be output to System.out while being built
|
* Should the log be output to System.out while being built
|
||||||
*/
|
*/
|
||||||
private boolean sysOut = false;
|
private boolean sysOut = true;
|
||||||
|
|
||||||
public CompileLog() {
|
public CompileLog() {
|
||||||
this.log = new StringBuilder();
|
this.log = new StringBuilder();
|
||||||
|
@ -41,7 +41,7 @@ public class TestPrograms {
|
|||||||
public static void tearDown() {
|
public static void tearDown() {
|
||||||
CompileLog log = new CompileLog();
|
CompileLog log = new CompileLog();
|
||||||
log.setSysOut(true);
|
log.setSysOut(true);
|
||||||
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
|
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -16,6 +16,9 @@ byte[PLAYFIELD_LINES*PLAYFIELD_COLS] playfield;
|
|||||||
// Pointers to the playfield address for each playfield line
|
// Pointers to the playfield address for each playfield line
|
||||||
byte*[PLAYFIELD_LINES] playfield_lines;
|
byte*[PLAYFIELD_LINES] playfield_lines;
|
||||||
|
|
||||||
|
// Indixes into the playfield for each playfield line
|
||||||
|
byte[PLAYFIELD_LINES+1] playfield_lines_idx;
|
||||||
|
|
||||||
// The current moving piece. Points to the start of the piece definition.
|
// The current moving piece. Points to the start of the piece definition.
|
||||||
byte* current_piece = 0;
|
byte* current_piece = 0;
|
||||||
|
|
||||||
@ -105,6 +108,8 @@ byte play_move_down(byte key_event) {
|
|||||||
} else {
|
} else {
|
||||||
// Lock current piece
|
// Lock current piece
|
||||||
lock_current();
|
lock_current();
|
||||||
|
// Check for new lines
|
||||||
|
remove_lines();
|
||||||
// Spawn a new piece
|
// Spawn a new piece
|
||||||
spawn_current();
|
spawn_current();
|
||||||
}
|
}
|
||||||
@ -232,6 +237,48 @@ void spawn_current() {
|
|||||||
current_piece_color = PIECES_COLORS[piece_idx];
|
current_piece_color = PIECES_COLORS[piece_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Look through the playfield for lines - and remove any lines found
|
||||||
|
void remove_lines() {
|
||||||
|
byte done = 0;
|
||||||
|
do {
|
||||||
|
byte line_ypos = find_line();
|
||||||
|
if(line_ypos!=$ff) {
|
||||||
|
remove_line(line_ypos);
|
||||||
|
} else {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
} while(done==0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look through the playfield for lines - and return the ypos of any filled line.
|
||||||
|
// Returns $ff if no line was found
|
||||||
|
byte find_line() {
|
||||||
|
byte i = 0;
|
||||||
|
for(byte y:0..PLAYFIELD_LINES-1) {
|
||||||
|
byte filled = 1;
|
||||||
|
for(byte x:0..PLAYFIELD_COLS-1) {
|
||||||
|
if(playfield[i++]==0) {
|
||||||
|
filled = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(filled==1) {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a single line by scrolling all lines above it down and emptying the top line
|
||||||
|
void remove_line(byte ypos) {
|
||||||
|
byte i2 = playfield_lines_idx[ypos+1]-1;
|
||||||
|
byte i1 = playfield_lines_idx[ypos]-1;
|
||||||
|
for(byte y=ypos;y!=1;y--) {
|
||||||
|
for(byte x:0..PLAYFIELD_COLS-1) {
|
||||||
|
playfield[i2--] = playfield[i1--];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the screen and data tables
|
// Initialize the screen and data tables
|
||||||
void init() {
|
void init() {
|
||||||
// Clear the screen
|
// Clear the screen
|
||||||
@ -244,11 +291,15 @@ void init() {
|
|||||||
li += 40;
|
li += 40;
|
||||||
}
|
}
|
||||||
// Initialize the playfield line pointers;
|
// Initialize the playfield line pointers;
|
||||||
|
byte idx = 0;
|
||||||
byte* pli = playfield;
|
byte* pli = playfield;
|
||||||
for(byte j:0..PLAYFIELD_LINES-1) {
|
for(byte j:0..PLAYFIELD_LINES-1) {
|
||||||
playfield_lines[j<<1] = pli;
|
playfield_lines[j<<1] = pli;
|
||||||
pli += 10;
|
playfield_lines_idx[j] = idx;
|
||||||
|
pli += PLAYFIELD_COLS;
|
||||||
|
idx += PLAYFIELD_COLS;
|
||||||
}
|
}
|
||||||
|
playfield_lines_idx[PLAYFIELD_LINES] = PLAYFIELD_COLS*PLAYFIELD_LINES;
|
||||||
// Prepare the playfield frame
|
// Prepare the playfield frame
|
||||||
byte* line = COLS + 14;
|
byte* line = COLS + 14;
|
||||||
for(byte l:0..PLAYFIELD_LINES+1) {
|
for(byte l:0..PLAYFIELD_LINES+1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user