Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Commodity, Tools menu, vbcc support #5

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

chris-y
Copy link

@chris-y chris-y commented Dec 9, 2021

This PR allows DAControlGUI to be built with vbcc.
It also;

  1. adds an "Eject ADF" item to the tools menu (highlight mounted disk and eject from WB)
  2. registers DAControlGUI as a commodity
  3. reworks iconification (so Exchange's show/hide options work as expected, and Eject ADF from menu still works when iconified)
  4. adds Tooltypes reading (for Commodities standard tooltypes and to disable Eject ADF menu item)
  5. other minor fixes

Note CX_POPKEY is not implemented - it probably should be.
Note closing the main window still quits the app, maybe it should just hide the window now?

Supercedes #3 #4 - I've merged everything into the same pull request as some later changes were inseparable from earlier ones.

Fixes:
  Missing includes
  Missing OpenLibrarys
  Wrong types (mostly BPTR=NULL changed to 0)
  Bug in UnlockPubScreen
  Added makefile for vbcc

The semicolon at the start of main.c needs to be removed for the makefile to work.
This adds an "Eject ADF" item to the Workbench Tools menu.
With any number of disk icons selected, choosing Eject ADF will attempt to eject them.
Check name is '' before searching list
Attach CX Hide/Show to the same functions (but without AppIcon/AppMenu so it is hidden rather than iconified)
Note: CX_POPKEY not implemented
Also react correctly to CXCMD_UNIQUE
Menu items opening requesters should end with ellipsis
@MM-Mikhail
Copy link

Nice, but it no longer compiles with SAS

@chris-y
Copy link
Author

chris-y commented Jan 4, 2022

I don't have SAS/C so couldn't test it. Some error messages would help?

@MM-Mikhail
Copy link

Compiler Phase 1 for "main.c"

====================
 struct Library *IntuitionBase = NULL ;
                               ^
main.c 48 Error 72: conflict with previous declaration
                    See line 29 file "INCLUDE:proto/intuition.h"

====================
char appPath[PATH_MAX+NAME_MAX];
 ^^^^
main.c 148 Error 102: conflicting keywords in declaration
main.c 169 Warning 93: no reference to identifier "i"
main.c 170 Warning 93: no reference to identifier "olddir"

====================
                        NameFromLock(EjectADFMsg->am_ArgList[i].wa_Lock, &VolName, 104);
                                                                                 ^
main.c 250 Warning 88: argument type incorrect
                       Expecting "STRPTR", found "char (* )[104]"

====================
        if(EjectMenu ==  0 ) return;
                                   ^
main.c 281 Warning 85: return value mismatch for function "addEjectADFMenu"
                       Expecting "struct AppMenuItem *", found "void"

====================
        struct AppMenuItem *appmenuitem = NULL;
        ^^^^^^
main.c 283 Error 218: declaration found in statement block

====================
}
 ^
main.c 305 Warning 85: return value mismatch for function "unregisterCommodity"
                       Expecting "int", found "void"

====================
         __builtin_strcpy( appPath , curPath ) ;
                                   ^
main.c 356 Warning 88: argument type incorrect
                       Expecting "char *", found "int *"

====================
        strcat(appPath, "/DAControlGUI");
                      ^
main.c 357 Warning 88: argument type incorrect
                       Expecting "char *", found "int *"

====================
        strcat(manualPath, appPath);
                                  ^
main.c 360 Warning 88: argument type incorrect
                       Expecting "char const *", found "int *"

====================
        dobj=GetDiskObject(appPath);
                                  ^
main.c 365 Warning 88: argument type incorrect
                       Expecting "CONST_STRPTR", found "int *"

====================
        if (!(WindowPtr = (struct Window *) DoMethod(WindowObjectPtr, WM_OPEN, NULL)))
                                                                    ^
main.c 486 Warning 88: argument type incorrect
                       Expecting "Object *", found "struct Object *"

====================
                while ((result = DoMethod(WindowObjectPtr, WM_HANDLEINPUT, &code)) != W
                                                         ^
main.c 550 Warning 88: argument type incorrect
                       Expecting "Object *", found "struct Object *"

====================
     if (DosBase) {CloseLibrary (DosBase); DosBase=NULL;} ;
                                        ^
main.c 712 Warning 88: argument type incorrect
                       Expecting "struct Library *", found "struct DosBase *"

====================
r( ( ( ( ((ULONG)(1UL<<31))  + 0x5000000) +0x0002000) +1) , o[3], &deviceNo);
                                                             ^
main.c 1113 Warning 88: argument type incorrect
                        Expecting "ULONG *", found "int *"

====================
                                                        resGetFile =  DoMethod( o[2] , GFILE_REQUEST,  lo
adAdfWin ) ;
                                                                                     ^
main.c 1148 Warning 88: argument type incorrect
                        Expecting "Object *", found "WORD *"

====================
 ( ( ( ((ULONG)(1UL<<31))  + 0x5000000) +0x0002000) +1) , co[3], &cdeviceNo);
                                                           ^
main.c 1357 Warning 88: argument type incorrect
                        Expecting "ULONG *", found "int *"

====================
                                                        cresGetFile =  DoMethod( co[2] , GFILE_REQUEST,  
createAdfWin ) ;
                                                                                       ^
main.c 1383 Warning 88: argument type incorrect
                        Expecting "Object *", found "WORD *"

====================
        WindowPtr = (struct Window *)  (struct Window *)DoMethod( WindowObjectPtr , WM_
                                                                                  ^
main.c 1483 Warning 88: argument type incorrect
                        Expecting "Object *", found "struct Object *"

====================
         DoMethod( WindowObjectPtr , WM_CLOSE, NULL) ;
                                   ^
main.c 1502 Warning 88: argument type incorrect
                        Expecting "Object *", found "struct Object *"
3 errors; 18 warnings; 63 user suppressed warnings

@chris-y
Copy link
Author

chris-y commented Jan 5, 2022

I'm going to ignore the warnings as they may well have been there before - I had lots with vbcc too and didn't look at fixing them (except in the cases where the code didn't work after compilation).

> ====================
>  struct Library *IntuitionBase = NULL ;
>                                ^
> main.c 48 Error 72: conflict with previous declaration
>                     See line 29 file "INCLUDE:proto/intuition.h"

Appears I added that line - SAS must define it internally.

Probably needs #ifndef __SASC__ (I think that's the correct define) around the Intuition BASEDEF/OPENLIB/CLOSELIB calls.

> ====================
> char appPath[PATH_MAX+NAME_MAX];
>  ^^^^
> main.c 148 Error 102: conflicting keywords in declaration

No clue - that isn't even something I've added. Maybe rename PATH_MAX/NAME_MAX in includes.h and in the main code, in case they are conflicting with something in the includes which wasn't included previously?

> ====================
>         struct AppMenuItem *appmenuitem = NULL;
>         ^^^^^^
> main.c 283 Error 218: declaration found in statement block

That's an easy one! That line needs moving up two lines to the top of the function.

@MM-Mikhail
Copy link

enum { }; is missing ; at the end, that fixes a lot of issues ;-)

but then the problem comes from all added BASEDEF

Error 510: _IconBase symbol - Near Reference to data item not in near data section

Commenting them out builds the code, but the executable does not work

@MM-Mikhail
Copy link

Also wondering what version of reaction.lib you use to build under VBCC, I made a setup for it, but it gives errors with 1.0, 1.5 and 47.3

@chris-y
Copy link
Author

chris-y commented Jan 5, 2022

Also wondering what version of reaction.lib you use to build under VBCC, I made a setup for it, but it gives errors with 1.0, 1.5 and 47.3

vbcc 0.906 (0.9f?) according to various files in that directory. reaction.lib is from 2007 (20484 bytes) - I assume this came with it as this is the first time I've needed it.

I've fixed the semicolon and the declaration in the wrong place.

but then the problem comes from all added BASEDEF
Error 510: _IconBase symbol - Near Reference to data item not in near data section
Commenting them out builds the code, but the executable does not work

Hmm, not sure. Is it to do with DATA=FAR in scoptions or one of the optimisation options?

@MM-Mikhail
Copy link

Interesting, you should make that special lib available, I can't find a VBCC compatible version of it, old/new ones are only for SAS.

@chris-y
Copy link
Author

chris-y commented Jan 5, 2022

Here you go: reaction.lib.zip

@MM-Mikhail
Copy link

Well, this finally links under VBCC, but has the same issue as original, too many enforcer hits due to incorrect initialization of listbrowser, almost endless loop of hits

06-Jan-22    07:57:01
LONG READ from 00000000                        PC: 407A953E
USP : 4083CD14 SR: 0009  (U0)(-)(-)  TCB: 40838F50
Data: FFFFFFFF 00000016 00000100 00000000 00001000 00000008 00000000 40838958
Addr: 40838958 00000000 4076B5B8 00000000 4083CEE8 4083CEA0 40004BF0 40002328
Stck: 00000100 00000000 00001000 00000008 00000000 00000000 4083CEA0 4076B54C
Stck: 4076B5B8 4068B0C0 4000CF24 40647268 40647268 4083CEE8 40668D98 4068B0C0
Stck: 4076B54C 4076B54C 0000B0C0 0001CF24 0000CD74 0001CF24 0000C864 000080D4
Stck: 80020004 0000000A 00000001 4083CEF0 407A80EA 4083CEA0 00000100 00000000
----> 407A953E - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00001D56
----> 407A80EA - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00000902
PC-8: D0952040 08E80006 0018200B D0952040 08280004 000F6604 52AA0018 52862653
PC *: 4A936692 70FFB0AA 00086604 42AA0040 B0AA0004 660442AA 0044222A 026C2401
407a951e :  d095                       add.l (a5),d0
407a9520 :  2040                       movea.l d0,a0
407a9522 :  08e8 0006 0018             bset #$6,$18(a0)
407a9528 :  200b                       move.l a3,d0
407a952a :  d095                       add.l (a5),d0
407a952c :  2040                       movea.l d0,a0
407a952e :  0828 0004 000f             btst #$4,$f(a0)
407a9534 :  6604                       bne.s $407a953a
407a9536 :  52aa 0018                  addq.l #$1,$18(a2)
407a953a :  5286                       addq.l #$1,d6
407a953c :  2653                       movea.l (a3),a3
407a953e : *4a93                       tst.l (a3)
407a9540 :  6692                       bne.s $407a94d4
407a9542 :  70ff                       moveq.l #-$1,d0
407a9544 :  b0aa 0008                  cmp.l $8(a2),d0
407a9548 :  6604                       bne.s $407a954e
407a954a :  42aa 0040                  clr.l $40(a2)
407a954e :  b0aa 0004                  cmp.l $4(a2),d0
407a9552 :  6604                       bne.s $407a9558
407a9554 :  42aa 0044                  clr.l $44(a2)
407a9558 :  222a 026c                  move.l $26c(a2),d1
407a955c :  2401                       move.l d1,d2
Name: "DAControlGUI"

LONG READ from FFFFFFFC                        PC: 407A9502
USP : 4083CD14 SR: 0014  (U0)(-)(-)  TCB: 40838F50
Data: 00000000 00000016 00000100 00000000 00001000 00000008 00000000 40838958
Addr: 00000000 00000000 4076B5B8 00000000 4083CEE8 FFFFFFFC 40004BF0 40002328
Stck: 00000100 00000000 00001000 00000008 00000000 00000000 4083CEA0 4076B54C
Stck: 4076B5B8 4068B0C0 4000CF24 40647268 40647268 4083CEE8 40668D98 4068B0C0
Stck: 4076B54C 4076B54C 0000B0C0 0001CF24 0000CD74 0001CF24 0000C864 000080D4
Stck: 80020004 0000000A 00000001 4083CEF0 407A80EA 4083CEA0 00000100 00000000
----> 407A9502 - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00001D1A
----> 407A80EA - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00000902
PC-8: 2040D290 204108A8 00070018 206A0040 B1CB6604 25460008 200B5980 2A40200B
PC *: D0952040 4A280018 6A0452AA 017A206A 0044B1CB 66102546 0004200B D0952040 

BYTE READ from ABADFF05                        PC: 407A9506
USP : 4083CD14 SR: 0008  (U0)(-)(-)  TCB: 40838F50
Data: ABADFEED 00000016 00000100 00000000 00001000 00000008 00000000 40838958
Addr: ABADFEED 00000000 4076B5B8 00000000 4083CEE8 FFFFFFFC 40004BF0 40002328
Stck: 00000100 00000000 00001000 00000008 00000000 00000000 4083CEA0 4076B54C
Stck: 4076B5B8 4068B0C0 4000CF24 40647268 40647268 4083CEE8 40668D98 4068B0C0
Stck: 4076B54C 4076B54C 0000B0C0 0001CF24 0000CD74 0001CF24 0000C864 000080D4
Stck: 80020004 0000000A 00000001 4083CEF0 407A80EA 4083CEA0 00000100 00000000
----> 407A9506 - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00001D1E
----> 407A80EA - "LIBS:gadgets/listbrowser.gadget"  Hunk 0000 Offset 00000902
PC-8: 204108A8 00070018 206A0040 B1CB6604 25460008 200B5980 2A40200B D0952040
PC *: 4A280018 6A0452AA 017A206A 0044B1CB 66102546 0004200B D0952040 08E80006    

@MM-Mikhail
Copy link

Ohh... the REFRESH button in the GUI crashes the machine instantly.

to reproduce:
Open fresh GUI, mount two adf disks via WB icons (double click), return to GUI, ask refresh, BOOM.

@MM-Mikhail
Copy link

To make the GUI a little bit nicer, I would remover the outer group bevel and maybe add a little spacer below the buttons so they do not touch the border when spacing is set below 4.

@MM-Mikhail
Copy link

Load and create windows GUI needs revising, they probably should not allow vertical stretching, it just looks bad when spaced out and some elements stretched vertically.

@chris-y
Copy link
Author

chris-y commented Jan 6, 2022

Ohh... the REFRESH button in the GUI crashes the machine instantly.

to reproduce: Open fresh GUI, mount two adf disks via WB icons (double click), return to GUI, ask refresh, BOOM.

That's probably the same as the other listbrowser issue (which I didn't touch, but I noticed the program crashes immediately under OS4 so figured there were some bugs with initialisation other than the one I fixed). The refresh button basically wipes out the listbrowser and recreates it.

Also... you do realise I didn't write this? 😀 Probably best to raise issues separately for the other problems (or do your own PR).

@MM-Mikhail
Copy link

I understand, let's hope it will be picked up and finished properly and none hacky way.

So extra details and fixes required

  • use NewList() on an uninitialized list
    NewList(&adfList);
    if (!(WindowObjectPtr = NewObject

since list is not initialized at all, could have two side-effects.
The first is that the empty window opens with an Enforcer hit.
Later any call to freeList(&adfList) will trash memory.

In main.c/createADFList() there's a free(buffer) call which should be removed
because the "buffer" variable is declared as UBYTE buffer[BUFFERSIZE];.
This likely will trash the stack and system memory, too.

  • Execute("Delete RAM:dacgui.log >NIL:", NULL, NULL)
    replaced with proper -> DeleteFile("RAM:dacgui.log")

  • string buffer sizes should be checked for overflow cases or it can go boom

@chris-y
Copy link
Author

chris-y commented Jan 6, 2022

In main.c/createADFList() there's a free(buffer) call which should be removed because the "buffer" variable is declared as UBYTE buffer[BUFFERSIZE];. This likely will trash the stack and system memory, too.

I fixed this one in my fork already - I think it crashed here after I'd built it with vbcc.

@emartisoft
Copy link
Owner

Load and create windows GUI needs revising, they probably should not allow vertical stretching, it just looks bad when spaced out and some elements stretched vertically.
2022-01-08_02-24-03

@emartisoft
Copy link
Owner

In main.c/createADFList() there's a free(buffer) call which should be removed because the "buffer" variable is declared as UBYTE buffer[BUFFERSIZE];. This likely will trash the stack and system memory, too.

I fixed this one in my fork already - I think it crashed here after I'd built it with vbcc.

Sorry but SAS/C does not compile your edited/added lines.

@emartisoft
Copy link
Owner

With 3.2.1 update, added an "Eject ADF" item to the tools menu (highlight mounted disk and eject from WB)

@emartisoft
Copy link
Owner

I think that if you are coding with reaction library, SAS/C is good/stable solution.

@MM-Mikhail
Copy link

I think that if you are coding with reaction library, SAS/C is good/stable solution.

It would be better not to use it to begin with. Reaction GUI application do not require the reaction.lib link library. eg. 3.2 ShowConfig is an example and it uses all the same classes and function as this tool.
This would simplify compiling with different compilers since the library needs to be specially made for each one and it's not widely available and even then in different incompatible versions.

@MM-Mikhail
Copy link

In main.c/createADFList() there's a free(buffer) call which should be removed because the "buffer" variable is declared as UBYTE buffer[BUFFERSIZE];. This likely will trash the stack and system memory, too.

I fixed this one in my fork already - I think it crashed here after I'd built it with vbcc.

Sorry but SAS/C does not compile your edited/added lines.

It would compile if you comment out some of BASEDEF() at start of file, but this is not the main problem, which ever branch you take and which compiler is used the code produces is of poor quality and can not work reliably since it trashes memory due to improper initialization and clearing of the list.

@MM-Mikhail
Copy link

Load and create windows GUI needs revising, they probably should not allow vertical stretching, it just looks bad when spaced out and some elements stretched vertically.
2022-01-08_02-24-03

User spacing has nothing to do with the GUI construction since spacings need to be defined by extra objects and some gadgets need they sizes locked to prevent then from stretching when the gui is resized, in our case the windows in question should not allow vertical resize, only horizontal, Then it will not fall apart when window is sized big.

@MM-Mikhail
Copy link

This image shows the removed extra bevel around the window frame
Problem with GUI sized small, buttons get cut/write to borders
Extra padding required below bottom buttons so they do not write into border
Oversized and bad scaling in extra windows
DAGUI-BAD

@emartisoft
Copy link
Owner

This image shows the removed extra bevel around the window frame
Problem with GUI sized small, buttons get cut/write to borders
Extra padding required below bottom buttons so they do not write into border
Oversized and bad scaling in extra windows

You're are right. for Load/Change and Create ADF Window, They have horizontal resize only but not vertical.

@emartisoft
Copy link
Owner

I think that if you are coding with reaction library, SAS/C is good/stable solution.

It would be better not to use it to begin with. Reaction GUI application do not require the reaction.lib link library. eg. 3.2 ShowConfig is an example and it uses all the same classes and function as this tool. This would simplify compiling with different compilers since the library needs to be specially made for each one and it's not widely available and even then in different incompatible versions.

OS 3.2 includes ReAction preferences and OS3.2 CD includes c source codes/samples to compile with reaction lib. But NDK3.2 does not include reaction lib/src. It has only header files.

@chris-y
Copy link
Author

chris-y commented Jan 8, 2022

What does reaction.lib do other than open the classes automatically?

@emartisoft
Copy link
Owner

What does reaction.lib do other than open the classes automatically?

So I use reaction.lib

@chris-y
Copy link
Author

chris-y commented Jan 8, 2022

What does reaction.lib do other than open the classes automatically?

So I use reaction.lib

That didn't answer the question. I know you use it, I was wondering if it did anything other than opening the classes, as if not it can be easily avoided.

@emartisoft
Copy link
Owner

What does reaction.lib do other than open the classes automatically?

So I use reaction.lib

That didn't answer the question. I know you use it, I was wondering if it did anything other than opening the classes, as if not it can be easily avoided.

Following classes/gadgets are openning by reaction.

window.class
requester.class
gadgets/layout.gadget
gadgets/listbrowser.gadget
gadgets/slider.gadget
gadgets/scroller.gadget
gadgets/radiobutton.gadget
gadgets/texteditor.gadget
gadgets/space.gadget
gadgets/clicktab.gadget
gadgets/string.gadget
gadgets/getfile.gadget
gadgets/getfont.gadget
gadgets/getscreenmode.gadget
gadgets/integer.gadget
gadgets/chooser.gadget
gadgets/button.gadget
gadgets/checkbox.gadget
gadgets/fuelgauge.gadget
gadgets/palette.gadget
images/label.image
images/penmap.image
images/bitmap.image
images/glyph.image

@chris-y
Copy link
Author

chris-y commented Jan 8, 2022

What does reaction.lib do other than open the classes automatically?

So I use reaction.lib

That didn't answer the question. I know you use it, I was wondering if it did anything other than opening the classes, as if not it can be easily avoided.

Following classes/gadgets are openning by reaction.

window.class
requester.class
gadgets/layout.gadget
gadgets/listbrowser.gadget
gadgets/slider.gadget
gadgets/scroller.gadget
gadgets/radiobutton.gadget
gadgets/texteditor.gadget
gadgets/space.gadget
gadgets/clicktab.gadget
gadgets/string.gadget
gadgets/getfile.gadget
gadgets/getfont.gadget
gadgets/getscreenmode.gadget
gadgets/integer.gadget
gadgets/chooser.gadget
gadgets/button.gadget
gadgets/checkbox.gadget
gadgets/fuelgauge.gadget
gadgets/palette.gadget
images/label.image
images/penmap.image
images/bitmap.image
images/glyph.image

OK, so we could open those manually (the ones you use) and not need reaction.lib?

@MM-Mikhail
Copy link

so something like this

BOOL ReAction_Init(void) 
{
	if(GadToolsBase = (struct Library *) OpenLibrary("gadtools.library", 0))
		if(WindowBase = (struct Library *) OpenLibrary("window.class", 0)) 
			if (ListBrowserBase = (struct Library*) OpenLibrary("gadgets/listbrowser.gadget", 0)) 
				if (LayoutBase = (struct Library*) OpenLibrary("gadgets/layout.gadget", 0))
					if (StringBase = (struct Library*) OpenLibrary("gadgets/string.gadget", 0)) 
				    		return TRUE;

	return FALSE;
}

void ReAction_Close() 
{
	if(StringBase) CloseLibrary((struct Library *) StringBase);
	if(LayoutBase) CloseLibrary((struct Library *) LayoutBase);
	if(ListBrowserBase) CloseLibrary((struct Library *) ListBrowserBase);
	if(WindowBase) CloseLibrary((struct Library *) WindowBase);
	if(GadToolsBase) CloseLibrary((struct Library *) GadToolsBase);
}

@chris-y
Copy link
Author

chris-y commented Mar 6, 2022

I missed this when it was released, but vbcc 0.9h contains reaction.lib:

vclib: m68k-amigaos adds reaction.lib for ReAction GUI support

@MM-Mikhail
Copy link

I believe it is reimplementation of the lib based on OS 3.2 project and NDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants