ThinkC [Study Group 1] Drawing on the Macintosh

Relating to ThinkC Development

pfuentes69

Active Tinkerer
Oct 27, 2021
380
290
63
Switzerland
Is it a linker error or a compilation error? I get that linker error if I don't link against the MacTraps library. Did you link against the MacTraps library?
It is a linker error, but MacTraps is there...
Screenshot 2022-10-07 at 16.57.51.png
 

Mu0n

Active Tinkerer
Oct 29, 2021
570
532
93
Quebec
www.youtube.com
It is a linker error, but MacTraps is there...
View attachment 9184
Side note:

if your project name is OffscreenTC6.pi (where 'pi' is the pi character that you can make with ctrl-p) or something easier like OffscreenTC6.pr
and your resource file in the same folder as the project file is called OffscreenTC6.pr.rsrc,
then you don't need to link your resource file manually in the project linker window at all like is seen here. Think C will connect it for you.
 
  • Like
Reactions: pfuentes69

Patrick

Tinkerer
Oct 26, 2021
434
1
223
43
you don't need to link your resource file manually in the project linker window at all like is seen here. Think C will connect it for you.
i've actually caused an error when i tried to do both(on accident, i didn't understand this feature at the time) Think C will think i'm trying to link the same resource file twice and yell at me.

...

at least thats what i remember.
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
I'm trying to understand why the Mondrian app fails to run on a Mac SE but works on the emulated Mac II? Here's what I get:

Mac SE crash:
Screen Shot 2023-05-09 at 6.31.36 AM.png


Mac II success:
Screen Shot 2023-05-09 at 6.35.52 AM.png


Code:

(See attached "Mondrian.c.txt")
 

Attachments

  • Mondrian.c.txt
    2.7 KB · Views: 47

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Normally that happens when you use Color QuickDraw, but you don’t appear to be doing that here (ForeColor/BackColor don’t count).

Have you tried running this under THINK C on an SE, rather than just running the complied app? If you run it in the THINK C environment (check “Use Debugger” first), it should drop into Lightsbug and tell you where this error is happening.

Or install Macsbug (which you should do anyway if you are developing Mac programs) and post a screenshot of what it shows you during the crash here.
 
  • Like
Reactions: retr01

retr01

Senior Tinkerer
Jun 6, 2022
2,469
1
778
113
Utah, USA
retr01.com
I noticed colors on emulated Mac II but crashed on emulated SE, which makes me wonder if there wasn't a way to handle if colors were not supported, especially on SE, Plus, and the other compact Macs that can't process color.
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
Normally that happens when you use Color QuickDraw, but you don’t appear to be doing that here (ForeColor/BackColor don’t count).

Have you tried running this under THINK C on an SE, rather than just running the complied app? If you run it in the THINK C environment (check “Use Debugger” first), it should drop into Lightsbug and tell you where this error is happening.

Or install Macsbug (which you should do anyway if you are developing Mac programs) and post a screenshot of what it shows you during the crash here.
I have tried running it from within THINK C with the same results. I have Macsbug on my 6.0.8 image which also crashes the same way. I still need to get it installed to my 7.5.5 image though so I'll do that later today.
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
I noticed colors on emulated Mac II but crashed on emulated SE, which makes me wonder if there wasn't a way to handle if colors were not supported, especially on SE, Plus, and the other compact Macs that can't process color.
Just tried removing the non-black/white colors from the code & it still crashes the same way.
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
Have you tried running this under THINK C on an SE, rather than just running the complied app? If you run it in the THINK C environment (check “Use Debugger” first), it should drop into Lightsbug and tell you where this error is happening.
Running this from within THINK C on the SE runs out of memory which is why I was compiling it to a binary first.
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
I have tried running it from within THINK C with the same results. I have Macsbug on my 6.0.8 image which also crashes the same way. I still need to get it installed to my 7.5.5 image though so I'll do that later today.
If you have Macsbug properly installed and running you should never see that type of crash. Any system bomb for example “illegal instruction” should always drop into Macsbug instead. Double check that Macsbug 6.x is in your System Folder and that you are seeing “Macsbug installed” under “Welcome to Macintosh” during startup. If not, something is wrong with your copy of Macsbug.
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
I noticed colors on emulated Mac II but crashed on emulated SE, which makes me wonder if there wasn't a way to handle if colors were not supported, especially on SE, Plus, and the other compact Macs that can't process color.
@superbenk is only using the legacy ForeColor and BackColor routines, which only support 8 colors but were present from day one and should work fine on an SE (or Plus, or 128k). You are correct that Color QuickDraw generally is not supported on an SE, so he could not for example call RGBForeColor … but his code doesn’t appear to be doing this, so it’s not clear to me immediately why he’s getting this crash. MacsBug will provide the answer.
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
OH @superbenk make sure you aren’t compiling with 68020 instructions enabled. Look under edit/preferences in the “THINK C” drop-down and ensure that checkbox is unchecked.
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
OH @superbenk make sure you aren’t compiling with 68020 instructions enabled. Look under edit/preferences in the “THINK C” drop-down and ensure that checkbox is unchecked.
Ah, I'll check that.

In the meantime I finally got the right MacsBug installed in my 7.5.5 image & it looks like this when it crashes on an SE:

1683650916916.png
 

superbenk

New Tinkerer
Apr 9, 2023
15
6
3
Compiling with 68020 instructions was indeed the problem. Thank you! Appreciate you all being so patient with this n00b :) Reading some of the other comments in the threads makes me realize just how much of a programmer I AM NOT! But it's still fun to learn.
 
  • Like
Reactions: retr01

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Yeah that Macsbug dump is exactly what you needed. MULU.L (multiple two unsigned long integers in a single instruction) is a 68020 instruction that won’t work on a SE. Glad it worked!
 
  • Like
Reactions: retr01

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Right. You can get lucky for a while until you make some tiny code change that causes THINK to decide that it’s slightly faster to use a 68020 instruction. Then, without realizing it, you’ve suddenly introduced a bomb on an SE.
 

RickLawson

New Tinkerer
May 4, 2023
18
13
3
Boiling Springs, SC
Question - so I've done a couple examples - draw HelloWorld and Mondrian. One thing I noticed is there are no imports.
Does ThinkC automatically add mac imports for you? I was expecting stuff like import "quickdraw.h" at the top of the samples?