Author Topic: Textmode Demo Questions.  (Read 7847 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Textmode Demo Questions.
« on: December 24, 2008 »
I was looking at this demo today;


http://www.pouet.net/prod.php?which=52319

I've always had a real soft spot for textmode demos, Probably Northern dragons Signal To Droids and Clockwerk are my favourites.

This one be Crimson shine just re-kindles the flame though.

The Northern Dragons released a "kit" a while ago to allow people to take part in TMDC 2008, that was not for me though.

I don't want to use a kit, I want to develop my own engine in Freebasic. The reason for this is really because I made so many software routines for drawing vectors and polygons that I think it would be easy for me to convert them to run with text.

I've seen it done in Freebasic, what I would love to be able to do first of all is to be able to open a text mode screen, and define the colours of that screen.

I don't think I need source code how to do it, I just need pointing the right way for now.

Any takers? :)

Thanks.

(I have looked at the screen command and it just seems to be gfx modes).
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Textmode Demo Questions.
« Reply #1 on: December 24, 2008 »
Ps. If it's better that I write it in C ++ or Fasm it would make very littel difference :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Textmode Demo Questions.
« Reply #2 on: December 24, 2008 »
Delphi has a crt unit that can display the full color set in a console window. I'll post the code; it may give you some ideas. This would be windows only though, which might rule it out.

EDIT: Sorry about the mess. I've attached a zip of the source. The main thing to look at here is the api for the console. It gives a good idea of what you need to do and in what order. MSDN also has a full scection on the console as well.
« Last Edit: December 24, 2008 by rdc »

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Textmode Demo Questions.
« Reply #3 on: December 24, 2008 »
@shockwave:
ah cool to see you are interested in coding textmode stuff.. i am very interested in this too since some years.. my mainproblem is how to convert the colors to charsets... for example like the simplest way to convert RGB greytones from 0 to 255... :P

something i found out in one the TMD which could be possible something like the converted chars...
Code: [Select]
      .   ..  ....::::;=;=tftf%$%$&KSZWXGM@@@@8888####????


@rdc:
Wow, i saw you posted a very long source while i wrote this.. (your source seems not be not comlete)... i will check your source now, is there a way to give a compiled version? thx
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Textmode Demo Questions.
« Reply #4 on: December 24, 2008 »
opening a console window in freebasic is easy.

but the only way i know of is to use the windows api. its the same process in fb/c++.

here is my ascii windows frame work.

Code: [Select]
#Include "windows.bi"
#include "win\mmsystem.bi"
#Include "crt.bi"

Type AsciiWindow

    Origin As COORD
    Dimensions As SMALL_RECT
    CHwnd As HANDLE
    Size As COORD
    WndPtr As CHAR_INFO Ptr

End Type

Const Black = 0
Const Blue = 1
Const Green = 2
Const Cyan = 3
Const Red = 4
Const Magenta = 5
Const Brown = 6
Const White = 7
Const Grey = 8
Const BBlue = 9
Const BGreen = 10
Const BCyan = 11
Const BRed = 12
Const Pink = 13
Const Yellow = 14
Const BWhite = 15


Declare Sub FlipAsciiBuffers( Buffer As AsciiWindow Ptr )
Declare Sub ClearAsciiBuffers( Buffer As AsciiWindow Ptr )
Declare Sub KillAsciiWindow( AscWindow As AsciiWindow Ptr )
Declare Function SetUpAsciiWindow( ByVal X As Integer = 0 , ByVal Y As Integer = 0 , Byval Wdth As Integer = 80 , ByVal Hght As Integer = 50 ) As AsciiWindow Ptr
Declare Function AsRgb( ByVal FCol As Integer , ByVal BCol As Integer )
Declare Function GetFRgb( Buffer As WORD ) As Ubyte
Declare Function GetBRgb( Buffer As WORD ) As Integer

Sub ClearAsciiBuffers( Buffer As AsciiWindow Ptr )
   
    Dim As Integer Y
   
    For Y = 0 To (Buffer->Size.X) * (Buffer->Size.Y)
         Buffer->WndPtr[Y].Char.AsciiChar = cast( CHAR , 219 )
         Buffer->WndPtr[Y].Attributes = AsRgb( Black , Black )
    Next
   
End Sub



Sub FlipAsciiBuffers( Buffer As AsciiWindow Ptr )
   
    WriteConsoleOutput( Buffer->CHwnd , Buffer->WndPtr , Buffer->Size , Buffer->Origin , @Buffer->Dimensions )

End Sub



Function AsRgb( ByVal FCol As Integer , ByVal BCol As Integer )

    Return FCol + ( BCol Shl 4 )

End Function



Function GetFRgb( Buffer As WORD ) As Ubyte
   
    Return Buffer and &H0f
   
End Function



Function GetBRgb( Buffer As WORD ) As Integer
   
    Return Buffer shr 4
   
End Function



Function SetUpAsciiWindow( ByVal X As Integer = 0 ,ByVal Y As Integer = 0 , Byval Wdth As Integer = 80 , ByVal Hght As Integer = 50 ) As AsciiWindow Ptr
   
    Dim As AsciiWindow Ptr TmpWindow
   
    TmpWindow = CAllocate( SizeOf( AsciiWindow ) )
   
    TmpWindow->WndPtr = CAllocate( Wdth * Hght *  Sizeof( AsciiWindow ) )
   
    TmpWindow->Size.X = Wdth
    TmpWindow->Size.Y = Hght
   
    TmpWindow->Origin.X = X
    TmpWindow->Origin.Y = Y
   
    TmpWindow->Dimensions.Left = 0
    TmpWindow->Dimensions.Top = 0
    TmpWindow->Dimensions.Right = Wdth - 1
    TmpWindow->Dimensions.Bottom = Hght - 1
   
    TmpWindow->CHwnd = CreateConsoleScreenBuffer( GENERIC_WRITE Or GENERIC_READ , 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL)
    SetConsoleActiveScreenBuffer( TmpWindow->CHwnd )
    SetConsoleScreenBufferSize( TmpWindow->CHwnd, TmpWindow->Size )
    SetConsoleWindowInfo( TmpWindow->CHwnd, TRUE, @TmpWindow->Dimensions )
   
    Return TmpWindow
   
End Function



Sub KillAsciiWindow( AscWindow As AsciiWindow Ptr )
   
    If ( AscWindow ) Then
        If ( AscWindow->WndPtr ) Then
            Deallocate( AscWindow->WndPtr )
        End If
        Deallocate( AscWindow )
    End If
   
End Sub

the main point of interest being setupaciiwindow and flip ascii buffers if you rip that stuff out and put the flip ascii buffer in your main loop and setupsciiwindow above your main loop. you will have a perfect console ready for drawing on. this is how pretty much everyone does it regardless of the laungage.

now to draw onto the screen

Buffer->WndPtr[Y].Char.AsciiChar = cast( CHAR , 219 ) 'ascii char you want to draw
Buffer->WndPtr[Y].Attributes = AsRgb( Black , Black ) 'forground and background color you want to draw your char

i know my code can be a bit hard too follow as i have my own way of writting it but i can come up with a simple example for you if needed that doesnt use pointers or types to let you see better whats going on.

remeber the transition comp i entered an ascii demo with full source that has conversion routines i know you probably wont want to use any of the code but its more than worth a look you should be able to get some ideas from it ;)
« Last Edit: December 24, 2008 by ninogenio »
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Textmode Demo Questions.
« Reply #5 on: December 24, 2008 »
Maybe sol's engine might be of interest. It comes full
full c++ source code to study and learn from :

http://sol.gfxile.net/zip/textfx5.zip
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Textmode Demo Questions.
« Reply #6 on: December 24, 2008 »
Ooh, Delphi, C++ and Freebasic code examples to work with :) Thank you so much RDC, Nino and Benny.

I think that I am going to go for the Freebasic or C++ route.

Vain, interesting that you have that strip of letters, I once spoke to Tetra about this and he had written a routine that analyzed the pixel densities of all the letters in the default font and it produced a similar kind of thing to what you have there.

This will be more than enough to get me started.

Thanks chaps :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Textmode Demo Questions.
« Reply #7 on: December 24, 2008 »
don't know if those charts help in any way, i hope they do :)





Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Textmode Demo Questions.
« Reply #8 on: December 24, 2008 »
Just a bump to let you know I updated my previous post and attached the source file to the message. This is the version I extended and my additions are marked with { rdc} . I needed the extra functionality in my little virtual machine, Atom, I wrote in Delphi.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Textmode Demo Questions.
« Reply #9 on: December 24, 2008 »
np shockwave,

but remember the way i open the ascii window and draw on it in my post is the way everyone does it even the tmdc guys. its the only way to get smooth console animations in c++/freebasic that i know of.
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Textmode Demo Questions.
« Reply #10 on: January 13, 2009 »
Cool, this is also something that I am quite interested in. The compo we did was also neat.
I dont want to bootleg this topic, so just a short few pennies worth. The thing I'm interested in is how to express the colours ( shades / density ) like they do in those TMDC 3D demos.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Textmode Demo Questions.
« Reply #11 on: January 13, 2009 »
A lot of the TMDC entries seem to be downsampled framebuffers.

I talked to Tetra about this too and he was very interested in making textmode demos so he wrote a program to analyze the pixel density of every letter in the charset to enable his renderer to choose the right letter.

I am guessing that you could render very high graphics to a frramebuffer and treat it as a set of cells, examining what pixels are set and the weight of the colours to determine what ascii character you cast to the dos window.

A more elegant way of doing it would be to write some routines to draw polygons, textures, lines, sprites etc in proper ascii.

I am exploring the second method at the moment :)

I will be releasing something at Sundown this year and it is going to be a textmode demo.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Textmode Demo Questions.
« Reply #12 on: January 13, 2009 »
Cool. Definately sounds interesting. Keep us informed here.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Textmode Demo Questions.
« Reply #13 on: January 19, 2009 »
Another facet I've been pondering over, is are textmode demos ascii or ansi, or perhaps a mixture? And what is the difference; if anyone can shed some light.

Cheers.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Textmode Demo Questions.
« Reply #14 on: January 20, 2009 »
Here Clyde..

This link explains the process really well.

http://sol.gfxile.net/textfx/
Shockwave ^ Codigos
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Textmode Demo Questions.
« Reply #15 on: January 20, 2009 »
i dont know why... but last night i had two times the dream that i have worked on a textmode demo effect - checkerboard O.O strange!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Textmode Demo Questions.
« Reply #16 on: January 20, 2009 »
Yeah, sol is well known and next to the fantastic explanation
he provides also handy libs to use : TextFX textmode graphics library ;-)
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Textmode Demo Questions.
« Reply #17 on: January 28, 2009 »
@Shockie: Cool and thankyou.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: