Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Commit

Permalink
nova lógica p/exibição de display
Browse files Browse the repository at this point in the history
  • Loading branch information
jbatistareis committed Jun 8, 2018
1 parent 54f7fd2 commit 5eeda51
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/jbatista/batatinha/EmulatorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ public void handle(long now) {
bufferPosition = 0;
scale = (chip8.getDisplay().length == 2048) ? 8 : 4;

// clear screen
canvas.getGraphicsContext2D().setFill(backgroundColor);
canvas.getGraphicsContext2D().fillRect(0, 0, canvas.getWidth(), canvas.getHeight());

// draw pixels
canvas.getGraphicsContext2D().setFill(pixelColor);
for (int iy = 0; iy < canvas.getHeight(); iy += scale) {
for (int ix = 0; ix < canvas.getWidth(); ix += scale) {
canvas.getGraphicsContext2D().setFill(
(chip8.getDisplay()[bufferPosition++] == 0)
? backgroundColor
: pixelColor);
canvas.getGraphicsContext2D().fillRect(ix, iy, scale, scale);
if(chip8.getDisplay()[bufferPosition++] == 1){
canvas.getGraphicsContext2D().fillRect(ix, iy, scale, scale);
}
}
}
}
Expand Down

0 comments on commit 5eeda51

Please sign in to comment.