Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old April 24, 2009, 06:24   #1
LanceDiamond
Rookie
 
Join Date: Apr 2009
Posts: 13
LanceDiamond is on a distinguished road
Visual Studio 2008 - building 32 & 64 bit now!

Took about 2 days to sort out but now I can build either 32 bit (x86) or 64 bit (x64) 3.1.0 beta using VS2008 on 64 bit Vista. Simple as changing my build config. I'm so proud of myself.

No clue why I did this - happy to share the main-win.c if anyone is interested. I actually didn't have to change that much though some of what I had to do would probably be viewed as an awful hack by any sane person.
LanceDiamond is offline   Reply With Quote
Old April 24, 2009, 06:25   #2
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,768
Donated: $40
Pete Mack will become famous soon enough
Getting it to build is a good start. The question is: does it work?
Pete Mack is offline   Reply With Quote
Old April 24, 2009, 07:33   #3
LanceDiamond
Rookie
 
Join Date: Apr 2009
Posts: 13
LanceDiamond is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
Getting it to build is a good start. The question is: does it work?
Haha fine point!

Guess I should have been a bit more clear - yes, it works - haven't actually played much with 64 bit yet, but I'm going to start a new char right now with the x64 binary and play a while. I have loaded a savefile from an old char I'd played in 32bit and it loads and I can move around etc.

Building an x64 binary was surprisingly easy. Tracking down what was causing the x64 binary to crash upon execution was time consumning. Fixing what was wrong was not too difficult. How I fixed it is where the awful hack comes in.
LanceDiamond is offline   Reply With Quote
Old April 25, 2009, 10:22   #4
LanceDiamond
Rookie
 
Join Date: Apr 2009
Posts: 13
LanceDiamond is on a distinguished road
64 bit is working fine - no awful hack any more either. I had been manually changing a pointer but then I noticed if I just changed SetWindowLong to SetWindowLongPtr that wasn't necessary.

The change necessary for 64 bit Windows were all around the assumption that a pointer is 4 bytes. That's correct for 32 bit but for 64 bit, a pointer is 8 bytes.

With the changes I made, both 32 and 64 bit compile and work.

Changes:

main-win.c, WinMain function
Code:
wc.cbWndExtra    = 4; /* one long pointer to term_data */
changed to
Code:
wc.cbWndExtra    = sizeof(LONG_PTR); // 4 on 32bit, 8 on 64bit
main-win.c, several places
Code:
td = (term_data *)GetWindowLong(hWnd, 0);
changed to
Code:
td = (term_data *)GetWindowLongPtr(hWnd, 0);
main-win.c, several places
Code:
SetWindowLong(hWnd, 0, (LONG)(my_td));
changed to
Code:
SetWindowLongPtr(hWnd, 0, (LONG_PTR)(my_td));
LanceDiamond is offline   Reply With Quote
Old April 25, 2009, 10:29   #5
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by LanceDiamond View Post
64 bit is working fine - no awful hack any more either.
Well it didn't break anything on my 32 bit compile so I've borrowed the code.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old April 25, 2009, 13:59   #6
LanceDiamond
Rookie
 
Join Date: Apr 2009
Posts: 13
LanceDiamond is on a distinguished road
Glad to help - if you're curious about the new version of the functions:

SetWindowLongPtr
http://msdn.microsoft.com/en-us/libr...98(VS.85).aspx

GetWindowLongPtr
http://msdn.microsoft.com/en-us/libr...85(VS.85).aspx

Looks like they were created to enable code that is compatible with 32-bit and 64-bit Windows.
LanceDiamond is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fundraiser 2008 pav Oook! 9 November 22, 2008 21:41
Something a bit different Aknight Variants 22 June 25, 2008 21:13
Getting Visual C++ 2008 Express Edition to compile Angband 3.0.9 Orillian Vanilla 5 February 10, 2008 09:23
Will we get rid of the 32 bit flag variables? Bandobras Vanilla 18 December 22, 2007 14:54
wall building? Slick Vanilla 8 November 1, 2007 01:29


All times are GMT +1. The time now is 18:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.