Making color text in 16 bit c++ program
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Making color text in 16 bit c++ program

  1. #1
    Join Date
    Aug 2010
    Posts
    9

    Making color text in 16 bit c++ program

    hey,

    I am playing around with an open source program called TrueCrypt. I want to add some color to the boot loader which is actually compiled using Microsoft Visual C++ 1.52 so its a 16 bit program.

    Is there a way to do this? I am not aware of any way. Probably no-one will know because that compiler is ancient and this boot loader runs before windows on the HDD.

    Here is a bit of the code i want to change so that 'TrueCrypt Bootloader is whatever color i chose'

    http://pastebin.com/vwH8NJ3x

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Making color text in 16 bit c++ program

    Well I'm ancient as well so I just started my "just for nostalgy reasons" win3.11 virtual machine (with an installed MSVC 1.52C)
    Oh man... everything in win3.11 feels very akward these days...

    In graph.h/graphics.lib I found _settextcolor but according to the help it does only affect text printed with _outtext not printf so you might have to change how Print works.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    Nice find for graph.h....

    After look at it i tried it like this... but I get this error:

    1>Linking...
    1>BootMain.obj(..\bootmain.cpp) : error L2029: '__outtext' : unresolved external
    1>BootMain.obj(..\bootmain.cpp) : error L2029: '__setbkcolor' : unresolved external
    1>BootMain.obj(..\bootmain.cpp) : error L2029: '__setvideomode' : unresolved external
    1>BootMain.obj(..\bootmain.cpp) : error L2029: '__settextcolor' : unresolved external
    1>NMAKE : fatal error U1077: 'C:\MSVC\bin\link.exe' : return code '0x2'

    for this:

    /*
    Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.

    Governed by the TrueCrypt License 3.0 the full text of which is contained in
    the file License.txt included in TrueCrypt binary and source code distribution
    packages.
    */

    #include "Crc.h"
    #include "Crypto.h"
    #include "Password.h"
    #include "Volumes.h"

    #include "Platform.h"
    #include "Bios.h"
    #include "BootConfig.h"
    #include "BootMain.h"
    #include "BootDefs.h"
    #include "BootCommon.h"
    #include "BootConsoleIo.h"
    #include "BootDebug.h"
    #include "BootDiskIo.h"
    #include "BootEncryptedIo.h"
    #include "BootMemory.h"
    #include "BootStrings.h"
    #include "IntFilter.h"
    #include "graph.h"



    static void InitScreen ()
    {

    _clearscreen(_GCLEARSCREEN);

    _setvideomode(_MRES4COLOR);

    _setbkcolor(_BLUE);

    _settextcolor(2);
    _outtext("Logitech 3D Mouse Simple Information Display\n");




    Any idea where i am going wrong? This is really hard lol.
    Last edited by whitelines2; August 8th, 2010 at 12:34 AM.

  4. #4
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    bare in mind i am using visual studio 2008 to compile but it is linked to ms v++ 1.52.

  5. #5
    Join Date
    Apr 1999
    Posts
    27,446

    Re: Making color text in 16 bit c++ program

    Quote Originally Posted by whitelines2 View Post
    bare in mind i am using visual studio 2008 to compile but it is linked to ms v++ 1.52.


    That doesn't make any sense.

    The compiler is responsible for producing the object code. The linker program, usually LINK.EXE, is responsible for linking the object code. LINK.EXE is not a compiler, so saying that your're "linked to ms vc++ 1.52" makes no sense.

    Second, the object code produced by VC 2008 must be linked to libraries (the CRT for example) created for VC 2008.

    Regards,

    Paul McKenzie

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Making color text in 16 bit c++ program

    Eh... as Paul say you have to use MSVC 1.52 both for compiling and linking.

    Seems like you forgot to add graphics.lib to your project (the .mak file)
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  7. #7
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    Quote Originally Posted by Paul McKenzie View Post


    That doesn't make any sense.

    The compiler is responsible for producing the object code. The linker program, usually LINK.EXE, is responsible for linking the object code. LINK.EXE is not a compiler, so saying that your're "linked to ms vc++ 1.52" makes no sense.

    Second, the object code produced by VC 2008 must be linked to libraries (the CRT for example) created for VC 2008.

    Regards,

    Paul McKenzie
    I just meant that vc+1.52 was doing the linking, i know that link.exe is not a compiler. I know my sentence didn't make any sense but i am a noob lol. So how do i add graphics.lib to the makefile? My coding experience is limited to C# and some web development... this stuff is confusing to me. So anyway... graphics.lib is at the moment in C:/MSCV/LIB....... so where should i add that to my project, there are some makefiles in my project but when i open them up its all confusing.
    Last edited by whitelines2; August 8th, 2010 at 09:03 AM.

  8. #8
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Making color text in 16 bit c++ program

    Select Project/Edit. Change to list *.lib, browse to List and then browse to C:/MSCV/LIB, select graphics.lib and then click add. If you succed graphics.lib should show up in Files in Project.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  9. #9
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    in vs2008 i did project, add existing item... found the graphics.lib added it to project.... but still get same unresolved external error.
    Last edited by whitelines2; August 8th, 2010 at 10:33 AM.

  10. #10
    Join Date
    Apr 1999
    Posts
    27,446

    Re: Making color text in 16 bit c++ program

    Quote Originally Posted by whitelines2 View Post
    in vs2008 i did project, add existing item... found the graphics.lib added it to project.... but still get same unresolved external error.
    You can't use Visual Studio 2008.. What do you not understand about that? You say you're using VC 1.52. If that is the case, Visual Studio 2008 shouldn't even be mentioned in your posts at all.

    Graphics.lib is a 16-bit library, and Visual Studio 2008 creates 32-bit programs, not 16 bit programs. The compiler that creates 16-bit programs is MSVC 1.52.

    Regards,

    Paul McKenzie

  11. #11
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    The open source program i am compiling/editing is done in visual studio 2008. When i hit build solution in 2008 it is using vc ++ 1.52 to compile some of it and linking it all together. At no point is it necessary to actually open up mscv 1.52 myself to compile the program.

    All i had to do was create an environment variable 'MSVC16_ROOT' pointing to the installation
    directory of MS Visual C++ 1.52 and then from within visual 2008 i hit the compile button. 90% of this program is 32 bit... just one part called 'boot' has to be 16 bit and makes use of visual 1.52 to compile and link.

    I am well aware of the distinction you are trying to make.

    If you downloaded the truecrypt source code and tried to compile it or even just read the readme file you would get it.
    Last edited by whitelines2; August 8th, 2010 at 11:41 AM.

  12. #12
    Join Date
    Apr 1999
    Posts
    27,446

    Re: Making color text in 16 bit c++ program

    Quote Originally Posted by whitelines2 View Post
    The open source program i am compiling/editing is done in visual studio 2008. When i hit build solution in 2008 it is using vc ++ 1.52 to compile some of it and linking it all together. At no point is it necessary to actually open up mscv 1.52 myself to compile the program.
    How about falling back to simplicity, and that is attempt to compile and link using MSVC 1.52 IDE for that particular component.

    This means opening up the IDE for 1.52c instead of doing all of this in the IDE of Visual Studio 2008, add the files, libraries, etc. and solve the problem first that way. When you get it solved using 1.52c proper, then you can think about doing all of these tricks in the 2008 IDE.

    Regards,

    Paul McKenzie

  13. #13
    Join Date
    Aug 2010
    Posts
    9

    Re: Making color text in 16 bit c++ program

    i've no doubt it would be easy to compile in the c 1.52 IDE but that doesn't help in this case.

  14. #14
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Making color text in 16 bit c++ program

    MSVC1.5.2 also usually compiles 32-bit code. It runs using Win32s within a Windows 3.11 environment.

    You also can produce 16-bit code with MSVC1.5.2 but that means no MFC and - normally - usage of some DOS extender library.

    If only the 'boot' is a 16-bit component which runs before Windows 3.11 it definitively is a DOS program rather than a Windows program and if you want to change color output it means that you need to manipulate a 16-bit DOS-Box. That probably can be done by using escape sequences in the output statements sent to terminal (screen). I remember of VT220 emulation programs for DOS like 'reflection' which used colored output modus. If you want to do that programmatically I would recommend to check the Online Help that came with VC1.5.2. As far as I remember it is pretty well even for nowadays nearly unknown DOS functions.

    The open source program i am compiling/editing is done in visual studio 2008. When i hit build solution in 2008 it is using vc ++ 1.52 to compile some of it and linking it all together. At no point is it necessary to actually open up mscv 1.52 myself to compile the program.

    All i had to do was create an environment variable 'MSVC16_ROOT' pointing to the installation
    directory of MS Visual C++ 1.52 and then from within visual 2008 i hit the compile button. 90% of this program is 32 bit... just one part called 'boot' has to be 16 bit and makes use of visual 1.52 to compile and link.

    I am well aware of the distinction you are trying to make.

    If you downloaded the truecrypt source code and tried to compile it or even just read the readme file you would get it.
    I don't know exactly what you want to say with that. Of course you can only use the compiler and linker of MSVC1.5.2 and use the VS2008 IDE to do that for you. But, I am pretty sure that the old IDE is still running on modern windows (I lastly did it maybe 5 years ago on a W2k system) and it has the advantage that you can get appropriate help for that what you were doing.

    Regards, Alex

  15. #15
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Making color text in 16 bit c++ program

    Quote Originally Posted by whitelines2 View Post
    All i had to do was create an environment variable 'MSVC16_ROOT' pointing to the installation
    directory of MS Visual C++ 1.52 and then from within visual 2008 i hit the compile button. 90% of this program is 32 bit... just one part called 'boot' has to be 16 bit and makes use of visual 1.52 to compile and link.
    How do you manage which files in the project that is for the 16-bit build? There should be a similar way of handling linking to 16-bit libs since at least the C runtime has to be linked in.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center