View Javadoc

1   package com.tapina.robe.swi;
2   
3   import com.tapina.robe.runtime.Environment;
4   
5   import java.lang.reflect.Method;
6   
7   /***
8    * This class represents the VectorUtil module which is used by Jonathan Marten's Draw Plus, Vector, GridPro etc.
9    * It is not a RISC OS ROM module but until we can handle loading RISC OS modules we need to reimplement this one in
10   * Java and pretend it is.
11   */
12  public final class VectorUtil extends SWIHandler {
13      private static VectorUtil ourInstance;
14      private int numTasks = 0;
15      private boolean resFlag = false;
16  
17      public synchronized static VectorUtil getInstance() {
18          if (ourInstance == null) {
19              ourInstance = new VectorUtil();
20          }
21          return ourInstance;
22      }
23  
24      private VectorUtil() {
25      }
26  
27      public static int getBase() {
28          return 0x81e40;
29      }
30  
31      private static final String[] methodNames = new String[] {
32          "ReleaseTask", "SetPointer", "ReleasePointer", "PollPointer", "IconAction", "ClaimTask", "InfoAddress", "SetResolution", // 0x81e40
33          "", "", "", "", "", "", "", "", // 0x81e48
34          "", "", "", "", "", "", "", "", // 0x81e50
35          "", "", "", "", "", "", "", "", // 0x81e58
36          "", "", "", "", "", "", "", "", // 0x81e60
37          "", "", "", "", "", "", "", "", // 0x81e68
38          "", "", "", "", "", "", "", "", // 0x81e70
39          "", "", "", "", "", "", "", "" // 0x81e78
40      };
41  
42      public static Method getMethod(Integer offset) throws NoSuchMethodException {
43          return getMethod(methodNames[offset.intValue()]);
44      }
45  
46      private static final Method getMethod(String name) throws NoSuchMethodException {
47          return VectorUtil.class.getMethod(name, METHOD_PARAMETERS);
48      }
49  
50      public String getHelp() {
51          return "Vector Utility\t3.24 (06 Oct 1996) © JJM/4Mation ROBE";
52      }
53  
54      /***
55       * Increment our count of the number of tasks that are using us. Preserves all registers.
56       * @param env
57       */
58      public final void ClaimTask(Environment env) {
59          claimTask();
60      }
61  
62      public void claimTask() {
63          this.numTasks++;
64      }
65  
66      /***
67       * Set resolution to use for pointer sprites.
68       * Entry:	R0 = TRUE for high resolution, FALSE for low. Preserves all registers.
69       * @param env
70       */
71      public final void SetResolution(Environment env) {
72          setResolution(env.getCpu().R[0] != 0);
73      }
74  
75      public final void setResolution(boolean resFlag) {
76          this.resFlag = resFlag;
77      }
78  }
79