http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223051_war.jpg
汤哥和皮导又一次的合作为我们带来了近期最令人期待的电影——世界大战

[片名]:世界大战The War of the Worlds
[导演]:斯蒂文·斯皮尔伯格
[主演]:汤姆·克鲁斯、蒂姆·罗宾斯
[出品]:派拉蒙
[上映时间]:2005-06-29
[影视类别]:动作/科幻

[影片介绍]:
  根据HG·威尔斯的同名小说改编,这部小说过去曾有电影与电视版共七个,但规模和影响都不算大。早在上世纪70年代,派拉蒙就试图把威尔斯1898年的这本小说搬上银幕,但最终计划流产。关于此片的另一经典趣闻是:1938年的万圣节,大导演奥逊·威尔斯(Orson Welles)根据原著小说制作的广播剧在美国播出,引起巨大恐慌,威尔斯革命性的艺术技巧令人们信以为真,以为火星人真的登陆了地球。据说当时此剧的听众都纷纷跑到街上,拿湿毛巾挡着头,以保护自己免受"火星毒气"伤害。随后,新闻媒体还对这一事件做了报道,更令此事变得"真假莫辨"。

http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223137_10_2yq5japan2_1024x768.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223148_10_2yq5downloads_art_1024x768.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223200_10_07ycglass_1024x768.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223209_10_sphvphotos_art_1024x768.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223222_10_wtlzmedia_art_1024x768.jpg
http://www.felixwoo.com/wp-content/uploads/attachments/200507/16_223231_10_wtlzglobe_1024x768.jpg


微软的hotmail邮箱默认只能注册@hotmail.com的邮箱,用下面的链接就可以注册@msn.com的邮箱了。
https://accountservices.passport.net/reg.srf?rollrs=11&id=963&sl=1&vv=30

http://www.felixwoo.com/ip/Look_Ip.asp

我的Gmail邮箱email.png于今年五月某日的凌晨3点左右被一心狠手辣卑鄙无耻且毫无技术含量的所谓的黑客给黑掉了。从那天起我便开始了与Google长达2个月的交涉,其间给Google写了N封信,回复总是“您的证据不足”。在我几乎绝望的时候,怀着我对Google几乎殆尽的信心写了第N+1封信……成功!把我的经验和大家分享一下:
1、再复杂的密码都是防君子不防小人
2、真人不露相,真正的黑客是不会迷恋这种低级趣味的。所以不要妥协,为了自己的利益斗争到底。
3、黑客是让你提高安全意识和技术水平的源动力。而收获也不只如此,和Google的交涉让我的英文水平提高不少,呵呵

最后要对那个黑我的人说一句:吃一堑长一智,谢谢了。

毕业了,网站的空间从教育网转移到了上海网通,国外的用户也可以访问了。

The state-controlled China National Offshore Oil Corporation has bid $18.5 billion for Unocal, an American energy company, in the latest sign that China is looking overseas for natural resources and brands. Controversially, acquisitive Chinese firms are getting a lot of help from their government

http://www.felixwoo.com/wp-content/uploads/attachments/200506/29_123938_dragon.jpg

OTHER than capturing the mood of cold-war paranoia, the 1960s film “Battle Beneath the Earth” has little to recommend it. But the message that Communist China was set to take over America by sending an army through a set of tunnels dug beneath the Pacific Ocean played on popular fears. Nowadays it is China’s economic might that has the world in a tizzy, and the Chinese are coming armed with money to buy assets, not guns.

China’s biggest strike so far is an offer for Unocal, a California-based oil and gas firm. On Thursday June 23rd, the state-controlled China National Offshore Oil Corporation (CNOOC) made a cash bid of $18.5 billion for Unocal ($20.6 billion including assumed debt and a break-up fee), trumping a $18 billion share-and-cash offer (including the debt) from Chevron, America’s second-largest oil company. Opponents in America have based their hostility to CNOOC’s bid on national-security issues. The Chinese firm has promised to preserve American jobs and keep Unocal’s products on sale in the country to assuage nationalist sentiment. Unocal said it will evaluate the bid but that its board’s recommendation of Chevron’s offer “remains in effect”.

China’s move for Unocal neatly sums up the two forces driving the country’s ongoing bid to acquire foreign assets: the thirst for raw materials to feed and maintain its booming economy, and the desire to obtain western brands to help market Chinese exports.

Last year China’s economy grew by 9.5%, and the pace does not appear to be slowing much. The economy is in the throes of a gradual transition from state control to the free market. Much of Chinese industry is government-controlled, and some years ago China’s authorities concluded that to challenge the rest of the world they needed to build up to 50 of the country’s better firms into globally competitive multinationals—helping them along the way with tax breaks, free land and all-but-free financing through state-owned banks. The eventual aim was to create national champions that could take on the world’s leading companies while remaining under the watchful eye of the state.

To this end, Chinese firms have made deals to gain access to natural resources. Buying Unocal would give CNOOC fresh oil and gas reserves (many of which are located in Asia) at a time when energy prices are high and China’s appetite is strong. Last year Baosteel, China’s leading steelmaker, entered into joint-ventures in Australia and Brazil to assure supplies of iron ore. PetroChina and Sinopec, the two biggest state oil firms, have also shopped abroad. But this quest for commodities has not always proved successful. Last year China Minmetals, the country’s biggest base-metals firm, failed in a $7 billion attempted takeover of Canada’s Noranda, an ore producer. Fears that Minmetals still harbours ambitions spurred Canada’s government to introduce a bill this week intended to block foreign takeovers on national-security grounds.

As well as securing the natural resources necessary to keep output bubbling, Chinese firms are looking around the world for struggling but globally recognised brands. This is because Chinese companies, while enjoying cost advantages thanks to a vast pool of cheap labour, have an image problem. Foreign consumers think of Chinese goods as admirably cheap but lacking in quality. As Chinese firms move up the “value chain”, they are keen to buy foreign brands that they can attach to their more promising products.

Late last year Lenovo, China’s leading PC-maker, which is connected to the government through its ownership by the Chinese Academy of Science, bought the PC business of IBM for $1.75 billion. Under the terms of the deal, Lenovo acquired the right to use the IBM name on its computers for five years. And this week Haier, China’s leading appliance maker, teamed up with two American buy-out firms to bid $1.3 billion for Maytag in an effort to make a substantial move beyond China, where it has a market share of up to 70% for some products. The ailing American maker of Hoover vacuum cleaners had previously agreed to a $1.1 billion offer from a domestic private-equity firm. In early 2004, China’s TCL bought the television-making business of France’s Thomson, making it the world’s leading volume manufacturer of TV sets.

Undoubtedly, it is quicker (and possibly cheaper) to buy a well-known brand than to build one from scratch. But the Chinese are not throwing money at any and every firm with a well-known name. Shanghai Automotive Industry Corp (SAIC), which last year trumped a South Korean rival to buy Ssangyong, Korea’s fourth-largest carmaker, recently pulled out of a deal to buy MG Rover, a foundering British car company that has since folded. In fact, SAIC had apparently acquired much of the intellectual property that it wanted from Rover and was unwilling to foot the bill to keep the firm going. In this case, the Chinese were as keen to get their hands on useful technology as they were to secure the rights to a western brand.

The Chinese government’s coddling of its state-owned firms is another force behind the current wave of overseas expansion. While officials want to see markets develop at home, up to a point, they fear the fallout from the collapse of hundreds of large, communist-era basket-cases. So the government props these enterprises up with ultra-cheap loans through the banking system and other favours, which have the effect of creating overcapacity and nurturing unfair competition. This, in turn, pushes the more successful state firms, and private companies like Haier, to seek opportunities in markets abroad.

China’s favoured companies, with their access to cut-price funding, will usually be at an advantage compared with overseas rivals when bidding for assets, and may be prepared to pay over the odds. Critics suggest that CNOOC is paying too high a price for Unocal and that the money is coming from China’s government, which has let its desire to create global businesses cloud commercial logic. CNOOC has said it will borrow $16 billion from its government-owned parent and banks to finance the offer.

Shareholders of target firms like Unocal may well be pleased by this readiness to splash out, but their workers might worry. Jobs often go as Chinese buyers shift production to lower-cost plants at home. This fuels opposition to such takeovers in the targets’ countries. But for now at least, the spread of Chinese business around the world is set to continue.

http://www.felixwoo.com/wp-content/uploads/attachments/200507/17_005535_4year.jpg
  本想把大学的回忆封存起来,就像黑盒测试一样,不考虑中间的过程如何,只关心输入的变量和输出的结果。然而,我越来越觉得如果只把这四年黑盒测试的结果作为下一个黑盒的输入,那么本是连续的丰富多彩的生活和记忆却被抽样成离散了。确实应该明察黑盒中的每个过程,把四年中值得回忆的细节都记录下来,这样我的大学生活才算功德圆满。

  中学的时候从来没想到我的大学会走出这样的路,就连现在的我也惊异自己的变化。可能这种变化从高中就埋下了种子,在大学生根发芽。初中的我绝对是个不折不扣的听话懂事爱学习的孩子,毕竟中考全校第三还是能佐证我的评价的。然而从高中开始,我便走上了素质教育的不归路,那时还被树立为我们学校素质教育的典型,而代价是不那么听话、不那么爱学习了。追求思想解放和不受约束的行动自由成为了我当时人生观的主要内容,然而大学正是给了我实现理想的沃土,但却没有成为我学习的良田。

  大学的我一共做了两件事,应付考试和用心网协。对计算机的偏执和热爱的我来到大学的第一件大事就是加入了网络开拓者协会。通过我的努力两年后我成为了网协的当家。然而当时的协会是盛名之下,其实难副。资金短缺、设备落后、人才流失……我的主要精力都投入到了协会的发展中,经过了非典黄金月的洗礼和黑客的一次又一次拜访,网协逐渐又壮大了起来。网协论坛、视听在线、网络广播电台、电子竞技、校内即时通讯等等成为了校园网上最受同学欢迎的服务。网络技术讲座、金秋网络节、电子竞技联赛、网协论坛庆典等活动不仅锻炼了我也丰富了校园生活。一个社团之所以让我如此投入,是因为一点:我可以按照自己的想法做事情。这样的自由在学生会甚至是校内的其他社团都是相当奢侈的。我在这里体验了白手起家的艰难和指点江山的激情,体会了团队合作的重要和情同手足的感动。在即将离开校园的时候,当我再次回想起在网协的日日夜夜,我才发现我留给了网协问心无愧的汗水,网协也留给了我珍贵的体验和美好的回忆。“为什么我的眼里常含着泪水,因为我对网协爱得深沉!”

  说起大学的学业,我算得上一波三折。物理系一班,电子系实验班,电子系三班都是和我有关的班号。一个月,一年,三年,我很自豪我曾经是实验班63人中的一员,我也很自豪我现在是一名三班人。无论是在实验班还是现在的三班我生活的关键字都和学习无关。这也难怪我跟别人我说我去自习他们说我虚伪,我跟别人说我要考研他们说我有病。似乎我的大学真的是和学习背道而驰了。

  大学四年我改变了很多,唯一没变的是我的理想。小时候我的理想是当一名发明家,偶像自然是爱迪生。中学时我的理想是创办一家自己的计算机公司,偶像当然就是比尔了。现在,我的理想似乎并不具体,但却很明确——开创自己的品牌。在我的价值观中,为人类和社会创造价值才能体现出我存在的意义。像通用、福特这样的百年品牌是不会因为斯隆和福特的离开而消失。我知道自己成为斯隆和福特这样的人属于小概率事件。但创办世代传承品牌的理想并不狂妄,无论是服装品牌、IT品牌、教育品牌还是饮食品牌都是我理想的元素。大学四年的时光让我提前享受了打造品牌的乐趣,更加坚定了我实现理想的信心。

  大学时光太长了,因为四年的时光对于我们来说实在太珍贵;大学时光又太短了,因为自己还有很多知识要学,还有很多事情没有做,还有很多的同学没能熟识。如果有人问我现在最想做的事,我会跟他说:再借我四年。

Apple has announced that it will switch its computers from microprocessors supplied by IBM and Freescale to those made by Intel, the world’s biggest chipmaker. Emboldened by the success of its iPod music player, this is Apple’s latest move in an attempt to return to the mass market

http://www.felixwoo.com/wp-content/uploads/attachments/200506/09_091939_apple.jpg

ASK people to describe their computers. Most, with a shrug, will mention a couple of grey-coloured (or is that cream?) boxes, and software that crashes occasionally. But the sliver of the population who own one of Apple’s products are more likely to enthuse about the cool design of their hardware and the robustness and user-friendliness of their software. It is a surprise, then, that more people don’t chose the American firm’s computers. This is what Steve Jobs, its chief executive, hopes to put right.

On Monday June 6th, Mr Jobs used the platform of Apple’s annual developers conference to announce that the firm will switch from the chips supplied for over a decade by IBM and Freescale (which was spun off from Motorola last year) to products from Intel, the world’s biggest chipmaker. The first products with Intel chips should be available next year. Most observers suggest that the move is part of a strategy dedicated to returning Apple to the mass market for computers, which it dominated before the advance of Microsoft and Intel in the 1980s.

There are several suggestions about what prompted the change. Apple blamed its current chip suppliers for slow delivery last year, which held up production of some lines. And chip development has not lived up to promises Apple made for improvements in processing speed. Intel’s chips are faster and run cooler than Apple’s current chips. And cooler chips are important for the production of better laptops, a market growing considerably faster than that for desktop PCs. But there is much speculation that Intel can simply supply chips more cheaply than IBM and Freescale, and that Apple can use the saving to cut the retail price of its computers.

Apple’s problems in increasing its market share are, to a large extent, a result of the high prices it charges for its computers compared with similar products from the likes of Dell or Hewlett-Packard. Apple sold only around 2.3% of new desktop and laptop computers worldwide in the first quarter of 2005, according to IDC, a research firm. Dell commanded 18.9% of the market, HP 15.4%. But Apple is concentrating hard on ways to improve its market share and is banking on the huge success of the iPod, its digital music player, to create a “halo effect” and speed the revival of Apple as a force in world computing.

The firm’s recovery has been apparent for 18 months, after several years in the doldrums. In 2004, Apple’s net profits were four times higher than the year before, at $276m, and in mid-April the firm announced another blistering set of quarterly results: revenues up by 70% compared with the same period the year before, and net profits 530% higher, at $290m; Apple shipped over 1m computers (a 43% rise) and a staggering 5.3m iPods (over six times more than the year before).

The iPod has done wonders for Apple, providing not only profits but a positive brand image to a swathe of new young consumers. Though the iPod was derided by some as exorbitantly expensive at the time of its launch in 2001, it has amassed some two-thirds of the world market for hand-held music devices. And not content with anything less than total domination, in January Apple introduced the iPod shuffle, a flash-memory player, which is naturally smaller and better looking than anything the competition can yet muster. No wonder iTunes, Apple’s online music store, leads the field.

But Apple still makes most of its cash from computers, and to extend its product range it introduced the Mac mini at the beginning of the year. This small, relatively cheap computer comes without “peripherals”—customers can add their own keyboard, mouse or screen. This helps to keep costs low and so, it is hoped, will nudge more users of Microsoft’s Windows to switch to Apple. Mr Jobs hopes to spread the Apple message further still through a network of Apple retail stores. There are now over 100 around the world in prized locations.

The lead that the iPod has in the hand-held music player market looks unassailable for the time being. That said, Bill Gates is touting Microsoft’s own software format, Windows Media, to several online music services and hardware firms, hoping to set a rival standard with greater interoperability. At present, iTunes offerings only work with the iPod. Mr Gates suggests that the convergence of mobile phones and music players (using his software, of course) could threaten the iPod’s dominance. Apple should take the threat seriously. Nokia recently announced that it was preparing to launch a handset with a hard drive. Sony Ericsson will unveil its first Walkman phone later this year. To counter these threats, a deal between Motorola and Apple is expected to spawn phones with iTunes included in a couple of months.

If Apple is to make the most of the halo effect from the iPod to push its upmarket computers on greater numbers of customers, it would be well to do so as soon as it can. Such is the importance of the iPod to Apple that on June 3rd the firm’s shares fell by 4.5% after analysts suggested that sales of the device may be flat in the current quarter. If the halo slips, Apple may have to content itself with selling its wares just to the select, fashion-conscious bunch who presently make up the company’s loyal fan base.

1.引言
  液晶显示器(LCD)具有显示信息丰富、功耗低、体积小、重量轻、超薄等许多其他显示器无法比拟的优点,近几年来被广泛用于单片机控制的智能仪器、仪表和低功耗电子产品中。LCD可分为段位式LCD、字符式LCD和点阵式LCD。其中,段位式LCD和字符式LCD只能用于字符和数字的简单显示,不能满足图形曲线和汉字显示的要求;而点阵式LCD不仅可以显示字符、数字,还可以显示各种图形、曲线及汉字,并且可以实现屏幕上下左右滚动、动画、分区开窗口、反转、闪烁等功能,用途十分广泛。本文介绍点阵式液晶显示器HS12232-1、HS12232-9与单片机的接口及编程的方法,同时给出两种显示器常用的字符显示和汉字显示程序。

2.不带汉字库的HS12232-1下的汉字显示
  2.1 显示原理
  利用PC上的16×16点阵汉字库,提取后将点阵文件存入ROM,直接利用PC中汉字内码作为单片机系统的编码(不再形成新的汉字编码)。

  2.2 硬件组成
  首先要采用点阵图形液晶显示器。(例如一行为240点,总列数为128点,可以容纳16×16点阵的汉字15个[因为240/16=15],128列可以显示8行[因为128/16=8]),广州市千喜科技开发有限公司的HS12232-1内置SED1520驱动控制器的点阵为122×32点,每行7个半汉字,共2行。如果要扩展存储器,全部国标16×16点阵汉字、8×16点阵的ASCII码点阵数据及汉字语句编码数据要使用1片512KB的存储器来存储,多出部分可以留作数据存储器。本文只探讨液晶显示器与单片机的接口部分,扩展存储器部分略。下面给出HS-12232-1与单片机8031的一种接口,如图1所示(VDD=+5V)。

  2.3 汉字显示原理
  国家标准信息交换用汉字字符集GB 2312-80共收录了汉字、图形符号等共7445个,其中汉字6763个,按照汉字使用的频度分为两级,其中一级汉字3755个,二级汉字3008个。汉字、图形符号根据其位置将其分为94个“区”,每个区包含94个汉字字符,每个汉字字符又称为“位”。其中“区”的序号由01区至94区,“位”的序号也由01位至94位。若以横向表示“位”号,纵向表示“区” 号,则“区”和“位”构成一个二维坐标。给定一个“区”值和“位”值就可以确定一个惟一的汉字或图形符号。即4位阿拉伯数字就可以惟一地确定一个汉字或符号。如“北”字的区位码是“1717”,而京字的区位码是“3009”。前两位是“区”号,后两位是“位”号。其中1至15区是各种图形符号、制表符和一些主要国家的语言字母,16区至87区是汉字,其中16区至55区是一级汉字,56至87区是二级汉字。

  UCDOS软件中的文件HZK16和文件ASC16分别为16×16的国际汉字点阵文件和8×16的ASCII码点阵文件,HZK16中按汉字区位码从小到大依次存放国标区位码表中的所有汉字,每个汉字占用32字节,每个区为94个汉字。而asc16文件中按ascii码从小到大依次存有8×16的ASCII码点阵,每个ASCII码占用16字节。

  PC的文本文件中,汉字是用机内码的形式存储的,每个汉字占2字节,其中第一个字节为机内码的区码,汉字机内码的区码范围是从0A1H(十六进制)开始,对应区位码中区码的第一区;而机内码的第二个字节为机内码的位码,范围也是从0A1H(十六进制)开始,对应某区中的第一个位码。就是说将汉字机内码减去0A0AH就得到该汉字的区位码。例如汉字“北”的机内码是十六进制的“B1B1”,其中前两位“B1”表示机内码的区码,后两位“B1”表示机内码的位码。所以“北”的区位码为0B1B1H-0A0A0H=1111H,将区码和位码分别转换为十进制,得汉字“北”的区位码为“1717”。即“北”的点阵位于第17区的第17个字的位置,在文件HZK16中的位置为第32×[(17-1)×94+(17-1)]=48640D以后的32个字节为“北”的显示点阵。用RF-1800编程器读入二进制文件hzk16j.bin后利用其编辑功能中的缓冲区编辑查找到BE00 H (48640D是十进制,将其转变为十六进制后得BE00 H)开始的32个字节:04 80 04 80 04 88 04 98 04 A0 7C C0 04 80 04 80 04 80 04 80 04 80 04 80 1C 82 E4 82 44 7E 00 00(以上全为下十六进制),将其写在16×16点阵方格纸上,即得图2。由此可以理解其相互逻辑关系。

  在单片机系统中,连续取32个字节送到LCD的相应位置,就能正确显示汉字后的图形符号。从HS-12232-1使用的SED1520的控制原理得知,字模送显示前要旋转90°,例如“逢”的区位码是3778,在HZK16中的位置为第32*[(37-1)*94+(78-1)]=110752D以后的32个字节:04 44 FF FE 05 40 41 F8 33 10 14 E0 01 18 F6 46 1B F8 10 40 13 F8 10 40 17 FC 10 40 28 46 47 FC , 旋转90°后上16个字节:82 8A 92 B2 02 A7 92 5E 2A AF 2A 5A 4A 83 82 00,下16个字节;00 80 40 3F 04 90 95 95 95 FF 95 95 95 D0 40 00。

  2.4 ASCII码的显示原理
  ASCII码的显示与汉字的显示基本原理相同,在ASC16文件中不存在机内码的问题,其显示点阵直接按ASCII码从小到大依次排列,不过每个ASCII码在文本文件中只占1个字节并且小于80 H, 每个ASCII码为8×16点阵,即在ASCII16文件中,每个ASCII码的点阵也只占16个字节。

3.带汉字库的HS12232-9下的汉字显示
  广州市千喜科技开发有限公司阵的HS12232-9内置ST7920A驱动控制器,点阵为122×32点,每行7个半汉字,共2行。内部字型ROM 包括8192个16×16点阵的中文字型和126个16×8点阵的字母符号字型,另外还提供一个64×256点的绘图区域(GDRAM)及240点的ICON RAM,可以和文字画面混合显示。内含的CGRAM有4组可编程的1616点阵的造字功能。与单片机的接口有8位并行、4位并行、2/3线串行。它采用低功率电源消耗,电压范围2.7~5.5V,功能齐全,汉字、点阵图形、ASCII码、曲线同屏显示;上下左右移动当前显示屏幕、清屏、光标显示、闪烁、睡眠、唤醒、关闭显示功能齐备,适合许多场合应用。上面使用了并行方式,现在研究串行方式。

  3.1 串行时序与硬件接口电路
  HS12232-9与单片机的串行接口时序如图3所示,即24个时钟脉冲传送一个字节。单片机首先发送数据传输起始位5个“1”,HS12232-9收到连续的5个“1”,内部传输被重置,同时串行传输被同步,紧接着RW位用于决定数据的传输方向(读还是写),RS用来选择是内部数据寄存器还是指令寄存器,第8位固定为“0”。收到起始位、RW、RS、“0”组成的第一个字节后,一个字节的数据或指令被分成两个字节来串行传送或接收。数据或指令的高4位被放在第二个字节串行数据的高4位,低4位补4个“0”,数据或指令的低4位被放在第三个字节串行数据的高4位,低4位补4个“0”,这样完成一个字节或数据的传送。HS12232-9内部没有发送/接收缓冲区,传送节奏要注意,否则要丢指令或数据。

  PIC16C5X单片机与HS12232-9接口电路如图4所示,只占用RA0、RA1两根I/O口,或者用16f877的RD6、RD7两根I/O口,RS(CS)引脚是片选,只有一片时固定接高电平使片选始终有效,SID引脚作数据线,SCLK引脚作时钟线。单片机通过SID数据线在SCLK同步时钟线配合下完成数据(指令)传输的任务。接口电路十分简单。

4.结束语
  利用自带字库的中文液晶图形点阵模块串口接口方式的优势比并口明显,节省I/O了口,不占用ROM,接口电路简单,解决了显示汉字
字符数量有限的瓶颈问题和小体积非总线结构单片机的汉字显示问题。笔者相信今后其使用率将逐步提高,对照本文的串并口两种方式,希望对广大同行在使用液晶图形点阵模块时有所启发和帮助。

  在具体介绍gba编程之前,我想先感谢一个人,他就是 水银 兄。在我学习的过程中水银兄给了我很多有用的宝贵资料,在此我向他表示感谢。

  GBA是新一代的32位手掌机,强大的机能吸引了无数玩家和编程爱好者。现在用于开发的编译器有两种,一种是完全免费的GCC,和收费的ARM SDT,目前我在使用的是gcc,虽然网上也有D过来的arm sdt但我是无福享用的,23MB的大家伙啊,当初下载gcc这个12MB的东东时我就已经吐血了,可怜我的小猫啊。

  好了,废话少说,进入正题。GBA使用的是卡带也就是只读rom为存储载体虽然容量可以很大,但问题也不少。也就是说我们不可能动态的分配使用卡上的内存了尽管它可以有128MB。当然gba也为我们提供了ram,至于容量嘛……,看下面的资料知道了。

单词含义:
1. GBA – 'Game Boy Advance' ^_^
2. BG(Backgroud) – '背景'
3. Sprite – '精灵'
4. Tile – '地图图块'
5. RAM(Random Access Memory) – '随机访问存储器'

接口地址 :

  外部 RAM: 地址: 0×02000000 大小: 256Kb 作用: 存放程序及数据
  内部 RAM: 地址: 0×03000000 大小: 32Kb? 作用: 我想是高速内存,和cache作用一样吧
  IO RAM: 地址: 0×04000000 大小: 1Kb 作用: 控制图像,声音,DMA等内存映射IO
  Palette – '调色板'
  地址: 0×05000000 大小: 0×400 bytes 作用: 存放调色板数据
  VRAM(Video RAM) – '视频内存'
  地址: 0×06000000 大小: 0×20000 bytes 作用: 位图模式下存放帧缓冲数据,图块模式下存放图块数据及图块地图数据
  OAM(Object Attribute Memory) – '精灵对象属性内存'
  地址: 0×07000000 大小: 0×400 bytes 作用: 用于控制精灵

6. ROM(Read Only Memory) – '只读存储器'
地址: 0×08000000 大小: 看你的游戏卡的大小罗 作用: 存放所有的程序和数据
7. ARM – 32bit 指令系统 (RISC,精简指令集)
8. Thumb – 16bit 指令系统 (具体区别详见 http://gbadev.org/files/armthumb-romram.txt)
9. DMA(Direct Memory Access) – 直接内存访问
10.DISPCNT(Display Controller) – 显示控制(内存地址)

  当初看水银兄写的gba教程时一直不明白明明是256色模式,可指向VRAM的指针却是short型的。后来才知道,gba访问VRAM时一次必须读写2个字节,即16bit。我晕~~!所以我只好严格要求自己的blit函数。虽然也找到一个可以写8bit的putpixel函数代码,但速度太慢了不适合用在显示大量图片的地方。

  需要注意的地方大概都说完了,我们可以进入代码部分了。

  虽然是专用游戏机,但显示模式也需要设定才行。

#define REG_DISPCNT *(u16*)0×04000000// 显示寄存器地址
#define VRAM 0×06000000 // 图像缓冲区地址
#define M5_VRAM 0×0600A000 // M5缓冲区地址
#define BACKBUFFER 0×010// 双缓冲/背缓冲地址
#define PALETTE 0×5000000// 调色板地址
#define MODE_3 0×03 // 240*160 15位/单缓冲区
#define MODE_4 0×04 // 240*160 8位/双缓冲区
#define MODE_5 0×05 // 160*128 15位/双缓冲区
#define BG2_ENABLE 0×0400 // BG_2
#define SetMode(Mode) REG_DISPCNT=(Mode) // 设置显示模式的宏定义

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;

typedef struct BITMAP
{
int x,y,w,h;
u16 MskCol;
float bitx,bity;
u8 flag;
u16 *dat;
}BITMAP;

BITMAP screen;

u16 *palette_mem = (u16 *)PALETTE;

void grp_init()
{
SetMode(MODE_4|BG2_ENABLE);
screen.w=240;
screen.h=160;
screen.dat=(u16 *)VRAM;
}

这样我们就进入了240*160*256的模式了, SetMode中的BG2_ENABLE这个参数不能少否则将没有任何显示。为了能够正常的显示图象还需要设置调色板。

void set_palette(unsigned short *palette)
{
int loop;
for(loop=0;loop<256;loop++)
{
palette_mem[loop] = palette[loop];
}
}

调色板数据可以从bmp2gba转换bmp图象后的.h中得到,需要注意的是bmp2gba不能够正确的转换过大的图象,大概是240*160以上的图片转换后都有问题,所以我自己写了一个pic2gba,可以转换256色的pcx,bmp(未压缩,转换前还需要进行一下旋转处理),gif格式的程序,但我不知道bmp2gba是如何转换调色板数据的,所以这部分数据是不正确的。

pic2gba使用方法:pic2gba in-file out-file。

水银兄的教程中是直接使用图象数据的,这对以后写game可不是一个好的方法,所以我才定义了BITMAP结构既然要显示图象就需要将图象数据装入BITMAP:

BITMAP load_bitmap(int width,int height,const unsigned char *dat)
{
BITMAP bitmap;
bitmap.dat=(u16*)dat;
bitmap.x=bitmap.y =0;
bitmap.w=width;
bitmap.h=height;
bitmap.MskCol=*bitmap.dat;
bitmap.flag=TRUE;
return bitmap;
}

然后再blit:

void blit(BITMAP dst,BITMAP src,int x1,int y1,int x,int y,int w,int h)
{
register int i=0,j;
register u16 *_bak1,*_bak2;
_bak1=dst.dat;
_bak2=src.dat;
_bak1+=x1+y1*(dst.w>>1);
_bak2+=x+y*(src.w>>1);

while(i<h)
{
memcpy(_bak1,_bak2,w);
_bak1+=120;
_bak2+=src.w>>1;
i++;
}
}

这个是最快的方法了。哦,对了还有更快的方法:直接使用DMA,可惜我这没资料。

如果是要显示汉字,除了水银兄的方法外(比较适合游戏中使用)也可以把整个汉字库都放到rom中去,用这个rhzk程序来转换数据。(需要UCDOS的HZK16,ASC16两个字库。)因为这里要写点,速度要求也比较低可以使用这个函数:

inline void putpixel(BITMAP bmp,int x,int y,u8 col)
{
u16 *tc;
tc=bmp.dat+(y)*(bmp.w>>1)+(x>>1);
if(x&1)*tc=((*tc&255)+(col<<8));
else
*tc=(*tc&65280)+col;
}

下面的是显示汉字的主体部分了,

struct ChinaHzk{
short len;
const u8 *CHzkBuf,*AHzkBuf;
char Loadhzk,HZK;
ChinaHzk();
}ChinaHzk;

ChinaHzk::ChinaHzk()
{
CHzkBuf=_CHzkBuf;
AHzkBuf=_AHzkBuf;//这两个指针在rhzk程序转换后的.h中定义
}

void hzput(int x,int y,int col,BITMAP bitmap1)
{
u8 dot;
register int i,j,k,mask;
if(ChinaHzk.HZK)
{
for(i=0;i<=15;i++)
{
for(j=0;j<=1;j++)
{
dot=*ChinaHzk.CHzkBuf++;
mask=0×80;
for(k=0;k<=7;k++)
{
if(dot&mask)
putpixel(bitmap1,x+j*8+k,y+i,col);
mask>>=1;
}
}
}
}
else
for(i=0;i<=15;i++)
{
dot=*ChinaHzk.AHzkBuf++;
mask=0×80;
for(k=0;k<=7;k++)
{
if(dot&mask)
putpixel(bitmap1,x+k,y+i,col);
mask>>=1;
}
}

ChinaHzk.HZK=1;
}

//显示字符
void textout(BITMAP bitmap1,char *Str,int x,int y,unsigned char col)
{
register unsigned long offset1;<
br /> int oldx;
const u8 *_bakCHzkBuf,*_bakAHzkBuf;

_bakCHzkBuf=ChinaHzk.CHzkBuf;
_bakAHzkBuf=ChinaHzk.AHzkBuf;
oldx=x;
while(*Str)
{
if(*Str=='\n') {y+=17;x=oldx;*Str++;continue;}
if(*Str==' ') {x+=8;*Str++;continue;}

if(!(*Str&0×80))
{
offset1=*Str<<4;
ChinaHzk.HZK=0;
ChinaHzk.AHzkBuf+=offset1;
hzput(x,y,col,bitmap1);
if(x+8+ChinaHzk.len<bitmap1.w)
{
x+=(8+ChinaHzk.len);
}
else
{
y+=17;x=oldx;
}
Str++;
ChinaHzk.HZK=1;
ChinaHzk.AHzkBuf=_bakAHzkBuf;
continue;
}

offset1=(unsigned int)((((*Str+95)<<6)+((*Str+95)<<5))-((*Str+95)<<1)+(*(Str+1)+95))<<5;
ChinaHzk.CHzkBuf+=(unsigned int)(offset1-778240);
hzput(x,y,col,bitmap1);
if(x+16+ChinaHzk.len<bitmap1.w)
{
x+=(16+ChinaHzk.len);
}
else
{
y+=17;x=oldx;
}
Str+=2;
ChinaHzk.CHzkBuf=_bakCHzkBuf;
}
}

//显示字符
void OutText(BITMAP bitmap,int x,int y,char *str,…)
{
va_list ptr;char *strr;
strr=(char*)malloc(strlen(str)+2);
va_start(ptr,str);
vsprintf(strr,str,ptr);
va_end(ptr);
textout(bitmap,strr,x,y,_COLOR);
free(strr);
}

你可以直接使用textout来显示也可以用OutText显示 变量-》字符 这样的信息,例:

OutText(screen,100,100,"X=%d,Y=%d",x,y);

有了这些基本函数,我想你已经可以写出一些东西来了,更多的资料请下载我写的函数库 GBA.ZIP
也许你看了这些会觉得有些眼熟,是的,如果你以前曾用过我写的游戏开发库Beauty的话,会发现基本上代码没有改变,而我当初也的确是有着样的想法, 即使在不同的平台上,不同的系统但使用一套相似的开发库进行开发可以为以后的移植工作省下很大力气。我在进行gba程序编写时就一直在使用Beauty库做测试相比之下要比用gba模拟器方便的多。

京ICP备05053527号
经过25次查询历时5.849秒终于生成了此页面
Powered by WordPress & Designed by Felix © 2008