Close
0%
0%

Esp little game engine

Game engine using a virtual machine with a simulator and a web compiler

Public Chat
Similar projects worth following
Game engine with web emulator and compiler. The image is displayed on the tft using the TFT_eSPI library.

https://github.com/corax89/esp8266_game_engine

The game engine has a virtual screen resolution of 128x128 pixels, 16 colors, one background layer, 32 soft sprites with collision tracking and rotation, 20kb of memory for the game and variables. The virtual machine performs approximately 900,000 operations per second at a drawing rate of 20 frames per second. Control of eight buttons.

The online compiler of the C subset to the assembler, and then to the virtual machine code.

User guide: https://corax89.github.io/esp8266Game/user_guide/index.html

VM description: https://github.com/corax89/esp8266_game_engine/blob/master/esp_little_game_engine_description.pdf

Portable Network Graphics (PNG) - 283.77 kB - 03/15/2019 at 14:05

Preview
Download

  • 1 × esp8266
  • 1 × tft 240x320 ili9341
  • 1 × PCF8574 Microprocessors, Microcontrollers, DSPs / Microprocessors (MPUs)
  • 1 × gameboy case

View all 20 project logs

Enjoy this project?

Share

Discussions

NeFar13 wrote 01/31/2021 at 14:27 point

В папке исходников лежит фаил ESP8266_little_game_engine.ino.d1_mini.bin , но я так и не нашел информацию о его применении, я как раз использую D1 mini и у меня вознекла проблема с клавиатурой

  Are you sure? yes | no

piter76 wrote 11/23/2020 at 22:33 point

Hi Igor. I would like to ask about the implementation of WiFi network functions in the LGE engine framework. Is it planned? Or maybe it is already, but I do not know how to use it? :) 

It would be nice to create games for two players with two ESPboy on the local network like this one for example  https://github.com/piter76/battleship

Thank You for great project :)

  Are you sure? yes | no

Chen Yung-Chung wrote 11/14/2020 at 11:55 point

ESP8266_little_game_engine.ino 

What do I need to change when using TFT ST7735 and PCF8574 ?

  Are you sure? yes | no

Loopingstar wrote 01/13/2020 at 19:10 point

Hi,

I have two questions about the compiler (I don't have a real console yet):

1) I created a little sketch which allows you to test the up, down, left, right, A and B buttons. I don't understand why I can't press all the buttons at the same time. Some are blocked.
See here: https://github.com/Loopingstar/ESPLGE-Buttons-tester

2) How to test the Start and Select buttons in the compiler?
Thank you

  Are you sure? yes | no

Igor wrote 01/14/2020 at 04:53 point

Beautiful sketch! 
2.The selection and start buttons are not engaged at the moment. They are on the console and can even be used, but they are not in the emulator. In addition, one of the buttons on the console is used to access the menu. 
1.The support of simultaneous pressing of all buttons (without Select and Start) depends on the keyboard. The touch screen now supports only two keystrokes simultaneously.

  Are you sure? yes | no

Loopingstar wrote 01/05/2020 at 10:53 point

Thank you for this very great project! The SPIFF uploader is just fantastic! Question: Why you don't use NodeMCU?

  Are you sure? yes | no

Igor wrote 01/14/2020 at 04:56 point

I am sorry for the long wait for an answer. You can use any board that contains esp8266. I used the ones available to me.

  Are you sure? yes | no

Marcus de Verdier wrote 11/15/2019 at 21:37 point

Hi Igor, over the summer I forked and rewrote big parts of your engine in inspiration of the PICO-8 fantasy console, naming it ESPiCo.

Some parts of it is a different beast from LGE, in that it doesn't have a sprite draw buffer but dedicated sprite and tilemap memory and such. But most of the basics are just the same. The compiler supports fixed point number handling of some sort and structs.

Anyway, I just wanted to give you gratitude for all the fun I've have tweaking this engine of yours and hope you can make use of some of that code.
https://github.com/mali1741/espico
https://github.com/mali1741/espico_compiler

  Are you sure? yes | no

Igor wrote 11/16/2019 at 03:01 point

That sounds awesome! I thought that no one could figure out my code. I am glad that you did it. And I'm interested in the result.

  Are you sure? yes | no

Marcus de Verdier wrote 11/16/2019 at 08:35 point

Cool!
I forgot to add that it uses 80 MHz SPI for the TFT, the setup file is included on github now.

  Are you sure? yes | no

AccidentalRebel wrote 11/22/2019 at 06:04 point

I have not looked through your code yet, but does this mean your code can play Pico8 games? Eager to hear your reply.

  Are you sure? yes | no

Marcus de Verdier wrote 11/23/2019 at 22:45 point

No, and its not lua. It's more like it uses the same api structure and methology. What it means though is that it's not too hard to rewrite pico8 code to espico code. But we still got all the restrictions with memory and speed to cope with.

  Are you sure? yes | no

AccidentalRebel wrote 11/23/2019 at 23:50 point

Interesting. I have some more questions so I'll just contact you directly. I don't want to flood @Igor 's thread.

  Are you sure? yes | no

facugalvan03 wrote 11/12/2019 at 23:42 point

Sorry for the ignorance but i need help. Inside the file "ESP8266_little_game_engine.ino", on the void setup you are coding for the mcp23017 instead the pcf8574P, right? Why?

  Are you sure? yes | no

Igor wrote 11/13/2019 at 05:47 point

mcp23017 is used by ESPboy. You can use any port extender. You can also connect buttons through resistors to the analog input.

  Are you sure? yes | no

AccidentalRebel wrote 11/24/2019 at 00:00 point

I don't have port extenders handy at the moment so I'll try the resistors route. Has anyone else done this before so I don't have to re-invent the wheel?

  Are you sure? yes | no

Igor wrote 11/24/2019 at 11:43 point

https://www.instructables.com/id/How-to-access-5-buttons-through-1-Arduino-input/

You must change the getKey () function in the keyboard.ino file

  Are you sure? yes | no

AccidentalRebel wrote 11/24/2019 at 12:04 point

Ah. Yes, it's similar to how I do it in my other projects. The problem with this is it can't handle multiple keypresses. Still good though. Thanks.

  Are you sure? yes | no

facugalvan03 wrote 10/28/2019 at 10:52 point

Does it make a difference if I use a pcf8574n instead of a pcf8574p? 

  Are you sure? yes | no

Igor wrote 10/28/2019 at 18:52 point

Yes. Can be used. This is the same chip from different manufacturers.

  Are you sure? yes | no

RomanS wrote 06/05/2019 at 14:18 point

Hello Igor. Could i port your engine for my ESPboy project? 

  Are you sure? yes | no

Igor wrote 06/05/2019 at 18:21 point

Yes. I will be happy.

  Are you sure? yes | no

shando69 wrote 05/25/2019 at 23:57 point

Sorry, ignore the last bit of my previous comment. I've just found the examples in the online editor :)

  Are you sure? yes | no

shando69 wrote 05/25/2019 at 23:52 point

Looks like an excellent project. I am about to buy an ODROID-GO and was wondering if there were any plans to expand the screen size from 128x128? The ODROID has a 320x240 screen. Also, is there any way to see the code behind some of the bin files?

  Are you sure? yes | no

Igor wrote 05/26/2019 at 14:40 point

I ran this firmware on esp32. However, this requires a small alteration of the code.

  Are you sure? yes | no

mystboy666 wrote 05/10/2019 at 09:54 point

Hi there!

Is there any plan supporting these small monochrome oled displays?

Thanks!

  Are you sure? yes | no

Igor wrote 05/20/2019 at 14:38 point

I did not plan this, but it is possible.

  Are you sure? yes | no

Hendra Kusumah wrote 04/23/2019 at 06:26 point

hi there, just try out your firmware and it work. But I use a different kind of ili9341 board and the screen got flipped upside down, is there anyway to change/flipped the screen orientation?

  Are you sure? yes | no

Hendra Kusumah wrote 04/23/2019 at 06:29 point

I am using this board:

https://www.tindie.com/products/thirtytwoteeth/game-boy-zero-handheld-edition/

since it is basically an ili9341 breakout without the pi zero I manage to get it running but there is the problem I mention above

  Are you sure? yes | no

Igor wrote 04/23/2019 at 18:13 point

In the setup () function, find tft.setRotation (1); and change to tft.setRotation (3); Or try to substitute other values from 0 to 3

  Are you sure? yes | no

Hendra Kusumah wrote 04/24/2019 at 06:12 point

Ok, it works. Thanks for the follow up

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 07:34 point

Anyone is interested in Wii nunchuck support (I didn't have any pcf8574 laying around..)? 

  Are you sure? yes | no

Igor wrote 04/04/2019 at 16:59 point

Here I found the instructions for connecting. This is i2c so the scheme does not change. Need to rewrite the button processing code. https://www.instructables.com/id/ESP8266-and-Visuino-WiFi-Remote-Control-Smart-Car-/

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 18:40 point

Yup, already done it, code can be found in:

https://github.com/mali1741/esp8266_game_engine/tree/nunchuck

  Are you sure? yes | no

Marcus de Verdier wrote 04/03/2019 at 15:18 point

Nice project! I've had some problems running some of the games (mars and breakout) on the esp, and found that setinterrupt in cpu.ino didn't use the stack as in cpu.js .  When I changed it to behave like in cpu.js it works fine though.

  Are you sure? yes | no

dan wrote 04/03/2019 at 22:52 point

Im have issues with running games on my ESP hardware also. Can you explain more in detail what you did to fix this problem.

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 07:17 point

I can get a github pull request out tomorrow, but until then:
in cpu.ino:setinterrupt

shadow_reg[0] = flagsToByte();
for(int8_t j = 1; j <= 15; j++){
shadow_reg[j] = reg[j];
}

should be changed to:

reg[0] -= 2;
writeInt(reg[0], flagsToByte());
for(int8_t j = 1; j <= 15; j++){
reg[0] -= 2;
writeInt(reg[0], reg[j]);
}

and the op return code 0x9A:

for(int8_t j = 15; j >= 1; j--){
reg[j] = shadow_reg[j];
}
byteToFlags(shadow_reg[0]);

should be changed accordingly:

for(int8_t j = 15; j >= 1; j--){
reg[j] = readInt(reg[0]);
reg[0] += 2;
}
byteToFlags(readInt(reg[0]));
reg[0] += 2;

Besides that there are a few cpu-instructions that handles sprites that need a limiter of the spite index ( & 31  as most of them already has).

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 18:39 point

  Are you sure? yes | no

Igor wrote 04/04/2019 at 17:02 point

Strange. This should not be a problem. Interrupt handling through additional registers faster.

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 17:44 point

Yes, I agree. Somehow I got a full interrupt queue with the shadow reg code.

  Are you sure? yes | no

Marcus de Verdier wrote 04/04/2019 at 21:22 point

So I found the error, the reg and shadow_reg arrays are one element short!
int16_t reg[16];
int16_t shadow_reg[16];

should do the trick!

  Are you sure? yes | no

Igor wrote 04/08/2019 at 06:09 point

Thanks!

  Are you sure? yes | no

Mr Rockgovsky wrote 04/01/2019 at 09:07 point

I'm not sure how I'm supposed to run this thing - I uploaded the game.bin file to the esp8266,
but don't know what else should I do/how to proceed.
I've also struggled to hook everything up properly, and I'm not sure if I've done everything correctly. Could you provide a more detalied schematic? Thanks in advance, very nice work!

  Are you sure? yes | no

amera64 wrote 03/19/2019 at 06:04 point

I have everything hooked up and firmware loaded but can't figure out how to load the .bin file into the Esp8266.  Can anyone point me in the right direction? Thanks

  Are you sure? yes | no

Igor wrote 03/21/2019 at 19:42 point

https://github.com/esp8266/arduino-esp8266fs-plugin

All uploaded files must be in the data folder.

  Are you sure? yes | no

tormozedison wrote 03/12/2019 at 20:17 point

Cool! A project with open source firmware, but top secret circuit diagram. Why?

  Are you sure? yes | no

Igor wrote 03/15/2019 at 13:00 point

Nothing secret. Just a screen on spi and a keyboard on i2c

  Are you sure? yes | no

tormozedison wrote 03/15/2019 at 21:04 point

Thanks. Take a look at this review:

https://habr.com/ru/post/443918

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates