 |
|
 |
|
Next: [TOME] Danger levels on wilderness map
|
| Author |
Message |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 1) Posted: Mon Jun 26, 2006 11:04 am
Post subject: [OS X only] Questions about main-crb.c Archived from groups: rec>games>roguelike>angband, others (more info?)
|
|
|
As an exercise in finally learning to program my computer as more than
a generic unix box, I am *attempting* to migrate main-crb.c to
Quartz/Carbon.
There is good reason to do so. Quote from Quickdraw Reference:
"Important: Quickdraw has been deprecated for deployment targets Mac
OS X version 10.4 and later. The replacement API is Quartz. Because of
the fundamental differences in the imaging models and design goals
between Quickdraw and Quartz, there is no direct correspondence between
Quickdraw and Quartz concepts and interfaces. For certain purposes,
some Quickdraw functions may still be needed during a transition
period; nevertheless, most of them have been deprecated to express the
overriding goal of eliminating the use of Quickdraw in the future."
There are opportunities for significant simplification. (I am making
the assumption that I can throw away all the non-OS X stuff; nobody
sane wants to--or even can--maintain that cruft.)
Some possibilities: (it took several days lost in the weeds to find
some of this stuff.)
1. Artifact elimination and text clipping.
There are two ways to get rid of this once and for all:
CGContextSetShouldAntialias (disable antialiasing) or Graphics Mode
kCGBlendModeDifference: either of these should allow use of Julian's
"overwrite hack". Subtraction of antialiased text seems a particularly
elegant hack.
2. Use more advanced text layout.
void CGContextShowGlyphsWithAdvances (
CGContextRef context, const CGGlyph glyphs[],
const CGSize advances[], size_t count);
This allows you to specify a set of glyphs and a set of relative
offsets at which to display them. If all the offsets are the same, you
automatically get efficient monospace with any font. And by rescaling
the canvas, you can get grid-based addressing, which eliminates all
pixel-based calculations.
3. Use of Quartz transparency layers for ... transparency.
4. the nib file. This is a lot easier (for me) to manipulate than
resource files.
I'd also like to see a finer grained interface to the OS (graphics,
text and events wrappers, rather than the current terminal wrapper) but
that's a problem for another day.
Any comments or additional suggestions? >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 2) Posted: Tue Jun 27, 2006 10:12 am
Post subject: Status report on coding OS X [was: Questions about main-crb.c] [Login to view extended thread Info.] Archived from groups: rec>games>roguelike>angband (more info?)
|
|
|
pete mack wrote:
> As an exercise in finally learning to program my computer as more than
> a generic unix box, I am *attempting* to migrate main-crb.c to
> Quartz/Carbon.
>
Well, the good news is, I've written -2200 lines of code in a week
(including obsolete comments and #ifdefs), and I haven't even started
on the Quartz part yet--Just tightened up the code, and switched to a
simpler event model. (6700 lines down to 4500 lines.)
The bad news is, it isn't running anymore... >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jul 12, 2005 Posts: 214
|
(Msg. 3) Posted: Tue Jun 27, 2006 11:48 am
Post subject: Re: Status report on coding OS X [was: Questions about main-crb.c] [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
pete mack wrote:
> pete mack wrote:
> > As an exercise in finally learning to program my computer as more than
> > a generic unix box, I am *attempting* to migrate main-crb.c to
> > Quartz/Carbon.
> >
>
> Well, the good news is, I've written -2200 lines of code in a week
> (including obsolete comments and #ifdefs), and I haven't even started
> on the Quartz part yet--Just tightened up the code, and switched to a
> simpler event model. (6700 lines down to 4500 lines.)
>
> The bad news is, it isn't running anymore...
I dont have a lot of useful things to say,
except that I find you a brave man and applaud your efforts.
T. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 4) Posted: Wed Jun 28, 2006 5:37 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
pete mack wrote:
> As an exercise in finally learning to program my computer as more than
> a generic unix box, I am *attempting* to migrate main-crb.c to
> Quartz/Carbon
Question for any OS X programmer:
What exactly is a Resume event (associated with the deprecated
suspendResumeMessage), and is there an equivalent Carbon Event?
I can find no user's guide for the old event model, so I don't know
what it does, or even if it is still has any use. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jun 03, 2005 Posts: 30
|
(Msg. 5) Posted: Thu Jun 29, 2006 7:58 am
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2006-06-29, pete mack <pmac360.DeleteThis@hotmail.com> wrote:
>
> pete mack wrote:
>> As an exercise in finally learning to program my computer as more than
>> a generic unix box, I am *attempting* to migrate main-crb.c to
>> Quartz/Carbon
>
> Question for any OS X programmer:
>
> What exactly is a Resume event (associated with the deprecated
> suspendResumeMessage), and is there an equivalent Carbon Event?
>
> I can find no user's guide for the old event model, so I don't know
> what it does, or even if it is still has any use.
>
If it works the same way as under Unix, then suspend will send a program
in a terminal window to the background and give access to the command line.
Resume is the reverse that re-activates the program. It could work a little
differently on OS X however.
--
Christer Nyfalt >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 6) Posted: Thu Jun 29, 2006 9:21 am
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Matthew and Chris --
It helps a lot. I suspect that event is mostly obselete on OS X, since
it has preemptive multitasking, and from what I understand about how
Quartz 2D works, it does not require window refresh in situations like
that.
I have a much worse problem right now. Apparently there's some memory
corruption going on, but I cannot see how; It's happening somewhere
before the init_file_paths() call, and that is basically right at the
beginning of the program.
The symptom is that RunApplicationEventLoop() crashes in initialization
if I put it anywhere after allocation of ANGBAND_DIR in
init_file_paths(), but it succeeds if the call is before. I tried the
malloc debug macros, but it didn't help.
Has anyone ever run Purify or some other memory verifier on Angband?
In any case, I have some miserable work cut out for myself.
Matthew Collett wrote:
> In article <1151541447.554871.203220.DeleteThis@y41g2000cwy.googlegroups.com>,
>
> From 'Inside Macintosh: Macintosh Toolbox Essentials':
>
> If the user switches between your application and another application
> (by clicking in the window of another application, for example), your
> application is responsible for activating or deactivating any windows
> as appropriate. Your application is notified of this occurrence
> through operating-system events. If your application has the
> acceptSuspendResumeEvents and doesActivateOnFGSwitch flags set in its
> 'SIZE' resource, your application is notified of the switch through an
> operating-system event and does not receive a separate activate event
> when the user switches between applications.
>
>
> The Carbon Porting Guide says that "Carbon applications must contain a
> SIZE resource, and the resource must have the acceptSuspendResumeEvents
> flag set." Comments in the sample code therein say that "suspend/resume
> is also an activate/deactivate".
>
> So the nearest equivalent Carbon event to a Resume event would be
> kEventAppActivated.
>
> But I will be amazed if any of that actually helps you. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 7) Posted: Thu Jun 29, 2006 11:10 am
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Andrew Doull wrote:
> Pete Mack wrote:
> >
> > Has anyone ever run Purify or some other memory verifier on Angband?
> >
>
> Valgrind works well on a Linux environment... if course that doesn't help
> you...
:-/
And no Darwin/BSD/OSX port, more's the shame. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 8) Posted: Thu Jun 29, 2006 12:46 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Christer Nyfalt wrote:
> Well, I did spot a memory leak with Valgrind on Sangband in
> init_file_paths(). The problem was that ANGBAND_DIR_APEX, ANGBAND_DIR_BONE,
> ANGBAND_DIR_DATA and ANGBAND_DIR_SAVE are redefined by the USE_PRIVATE_PATHS
> stuff after they already have been allocated, but the old paths created aren't
> freed and gets leaked. Could this be your problem?
I doubt it very much. Memory leaks are generally harmless unless they
are down inside your main loop. They certainly don't cause corruption.
But thanks, I can at least fix that.
After more snooping, I found that there's a compiler option -fmudflap,
but it's only available in gcc4. I've got V 10.3.9, which comes with
gcc3.4
I've been putting off the upgrade for a long time now; maybe it's time
to shell out another $120. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: May 31, 2005 Posts: 78
|
(Msg. 9) Posted: Thu Jun 29, 2006 5:33 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2006-06-29 18:21:20, "pete mack" <pmac360.TakeThisOut@hotmail.com> wrote:
> Matthew and Chris --
>
> It helps a lot. I suspect that event is mostly obselete on OS X, since
> it has preemptive multitasking, and from what I understand about how
> Quartz 2D works, it does not require window refresh in situations like
> that.
>
>
> I have a much worse problem right now. Apparently there's some memory
> corruption going on, but I cannot see how; It's happening somewhere
> before the init_file_paths() call, and that is basically right at the
> beginning of the program.
>
> The symptom is that RunApplicationEventLoop() crashes in initialization
> if I put it anywhere after allocation of ANGBAND_DIR in
> init_file_paths(), but it succeeds if the call is before. I tried the
> malloc debug macros, but it didn't help.
>
>
> Has anyone ever run Purify or some other memory verifier on Angband?
>
Valgrind works well on a Linux environment... if course that doesn't help
you...
Andrew
--
Unangband L:C E+ T- R- P+ D-- G+(+) F:Sangband RL-- RLA-- W:F Q++
AI+(++) GFX++ SFX++ RN+++(+) PO++ Hp+++ Re--(+) S++ C- O* KG-- >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jun 03, 2005 Posts: 30
|
(Msg. 10) Posted: Thu Jun 29, 2006 7:25 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2006-06-29, pete mack <pmac360.RemoveThis@hotmail.com> wrote:
> Matthew and Chris --
>
> It helps a lot. I suspect that event is mostly obselete on OS X, since
> it has preemptive multitasking, and from what I understand about how
> Quartz 2D works, it does not require window refresh in situations like
> that.
>
>
> I have a much worse problem right now. Apparently there's some memory
> corruption going on, but I cannot see how; It's happening somewhere
> before the init_file_paths() call, and that is basically right at the
> beginning of the program.
>
> The symptom is that RunApplicationEventLoop() crashes in initialization
> if I put it anywhere after allocation of ANGBAND_DIR in
> init_file_paths(), but it succeeds if the call is before. I tried the
> malloc debug macros, but it didn't help.
>
>
> Has anyone ever run Purify or some other memory verifier on Angband?
>
> In any case, I have some miserable work cut out for myself.
>
Well, I did spot a memory leak with Valgrind on Sangband in
init_file_paths(). The problem was that ANGBAND_DIR_APEX, ANGBAND_DIR_BONE,
ANGBAND_DIR_DATA and ANGBAND_DIR_SAVE are redefined by the USE_PRIVATE_PATHS
stuff after they already have been allocated, but the old paths created aren't
freed and gets leaked. Could this be your problem?
--
Christer Nyfalt >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Dec 09, 2005 Posts: 345
|
(Msg. 11) Posted: Thu Jun 29, 2006 9:26 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
pete mack wrote:
> After more snooping, I found that there's a compiler option -fmudflap,
> but it's only available in gcc4. I've got V 10.3.9, which comes with
> gcc3.4
>
> I've been putting off the upgrade for a long time now; maybe it's time
> to shell out another $120.
Upgrading gcc from 3.4 to 4.x should not cost $120. Gcc is free
software (as in speech, and as in beer). >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jul 23, 2004 Posts: 7
|
(Msg. 12) Posted: Fri Jun 30, 2006 12:24 am
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <1151541447.554871.203220 DeleteThis @y41g2000cwy.googlegroups.com>,
"pete mack" <pmac360 DeleteThis @hotmail.com> wrote:
> > As an exercise in finally learning to program my computer as more than
> > a generic unix box, I am *attempting* to migrate main-crb.c to
> > Quartz/Carbon
>
> Question for any OS X programmer:
>
> What exactly is a Resume event (associated with the deprecated
> suspendResumeMessage), and is there an equivalent Carbon Event?
>
> I can find no user's guide for the old event model, so I don't know
> what it does, or even if it is still has any use.
From 'Inside Macintosh: Macintosh Toolbox Essentials':
If the user switches between your application and another application
(by clicking in the window of another application, for example), your
application is responsible for activating or deactivating any windows
as appropriate. Your application is notified of this occurrence
through operating-system events. If your application has the
acceptSuspendResumeEvents and doesActivateOnFGSwitch flags set in its
'SIZE' resource, your application is notified of the switch through an
operating-system event and does not receive a separate activate event
when the user switches between applications.
The Carbon Porting Guide says that "Carbon applications must contain a
SIZE resource, and the resource must have the acceptSuspendResumeEvents
flag set." Comments in the sample code therein say that "suspend/resume
is also an activate/deactivate".
So the nearest equivalent Carbon event to a Resume event would be
kEventAppActivated.
But I will be amazed if any of that actually helps you.
Best wishes,
Matthew
--
Those who assert that the mathematical sciences have nothing to say
about the good or the beautiful are mistaken. -- Aristotle >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jun 19, 2005 Posts: 19
|
(Msg. 13) Posted: Fri Jun 30, 2006 6:07 am
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
pete mack wrote:
> It helps a lot. I suspect that event is mostly obselete on OS X, since
> it has preemptive multitasking, and from what I understand about how
> Quartz 2D works, it does not require window refresh in situations like
> that.
I'm not sure about obsolete -an example might be the minesweeper game
that I sometimes play, when you click to another application it pauses
the game and hides the board to prevent cheating- but probably of
doubtful relevance to a roguelike.
--
Daniel C. Stillwaggon
<dstillwa.DeleteThis@gmail.com> >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Jun 30, 2006 Posts: 1
|
(Msg. 14) Posted: Fri Jun 30, 2006 7:19 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"pete mack" <pmac360 RemoveThis @hotmail.com> writes:
> I have a much worse problem right now. Apparently there's some memory
> corruption going on, but I cannot see how; It's happening somewhere
> before the init_file_paths() call, and that is basically right at the
> beginning of the program.
>
> The symptom is that RunApplicationEventLoop() crashes in initialization
> if I put it anywhere after allocation of ANGBAND_DIR in
> init_file_paths(), but it succeeds if the call is before. I tried the
> malloc debug macros, but it didn't help.
Try using Guard Malloc (libgmalloc). It's slow, but catches more
memory smashers and premature deallocations.
% setenv DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib
% setenv DYLD_FORCE_FLAT_NAMESPACE
% ./angband
.... program will crash when a memory error occurs
--
Greg Parker gpakrer-usenet RemoveThis @sealiesoftware.com >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
External

Since: Mar 24, 2005 Posts: 411
|
(Msg. 15) Posted: Sun Jul 02, 2006 1:11 pm
Post subject: Re: OS X event question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
pete mack wrote:
>
> I have a much worse problem right now. Apparently there's some memory
> corruption going on, but I cannot see how; It's happening somewhere
> before the init_file_paths() call, and that is basically right at the
> beginning of the program.
>
> The symptom is that RunApplicationEventLoop() crashes in initialization
> if I put it anywhere after allocation of ANGBAND_DIR in
> init_file_paths(), but it succeeds if the call is before. I tried the
> malloc debug macros, but it didn't help.
>
Woohoo! I finally figured it out! It had to do with Pascal-style
function calls. I got rid of that, and it appears to be working now.
(I really don't understand how it works anyway.)
Working, at least, in the sense it is not crashing. Still along way
from actually playing the game. >> Stay informed about: [OS X only] Questions about main-crb.c |
|
| Back to top |
|
 |  |
| Related Topics: | RISCOS main-acn vs main-ros - There seems to be two *band RISCOS ports main-acn.c and main-ros.c. What are the differences? Which one should be used? -- Christer Nyfalt
Memory leak found in main-x11.c - Playing around with Valgrind, I found some memory leaks in main-x11.c for Sangband. I suspect that the leaks are not local to Sangband, so I report them here so that all maintainers can check them out. The problem is that the hints allocated with..
[All mac-ported variants] A change to main-crb.c that fixe.. - I'm not sure whether this is the right place to post this, but it seems to be the right audience.. r.g.r.d. is mostly non-Angband stuff. Anyway: As I'm sure most Mac users have noticed, the Mac OS X versions of Angband and variants have an annoying issue...
[Un] Frequently asked questions - Hi, The Unangband FAQ is included in the 0.6.0-beta 2 release. I reproduce it here: === Frequently Asked Questions === Most of these questions have been taken from the newsgroup rec.games.roguelike.angband. If something isn't answered here feel free t...
Steamband newbie questions - I have been playing Steamband a bit recently and have a few questions for the collective mind. So far it is a really fun game! I enjoy the flavor change a lot, it provides a refreshing shift from Vanilla every now and then. I haven't yet made it far.. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|