--- uae/src/od-amiga/ami-rexx.c 2018/04/24 16:40:30 1.1 +++ uae/src/od-amiga/ami-rexx.c 2018/04/24 16:42:49 1.1.1.2 @@ -7,14 +7,30 @@ * * History: * 05/09/97: Added UAEEXE support. + * 04/03/98: Added event-hack for SOUND(). Added do_inhibit_frame(). + * 03/05/98: Modified currprefs to changed_prefs where necessary. */ +/****************************************************************************/ + +#if defined(POWERUP) +#include /* sam: I've added this or else I have warnings about missing struct def. */ +#ifndef USE_CLIB +#include +#include +#include +#else +#include +#include +#endif +#else #include #include #include #ifndef __SASC #include #endif +#endif #include #include @@ -26,13 +42,15 @@ #include "sysconfig.h" #include "sysdeps.h" - #include "uae.h" #include "config.h" #include "options.h" #ifdef __GNUC__ #include "../include/memory.h" /* or else gcc includes machdep/memory.h */ +#else +#include "/include/memory.h" #endif +#include "events.h" #include "custom.h" #include "readcpu.h" #include "newcpu.h" @@ -72,6 +90,7 @@ void rexx_exit(void); void rexx_led(int led, int on); void rexx_filename(int num, char *name); void rexx_handle_events(void); +int do_inhibit_frame(int); /* from ami-win.c */ /****************************************************************************/ @@ -94,6 +113,7 @@ static int matchnum(char **line); /****************************************************************************/ extern int quit_program; /* ami-gui.c */ +extern ULONG frame_num; /* ami-win.c */ extern void activate_debugger(void); /* debug.c */ extern char *to_unix_path(char *s); /* ami-disk.c */ extern char *from_unix_path(char *s); /* ami-disk.c */ @@ -215,6 +235,9 @@ static int QUERY(char *line) else if(matchstr(&line, "FRAMERATE")) { sprintf(RESULT,"%d",currprefs.framerate); return RC_OK; + } else if(matchstr(&line, "FRAMENUM")) { + sprintf(RESULT,"%u",frame_num); + return RC_OK; } else if(matchstr(&line, "SOUND")) { sprintf(RESULT,"%d",sound_available?currprefs.produce_sound:-1); return RC_OK; @@ -266,16 +289,29 @@ static int FEEDBACK(char *line) static int VERSION(char *line) { if(matchstr(&line,"STRING")) { - sprintf(RESULT, - "UAE-%d.%d.%d © by Bernd Schmidt & contributors, " - "Amiga Port by Samuel Devulder.", - (version / 100) % 10, (version / 10) % 10, version % 10); + sprintf(RESULT, + "UAE-%d.%d.%d (%s%s%s) © by Bernd Schmidt & contributors, " +#ifdef POWERUP + "Amiga Port by Samuel Devulder & Holger Jakob (PPC extensions).", +#else + "Amiga Port by Samuel Devulder.", +#endif + UAEMAJOR, UAEMINOR, UAESUBREV, + currprefs.cpu_level==0?"68000": + currprefs.cpu_level==1?"68010": + currprefs.cpu_level==2?"68020":"68020/68881", + currprefs.address_space_24?" 24bits":"", + currprefs.cpu_compatible?" compat":""); } else if(matchstr(&line,"NUM")) { - sprintf(RESULT,"%d",version); + sprintf(RESULT,"%d",UAEMAJOR*10000+UAEMINOR*100+UAESUBREV); } else if(matchstr(&line,"AUTHOR")) { sprintf(RESULT,"© by Bernd Schmidt & contributors"); } else if(matchstr(&line,"PORT")) { +#ifdef POWERUP + sprintf(RESULT,"Amiga Port by Samuel Devulder & Holger Jakob (PPC extensions)"); +#else sprintf(RESULT,"Amiga Port by Samuel Devulder"); +#endif } else return RC_ERROR; return RC_OK; } @@ -287,7 +323,7 @@ static int FRAMERATE(char *line) int num; num = matchnum(&line); if(num>=1 && num<=20) { - currprefs.framerate = num; + changed_prefs.framerate = num; } else { sprintf(RESULT,"Invalid frame rate: %d\n", num); return RC_WARN; @@ -299,9 +335,9 @@ static int FRAMERATE(char *line) static int FAKEJOYSTICK(char *line) { - if (matchstr(&line,"ON")) currprefs.fake_joystick = 2; - else if(matchstr(&line,"OFF")) currprefs.fake_joystick = 0; - else if(matchstr(&line,"TOGGLE")) currprefs.fake_joystick = + if (matchstr(&line,"ON")) changed_prefs.fake_joystick = 2; + else if(matchstr(&line,"OFF")) changed_prefs.fake_joystick = 0; + else if(matchstr(&line,"TOGGLE")) changed_prefs.fake_joystick = currprefs.fake_joystick?0:2; else return RC_ERROR; return RC_OK; @@ -311,9 +347,9 @@ static int FAKEJOYSTICK(char *line) static int DISPLAY(char *line) { - if (matchstr(&line,"ON")) inhibit_frame = 0; - else if(matchstr(&line,"OFF")) inhibit_frame = 1; - else if(matchstr(&line,"TOGGLE")) inhibit_frame = inhibit_frame?0:1; + if (matchstr(&line,"ON")) do_inhibit_frame(0); + else if(matchstr(&line,"OFF")) do_inhibit_frame(1); + else if(matchstr(&line,"TOGGLE")) do_inhibit_frame(inhibit_frame?0:1); else return RC_ERROR; return RC_OK; } @@ -333,6 +369,11 @@ static int SOUND(char *line) else if(matchstr(&line,"TOGGLE")) currprefs.produce_sound = currprefs.produce_sound<=1?2:1; else return RC_ERROR; + + /* sam: the next 2 lines is a hack and I don't like it */ +/* eventtab[ev_sample].active = (changed_prefs.produce_sound>=2)?1:0; + events_schedule (); +*/ return RC_OK; } @@ -384,7 +425,8 @@ void rexx_handle_events(void) msg->rm_Result1 = process_cmd(msg->rm_Args[0]); msg->rm_Result2 = NULL; if(msg->rm_Action & RXFF_RESULT) { - msg->rm_Result2 = (LONG)CreateArgstring(RESULT,strlen(RESULT)); + int len=strlen(RESULT); /* holger: trick for powerup */ + msg->rm_Result2 = (LONG)CreateArgstring(RESULT,len); } ReplyMsg((void*)msg); } @@ -450,7 +492,8 @@ static int ADDRESS(char *hostname, char if((RexxPort = (void *)FindPort(hostname))) { if((ReplyPort = (void *)CreateMsgPort())) { if((HostMsg = CreateRexxMsg(ReplyPort, NULL, hostname))) { - if((HostMsg->rm_Args[0] = CreateArgstring(cmd,strlen(cmd)))) { + int len=strlen(cmd); /* holger: trick for powerup */ + if((HostMsg->rm_Args[0] = CreateArgstring(cmd,len))) { HostMsg->rm_Action = RXCOMM | RXFF_RESULT; PutMsg(RexxPort, (void*)HostMsg); WaitPort(ReplyPort); @@ -532,3 +575,80 @@ static int matchnum(char **line) *line = s; return sign>0?num:-num; } + +/****************************************************************************/ + +#ifdef POWERUP +/* sam: those function should be in the ppc version of the unexisting + libamiga.a */ +#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \ + /*(l)->lh_Tail = NULL,*/ \ + (l)->lh_TailPred = (struct Node *)&(l)->lh_Head) +struct MsgPort *CreatePort(STRPTR name,LONG pri) +{ struct MsgPort *port = NULL; + UBYTE portsig; + + if ((BYTE)(portsig=AllocSignal(-1)) >= 0) + { if (!(port=PPCAllocMem(sizeof(struct MsgPort),MEMF_CLEAR|MEMF_PUBLIC))) + FreeSignal(portsig); + else + { + port->mp_Node.ln_Type=NT_MSGPORT; + port->mp_Node.ln_Pri=pri; + port->mp_Node.ln_Name=name; + /* done via AllocMem + port->mp_Flags=PA_SIGNAL; + */ + port->mp_SigBit=portsig; + port->mp_SigTask=FindTask(NULL); + NEWLIST(&port->mp_MsgList); + if (port->mp_Node.ln_Name) + AddPort(port); + } + } + return port; +} + +void DeletePort(struct MsgPort *port) +{ int i; + + if (port->mp_Node.ln_Name != NULL) + RemPort(port); + i=-1; + port->mp_Node.ln_Type=i; + port->mp_MsgList.lh_Head=(struct Node *)i; + FreeSignal(port->mp_SigBit); + PPCFreeMem(port,sizeof(struct MsgPort)); +} + +struct IORequest *CreateExtIO(struct MsgPort *port,long iosize) +{ + struct IORequest *ioreq=NULL; + + if (port && (ioreq=PPCAllocMem(iosize,MEMF_CLEAR|MEMF_PUBLIC))) + { + ioreq->io_Message.mn_Node.ln_Type=NT_REPLYMSG; + ioreq->io_Message.mn_ReplyPort=port; + ioreq->io_Message.mn_Length=iosize; + } + return ioreq; +} + +struct IOStdReq *CreateStdIO(struct MsgPort *port) +{ + return (struct IOStdReq *)CreateExtIO(port,sizeof(struct IOStdReq)); +} + +void DeleteExtIO(struct IORequest *ioreq) +{ + int i; + + i=-1; + ioreq->io_Message.mn_Node.ln_Type=i; + ioreq->io_Device=(struct Device *)i; + ioreq->io_Unit=(struct Unit *)i; + PPCFreeMem(ioreq,ioreq->io_Message.mn_Length); +} + +void DeleteStdIO(struct IORequest *ioreq) {DeleteExtIO(ioreq);} +#endif