OSDN Git Service

Remove all samples. They will work well and useful for reference. But there is no...
[nxt-jsp/etrobo-atk.git] / nxtOSEK / samples_c++ / cc / sprite_devl / Screen.cc
diff --git a/nxtOSEK/samples_c++/cc/sprite_devl/Screen.cc b/nxtOSEK/samples_c++/cc/sprite_devl/Screen.cc
deleted file mode 100644 (file)
index 4763023..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-#include "Screen.h"\r
-\r
-#ifdef _MSC_VER\r
-#include <assert.h>\r
-#else\r
-extern "C"\r
-{\r
-       #include "systick.h"\r
-}\r
-#endif\r
-\r
-Screen::Screen()\r
-{\r
-       memset(mLcd, 0x00, NXT_LCD_DEPTH*NXT_LCD_WIDTH);\r
-       for(int i = 0; i < NUM_SPRITES; ++i)\r
-       {\r
-               mSpriteList[i] = NULL;\r
-       }\r
-}\r
-\r
-void Screen::update()\r
-{\r
-       memset(mLcd, 0x00, NXT_LCD_DEPTH*NXT_LCD_WIDTH);\r
-       for(int i = 0; i < NUM_SPRITES; ++i)\r
-       {\r
-               if(mSpriteList[i])\r
-               {\r
-                       if(mSpriteList[i]->frameIsRenderable())\r
-                       {\r
-                               renderBitmap(   mLcd, \r
-                                                               mSpriteList[i]->getCurrentFramePtr(), \r
-                                                               mSpriteList[i]->getWidth(), \r
-                                                               mSpriteList[i]->getHeight(), \r
-                                                               mSpriteList[i]->getPosition().mX, \r
-                                                               mSpriteList[i]->getPosition().mY, \r
-                                                               mSpriteList[i]->getInvert(), \r
-                                                               mSpriteList[i]->getHFlip(), \r
-                                                               mSpriteList[i]->getVFlip());\r
-                       }\r
-                       \r
-                       mSpriteList[i]->update();\r
-               }\r
-       }\r
-#ifndef _MSC_VER\r
-       // Display update of NXT LCD takes 16msec according LEGO HW development kit. \r
-       // Thus faster refresh rate(update) than 16msec does not work. \r
-       // Actually it makes the system busy by frequest ISR requests and \r
-       // it may cause a system crash. Then it needs to insert 20msec (> 16msec) wait.\r
-       systick_wait_ms(20);\r
-#endif\r
-       display_bitmap_copy(mLcd, NXT_LCD_WIDTH, NXT_LCD_DEPTH, 0, 0);\r
-       display_update();\r
-}\r
-\r
-Sprite* Screen::newSprite(Sprite *sprite)\r
-{\r
-       for(int i = 0; i < NUM_SPRITES; ++i)\r
-       {\r
-               if(mSpriteList[i] == NULL)\r
-               {\r
-                       mSpriteList[i] = sprite;\r
-                       return sprite;\r
-               }\r
-       }\r
-\r
-       return sprite;\r
-}\r
-\r
-void Screen::deleteSprite(Sprite *sprite)\r
-{\r
-       for(int i = 0; i < NUM_SPRITES; ++i)\r
-       {\r
-               if(mSpriteList[i] == sprite)\r
-               {\r
-                       mSpriteList[i] = NULL;\r
-                       return;\r
-               }\r
-       }\r
-}\r
-#ifdef _MSC_VER\r
-void Screen::renderBitmap(U8 *lcd, const CHAR *sprite, S32 width, S32 height, S32 xPos, S32 yPos, bool invert, bool hflip, bool vflip)\r
-{\r
-    int spriteByteWidth = width/8;\r
-    int currentSpriteByte = 0;\r
-    int spriteRow = 0;\r
-\r
-    for (int y = 0; y < height; ++y)\r
-    {\r
-        if(vflip == true)\r
-        {\r
-            spriteRow = height - 1 - y;\r
-        }\r
-        else\r
-        {\r
-            spriteRow = y;\r
-        }\r
-\r
-        if (spriteRow + yPos < 0 || spriteRow + yPos > 63)\r
-        {\r
-            currentSpriteByte += spriteByteWidth;\r
-            continue;\r
-        }\r
-\r
-        int spriteCol = 0;\r
-        for (int x = 0; x < spriteByteWidth; x++)\r
-        {\r
-            if (hflip == true)\r
-            {\r
-                spriteCol = spriteByteWidth - 1 - x;\r
-            }\r
-            else\r
-            {\r
-                spriteCol = x;\r
-            }\r
-\r
-            unsigned char workByte = sprite[currentSpriteByte++];\r
-\r
-            if(invert)\r
-               {\r
-                workByte ^= 0xff;\r
-               }\r
-\r
-            int spritePixelOffset = (spriteCol * 8) + xPos;\r
-            \r
-            int lcdPixelOffset = ((spriteRow + yPos) * 100) + spritePixelOffset;\r
-            int pixelShift = 0;\r
-            for (int px = 0; px < 8; ++px)\r
-            {\r
-                if (hflip == true)\r
-                {\r
-                    pixelShift = px;\r
-                }\r
-                else\r
-                {\r
-                    pixelShift = 7 - px;\r
-                }\r
-\r
-                if (spritePixelOffset + px < 0 || spritePixelOffset + px > 99)\r
-                {\r
-                    continue;\r
-                }\r
-\r
-                if (workByte > 0)\r
-                {\r
-                    int lcdBytePos = (lcdPixelOffset + px) / 8;\r
-                    int lcdBitPos = (lcdPixelOffset + px) % 8;\r
-\r
-                    if ((workByte & (1 << pixelShift)) == (1 << pixelShift))\r
-                    {\r
-                        lcd[lcdBytePos] |= (char)(1 << lcdBitPos);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-}\r
-#else\r
-void Screen::renderBitmap(U8 *lcd, const CHAR *file, S32 width, S32 height, S32 xPos, S32 yPos, bool invert, bool hflip, bool vflip)\r
-{      \r
-       SINT bmp_line = width / 8;\r
-       if (width % 8)\r
-       {\r
-               bmp_line++;\r
-       }\r
-\r
-       //iterate through each row of the bitmap\r
-       for (SINT bmp_row = 0; bmp_row < height; bmp_row++)\r
-       {\r
-               //if the position of any row puts it off screen, the don' render it\r
-               if(bmp_row + yPos < 0 || bmp_row + yPos > 63)\r
-               {\r
-                       continue;\r
-               }\r
-\r
-               //setup the pixel position on the lcd to render\r
-               SINT lcd_row = (bmp_row + yPos) / 8;\r
-               SINT lcd_bit_pos = 7 - ((bmp_row + yPos) % 8);\r
-\r
-               //iterate through each column\r
-               for(SINT bmp_col = 0; bmp_col < bmp_line ; bmp_col++)\r
-               {\r
-                       //vflip if nevessary\r
-                       U8 row = bmp_row;\r
-\r
-                       if(vflip)\r
-                       {\r
-                               row = (height - bmp_row);\r
-                       }\r
-\r
-                       //hflp if necessary\r
-                       SINT renderColumn = bmp_col;\r
-\r
-                       if(hflip)\r
-                       {\r
-                               renderColumn = bmp_line - bmp_col;\r
-                       }\r
-\r
-                       //get the byte to render\r
-                       U8 bmp_data = file[(row * bmp_line) + bmp_col];\r
-\r
-                       //invert the bits if necessary\r
-                       if(invert)\r
-                       {\r
-                               bmp_data ^= 0xff;\r
-                       }\r
-\r
-                       //get the position on the lcd to render\r
-                       SINT lcd_pos = (lcd_row * NXT_LCD_WIDTH) + ((renderColumn * 8) + xPos);\r
-\r
-                       //now iterate through each bit in the render byte\r
-                       for (SINT bmp_bit_pos = 0; bmp_bit_pos < 8; bmp_bit_pos++)\r
-                       {\r
-\r
-                               //hflip the renderbytes bits if necessary\r
-                               U8 bitToDraw = (7 - bmp_bit_pos);\r
-\r
-                               if(hflip)\r
-                               {\r
-                                       bitToDraw = bmp_bit_pos;\r
-                               }\r
-\r
-                               //if ever a bit is off screen, don't render it\r
-                               if((renderColumn * 8) + xPos + bitToDraw < 0 || \r
-                                       (renderColumn * 8) + xPos + bitToDraw  > 99)\r
-                               {\r
-                                       continue;\r
-                               }\r
-\r
-                               //finally, render the pixel\r
-                               if (bmp_data & (0x01 << bitToDraw))\r
-                               {\r
-                                       SINT lcd_index = lcd_pos + bmp_bit_pos;\r
-                                       // checks the size of render data to be stored into LCD\r
-                                       if (lcd_index < NXT_LCD_DEPTH*NXT_LCD_WIDTH)\r
-                                       {\r
-                                               lcd[lcd_index] |= (0x80 >> lcd_bit_pos);\r
-                                       }\r
-                               }\r
-                               /*else\r
-                               {\r
-                                       //if the bitmap pixel is clear and we're not rendering transparently,\r
-                                       //clear this pixel location on the lcd\r
-                                       if(!transparent)\r
-                                       {\r
-                                               lcd[lcd_pos + bmp_bit_pos] &= (~0x80 >> lcd_bit_pos);\r
-                                       }\r
-                               }*/\r
-                       }\r
-               }\r
-       }\r
-}\r
-#endif\r
-\r