这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 杀手锏--不到500元的ARM平台(带240X160的彩色液晶显示)

共7条 1/1 1 跳转至

杀手锏--不到500元的ARM平台(带240X160的彩色液晶显示)

菜鸟
2002-07-05 04:27:51     打赏
如果你想玩ARM,又没有硬件,你还等什么?不要说你们那地方没有卖GBA的   目 录   1 GBA开发包   2 开发包的安装   3 最简单的程序   4 在MODE_4的程序   5 在MODE_5的程序   6 全屏显示的程序   7 GBA的双缓冲显示   8 GBA的按键输入   9 简单声音输出   10 用图素创建背景   11 实现背景的旋转   12 GBA下的中文显示   13 电子书的制作   14 12点阵的汉字库   15 传输函数与时钟函数   16 地图显示   17 精灵显示 1、DevKitAdv简介   GBA的开发包DevKitAdv主要包括两部分,一是GCC++编译器,二是GBA库。GCC++编译器功能和我们常用的VC差不多,只不过少了个编辑源代码的文本编辑器(至少我没发现,我用的是EditPlus,UltraEdit也可以),还有就是 — 不支持类(class),真是让人头痛,只能用结构体(struct)来替代。它的作用是把我们写的代码编译成二进制的可执行文件,当然这个可执行文件是相对GBA和GBA模拟器而言的。就象Windows里的EXE文件无法在Mac机上使用是一样的道理。GBA库提供了图像,控制及声音一系列的函数,和GCC++配合使用。链接地址(devkitadv.zip)。 2、DevKitAdv的安装   没啥好说的,解压后就可以直接使用,编译时设置DevKitAdv的路径就可以了,建议做一个批处理文件,比如:go.bat。   set PATH=d:\devkitadv\bin;%PATH%   cmd (Windows 98是command) 3、最简单的GBA程序(t1)   // main.c   // 一些基本数据类型   typedef unsigned char u8;   typedef unsigned short u16;   typedef unsigned long u32;   #define REG_DISPCNT  *(u16*)0x04000000  // 显示寄存器地址   #define VRAM      0x06000000      // 图像缓冲区地址   #define M5_VRAM    0x0600A000      // M5缓冲区地址   #define BACKBUFFER   0x010        // 双缓冲/背缓冲地址   #define PALETTE    0x5000000      // 调色板地址   #define MODE_3     0x03         // 240*160 15位/单缓冲区   #define MODE_4     0x04         // 240*160 8位/双缓冲区   #define MODE_5     0x05         // 160*128 15位/双缓冲区   #define BG2_ENABLE   0x0400        // BG_2   #define SetMode(Mode) REG_DISPCNT=(Mode)  // 设置显示模式的宏定义   // ----------- 主程序 ------------   int main()   {     // 设置屏幕模式,这里使用MODE_4     SetMode (MODE_4 | BG2_ENABLE);   }   1)MODE_5与MODE_3都是16位(bits),但MODE_3是单缓冲,制作动画效果肯定没双缓冲好,因此排除MODE_3。   2)MODE_4是8位,理论上256色对于掌机够用了,虽然16位真彩的诱惑没有人想抗拒,可MODE_5只有160*128,在实际应用中建议还是使用MODE_4。   很简单吧 — 的确是的,现在要用GCC编译它:   gcc -lm -o main.elf main.c   objcopy -v -O binary main.elf main.bin   你会看目录下多了个“main.bin”,这个就是能在GBA模拟器上执行的二进制文件。教程中t1-t7目录为源程序目录,里面有个make.bat,修改代码后直接执行它就可以编译,但要注意我的DevKitAdv是装在D盘,你要是装在别的盘就得改一下make.bat的path参数。 4、在MODE_4背景层画图的GBA程序(t2)   在GBA的MODE_4里画一幅图要经过3个步骤:   1)把原始256色图像文件转换成“*.h/*.c”的数据文件,我们用的是“BMP2GBA”工具,这里以“image.bmp”为例,转换后我们就得到了一个“image.h”文件。   2)在程序开头包含“image.h”,这样就能在程序中使用“image.h”定义的调色板和图像数据。   3)在程序中把“image.h”定义的调色板和图像数据写入MODE_4背景层的调色板和图像缓冲区。   另外,GBA还有专为精灵设置的物体层。它的用法和背景层一样,只是功能有点不一样,地址是0x06000000。有关用这里就不详细说了,大家可以把精灵数据直接输出到物体缓冲区就可以了。下面是源程序:   ... ...   // 包含图像调色板和数据的头文件   #include "gfx/image.h"   // ----------- 全局变量 --------   // 系统调色板   u16* palette_mem=(u16*)PALETTE;   // 图像缓冲区   u16* video_buffer=(u16*)VRAM;   // ----------- 函数定义 ---------   // MODE_4绘图函数   void Draw(u16* src_palette,u16* src_data,u16* dst_palette,u16* dst_data);   // ----------- 主程序 ------------   int main()   {     // 设置屏幕模式,这里使用MODE_4     SetMode (MODE_4 | BG2_ENABLE);     // 在背景层画图,Palette和Data是在"image.h"定义的调色板和图像数据数组名     Draw(Palette,Data,palette_mem,video_buffer);   }   // MODE_4绘图函数   void Draw(u16* src_palette,u16* src_data,u16* dst_palette,u16* dst_data)   {     int loop,x,y;     // 写入目的调色板     for(loop = 0; loop < 256; loop++)       dst_palette[loop] = src_palette[loop];     // 写入图像缓冲区     for(x = 0; x < 120; x++)     {       for(y = 0; y < 160; y++)       {         dst_data[(y) *120 + (x)]=src_data[(y) *120 + (x)];       }     }   }   编译后得到main.bin,然后在BA模拟器里运行,就可以得到这样的结果。大家看了可能有点失望~是啊,256色用来表现图像实在......。下一步我们就使用MODE_5来画16位真彩的眉眉。 [upload=jpg]uploadImages/20027420255640203.jpg[/upload]



关键词: 杀手锏     不到     500元     平台     240X160     彩色    

菜鸟
2002-07-05 04:29:00     打赏
2楼
[upload=jpg]uploadImages/20027420294166282.jpg[/upload]

菜鸟
2002-07-05 04:31:00     打赏
3楼
The Basics From the programmer's perspective, the system is composed of the following: CPU - A 16.78 Mhz ARM7tdmi Memory - 8 to 11 distinct areas of memory (depending on the Game Pak). IO - Special hardware functions available to the programmer, primarily pertaining to graphics, sound, DMA, timers, serial communication, key input, and interrupts. Programs run on the GBA are usually contained in a "Game Pak". A "Game Pak" consists mainly of ROM and possibly Cart RAM (in the form of SRAM, Flash ROM, or EEPROM, used mainly for save game info). The ROM is where compiled code and data is stored. Unlike home computers, workstations, or servers, there are no disks or other drives, so everything that might otherwise have been stored as separate resource files must be compiled into the program ROM itself. Luckily there are tools to aid in this process. The primary means a program accesses specialized hardware for graphics, sound, and other IO is through the memory-mapped IO. Memory mapped IO is a means of communicating with hardware by writing to/reading from specific memory addresses that are "mapped" to internal hardware functions. For example, you might write to address 0x4000000 with the value "0x0100", which tells the hardware "enable background 0 and graphics mode 0". A secondary means is through the BIOS, which is embedded in the internal GBA system ROM. Using software interrupts it is possible to access pre-programmed (and hopefully optimized) routines lying in the the system ROM. These routines then access the hardware through the memory-mapped IO. Other regions of memory that are directly mapped to the hardware are Palette RAM (which is a table consisting of all the available colors), VRAM (which performs a similar function to the video RAM on a PC - and thensome), and OAM (which contains the attributes for hardware accelerated sprites). Programming for the GBA C, C++, and ARM/Thumb assembly are the most common languages used in GBA development, mainly because they are fast and relatively low level (i.e. there is a large degree of correspondance between the structure of the language and underlying instruction set of the architecture). Members of the GBA development community have put together some development kits that greatly simplify the task of configuring a C/C++ compiler for GBA development. Two that I know of are Devkit Advance and HAM. Most GBA programs are structured around the timing of the CPU and graphics hardware. The LCD has a refresh rate of about 59.73 hz, with each refresh consisting of a vertical draw period (when the GBA is drawing the screen) followed by a vertical blank period (when nothing is being drawn). The vertical draw and vertical blank periods are further subdivided into horizontal draw and blank periods. Programs typically use the VBlank and possibly the HBlank periods to update VRAM or graphics hardware registers in order to avoid unwanted visual artifacts, leaving the VDraw and HDraw periods to perform any software processing that will not effect the display. Common methods of syncing to VBlank include polling REG_DISPSTAT or REG_VCOUNT, calling the VBlankIntrWait BIOS function, or setting up an interrupt. For those wishing to learn how to write a program for the GBA, this is not really the right place. This document is more like a reference that you can keep open in the background and quickly thumb through as questions arise. However, I suggest the following resources as being invaluable to the beginner: http://www.gbadev.org - This is one of the main hubs for GBA development on the web, containing numerous docs, tutorials, demos (many with source code), tools, and news. http://www.devrs.com/gba - This is Jeff Frohwein's GBA site. Jeff Frohwein is something of a GBA dev guru; you will likely hear his name mentioned often throghout the community. His site contains many good links, documents, and tools, many of which he wrote himself. http://groups.yahoo.com/group/gbadev/ -A forum on yahoo with a large archive of back posts. PERN project tutorials - These great tutorials by Dovoto explain everything in an easy-to-understand, step-by-step fashion. The Audio Advance - Documents and tutorials on the formerly enigmatic GBA sound system. Courtesy of Uze. HAM - Emanuel's HAM devkit is especially easy to install and can have you up and running in minutes.

菜鸟
2002-07-05 04:40:00     打赏
4楼
[upload=jpg]uploadImages/20027420395380796.jpg[/upload] [em27][em27][em27][em27][em27][em27][em27][em27]

菜鸟
2002-07-05 17:39:00     打赏
5楼
不是,是游戏机,任天堂的GBA

菜鸟
2002-07-05 17:58:00     打赏
6楼
可以啊,国外的开发已经如火如荼。可以到我帖子中提到的网站看看,我第一次去的时候简直象发现了一个宝藏。

菜鸟
2002-07-08 19:50:00     打赏
7楼
These tools allow you to upload data, images, multiboot files to the GBA and debug programs by using a simple UART (normal serial port) cable (maybe MBV2 too) [upload=gif]uploadImages/20027811492329422.gif[/upload]

共7条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]