Screen performance comparisons

General FreeBASIC programming questions.
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Screen performance comparisons

Postby MystikShadows » Jun 17, 2005 12:48

Hi everyone,

Has anyone ever tested the following:

In SCREEN 0 (80x25) writing to the screen, fuill screens of data to see hwo fast that happens and likewise in graphics mode. I'm trying to see if I'd be loozing speed by switching to a graphics mode instead of trying to stick to SCREEN 0 (assuming I want the same text character resolution in both modes.

Thanks in advance for any feedback.
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 17, 2005 13:06

using this test:

Code: Select all

screen 7
s# = timer
for i = 32 to 255
    locate 1,1
    ? string$(80*25,chr$(i));
next
st# = timer
locate 1,1
? st#-s#
sleep

i got console to be consistently about 0.8 seconds faster than gfx mode.
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 17, 2005 13:10

O_O

Code: Select all

width 80, 25
s# = timer
for i = 32 to 255
    locate 1,1
    ? string$(80*25-1,chr$(i));
next
st# = timer
locate 1,1
? st#-s#
sleep

took .1 seconds... the other test had both console + gfxlib taking > .4 seconds. take the -1 out of the string$ command on this one though, and it takes > 3 seconds :*(

[edit] actually, the original console one runs faster that way too. the gfxlib one shows no change, even in a 80x25 text mode.
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 17, 2005 13:21

Thanks for that info dumbledore.

Since there's no screen buffering in text mode (and seemingly non planned right now) I'm looking into the other alternative and see if it's worth it with screen buffering in graphics mode.

Too bad though...text mode screen buffering would be kewl to TEXT app builders...like me ;-).
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Postby Antoni » Jun 17, 2005 13:23

What console are you talking about?
Fullscreen console uses the VGA texmode and ROM char generator so it should be as fast as DOS textmode.
In a windowed console the characters are drawn by windows, so it's speed should be not very different from gfxlib text.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 17, 2005 13:29

Win32 console routines do internal buffering, skipping updates and such, in windowed modes. Fullscreen, as Antoni said, uses the hardware VGA text mode, so its speed should be roughly equivalent to a DOS program using text mode.

BTW, if you really want text-mode buffering, I could throw together a routine for DOS, but I don't want to mess with the Win32 console API. :) Plus, I'm going to be reworking/rewriting the DOS console text output, because I'm too lazy to figure out why DJGPP's conio routines aren't working as expected, causing those nasty scrolling bugs. :)
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 17, 2005 13:43

Oh...well if you're rewriting it I'll wait...what's the new method though? what will you be using since conio don't work as expected?
dumbledore
Posts: 680
Joined: May 28, 2005 1:11
Contact:

Postby dumbledore » Jun 17, 2005 13:48

i wrote a simple one in fb, it's not using any api calls because it's simple. it doesn't have colors, but they could be added without much difficulty.

Code: Select all

'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
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 17, 2005 14:01

MystikShadows wrote:Oh...well if you're rewriting it I'll wait...what's the new method though? what will you be using since conio don't work as expected?


Well, I'll be doing the mode-setting code with BIOS calls (because DJGPP's conio screen resize proc (_setscreenlines, iirc) doesn't allow a width parameter to be specified, only 80xN modes available - maybe use VESA text modes too) and the actual text output with the _far*() functions and/or movedata().
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 17, 2005 15:31

SOunds good Dr_V :-) what are they agan

$0109 for 132x25
$010A for 132x43
$010B for 132x50
$010C for 132x60

right? :-)....move data should work...however that also means we'll need to code for the scrolling as moving data like this won't allow the screen to automatically scroll like it would with standard printing.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 17, 2005 15:56

Yeah, those are the standard VESA text modes (plus 80x60 - 0x0108). The scrolling will be taken care of internally - just a simple movedata() to copy the portion of the screen that needs to be scrolled. From the user's point of view, it will work just like the Win32 version (except without the crazy resize-the-console-by-printing-beyond-it 'feature' :).
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 17, 2005 16:16

Absolutely awesome.....fire that puppy up, I'm a itching for some VESA Codin here LOL...don't worry I'm patient and I'll wait angelically....but remember that Lucifer was once Lucibel before he/she (never know lol) let vanity take over. even an angel's patience has it's limits...LOLOL
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 18, 2005 0:41

Here's a simple buffered text mode demonstration for DOS:

Code: Select all

''
'' simple DOS text-mode example to demonstrate DOS-specific features
''

Option Explicit

#include "dos/go32.bi"
#include "dos/pc.bi"
#include "dos/sys/movedata.bi"

Sub TextBufferToScreen(buffer() As UByte, size As Integer)
   
   Do Until inportb(&H3DA) And 8: Loop   ' wait for vertical blank
   
   dosmemput(@buffer(0), size, ScreenPrimary)
   
End Sub

Const ScreenWidth As Integer = 80
Const ScreenHeight As Integer = 50
Const ScreenBytes As Integer = ScreenWidth * ScreenHeight * 2

Dim buffer(ScreenBytes - 1) As UByte
Dim i As Integer

Width ScreenWidth, ScreenHeight

Locate , , 0   ' turn off cursor

Do Until Len(Inkey)

   For i = 0 To ScreenBytes - 1 Step 2
      buffer(i) = Int(Rnd * 3) + 176
   Next i
   
   For i = 1 To ScreenBytes - 1 Step 2
      buffer(i) = Int(Rnd * 16)
   Next i
   
   TextBufferToScreen buffer(), ScreenWidth * ScreenHeight * 2
   
Loop

Cls
The buffer is in the same format as a regular text-mode screen, i.e. a character byte, a color byte, char byte, color byte, etc. It'll be in examples/DOS/textbuff.bas in the next release. (Run it in fullscreen mode on Windows)
MystikShadows
Posts: 612
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jun 18, 2005 1:41

Wow, that's a very impressive test there. can I expect the same performances with the heighter text screen resolutions? I mean a bit slower cause there's more character's per screen but let's say the same charter/time ratio? or does it speed it or slow down in thos enhanced text modes?
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Jun 18, 2005 2:17

Should be the same speed per character; the VESA text mode memory layout is just like a regular mode, except with more characters. No ugly bank-switching or anything horrible like that. :)

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests