Skip to content

Commit

Permalink
fix sound & update draw rotate sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
corax89 committed Dec 8, 2019
1 parent 1667846 commit 274f205
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 276 deletions.
Binary file modified ESP8266_little_game_engine.ino.d1_mini.bin
Binary file not shown.
156 changes: 0 additions & 156 deletions ESPboy_keyboard.cpp

This file was deleted.

53 changes: 0 additions & 53 deletions ESPboy_keyboard.h

This file was deleted.

2 changes: 0 additions & 2 deletions cpu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1256,5 +1256,3 @@ void cpuStep(){
break;
}
}

#pragma GCC pop_options
74 changes: 12 additions & 62 deletions display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,46 +64,6 @@ struct Tile {
uint16_t pixheight;
};

static const int8_t cosT[] PROGMEM = {
0x40, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c,
0x3c, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39, 0x38, 0x37, 0x37, 0x36, 0x36, 0x35, 0x35, 0x34, 0x33, 0x33, 0x32, 0x31,
0x31, 0x30, 0x2f, 0x2e, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20,
0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb,
0xa, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf5, 0xf4, 0xf3, 0xf2,
0xf1, 0xf0, 0xef, 0xee, 0xed,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0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb,
0xcc, 0xcc, 0xcd, 0xce, 0xce, 0xcf, 0xd0, 0xd1, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
0xdc, 0xdd, 0xde, 0xdf, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe
};
static const uint8_t keyboardImage[] PROGMEM = {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x17,0x9c,0x7d,0x12,0x21,0xe,0x71,0xc7,0xc,
0x60,0x84,0x0,0x79,0xe7,0x84,0x49,0x14,0x12,0x10,0xa2,0x20,0x11,0x49,0x1,0x8,0x21,0x2,0x1f,0x9,0x24,0x88,0x49,0x17,
Expand Down Expand Up @@ -159,14 +119,6 @@ void memoryAlloc(){
Serial.println(F("Out of memory"));
}

inline int16_t getCos(int16_t g){
return (int16_t)(int8_t)pgm_read_byte_near(cosT + g);
}

inline int16_t getSin(int16_t g){
return (int16_t)(int8_t)pgm_read_byte_near(sinT + g);
}

int16_t atan2_fp(int16_t y_fp, int16_t x_fp){
int32_t coeff_1 = 45;
int32_t coeff_1b = -56; // 56.24;
Expand Down Expand Up @@ -309,10 +261,10 @@ void setEmitter(uint16_t time, int16_t dir, int16_t dir1, int16_t speed){
if(dir < 0)
dir += 360;
emitter.time = time;
emitter.speedx = (int8_t)((speed * getCos(dir)) >> 6);
emitter.speedy = (int8_t)((speed * getSin(dir)) >> 6);
emitter.speedx1 = (int8_t)((speed * getCos(dir1)) >> 6);
emitter.speedy1 = (int8_t)((speed * getSin(dir1)) >> 6);
emitter.speedx = (int8_t)((speed * fixed_cos(dir)) >> MULTIPLY_FP_RESOLUTION_BITS);
emitter.speedy = (int8_t)((speed * fixed_sin(dir)) >> MULTIPLY_FP_RESOLUTION_BITS);
emitter.speedx1 = (int8_t)((speed * fixed_cos(dir1)) >> MULTIPLY_FP_RESOLUTION_BITS);
emitter.speedy1 = (int8_t)((speed * fixed_sin(dir1)) >> MULTIPLY_FP_RESOLUTION_BITS);
}

void setEmitterSize(uint8_t width, uint8_t height, uint8_t size){
Expand Down Expand Up @@ -688,8 +640,8 @@ void spriteSetDirectionAndSpeed(int8_t n, uint16_t speed, int16_t dir){
dir = dir % 360;
if(dir < 0)
dir += 360;
sprite_table[n].speedx = ((speed * getCos(dir)) >> 6);
sprite_table[n].speedy = ((speed * getSin(dir)) >> 6);
sprite_table[n].speedx = ((speed * fixed_cos(dir)) >> MULTIPLY_FP_RESOLUTION_BITS);
sprite_table[n].speedy = ((speed * fixed_sin(dir)) >> MULTIPLY_FP_RESOLUTION_BITS);
}

void setSprWidth(int8_t n, uint8_t w){
Expand Down Expand Up @@ -810,8 +762,8 @@ void setSpriteValue(int8_t n, uint8_t t, int16_t v){
}

inline void drawRotateSprPixel(int8_t pixel, int8_t x0, int8_t y0, int16_t x, int16_t y, int16_t hw, int16_t hh, int16_t c, int16_t s){
int16_t nx = hw + (((x - hw) * c - (y - hh) * s) >> 6);
int16_t ny = hh + (((y - hh) * c + (x - hw) * s) >> 6);
int16_t nx = hw + (((x - hw) * c - (y - hh) * s) >> MULTIPLY_FP_RESOLUTION_BITS);
int16_t ny = hh + (((y - hh) * c + (x - hw) * s) >> MULTIPLY_FP_RESOLUTION_BITS);
int16_t nnx = nx / 2;
int8_t nnx0 = x0 / 2;
if(nnx0 + nnx >= 0 && nnx0 + nnx < 64 && y0 + ny >= 0 && y0 + ny < 128){
Expand Down Expand Up @@ -869,8 +821,8 @@ void drawSpr(int8_t n, int16_t x, int16_t y){
}
}
else{
c = getCos(sprite_table[n].angle);
s = getSin(sprite_table[n].angle);
c = fixed_cos(sprite_table[n].angle);
s = fixed_sin(sprite_table[n].angle);
if(SPRITE_IS_FLIP_HORIZONTAL(n)){
for(int8_t y1 = 0; y1 < h; y1 ++)
if(y1 + y >= -h && y1 + y < 128 + h){
Expand Down Expand Up @@ -930,8 +882,8 @@ void drawSpr(int8_t n, int16_t x, int16_t y){
}
}
else{
c = getCos(sprite_table[n].angle);
s = getSin(sprite_table[n].angle);
c = fixed_cos(sprite_table[n].angle);
s = fixed_sin(sprite_table[n].angle);
if(SPRITE_IS_FLIP_HORIZONTAL(n)){
for(int8_t y1 = 0; y1 < h; y1++)
for(int8_t x1 = 0; x1 < ww; x1++){
Expand Down Expand Up @@ -1764,5 +1716,3 @@ void putchar(char c, uint8_t x, uint8_t y) {
}
}
}

#pragma GCC pop_options
4 changes: 2 additions & 2 deletions file_manager.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uint8_t drawDialog(){
drwLine(108, 30, 108, 90);
x = 24;
y = 32;
for(i = 0; i < 43; i++){
for(i = 0; i < 37; i++){
putchar(txt[i], x, y);
x += 6;
if(x > 102){
Expand Down Expand Up @@ -215,7 +215,7 @@ void fileList(String path) {
getKey();
while(thiskey == 0){
clearScr(0);
putString("No files, please upload files", 2);
putString((char*)"No files, please upload files", 2);
redrawScreen();
getKey();
delay(100);
Expand Down
2 changes: 1 addition & 1 deletion sound.ino
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int playRtttl(){
// now play the note
rtttl.delay = duration;
if(note){
rtttl.this_tone = notes[note];
rtttl.this_tone = notes[note + ((scale - 4) * 12)];
tone(SOUNDPIN, rtttl.this_tone, rtttl.delay);
}
else{
Expand Down

0 comments on commit 274f205

Please sign in to comment.