22 April 2010, 19:13 | #1 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
Icon tooltypes and stuff
I have a new idea for my NES emulator. Imagine starting a ROM directly using a icon instead of loading it using the regular emulator-interface.
Wouldn't it look cool? Having a SuperMarioBros icon on your workbench and when you doubleclick it, the game will start as any other Amiga-game. My question is, what's the best way of doing this (I haven't done much icon-related coding in my days..) My first thought was something like, when the user clicks the game-icon, A/NES starts with an argument, something like: "ANES SuperMarioBros.nes" Is there a smarter way of doing this? |
22 April 2010, 19:24 | #2 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
Quote:
The Amiga way of doing this is to make project icons for the ROMs with ANES as the default tool. In ANES you then examine the startup message you get from Workbench. It contains a pointer to a struct WBArg which contains the lock of the directory the ROM was started from and the name of the ROM file. |
|
22 April 2010, 20:07 | #4 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
If ANES and games could be started from shell with arguments that would be GREAT.
Eg- ANES Turtles.NES I could add NES games along side Amiga games in my AGS boot menu or have a separate AGS menu for NES games. Last edited by Retro1234; 22 April 2010 at 20:13. |
22 April 2010, 20:49 | #5 | |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
Quote:
|
|
22 April 2010, 22:01 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
Here is an example:
Code:
#include <proto/exec.h> #include <proto/dos.h> #include <workbench/startup.h> int main (int argc,char **argv) { struct WBStartup *wbmsg; BPTR win; if (argc != 0) { Printf ("This program cannot be run in DOS mode :-)\n"); return (RETURN_ERROR); } wbmsg = (struct WBStartup *)argv; if (win = Open ("con:0/0/640/400/WB Icon/CLOSE/WAIT",MODE_NEWFILE)) { char buffer[256]; long i; NameFromLock (wbmsg->sm_ArgList->wa_Lock,buffer,256); AddPart (buffer,wbmsg->sm_ArgList->wa_Name,256); FPrintf (win,"Program name: <%s>\n",buffer); for (i = 1; i < wbmsg->sm_NumArgs; i++) { NameFromLock (wbmsg->sm_ArgList[i].wa_Lock,buffer,256); AddPart (buffer,wbmsg->sm_ArgList[i].wa_Name,256); FPrintf (win,"Argument #%ld: <%s>\n",i,buffer); } Close (win); } return (RETURN_OK); } |
27 April 2010, 13:15 | #7 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
An example in asm would be even better, but thanks.
|
27 April 2010, 13:26 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
Well, assembler output of the C compiler:
Code:
section text,code debug 5 ; int main (int argc,char **argv) ds.l 0 procstart ds.w 0 xdef _main _main: movem.l l18,-(sp) move.l l17-4(A7),D7 move.l l17+0(A7),A3 link A5,#-l15 debug 11 ; ; ; { ; struct WBStartup *wbmsg; ; BPTR win; ; ; if (argc != 0) tst.l D7 beq l2 l1 debug 13 ; ; { ; Printf ("This program cannot be run in DOS mode :-)\n"); pea.l l11(A4) jsr _Printf(pc) addq.l #4,sp debug 14 ; ; return (10); moveq.l #10,D0 bra l16 l2 l3 debug 17 ; ; } ; ; wbmsg = (struct WBStartup *)argv; move.l A3,A2 debug 19 ; ; ; if (win = Open ("con:0/0/640/400/WB Icon/CLOSE/WAIT",1006)) lea.l l12(A4),A0 move.l A0,D1 move.l #$03EE,D2 move.l _DOSBase(A4),A6 jsr -30(A6) move.l D0,D6 tst.l D6 beq l5 l4 debug 24 ; ; { ; char buffer[256]; ; long i; ; ; NameFromLock (wbmsg->sm_ArgList->wa_Lock,buffer,256); move.l 36(A2),A6 move.l (A6),D1 lea.l -256(A5),A6 move.l A6,D2 move.l #$0100,D3 move.l _DOSBase(A4),A6 jsr -402(A6) debug 25 ; ; AddPart (buffer,wbmsg->sm_ArgList->wa_Name,256); lea.l -256(A5),A6 move.l A6,D1 move.l 36(A2),A6 move.l 4(A6),D2 move.l #$0100,D3 move.l _DOSBase(A4),A6 jsr -882(A6) debug 26 ; ; FPrintf (win,"Program name: <%s>\n",buffer); pea.l -256(A5) pea.l l13(A4) move.l D6,-(sp) jsr _FPrintf(pc) lea 12(sp),sp debug 28 ; ; ; for (i = 1; i < wbmsg->sm_NumArgs; i++) moveq.l #1,D5 bra l10 l7 debug 30 ; ; { ; NameFromLock (wbmsg->sm_ArgList[i].wa_Lock,buffer,256); move.l D5,D3 asl.l #$03,D3 move.l 36(A2),A6 add.l D3,A6 move.l (A6),D1 lea.l -256(A5),A6 move.l A6,D2 move.l #$0100,D3 move.l _DOSBase(A4),A6 jsr -402(A6) debug 31 ; ; AddPart (buffer,wbmsg->sm_ArgList[i].wa_Name,256); lea.l -256(A5),A6 move.l A6,D1 move.l D5,D3 asl.l #$03,D3 move.l 36(A2),A6 add.l D3,A6 move.l 4(A6),D2 move.l #$0100,D3 move.l _DOSBase(A4),A6 jsr -882(A6) debug 32 ; ; FPrintf (win,"Argument #%ld: <%s>\n",i,buffer); pea.l -256(A5) move.l D5,-(sp) pea.l l14(A4) move.l D6,-(sp) jsr _FPrintf(pc) lea 16(sp),sp l8 addq.l #$01,D5 l10 cmp.l 28(A2),D5 blt l7 l20 l9 debug 35 ; ; } ; ; Close (win); move.l D6,D1 move.l _DOSBase(A4),A6 jsr -36(A6) l5 l6 debug 38 ; ; } ; ; return (0); moveq.l #0,D0 bra l16 l16 unlk A5 movem.l (sp)+,D2/D3/D5/D6/D7/A2/A3/A6 rts l18 reg D2/D3/D5/D6/D7/A2/A3/A6 l17 equ 40 l15 equ 256 procend debug 39 ; ; } xref _Close xref _FPrintf xref _AddPart xref _NameFromLock xref _Open xref _Printf xref _DOSBase section data,data ds.w 0 l14 dc.b $41,$72,$67,$75,$6D,$65,$6E,$74,$20,$23,$25,$6C dc.b $64,$3A,$20,$3C,$25,$73,$3E,$0A,$00 ds.w 0 l13 dc.b $50,$72,$6F,$67,$72,$61,$6D,$20,$6E,$61,$6D,$65 dc.b $3A,$20,$3C,$25,$73,$3E,$0A,$00 ds.w 0 l12 dc.b $63,$6F,$6E,$3A,$30,$2F,$30,$2F,$36,$34,$30,$2F dc.b $34,$30,$30,$2F,$57,$42,$20,$49,$63,$6F,$6E,$2F dc.b $43,$4C,$4F,$53,$45,$2F,$57,$41,$49,$54,$00 ds.w 0 l11 dc.b $54,$68,$69,$73,$20,$70,$72,$6F,$67,$72,$61,$6D dc.b $20,$63,$61,$6E,$6E,$6F,$74,$20,$62,$65,$20,$72 dc.b $75,$6E,$20,$69,$6E,$20,$44,$4F,$53,$20,$6D,$6F dc.b $64,$65,$20,$3A,$2D,$29,$0A,$00 END |
27 April 2010, 14:28 | #9 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
@Offtopic:
"pea"? Isn't that one of the "missing" instructions on the 68060 that has to be emulated? |
27 April 2010, 15:03 | #10 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
27 April 2010, 15:12 | #11 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
Ah thanks
|
27 April 2010, 20:37 | #12 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
By studying the source for awhile I just realised I am gonna fail with this task, pretty bad, since I haven't got a clue what's going on.
If anyone feels up for the task and have some free time, please let me know. |
28 April 2010, 09:16 | #13 | |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
Quote:
1>ANES SuperMarioBros.nes |
|
28 April 2010, 10:17 | #14 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,812
|
|
28 April 2010, 10:23 | #15 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
@BooBoo:
A simple frameskip is already implemented in the next release. However since all the major changes I've done, you'll still require a pretty fast Amiga (at the moment anyway) to make the games enjoyable. So if you haven't got yourself a 060 yet, now is the time. |
28 April 2010, 11:54 | #16 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
Quote:
The major question is, is you code already be able to be started from Workbench (i.e. by double click on its icon) ? Or does it crash if you try it ? Of course you first have to make it startable from Workbench. This means you need to check if pr_CLI is set and if not, you should receive the WBStartup message from the process' message port. Once you've got the message, it should be rather easy to read the sm_ArgList array which contains pointers to the program itself and each project icon which was highlighted when the program was started. |
|
28 April 2010, 12:15 | #17 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
@Thomas. Yes, I've got special startupcode that makes it run properly from an icon (haven't written it myself however..)
|
28 April 2010, 13:20 | #18 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
I've changed the example to include the necessary startup code:
Code:
#define __NOLIBBASE__ #include <proto/exec.h> #include <proto/dos.h> #include <workbench/startup.h> struct Library *SysBase = NULL; struct Library *DOSBase = NULL; #ifdef __VBCC__ #define __D0 __reg("d0") #define __A0 __reg("a0") #endif long start (__D0 long arglen,__A0 long argstr) { struct Process *pr; /* pointer to own process structure */ struct WBStartup *wbmsg = NULL; /* pointer to startup message */ long rc = RETURN_FAIL; /* return code */ SysBase = *((struct Library **)4); /* store pointer to ExecBase in local variable */ pr = (struct Process *) FindTask (NULL); /* get pointer to own process structure */ if (!pr->pr_CLI) /* check if run from Workbench */ { WaitPort (&pr->pr_MsgPort); /* yes -> wait for startup message */ wbmsg = (struct WBStartup *) GetMsg (&pr->pr_MsgPort); /* and fetch it */ } if (DOSBase = OpenLibrary ("dos.library",36)) /* open dos library */ { if (!wbmsg) /* if not run from Workbench print message and quit */ { VPrintf ("This program cannot be run in DOS mode :-)\n",NULL); rc = RETURN_ERROR; } else { BPTR win; /* open a console window */ if (win = Open ("con:0/0/640/400/WB Icon/CLOSE/WAIT",MODE_NEWFILE)) { char buffer[256]; long i; struct { long n; char *p; } va; /* arguments for VFPrintf */ va.p = buffer; NameFromLock (wbmsg->sm_ArgList->wa_Lock,buffer,256); /* get name of directory of first icon in sm_ArgList */ AddPart (buffer,wbmsg->sm_ArgList->wa_Name,256); /* add name of file */ VFPrintf (win,"Program name: <%s>\n",&va.p); /* print to the window */ for (i = 1; i < wbmsg->sm_NumArgs; i++) /* walk through all project icons */ { NameFromLock (wbmsg->sm_ArgList[i].wa_Lock,buffer,256); /* get name of directory */ AddPart (buffer,wbmsg->sm_ArgList[i].wa_Name,256); /* add name of file */ va.n = i; VFPrintf (win,"Argument #%ld: <%s>\n",&va); /* print to the window */ } rc = RETURN_OK; /* set good return code */ Close (win); /* close console window */ } } CloseLibrary (DOSBase); /* close dos library */ } if (wbmsg) /* if run from workbench */ { Forbid(); /* forbid task switching until this task ends */ ReplyMsg (&wbmsg->sm_Message); /* return startup message to sender */ } return (rc); /* set return code and quit */ } Code:
section text,code xdef _SysBase section fardata,data ds.w 0 _SysBase dc.l $0 xdef _DOSBase ds.w 0 _DOSBase dc.l $0 section text,code debug 15 ; long start (__D0 long arglen,__A0 long argstr) ds.l 0 procstart ds.w 0 xdef @start @start: movem.l l30,-(sp) move.l D0,D7 move.l A0,D6 link A5,#-l27 debug 20 ; ; ; { ; struct Process *pr; ; struct WBStartup *wbmsg = 0L; ; long rc = 20; suba.l A2,A2 debug 22 ; ; ; SysBase = *((struct Library **)4); moveq.l #20,D5 move.l $04.W,_SysBase debug 24 ; ; ; pr = (struct Process *) FindTask (0L); suba.l A1,A1 move.l _SysBase,A6 jsr -294(A6) move.l D0,A3 debug 26 ; ; ; if (!pr->pr_CLI) tst.l 172(A3) bne l4 l3 debug 28 ; ; { ; WaitPort (&pr->pr_MsgPort); lea.l 92(A3),A0 move.l _SysBase,A6 jsr -384(A6) debug 29 ; ; wbmsg = (struct WBStartup *) GetMsg (&pr->pr_MsgPort); lea.l 92(A3),A0 move.l _SysBase,A6 jsr -372(A6) move.l D0,A2 l4 l5 debug 32 ; ; } ; ; if (DOSBase = OpenLibrary ("dos.library",36)) lea.l l22,A1 moveq.l #36,D0 move.l _SysBase,A6 jsr -552(A6) move.l D0,_DOSBase tst.l _DOSBase beq l7 l6 debug 34 ; ; { ; if (!wbmsg) move.l A2,D0 bne l10 l9 debug 36 ; ; { ; VPrintf ("This program cannot be run in DOS mode :-)\n",0L); lea.l l23,A6 move.l A6,D1 moveq.l #0,D2 move.l _DOSBase,A6 jsr -954(A6) debug 37 ; ; rc = 10; moveq.l #10,D5 bra l11 l10 debug 44 ; ; } ; else ; { ; BPTR win; ; ; ; if (win = Open ("con:0/0/640/400/WB Icon/CLOSE/WAIT",1006)) lea.l l24,A6 move.l A6,D1 move.l #$03EE,D2 move.l _DOSBase,A6 jsr -30(A6) move.l D0,D4 tst.l D4 beq l13 l12 debug 53 ; ; { ; char buffer[256]; ; long i; ; struct { ; long n; ; char *p; ; } va; ; ; va.p = buffer; lea.l -256(A5),A6 move.l A6,-260(A5) debug 55 ; ; ; NameFromLock (wbmsg->sm_ArgList->wa_Lock,buffer,256); move.l 36(A2),A6 move.l (A6),D1 lea.l -256(A5),A6 move.l A6,D2 move.l _DOSBase,A6 move.l #$0100,D0 move.l D3,-(sp) move.l D0,D3 jsr -402(A6) move.l (sp)+,D3 debug 56 ; ; AddPart (buffer,wbmsg->sm_ArgList->wa_Name,256); lea.l -256(A5),A6 move.l A6,D1 move.l 36(A2),A6 move.l 4(A6),D2 move.l _DOSBase,A6 move.l #$0100,D0 move.l D3,-(sp) move.l D0,D3 jsr -882(A6) move.l (sp)+,D3 debug 57 ; ; VFPrintf (win,"Program name: <%s>\n",&va.p); move.l D4,D1 lea.l l25,A6 move.l A6,D2 move.l _DOSBase,A6 lea.l -260(A5),A0 move.l A0,D0 move.l D3,-(sp) move.l D0,D3 jsr -354(A6) move.l (sp)+,D3 debug 59 ; ; ; for (i = 1; i < wbmsg->sm_NumArgs; i++) moveq.l #1,D3 bra l18 l15 debug 61 ; ; { ; NameFromLock (wbmsg->sm_ArgList[i].wa_Lock,buffer,256); move.l D3,D0 asl.l #$03,D0 move.l 36(A2),A6 add.l D0,A6 move.l (A6),D1 lea.l -256(A5),A6 move.l A6,D2 move.l _DOSBase,A6 move.l #$0100,D0 move.l D3,-(sp) move.l D0,D3 jsr -402(A6) move.l (sp)+,D3 debug 62 ; ; AddPart (buffer,wbmsg->sm_ArgList[i].wa_Name,256); lea.l -256(A5),A6 move.l A6,D1 move.l D3,D0 asl.l #$03,D0 move.l 36(A2),A6 add.l D0,A6 move.l 4(A6),D2 move.l _DOSBase,A6 move.l #$0100,D0 move.l D3,-(sp) move.l D0,D3 jsr -882(A6) move.l (sp)+,D3 debug 63 ; ; va.n = i; move.l D3,-264(A5) debug 64 ; ; VFPrintf (win,"Argument #%ld: <%s>\n",&va); move.l D4,D1 lea.l l26,A6 move.l A6,D2 move.l _DOSBase,A6 lea.l -264(A5),A0 move.l A0,D0 move.l D3,-(sp) move.l D0,D3 jsr -354(A6) move.l (sp)+,D3 l16 addq.l #$01,D3 l18 cmp.l 28(A2),D3 blt l15 l32 l17 debug 67 ; ; } ; ; rc = 0; moveq.l #0,D5 debug 69 ; ; ; Close (win); move.l D4,D1 move.l _DOSBase,A6 jsr -36(A6) l13 l14 l11 debug 73 ; ; } ; } ; ; CloseLibrary (DOSBase); move.l _DOSBase,A1 move.l _SysBase,A6 jsr -414(A6) l7 l8 debug 76 ; ; } ; ; if (wbmsg) move.l A2,D4 beq l20 l19 debug 78 ; ; { ; Forbid(); move.l _SysBase,A6 jsr -132(A6) debug 79 ; ; ReplyMsg (&wbmsg->sm_Message); lea.l (A2),A1 move.l _SysBase,A6 jsr -378(A6) l20 l21 debug 82 ; ; } ; ; return (rc); move.l D5,D0 bra l28 l28 unlk A5 movem.l (sp)+,D2/D3/D4/D5/D6/D7/A2/A3/A6 rts l30 reg D2/D3/D4/D5/D6/D7/A2/A3/A6 l29 equ 44 l27 equ 264 procend debug 83 ; ; } xref _ReplyMsg xref _Forbid xref _CloseLibrary xref _Close xref _VFPrintf xref _AddPart xref _NameFromLock xref _Open xref _VPrintf xref _OpenLibrary xref _GetMsg xref _WaitPort xref _FindTask section fardata,data ds.w 0 l26 dc.b $41,$72,$67,$75,$6D,$65,$6E,$74,$20,$23,$25,$6C dc.b $64,$3A,$20,$3C,$25,$73,$3E,$0A,$00 ds.w 0 l25 dc.b $50,$72,$6F,$67,$72,$61,$6D,$20,$6E,$61,$6D,$65 dc.b $3A,$20,$3C,$25,$73,$3E,$0A,$00 ds.w 0 l24 dc.b $63,$6F,$6E,$3A,$30,$2F,$30,$2F,$36,$34,$30,$2F dc.b $34,$30,$30,$2F,$57,$42,$20,$49,$63,$6F,$6E,$2F dc.b $43,$4C,$4F,$53,$45,$2F,$57,$41,$49,$54,$00 ds.w 0 l23 dc.b $54,$68,$69,$73,$20,$70,$72,$6F,$67,$72,$61,$6D dc.b $20,$63,$61,$6E,$6E,$6F,$74,$20,$62,$65,$20,$72 dc.b $75,$6E,$20,$69,$6E,$20,$44,$4F,$53,$20,$6D,$6F dc.b $64,$65,$20,$3A,$2D,$29,$0A,$00 ds.w 0 l22 dc.b $64,$6F,$73,$2E,$6C,$69,$62,$72,$61,$72,$79,$00 END |
23 May 2010, 20:12 | #19 |
Zone Friend
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
|
I appreciate your effort Thomas, but I can't get the asm-output to run in AsmOne, it just refuses and gives me lots of problems.
Wonder if there's an easier way for me to implement this... hm.. |
23 May 2010, 21:05 | #20 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
I know I sound like a nag, but if you switch to a more modern assembler and use a linker then you can link M68K object code from any compiler or assembler together without hassle. ASM-One is really neat, but as an end-all be-all development tool it is very poor.
You can adjust Thomas' code by removing the procstart, procend and debug statements (they are obviously not M68K assembly), remove the ds.w 0 statements in the end, or replace with even if that doesn't work, and find the l30 label and move the registers specified to the movem.l instruction farther up that references them. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WHDLoad tooltypes not saving | vagrant | support.WinUAE | 20 | 22 November 2015 19:43 |
WHDLoad.prefs and tooltypes | Bamiga2002 | project.WHDLoad | 6 | 14 October 2013 00:01 |
WHDLoad Tooltypes | Aljrob | project.WHDLoad | 10 | 31 March 2007 15:49 |
Assigning tooltypes to files? | Gnorman | project.ClassicWB | 2 | 06 March 2006 20:42 |
Tool to add tooltypes | MarlboroMan | request.Apps | 1 | 18 May 2005 06:29 |
|
|