Hi guys,

Attached is a simple patch to allow the Linux version of RPCEmu to be run
in a non-interactive fashion from an ordinary console window. This makes the emulator suitable for use in autobuilders and the like, where you don't want RPCEmu windows popping up every five minutes. It also allows
the emulator to run if X isn't available, which is another useful feature
for autobuilders. This new version can be selected by passing the '--enable-console-interface' option to configure.

Since this patch was a quick 5-minute job the emulator will run in a noninteractive fashion, apart from a simple hook that sits on OS_WriteC and echoes the characters to stdout. This catches 99% of the text output RISC OS produces, along with some stuff it probably shouldn't catch, e.g. if VDU output has been disabled. But for the purpose of running the ROOL build system it seems to work OK.

Note that although I've edited configure.ac I haven't included the rebuilt configure file in the patch - I'm using a newer version of autoconf, so ran autoreconf for safety, which caused the diff to grow from 5KB to 338KB. So whoever submits this will have to run autoconf/autoreconf themselves.

Let me know if there's anything you want me to tidy up in the patch before you're willing to accept it.

Cheers,

- Jeffrey
diff -r 980dd303ac7b src/arm_common.c
--- a/src/arm_common.c  Sun Jul 11 20:56:22 2010 +0100
+++ b/src/arm_common.c  Sat Jul 24 23:49:46 2010 +0100
@@ -37,6 +37,14 @@
        rinscount++;
        templ = opcode & 0xdffff;
 
+#ifdef RPCEMU_CONSOLE_INTERFACE
+       if (!templ) {
+               /* OS_WriteC */
+               int c = armregs[0] & 0xff;
+               if(((c>=32)&&(c!=127)) || (c==10))
+                       putchar(c);
+               goto realswi;
+#else
        if (mousehack && templ == 7 && armregs[0] == 0x15) {
                if (readmemb(armregs[1]) == 1) {
                        /* OS_Word 21, 1 Define Mouse Coordinate bounding box */
@@ -54,7 +62,7 @@
                /* OS_Mouse */
                mouse_hack_osmouse();
                armregs[cpsr] &= ~VFLAG;
-
+#endif
        } else if (templ == ARCEM_SWI_HOSTFS) {
                ARMul_State state;
 
@@ -83,6 +91,7 @@
 #endif
        else {
 realswi:
+#ifndef RPCEMU_CONSOLE_INTERFACE
                if (mousehack && templ == 7 && armregs[0] == 0x15 &&
                    readmemb(armregs[1]) == 0)
                {
@@ -93,6 +102,7 @@
                        /* OS_Byte 106 Select pointer / activate mouse */
                        mouse_hack_osbyte_106(armregs[1]);
                }
+#endif
                exception(SUPERVISOR, 0xc, 4);
        }
 }
diff -r 980dd303ac7b src/configure.ac
--- a/src/configure.ac  Sun Jul 11 20:56:22 2010 +0100
+++ b/src/configure.ac  Sat Jul 24 23:49:46 2010 +0100
@@ -44,6 +44,18 @@
    esac
 fi
 
+AC_MSG_CHECKING([whether to build the console version])
+AC_ARG_ENABLE(console-interface,
+              AC_HELP_STRING([--enable-console-interface],
+                             [build GUIless version suitable for use from the 
command line]),,
+              enable_console_interface=no)
+if test "$enable_console_interface" = "yes"; then
+   CFLAGS="$CFLAGS -DRPCEMU_CONSOLE_INTERFACE"
+   AC_MSG_RESULT([yes])
+else
+   AC_MSG_RESULT([no])
+fi
+
 AC_MSG_CHECKING([for Operating System])
 case "${host_os}" in
     linux*)
diff -r 980dd303ac7b src/rpc-linux.c
--- a/src/rpc-linux.c   Sun Jul 11 20:56:22 2010 +0100
+++ b/src/rpc-linux.c   Sat Jul 24 23:49:46 2010 +0100
@@ -138,6 +138,7 @@
 {
 }
 
+#ifndef RPCEMU_CONSOLE_INTERFACE
 static pthread_t thread;
 static pthread_cond_t vidccond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t vidcmutex = PTHREAD_MUTEX_INITIALIZER;
@@ -185,6 +186,7 @@
 {
     if (pthread_mutex_unlock(&vidcmutex)) fatal("Releasing vidc mutex failed");
 }
+#endif
 
 static void close_button_handler(void)
 {
@@ -218,6 +220,7 @@
 
         while (!quited)
         {
+#ifndef RPCEMU_CONSOLE_INTERFACE
                 if (infocus)
                         execrpcemu();
                         if (updatemips)
@@ -235,6 +238,9 @@
                         mousecapture=0;
                         updatemips=1;
                 }
+#else
+               execrpcemu();
+#endif
         }
         if (mousecapture)
         {
diff -r 980dd303ac7b src/vidc20.c
--- a/src/vidc20.c      Sun Jul 11 20:56:22 2010 +0100
+++ b/src/vidc20.c      Sat Jul 24 23:49:46 2010 +0100
@@ -40,6 +40,7 @@
         int curchange;
 } vidc;
 
+#ifndef RPCEMU_CONSOLE_INTERFACE
 /* This state is a cached version of the main state, and is read by the 
display thread.
    The main thread should only change them when it has the mutex (and so the 
display
    thread is not running). */
@@ -195,28 +196,6 @@
 }
 
 
-/**
- * Return the width in pixels of the displayed portion of the screen.
- *
- * @return width
- */
-int
-getxs(void)
-{
-        return vidc.hder-vidc.hdsr;
-}
-
-/**
- * Return the height in pixels of the displayed portion of the screen.
- *
- * @return height
- */
-int
-getys(void)
-{
-        return vidc.vder-vidc.vdsr;
-}
-
 static void freebitmaps(void)
 {
         if (b) destroy_bitmap(b);
@@ -1294,7 +1273,61 @@
         blitterthread(thr.xsize, thr.ysize, yl, yh, thr.doublesize);
 }
 
+#else /* RPCEMU_CONSOLE_INTERFACE */
 
+static uint8_t dirtybuffer1[512*4];
+uint8_t *dirtybuffer = dirtybuffer1;
+
+void initvideo(void)
+{
+}
+
+void closevideo(void)
+{
+}
+
+void togglefullscreen(int fs)
+{
+}
+
+/* Called periodically from the main thread. If needredraw is non-zero
+   then the refresh timer indicates it is time for a new frame */
+void drawscr(int needredraw)
+{
+       /* Trigger vsync every 200 calls. This should give ~60fps if called 
every 20000 cycles (as suggested by execrpcemu()) */
+       static int vsynccounter=200;
+       if(!vsynccounter--)
+       {
+               iomdvsync(1);
+               vsynccounter=200;
+       }
+       else
+               iomdvsync(0);
+}
+
+#endif
+
+/**
+ * Return the width in pixels of the displayed portion of the screen.
+ *
+ * @return width
+ */
+int
+getxs(void)
+{
+        return vidc.hder-vidc.hdsr;
+}
+
+/**
+ * Return the height in pixels of the displayed portion of the screen.
+ *
+ * @return height
+ */
+int
+getys(void)
+{
+        return vidc.vder-vidc.vdsr;
+}
 
 void writevidc20(uint32_t val)
 {
_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu

Reply via email to