Fix makefile for OS X

This commit is contained in:
Simon 2011-03-09 18:01:53 +00:00
commit 0ded22493e
8 changed files with 849 additions and 382 deletions

View File

@ -11,67 +11,84 @@ FLAGS_DBUG := -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -pg -DX86 -DX86_SSE3 -mss
COMPILER := gcc
LINUX_TARG := powder-64-sse2 powder-sse powder-sse2
WIN32_TARG := powder-sse.exe powder-sse2.exe
PYCOMMAND := python2 getheader.py
powder: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -DINTERNAL -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
mv $@ build
powder-debug-64: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m64 -o$@ $(FLAGS_DBUG) -DLIN64 $(SOURCES) -Iincludes/
mv $@ build
powder-debug: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m32 -o$@ $(FLAGS_DBUG) -DLIN32 $(SOURCES) -Iincludes/
mv $@ build
powder-sse3: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN32
strip $@
mv $@ build
powder-sse2: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN32
strip $@
mv $@ build
powder-sse: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE) $(SOURCES) -DLIN32
strip $@
mv $@ build
powder-64-sse3-opengl: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64 -lGL -lGLU -DOpenGL
strip $@
mv $@ build
powder-64-sse3: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
strip $@
mv $@ build
powder-64-sse2: $(SOURCES)
$(PYCOMMAND)
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN64
strip $@
mv $@ build
powder-icc: $(SOURCES)
$(PYCOMMAND)
/opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L
powder-res.o: powder-res.rc powder.ico
$(PYCOMMAND)
i586-mingw32msvc-windres powder-res.rc powder-res.o
powder-sse3.exe: $(SOURCES) powder-res.o
$(PYCOMMAND)
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
mv $@ build
powder-sse2.exe: $(SOURCES) powder-res.o
$(PYCOMMAND)
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
mv $@ build
powder-sse.exe: $(SOURCES) powder-res.o
$(PYCOMMAND)
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
mv $@ build
powder-x: $(SOURCES)
$(PYCOMMAND)
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework Python
strip $@
mv $@ build
powder-x-ogl: $(SOURCES)
$(PYCOMMAND)
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DOpenGL -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework OpenGL -framework Python
strip $@
mv $@ build

211
build/ext_chat.py Normal file
View File

@ -0,0 +1,211 @@
import tpt
import sys
import time
import socket
import tpt_console
HOST="irc.freenode.net"
PORT=6667
name=tpt.get_name()
print "name is %s"%repr(name)
if(name==""):
#fuck. abort?
raise SystemExit("please log in!")
def raw(s,st):
s.send("%s\n\r"%st)
def init():
global frame,s,rec,readbuffer,namelist,typing,typed,IDENT,NICK
global REALNAME,CHANNEL
frame=0
s=None
rec=([("",0,0,0,255)]*20)+[("connected.",255,0,0,128)]
readbuffer=""
namelist=[]
typing=False
typed=""
NICK=name+"[tpt]"
IDENT=name+"[tpt]"
REALNAME=name
CHANNEL="#foobar7"
readbuffer=""
def exit():
raw(s,"QUIT")
s.close()
def console_handle(txt):
"""
:doxin!~lieuwe@unaffiliated/lieuwe JOIN :#foobar7
:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG #foobar7 :there
:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG #foobar7 :ACTION is fat
"""
lst=txt.split(" ")
if(lst[0]=="/me"):
rec.append(("%s %s"%(NICK,txt[4:]),255,0,255,128))
raw(s,"PRIVMSG %s :\x01ACTION %s\x01"%(CHANNEL,txt[4:]))
tpt.console_close()
else:
rec.append(("<%s>: %s"%(NICK,txt),255,255,0,128))
raw(s,"PRIVMSG %s :%s"%(CHANNEL,txt))
tpt.console_close()
def key(keyy) :
try:
a=key.pmod
except:
key.pmod=(False,False,False)
global typing,typed
print "got %s"%repr(keyy)
ctrl1,ctrl2,alt1,alt2,shift1,shift2=tpt.get_modifier()
mod=(ctrl1 or ctrl2,alt1 or alt2,shift1 or shift2)
skip=False
if(not key.pmod[0] and mod[0]):
skip=True
if(not key.pmod[1] and mod[1]):
skip=True
if(not key.pmod[2] and mod[2]):
skip=True
key.pmod=mod
if(skip):
return
if(typing and ord(keyy)>=32 and ord(keyy)<=126):
if(mod[2]):
typed+=keyy.upper()#needs to be fixed for special chars
else:
typed+=keyy
if(keyy=="\x1b" and typing):
typing=False
typed=""
tpt.shortcuts_enable()
if(keyy=="t" and typing==False):
typing=True
tpt.shortcuts_disable()
if(keyy=="\r" and typing==True):
console_handle(typed)
typed=""
typing=False
tpt.shortcuts_enable()
#got '\t'
#got '\x08'
if(keyy=="\x08"):
typed=typed[:-1]
#if(keyy=="\t"):
# startswith=
def step():
global frame,s,rec,readbuffer,namelist
frame+=1
if(frame==1):
tpt.console_close()
#lets see if we can seize the console:
tpt_console._handle=console_handle
if(frame==2):
tpt.draw_fillrect(0,0,612,384,0,0,0,128)
tpt.draw_text(32,32,"opening connection\nhold on to your pants.",255,255,255)
if(frame==3):
s=socket.socket()
s.settimeout(5)
s.connect((HOST, PORT))
raw(s,"NICK %s" % NICK)
raw(s,"USER %s %s bla :%s" % (IDENT, HOST, REALNAME))
s.settimeout(0)
if(frame==120):
raw(s,"JOIN %s"%CHANNEL)
rec.append(("joined",255,0,0,255))
if(frame>=3):
try:
readbuffer=readbuffer+s.recv(1024)
except IOError:
pass
else:
temp=readbuffer.split("\n")
readbuffer=temp.pop()
for line in temp:
line=line.strip()
#print repr(line)
line=line.split()
if(line[1]=="PRIVMSG"):
#:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG doxin[tpt] :some shit
frm=line[0][1:].partition("!")[0]
msg=' '.join(line[3:])[1:]
tmp=["<",frm,"> ",msg]
if(msg[0]=="\x01" and msg[-1]=="\x01"):
msg=msg[8:-1]#ACTION
tmp=[frm," ",msg]
if(line[2]==NICK):
rec.append((''.join(tmp),255,255,255,255))
else:
rec.append((''.join(tmp),255,255,255,128))
elif(line[0]=="PING"):
raw(s,"PONG %s"%line[1])
elif(line[1]=="353"):
#:leguin.freenode.net 353 doxin[tpt] = #powder :doxin[tpt] ZebraineZ _-_Rafael_-_ doxin bildramer BlueMaxima TheRazorsEDGE raj-k webb|AP where @devast8a Merbo FrozenKnight EppyMoon EvilJStoker Mortvert SpitfireWP @frankbro Ares
names=line[4:]
namelist=[]
for item in names:
item=item.strip()
r=255
g=255
b=255
if(item[0]==":"):
item=item[1:]
elif(item[0]=="@"):
g=0
b=0
namelist.append((item,r,g,b,128))
elif(line[1]=="JOIN"):
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net JOIN :#powder'
tmp=line[0][1:].partition("!")[0]
namelist.append((tmp,255,255,255,128))
rec.append(("%s joined"%name,0,255,0,128))
elif(line[1]=="PART"):
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net PART #powder :"Leaving."'
tmp=line[0][1:].partition("!")[0]
msg=' '.join(line[2:])[1:]
rem=None
for item in namelist:
if(item[0]==tmp or item[0]=="@"+tmp):
rem=item
rec.append(("%s parted: %s"%(name,msg),0,255,0,128))
if(rem!=None):
namelist.remove(rem)
elif(line[1]=="NICK"):
#:doxin!~lieuwe@unaffiliated/lieuwe NICK :d0x1n
tmp=line[0][1:].partition("!")[0]
rem=None
for item in namelist:
if(item[0]==tmp or item[0]=="@"+tmp):
rem=item
rec.append(("%s is now known as %s"%(name,line[2]),0,255,0,128))
if(rem!=None):
if(rem[0][0]=="@"):
namelist.append(("@"+line[2][1:],rem[1],rem[2],rem[3],rem[4]))
else:
namelist.append((line[2][1:],rem[1],rem[2],rem[3],rem[4]))
namelist.remove(rem)
yy=32
if(len(rec)>20):
rec=rec[-20:]
for item in rec:
tpt.draw_text(8,yy,item[0],item[1],item[2],item[3],item[4])
yy+=8
if(typing):
if(frame%30<15):
tpt.draw_text(8,yy,typed+"|",255,255,255,255)
else:
tpt.draw_text(8,yy,typed,255,255,255,255)
#print namelist
yy=32
for item in namelist:
tpt.draw_text(604-tpt.get_width(item[0]),yy,item[0],item[1],item[2],item[3],item[4])
yy+=8

9
build/ext_fun.py Normal file
View File

@ -0,0 +1,9 @@
import tpt
def init():
pass
def key(keyy):
pass
def step():
tpt.draw_text(100,100,"FUCK YEAH!",255,255,255,255)
def exit():
pass

View File

@ -17,7 +17,7 @@ print args,"-I%s"%path
lst=[]
compileall.compile_dir("./src/python", force=1)
print "\n\n\ngenerating pyconsole.h"
print "generating pyconsole.h"
fname="./src/python/tpt_console.pyc"
try:

View File

@ -67,6 +67,8 @@ extern unsigned char ZSIZE;
#define SQUARE_BRUSH 1
#define BRUSH_NUM 2
#define PYCONSOLE
#ifdef PIX16
typedef unsigned short pixel;
#else

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,11 @@
import tpt
from tpt import *
from utils import *
import sys
import code
import ctypes
import traceback
DEBUG=False
#print "console module loaded."
#redirect stdout like this:
class logger:
@ -12,8 +13,10 @@ class logger:
txt=txt.strip().split("\n")[-1]
repr(txt)
tpt.log(txt)
sys.stdout=logger()
sys.stderr=logger()
if(DEBUG==False):
sys.stdout=logger()
sys.stderr=logger()
element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
"nitr":8,"clne":9,"gas":10,"plex":11,"goo":12,"icei":13,"metl":14,"sprk":15,
@ -43,6 +46,7 @@ element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
def fork_unblock():
pass#i need to implement this some day.
def error(ex):
traceback.print_exc()
err=traceback.format_exc()
sys.stdout.write(err)
@ -75,3 +79,38 @@ def _handle(txt):
exec txt in handle.glob
except Exception as ex:
error(ex)
_extensions=[]
def loadext(fname):
ext=__import__(fname)
ext.init()
_extensions.append(ext)
def keypress(key):
unload=[]
for item in _extensions:
try:
item.key(key)
except Exception as ex:
error(ex)
unload.append(item)
for item in unload:
item.exit()
_extensions.remove(item)
def step():
unload=[]
for item in _extensions:
try:
item.step()
except Exception as ex:
error(ex)
unload.append(item)
for item in unload:
try:
item.exit()
except Exception as ex:
error(ex)
_extensions.remove(item)