GamebuinoClassic archive

Archive of the Gamebuino Classic forum (2014-2018), rebuilt from the pages kept by the Wayback Machine: only part of the topics and pages were captured. Read-only. Removal on request: hi@gamebuino.com.

Forum › Software Development

A gamebuino "emulator" ?

65c02 Fri Mar 28, 2014 1:26 pm
Hi,

While waiting for a gamebuino I would like to code some stuff to test.
Is there an emulator or something else, that would allow me to see some rendering ?

( I've never worked on arduino project before so sorry if my question is stupid :mrgreen: )
adekto Fri Mar 28, 2014 1:33 pm
there arduino emulators out there, but i dont know any with the lcd screen
autodesk even has one
rodot Fri Mar 28, 2014 1:35 pm
Your question if far from being stupid, you're not the first one who ask for an emulator. The thing is, developing an emulator would take a lot of time, and I prefer to spend my time on developing Gamebuino itself. Moreover, once you'll have your Gamebuino, it will only be a matter of seconds to compile and upload your game, so you won't really need an emulator. And the Gamebuino library changes everyday, so I would have to update the emulator all the time...

But if you really can't wait, you can hook up a screen, a speaker and few buttons. Look in the "Hardware Gallery" category, there is already Gamebuino clones out there ;)
65c02 Fri Mar 28, 2014 1:42 pm
Whaou !

I did not ask that you develop an emulator :D
I just thought : Arduino seem to be a kind of standard hardware, and may be there is a plugin for Arduino IDE or a simulator.

Anyway, I'll wait;
It's just a question of time :)
65c02 Fri Mar 28, 2014 1:49 pm
adekto wrote:there arduino emulators out there, but i dont know any with the lcd screen
autodesk even has one

What a crazy tool !
But I'm too far from my comfort zone :mrgreen:
65c02 Sat Mar 29, 2014 4:24 pm
Ok,
I must confess that I'm looking forward to playing with gamebuino.
So, I started programming an as3 class that simulate its rendering.
For now, I've implemented the function DrawBitmap

My goal is to simulate the same data constraint (screen size, 8 pixels / byte, remanence)
I can now try to develop some graphic algorithms.

here is the current result

Here is the code if anyone interested

Code: Select all
package 
{
   import flash.display.Bitmap;
   import flash.display.BitmapData;
   import flash.geom.ColorTransform;
   
   /**
    * Try to simulate the gamebuino display
    * @author Alain Le Guirec
    */
   public class LCD extends Bitmap
   {
      // this buffer is the memory
      protected var m_buffer:Vector.<int> = new Vector.<int>(48 * (80 / 8));
      
      // this buffer is used by flash to render buffer fast
      // usefull to simulate the remanence to
      protected var m_colors:Vector.<uint> = new Vector.<uint>(48*80);

      public function LCD()
      {
         super();
         bitmapData = new BitmapData(80, 48, false, 0xFFFFFF);         
         transform.colorTransform = new ColorTransform(0.8, 0.9, 0.8); // put here the screen color (rgb values between 0.0 and 1.0)
      }
      
      public function setPixel(px:uint, py:uint, bState:Boolean):void
      {
         if (px >= 80 || py >= 48)
            return;
            
         if(bState)
            m_buffer[(py * 10) + (px >> 3)] |= 0xFF & (1 << (7 - (px & 7)));
         else
            m_buffer[(py * 10) + (px >> 3)] &= 0xFF ^ (1 << (7 - (px & 7)));
      }

      /*
       * simulate the gamebuino display function
       */
      public function drawBitmap(px:int, py:int, btm:Vector.<int>):void
      {
         var idxRead:int = 2;
         var byteWidth:int = btm[0] >> 3;
                  
         for (var py:int = 0; py < btm[1]; py++)
         {
            for (var nbyte:int = 0; nbyte < byteWidth; nbyte++)
            {
               var val:int = btm[idxRead++];
               
               for (var nbits:int = 0; nbits < 8; nbits++)
               {
                  setPixel(px + nbits, py, (val & 0x80) != 0);                   
                  val <<= 1;
               }
            }
         }
      }
      
      /*
       * this function transfert the memory buffer to the flash bitmap
       * must be called each frame
       */
      public function update():void
      {
         var idxRead:int = 0;
         var idxWrite:int = 0;
         
         for (var py:int = 0; py < 48; py++)
         {
            var px:int = 0;
            
            for (var nbyte:int = 0; nbyte < 10; nbyte++)
            {
               var byte:int = m_buffer[idxRead++];
               
               for (var npix:int = 0; npix < 8; npix++,px++, idxWrite++)
               {
                  if ((byte & 0x80) != 0)
                     m_colors[idxWrite] = 0;
                  else
                  {
                     var l:int = ((m_colors[idxWrite] & 0xFF) + 0xFF) >> 1;
                     m_colors[idxWrite] = l<<16 | l<<8 | l;
                  }   
                  
                  byte <<= 1;
               }               
            }
         }

         bitmapData.setVector(bitmapData.rect, m_colors);
      }
   }
}
adekto Sat Mar 29, 2014 4:36 pm
hi there, i have tryed this to but in lua
the problem is u have to interprite c code or the hex comiled code to emulate it properly
rodot Sat Mar 29, 2014 4:41 pm
I still think that it's easier to assemble a fake-buino on a breadboard :P
65c02 Sat Mar 29, 2014 5:01 pm
adekto wrote:hi there, i have tryed this to but in lua
the problem is u have to interprite c code or the hex comiled code to emulate it properly

I don't try to emulate the hardware. I just want to try some algorithm in the good constraint.
If my algorithms works on as3, it will be easy to recode everything in C.
65c02 Sat Mar 29, 2014 5:01 pm
rodot wrote:I still think that it's easier to assemble a fake-buino on a breadboard :P

:mrgreen:
mougino Wed Aug 12, 2015 11:28 am
Thanks for the quick response Deneth, I'll try that and keep you updated.

Nicolas
mougino Wed Aug 12, 2015 8:53 pm
Well, in the end I went another direction.
I was starting to get high sram alerts after compilation so I moved stuff to PROGMEM but then I climbed to almost 30k quite spectacularly... So I chose to stick with the debug/!debug use cases but with a differential compilation instead of differential C code (i.e. using preprocessor #ifdef debug rather than if(debug)...) I was able to save 6k of flash memory this way!
So I'll keep using two different binaries and switch between the two by commenting or not the first line of my main ino: #define debug.

Nicolas