05-29-2005, 06:59 AM
wrote this a while ago, wasn't going to put it up anywhere but i saw someone mentioned it on fbc sf requests page...
keep in mind this is very simple, and only supports a couple main functions, ie no coloring etc, but they should be easy to add if anyone's interested in it at all, just make a new udt and replace the ubyte thing with it... i might do it after i'm finished with my current project.
keep in mind this is very simple, and only supports a couple main functions, ie no coloring etc, but they should be easy to add if anyone's interested in it at all, just make a new udt and replace the ubyte thing with it... i might do it after i'm finished with my current project.
Code:
'by dumbledore
'a lightweight text-mode blitter
'should give a pretty impressive speed boost to text-mode games
'because the console won't be updated every time you print
'instead, stick the call to the blitter in a thread, or just
'call it when you want to ;P
type mConsole
scr(80*25) as ubyte
cursor as ushort
end type
dim parent as mConsole
parent.cursor=0
dim cons as mConsole ptr=@parent
declare sub _Print(byval cons as mConsole ptr,byval text as string)
declare sub _Blit(byval cons as mConsole ptr)
declare sub _Cls(byval cons as mConsole ptr)
declare sub _Locate(byval cons as mConsole ptr,byval row as integer=-1,byval col as integer=-1)
_cls cons
_locate cons,4
_print cons,"text blitter test..."
_print cons,"testing teh 1337 text blitter"
_blit cons
sleep
sub _Print(byval cons as mConsole ptr,byval text as string)
dim mystr as ubyte ptr=sadd(text)
for i=0 to len(text)-1
cons->scr(cons->cursor)=mystr[i]
cons->cursor+=1
next
cons->cursor=((cons->cursor\80)+1)*80
end sub
sub _Blit(byval cons as mConsole ptr)
locate 1,1
for i=0 to ubound(cons->scr)
? chr$(cons->scr(i));
next
locate 1,1
locate (cons->cursor\80)+1,(cons->cursor-(cons->cursor\80)*80)+1
end sub
sub _Cls(byval cons as mConsole ptr)
for i=0 to ubound(cons->scr)
cons->scr(i)=32
next
cons->cursor=0
end sub
sub _Locate(byval cons as mConsole ptr,byval row as integer=-1,byval col as integer=-1)
if row=-1 then row=cons->cursor\80
if col=-1 then col=1
cons->cursor=(row-1)*80+(col-1)
end sub