Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Oct 18, 2018 3:02 pm

All times are UTC




Post new topic  Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Sun Jan 09, 2005 1:04 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jul 08, 2004 10:14 pm
Posts: 8511
Skype: wile.e.coyote2
Location: Belgrade, Serbia
I'm working on program which will convert WIN graphics (GRF and EXE) to DOS graphics and vice versa. I know to program in Visual Basic only. I wrote algorhythms, but I have some problems in programming:

1. Of course, this program needs GRFcodec. Problem is that my program is faster than GRFcodec. When I convert file, GRFcodec must be executed twice (I use Shell command) and converter is trying to execute other GRFcodec, but first is not executed. That confuses program. I fixed it by inserting empty DOO-LOOP, but is there any other way to stop program executing during Shell command? Or is is other way to call programs from command prompt?

2. I can convert only GRFs. EXEs are less popular, but there are some of them available for download and I want to convert them too. I have problems again with Shell command. I must have data what sprites are changed, and their numbers. This is not problem to obtain, but I must create some file and then read this data. I can't create file. Command sequence
Code:
commandString = Graphic & " -l > " & tempFolder & "\sprites.txt"
Shell (commandString)

doesn't make any file.

3. I also have problem with package and deployment wizard. When I make installer, I can't install program. I use WIN XP. Is VB 6.0 compatible with WIN XP? Or maybe my VB is corrupted?

Thanx for help.

_________________
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!


Last edited by Wile E. Coyote on Thu Mar 03, 2005 8:36 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Sun Jan 09, 2005 1:13 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Jan 20, 2003 2:51 pm
Posts: 3849
Location: Broadstone, Dorset
@ point 2:
Why not allow it to run grdtogrf first, then convert the resulting grf file?

_________________
ImageDownloadsImageWikiImageLinks
Image Image Image Image Image


Top
   
 Post subject:
PostPosted: Sun Jan 09, 2005 1:17 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jul 08, 2004 10:14 pm
Posts: 8511
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Certainly that will be option in program, to convert EXE to GRF. But this is case when I'm trying to convert WIN EXE to DOS EXE and vice versa.

_________________
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!


Top
   
PostPosted: Sun Jan 09, 2005 1:33 pm 
Offline
Administrator
Administrator
User avatar

Joined: Fri Jan 26, 2001 8:18 pm
Posts: 23877
Skype: orudge
Location: Banchory, UK
Wile E. Coyote wrote:
1. Of course, this program needs GRFcodec. Problem is that my program is faster than GRFcodec. When I convert file, GRFcodec must be executed twice (I use Shell command) and converter is trying to execute other GRFcodec, but first is not executed. That confuses program. I fixed it by inserting empty DOO-LOOP, but is there any other way to stop program executing during Shell command? Or is is other way to call programs from command prompt?


Try using the following code:

Code:
Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&

Private Type STARTUPINFO
    cb As Long
    lpReserved As String

    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Private Type PROCESS_INFORMATION
    hProcess As Long
   
    hThread As Long
    dwProcessID As Long
    dwThreadID As Long
End Type

Sub ExecCmd(CmdLine As String)
   Dim proc As PROCESS_INFORMATION
   Dim start As STARTUPINFO

   ' Initialize the STARTUPINFO structure:
   start.cb = Len(start)

   ' Start the shelled application:
   ret& = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, _
      NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

   ' Wait for the shelled application to finish:
   ret& = WaitForSingleObject(proc.hProcess, INFINITE)
   ret& = CloseHandle(proc.hProcess)
End Sub


Then just call ExecCmd "command line" to use it.

Quote:
Command sequence ... doesn't make any file.


You can't use pipes like that except from the command interpreter. Now then, with the example I gave you above, you could do this (untested!):

Code:
' declare section
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long

Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const CREATE_ALWAYS = 2
Private Const FILE_ATTRIBUTE_NORMAL = &H80

' ...

Sub ExecCmd(CmdLine As String)
   Dim proc As PROCESS_INFORMATION
   Dim start As STARTUPINFO
   Dim hndl As Long

   ' Initialize the STARTUPINFO structure:
   start.cb = Len(start)

   hndl = CreateFile("c:\path\to\filename", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)

   If Hndl <> 0 Then
      start.hStdOutput = Hndl
   End If

   ' Start the shelled application:
   ret& = CreateProcessA(0&, CmdLine, 0&, 0&, 1&, _
      NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

   ' Wait for the shelled application to finish:
   ret& = WaitForSingleObject(proc.hProcess, INFINITE)
   ret& = CloseHandle(proc.hProcess)

   If Hndl <> 0 Then
      CloseHandle(Hndl)   ' you now have the output text in the file
   End If
End Sub


Quote:
3. I also have problem with package and deployment wizard. When I make installer, I can't install program. I use WIN XP. Is VB 6.0 compatible with WIN XP? Or maybe my VB is corrupted?


Possibly VB is corrupted. The VB PDW is a horrible thing anyway, don't use it. Just distribute your EXE file, most people have the VB6 runtimes.

_________________
Owen Rudge
owenrudge.net | Owen's Transport Tycoon Station | Owen's Locomotion Depot | The Transport Tycoon Wiki


Top
   
 Post subject:
PostPosted: Sun Jan 09, 2005 1:55 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jul 08, 2004 10:14 pm
Posts: 8511
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Thanx! :D This is first version (working only with GRFs, soon I'll add EXEs conversion). Please test it, I tested it only with WIN TTDpatch. Post here any bugs you'll found, so I'll fix them!


Attachments:
gc02.zip [27.24 KiB]
Downloaded 728 times

_________________
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
Top
   
 Post subject:
PostPosted: Sun Jan 09, 2005 6:55 pm 
Offline
Engineer
Engineer

Joined: Fri Mar 12, 2004 3:05 pm
Posts: 65
I created a shell program that worked out of dos and does all this.
I was unhappy with grfwizard and wanted more control.
Granted it is limited to dos names but because I was able to tie it
into other programs like grdtogrf, it gave me quite a menu for doing
all these functions to create a new grf. Since then I have added Sprites and
renum to the GRFMENU. I sure if you're interested you can do a search for it
here and find when I uploaded the code, etc. I haven't been able to find
the orginal author of the powre menu system.

JEB

If you would like my latest version which ties graphic and other programs
into grfmenu, Let me know and will ul to you.


Top
   
 Post subject:
PostPosted: Thu Mar 03, 2005 8:34 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jul 08, 2004 10:14 pm
Posts: 8511
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Yes, of course! Why you don't post it in forum here or in new topic?

I worked those days on next converter version. I had problems with second shell routine. I know it's untested, but if you help me? Here are problems:
1. There was problem with undefined variable:
Code:
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long 

SECURITY_ATTRIBUTES was undefined. I changed this to
Code:
lpSecurityAttributes As Long

Did I made a mistake?
2. Big problem is this code still doesn't make any file. I tried variants:
Code:
commandString = Graphic & " -l > " & tempFolder & "\sprites.txt" 
ExecCmd (commandString)

Code:
commandString = Graphic & " -l \to\ " & tempFolder & "\sprites.txt" 
ExecCmd (commandString)

I think I don't understand fthis:
Code:
hndl = CreateFile("c:\path\to\filename", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) 

What I need to write as "c:\path\to\filename"?
Thanx!

_________________
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!


Top
   
 Post subject:
PostPosted: Thu Feb 15, 2007 11:23 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Sep 16, 2005 12:23 pm
Posts: 1517
Skype: the_gremnon
Location: /home
Hmmm... I know some VB, although I don't pretend to know everything. I do have a few books about here I use to help.
I could look into the source code for you, root about and see if I can find any problems, but I'm not promising anything. It's been a while since I last used it.
Incidentally, VB6 works perfectly on 98SE, ME and 2k, but I've always had problems with XP and VB6. It's probably easier to get Microsoft Visual Studio, which contains VB6 and another program for working in C. I know nothing of C, so I just got VB6.
Anyway, I'll stop waffling for now.


Top
   
 Post subject:
PostPosted: Thu Feb 15, 2007 4:37 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Oct 17, 2005 8:56 pm
Posts: 3353
Location: Estonia
Hmm why to dig up two years old topic?

_________________
TT-Screenshot Of The Month - 2012 July, winner!
TT-Screenshot Of The Month - 2013 May, winner tie with Purno!
TT-Screenshot Of The Month - 2014 February, winner!
TT-Screenshot Of The Month - 2014 June, winner tie with alluke!
TT-Screenshot Of The Month - 2014 April, winner!

My screen shot thread ---> Have a look


Top
   
 Post subject:
PostPosted: Thu Feb 15, 2007 4:45 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13178
Location: The Netherlands
Please let old topics alone, Gremmon. It's been close to 2 years that this topic saw it's last reply which means you didn't happen to stumble upon it.

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
 Post subject:
PostPosted: Fri Feb 16, 2007 12:37 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 23, 2005 12:09 am
Posts: 3138
By the way, when a long time ago, I used this, the generated graphics had errors (some colors were wrong).

_________________
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.


Top
   
 Post subject:
PostPosted: Fri Feb 16, 2007 1:59 am 
Offline
TTDPatch Developer
TTDPatch Developer
User avatar

Joined: Wed May 26, 2004 4:37 pm
Posts: 1804
Location: Britain
I never saw what was wrong with using GrfCodec's own Win to DOS palette converter.
(the -m ? option).

~ Lakie

_________________
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.