本帖最后由 love_ourdev 于 2016-11-10 21:55 编辑
看了坛里的高手用51做俄罗斯方块,我也萌生了做一个游戏机的念头,把一边闲着的VGA显示器用起来。
我不求高手的挑战极限,我要留足资源多做几个游戏;而且还要尽可能方便的开发游戏,当然又不能太浪费。所以我用了STM32F030C8,
8KB RAM,64KB ROM,目前搭好了游戏框架,做出了演示。软件上支持双显存和但显存随意切换,简单适应多种显示分辨率,
软件耗费如下:
- 6 860 bytes of readonly code memory
- 84 bytes of readonly data memory
- 6 188 bytes of readwrite data memory
复制代码
优酷视频:
http://v.youku.com/v_show/id_XMTgxNDExNzE4OA==.html
电路连接实物图:
IMG_20161110_213241.jpg (357.77 KB, 下载次数: 0)
下载附件
电路链接图
2016-11-10 21:51 上传
演示的代码如下:
- #include "usrinc.h"
- #include <string.h>
- static const uint32_t sprite1[8] = {
- 0x66666666,
- 0x68111186,
- 0x61822816,
- 0x61288216,
- 0x61288216,
- 0x61822816,
- 0x68111186,
- 0x66666666,
- };
- void UserEntryInit(void)
- {
- HWU_BoardLedInit();
- HWU_VGASetup(&displayer640x480);
- GE2D_ClearScreen();
- GE2D_SwapBuffer();
- GE2D_ClearScreen();
- }
- void UserEntryLoop(void)
- {
- uint32_t tick = 0;
- uint32_t angle;
- GUI_RECT rect;
- int xDiff, yDiff;
-
- rect.x0 = 0;
- rect.y0 = 0;
- rect.x1 = GE2D_X_SIZE-1;
- rect.y1 = GE2D_Y_SIZE-1;
-
- while(1)
- {
- HWU_WaitVSync();
- GE2D_SwapBuffer();
-
- GE2D_ClearScreen();
- GE2D_SetForeColor(GUI_WHITE);
- GE2D_DrawRect(&rect);
-
- GE2D_SetForeColor(GUI_YELLOW);
- F8x8_DispString(4, 2, "STM32F0");
-
- GE2D_SetForeColor(GUI_RED);
- GE2D_DrawHLine(2, 12, 2+(tick%60));
- GE2D_DrawHLine(61-(tick%60), 14, 61);
- GE2D_DrawBitmap4((tick%60)-4, 13-4, sprite1, 0x00080008);
-
- GE2D_SetForeColor(GUI_BLUE);
- GE2D_DrawCircle(32, 48, 24);
-
- GE2D_SetForeColor(GUI_BLUE);
- angle = tick << 3;
- yDiff = 25*(util_sin_fixed28(angle)/65536)/4096;
- xDiff = 25*(util_cos_fixed28(angle)/65536)/4096;
- GE2D_DrawLine(32, 48, 32+xDiff, 48+yDiff);
- yDiff = 25*(util_sin_fixed28(angle+340)/65536)/4096;
- xDiff = 25*(util_cos_fixed28(angle+340)/65536)/4096;
- GE2D_DrawLine(32, 48, 32+xDiff, 48+yDiff);
- yDiff = 25*(util_sin_fixed28(angle-340)/65536)/4096;
- xDiff = 25*(util_cos_fixed28(angle-340)/65536)/4096;
- GE2D_DrawLine(32, 48, 32+xDiff, 48+yDiff);
-
- GE2D_DrawBitmap4(32-4+xDiff, 48-4+yDiff, sprite1, 0x00080008);
-
- HWU_BoardLedCtrl(tick>>3);
- tick++;
- }
- }
复制代码
环境不错,还有后山啊
IMG_20161217_220008.jpg (1.35 MB, 下载次数: 0)
下载附件
2016-12-17 21:48 上传
一周热门 更多>