From 7d3fe675ac99393277a9eb8a825459aad44f85f2 Mon Sep 17 00:00:00 2001
From: Robert Sprowson <rsprowson@gitlab.riscosopen.org>
Date: Tue, 30 Nov 2010 09:29:16 +0000
Subject: [PATCH] Enable 2 functions in RISC_OSLib shared entry table.

Needed by !Paint 2.02.
Fix some easy warnings in wimp.c/sprite.c.
Add new function (not in the ROM version) 'wimp_baseofromsprites()'.
bbc_adval fixed to return -1 when no ADC fitted to match Electron behaviour.
Note: the 2 reenabled functions haven't been appended to the table, so anyone who linked a RAM application against 'romastubs' would need to relink.

Version 5.58. Tagged as 'RISC_OSLib-5_58'
---
 VersionASM        | 12 ++++++------
 VersionNum        | 20 ++++++++++----------
 rlib/c/bbc        |  2 +-
 rlib/c/sprite     |  4 +---
 rlib/c/wimp       | 18 +++++++++++++-----
 rlib/h/sprite     |  7 +++++++
 rlib/h/wimp       |  7 +++++--
 rlib/s/rl_entries | 18 +++++++++---------
 8 files changed, 52 insertions(+), 36 deletions(-)

diff --git a/VersionASM b/VersionASM
index a55383a..d1950d3 100644
--- a/VersionASM
+++ b/VersionASM
@@ -11,13 +11,13 @@
                         GBLS    Module_HelpVersion
                         GBLS    Module_ComponentName
                         GBLS    Module_ComponentPath
-Module_MajorVersion     SETS    "5.57"
-Module_Version          SETA    557
+Module_MajorVersion     SETS    "5.58"
+Module_Version          SETA    558
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "26 Nov 2010"
-Module_ApplicationDate  SETS    "26-Nov-10"
+Module_Date             SETS    "30 Nov 2010"
+Module_ApplicationDate  SETS    "30-Nov-10"
 Module_ComponentName    SETS    "RISC_OSLib"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/Lib/RISC_OSLib"
-Module_FullVersion      SETS    "5.57"
-Module_HelpVersion      SETS    "5.57 (26 Nov 2010)"
+Module_FullVersion      SETS    "5.58"
+Module_HelpVersion      SETS    "5.58 (30 Nov 2010)"
                         END
diff --git a/VersionNum b/VersionNum
index 58225a7..6008bfd 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,23 +1,23 @@
-/* (5.57)
+/* (5.58)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  * Last processed by srccommit version: 1.1.
  *
  */
-#define Module_MajorVersion_CMHG        5.57
+#define Module_MajorVersion_CMHG        5.58
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                26 Nov 2010
+#define Module_Date_CMHG                30 Nov 2010
 
-#define Module_MajorVersion             "5.57"
-#define Module_Version                  557
+#define Module_MajorVersion             "5.58"
+#define Module_Version                  558
 #define Module_MinorVersion             ""
-#define Module_Date                     "26 Nov 2010"
+#define Module_Date                     "30 Nov 2010"
 
-#define Module_ApplicationDate          "26-Nov-10"
+#define Module_ApplicationDate          "30-Nov-10"
 
 #define Module_ComponentName            "RISC_OSLib"
 #define Module_ComponentPath            "castle/RiscOS/Sources/Lib/RISC_OSLib"
 
-#define Module_FullVersion              "5.57"
-#define Module_HelpVersion              "5.57 (26 Nov 2010)"
-#define Module_LibraryVersionInfo       "5:57"
+#define Module_FullVersion              "5.58"
+#define Module_HelpVersion              "5.58 (30 Nov 2010)"
+#define Module_LibraryVersionInfo       "5:58"
diff --git a/rlib/c/bbc b/rlib/c/bbc
index 30e6247..03ed7fd 100644
--- a/rlib/c/bbc
+++ b/rlib/c/bbc
@@ -537,7 +537,7 @@ int bbc_adval(int x)
    { /* ADC conversion info */
       int y;
       os_error *e = os_byte(0x80, &x, &y);
-      if (e) return 0x80000000; /* Panic, I suppose */
+      if (e) return -1; /* Panic! Return max conversion like an Electron does */
       return ((y << 24) | (x << 16)) >> 16; /* SignExtend result */
    }
    else
diff --git a/rlib/c/sprite b/rlib/c/sprite
index 555cb93..7e03dcc 100644
--- a/rlib/c/sprite
+++ b/rlib/c/sprite
@@ -479,7 +479,6 @@ os_error * sprite_put(sprite_area *area, sprite_id *spr, int gcol_action)
 }
 #endif
 
-#ifndef UROM
 os_error * sprite_put_given(sprite_area *area, sprite_id *spr, int gcol_action,
                             int x, int y)
 {
@@ -492,7 +491,6 @@ os_error * sprite_put_given(sprite_area *area, sprite_id *spr, int gcol_action,
   result = sprite__op(&r);
   return result;
 }
-#endif
 
 os_error * sprite_put_scaled(sprite_area *area, sprite_id *spr,
                              int gcol_action,
@@ -732,7 +730,7 @@ os_error * sprite_readmask(sprite_area *area, sprite_id *spr, int x, int y,
   result = sprite__op(&r);
   if (result == NULL) /* Only return result if no error */
   {
-    *resultmaskstate = r.r[5];
+    *resultmaskstate = (sprite_maskstate) r.r[5];
   }
   return result;
 }
diff --git a/rlib/c/wimp b/rlib/c/wimp
index e683f0a..7628044 100644
--- a/rlib/c/wimp
+++ b/rlib/c/wimp
@@ -602,7 +602,6 @@ os_error *wimp_readpalette(wimp_palettestr* p)
 {
   os_regset r;
   os_error *e;
-  int i ;
 
   r.r[1] = (int) p;
   r.r[2] = *(int *) "TRUE";
@@ -634,13 +633,24 @@ os_error *wimp_setcolour(int colour)
 }
 
 #ifndef UROM
-void *wimp_baseofsprites(void)
+sprite_area *wimp_baseofsprites(void)
 {
   os_regset r;
   os_error *e;
 
   e = os_swix(BaseOfSprites, &r);
-  return (void*) r.r[1];
+  return (sprite_area *) r.r[1];
+}
+#endif
+
+#ifndef UROM
+sprite_area *wimp_baseofromsprites(void)
+{
+  os_regset r;
+  os_error *e;
+
+  e = os_swix(BaseOfSprites, &r);
+  return (sprite_area *) r.r[0];
 }
 #endif
 
@@ -730,7 +740,6 @@ os_error *wimp_setfontcolours(int foreground, int background)
   return os_swi3(os_X | SetFontColours, 0, background, foreground);
 }
 
-#ifndef UROM
 os_error *wimp_readpixtrans(sprite_area *area, sprite_id *id,
                          sprite_factors *factors, sprite_pixtrans *pixtrans)
 {
@@ -760,7 +769,6 @@ os_error *wimp_readpixtrans(sprite_area *area, sprite_id *id,
   e = os_swix(ReadPixTrans, &r);
   return(e);
 }
-#endif
 
 #ifndef UROM
 os_error *wimp_commandwindow(wimp_commandwind commandwindow)
diff --git a/rlib/h/sprite b/rlib/h/sprite
index ab01823..de7e8ec 100644
--- a/rlib/h/sprite
+++ b/rlib/h/sprite
@@ -384,6 +384,13 @@ typedef struct
 extern os_error * sprite_readsize(sprite_area *, sprite_id *,
                            sprite_info *resultinfo);
 
+/* -------------------------------- sprite_readinfo ------------------------
+ * Read the size information for the specified sprite_id, like the function
+ * sprite_readsize except resultinfo is only updated if the sprite is found
+ *
+ */
+extern os_error * sprite_readinfo(sprite_area *, sprite_id *,
+                           sprite_info *resultinfo);
 
 typedef struct
 {
diff --git a/rlib/h/wimp b/rlib/h/wimp
index cb06f4b..afd48c5 100644
--- a/rlib/h/wimp
+++ b/rlib/h/wimp
@@ -723,8 +723,11 @@ os_error *wimp_spriteop(int reason_code, char *name) ;
 os_error *wimp_spriteop_full(os_regset *) ;
 /* call SWI Wimp_SpriteOp allowing full information to be passed */
 
-void *wimp_baseofsprites(void);
-/* Returns a sprite_area*. This may be moved about by mergespritefile. */
+sprite_area *wimp_baseofsprites(void);
+/* Returns the area for Wimp sprites in the RMA. This may be moved about by mergespritefile. */
+
+sprite_area *wimp_baseofromsprites(void);
+/* Returns the area for Wimp sprites in the ROM. */
 
 os_error *wimp_blockcopy(wimp_w, wimp_box *source, int x, int y);
 /* Copy the source box (defined in window coords) to the given destination
diff --git a/rlib/s/rl_entries b/rlib/s/rl_entries
index 6a3f864..1e317e7 100644
--- a/rlib/s/rl_entries
+++ b/rlib/s/rl_entries
@@ -39,7 +39,7 @@
 ; SJM 27-Aug-98: put alarm_anypending back in for NCFresco
 ;
 ; WARNING! Extra entries MUST, repeat MUST, be added ONLY to the end of the list
-; otherwise backwards compatiblity is SHAFTED!
+; otherwise backwards compatibility is SHAFTED!
 ;
 ; Copyright (C) Acorn Computers Ltd., 1989.
 ;
@@ -77,7 +77,7 @@
 ;        Entry   bbc_circle, imported, , , ,
 ;        Entry   bbc_circlefill, imported, , , ,
 ;        Entry   bbc_origin, imported, , , ,
-        Entry   bbc_gwindow, imported, , , ,
+      Entry   bbc_gwindow, imported, , , ,
       Entry   bbc_clg, imported, , , ,
 ;        Entry   bbc_fill, imported, , , ,
       Entry   bbc_gcol, imported, , , ,
@@ -109,7 +109,7 @@
       Entry   colourtran_setGCOL, imported, , , ,
 ;        Entry   colourtran_return_colournumber, imported, , , ,
       Entry   colourtran_return_GCOLformode, imported, , , ,
-        Entry   colourtran_return_colourformode, imported, , , ,
+      Entry   colourtran_return_colourformode, imported, , , ,
 ;        Entry   colourtran_return_OppGCOL, imported, , , ,
 ;        Entry   colourtran_setOppGCOL, imported, , , ,
 ;        Entry   colourtran_return_Oppcolournumber, imported, , , ,
@@ -294,7 +294,7 @@
 ;        Entry   sprite_get, imported, , , ,
 ;        Entry   sprite_get_rp, imported, , , ,
       Entry   sprite_get_given, imported, , , ,
-        Entry   sprite_get_given_rp, imported, , , ,
+      Entry   sprite_get_given_rp, imported, , , ,
       Entry   sprite_create, imported, , , ,
       Entry   sprite_create_rp, imported, , , ,
       Entry   sprite_select, imported, , , ,
@@ -303,7 +303,7 @@
       Entry   sprite_rename, imported, , , ,
       Entry   sprite_copy, imported, , , ,
 ;        Entry   sprite_put, imported, , , ,
-;        Entry   sprite_put_given, imported, , , ,
+      Entry   sprite_put_given, imported, , , ,
       Entry   sprite_put_scaled, imported, , , ,
 ;        Entry   sprite_put_greyscaled, imported, , , ,
 ;        Entry   sprite_put_mask, imported, , , ,
@@ -434,7 +434,7 @@
       Entry   wimp_get_caret_pos, imported, , , ,
       Entry   wimp_create_menu, imported, , , ,
 ;        Entry   wimp_decode_menu, imported, , , ,
-        Entry   wimp_which_icon, imported, , , ,
+      Entry   wimp_which_icon, imported, , , ,
       Entry   wimp_set_extent, imported, , , ,
 ;        Entry   wimp_set_point_shape, imported, , , ,
       Entry   wimp_open_template, imported, , , ,
@@ -446,7 +446,7 @@
       Entry   wimp_starttask, imported, , , ,
       Entry   wimp_getwindowoutline, imported, , , ,
       Entry   wimp_pollidle, imported, , , ,
-        Entry   wimp_ploticon, imported, , , ,
+      Entry   wimp_ploticon, imported, , , ,
 ;        Entry   wimp_setmode, imported, , , ,
       Entry   wimp_readpalette, imported, , , ,
 ;        Entry   wimp_setpalette, imported, , , ,
@@ -462,7 +462,7 @@
       Entry   wimp_slotsize, imported, , , ,
       Entry   wimp_transferblock, imported, , , ,
       Entry   wimp_setfontcolours, imported, , , ,
-;        Entry   wimp_readpixtrans, imported, , , ,
+      Entry   wimp_readpixtrans, imported, , , ,
 ;        Entry   wimp_commandwindow, imported, , , ,
       Entry   wimpt_poll, imported, , , ,
       Entry   wimpt_fake_event, imported, , , ,
@@ -568,7 +568,7 @@
       Entry   dbox_fillin_fixedcaret, imported, , , ,
       Entry   xfersend_clear_unknowns, imported, , , ,
 ;        Entry   template_use_fancyfonts, imported, , , ,
-        Entry   win_read_eventhandler, imported, , , ,
+      Entry   win_read_eventhandler, imported, , , ,
 ;        Entry   txtedit_register_open_handler, imported, , , ,
 ;        Entry   txtopt_set_name, imported, , , ,
       Entry   txtopt_get_name, imported, , , ,
-- 
GitLab