PSP编程概述



掌叔
2008-06-16 08:37:51

摘自:[url]http://www.blogjava.net/liwei[/url]

元旦准备买NDS,顺带关注了下PSP,其实是想,或许买PSP也不错~
PSP很像一个平台,提供了很多东西,譬如官方的PS模拟器~在上面编程也是个不错的想法。

国外的一个网站提供了很多信息,PS2Dev Network ([url]http://www.ps2dev.org[/url]),有教程[url]http://ps2dev.org/psp/Tutorials[/url],现在由于不久前的地震,基本无法登陆那个网站。更多的信息在[url]http://wiki.ps2dev.org/[/url]。
要想进行PSP编程,需要学习C或C++。在windows下,需要安装Cygwin [url]http://www.cygwin.com/[/url], 这其实是个模拟linux的环境。在Mac OS X或Linux下需要编译PSPSDK和PSP 工具。这些东西都可以在[url]http://ps2dev.org/psp/Projects[/url]找到。

ScriptScribbler ([url]http://www.scriptscribbler.com[/url]) 这个网站现在提供3篇教程,是由Brad Dwyer写的。他也可能会增加教程。第一篇([url]http://www.scriptscribbler.com/psp/tutorials/lesson01.htm[/url]) 教你在windows上搭建开发环境。第二篇([url]http://www.scriptscribbler.com/psp/tutorials/lesson02.htm[/url])教你写一个简单的“HelloWorld”程序。第三篇([url]http://www.scriptscribbler.com/psp/tutorials/lesson03.htm[/url])最有用了,也就是“PSP编程速成”。

如果你不想学C或C++,那你可以用LuaPlayer ([url]http://www.luaplayer.org/[/url]),它也有教程[url]http://www.luaplayer.org/tutorial/index.html[/url]教你编程。如果你想学这个,可以到[url]http://forums.ps2dev.org/viewforum.php?f=21[/url]多逛逛。使用Lua,你可以在Windows上测试调试,不需要每次修改后都要放到PSP上运行看效果。关于Windows版的LuaPlayer 你可以到[url]http://forums.ps2dev.org/viewtopic.php?p=22332#22332[/url]察看更多信息。
这里有一个例子。


-- starting positions for the character
x = 200
y = 100

-- A nice color
color = Color.new( 128 , 255 , 0)

-- this flag tells whether the program needs to draw
draw_character = true

-- loop forever
while true do

if draw_character then
-- print a rogue at the x / y coordinates
screen: print (x, y, " @ " , color)
screen.flip()
end

-- check whether the user pressed the pad, and move accordingly
pad = Controls.read()
draw_character = true
if pad:left() then
x = x - 3
elseif pad:right() then
x = x + 3
elseif pad:up() then
y = y - 3
elseif pad:down() then
y = y + 3
else
draw_character = false
end

-- wait for the next vertical blank
screen.waitVblankStart()

end