Wasn't sure what was happening with the Wiki at the moment, but if this looks interesting I'll stick this on it. Let me know.
In this example I will be using my own little Assembly routine which plots an image to screen:
org &8000
;; Conditions of Entry Usage - |PLOTIMAGE,<xpos>,<ypos>,<address of image>
;; e.g |PLOTIMAGE,100,200,&80A5
ld hl,workspace
ld bc,table
call &bcd1
ret
.table defw table2
jp beginplot
.workspace
defb 0,0,0,0
.table2
defb 'PLOTIMAG'
defb 'E'+&80
defb 0
.beginplot
ld l,(ix+00) ;; Address of Data Colour
ld h,(ix+01)
ld (addrcolour),hl ;; Place this into Address Colour
ld l,(ix+04)
ld h,(ix+05)
ld (xpos),hl ;; Place co-ordinates of Image into Xpos
ld (resxpos),hl
ld l,(ix+02)
ld h,(ix+03)
ld (ypos),hl ;; Place co-ordinates of Images into Ypos
.plotimg
ld hl,(addrcolour) ;; Place Contents of Address Colour into HL
ld a,(hl) ;; Put Contents of HL into A
call do_colour
ld de,(xpos) ;; XPOS data into DE
ld hl,(ypos) ;; YPOS data into HL
call &bbea ;; GRA ABSOLUTE PLOT
ld hl,(xpos) ;; Obtain Contents of XPOS
inc hl ;; Is 16bit Value so Increment
inc hl ;; Twice
ld (xpos),hl ;; Place next value into XPOS
ld a,(fcount) ;; First Counter Position into A
inc a ;; Increment this
ld (fcount),a ;; Put New Value into First Count Position
ld b,a ;; Put this value into B
ld a,(xlcount) ;; Place First Counter Marker into A
cp b ;; Has value of B reached A value
jr nz,plotimg ;; If No Loop back, otherwise continue
ld a,(fcount) ;; At this stage fcount equals 8
xor a ;; This will make it 0 again
ld (fcount),a ;; And put that value into fcount
ld hl,(ypos) ;; YPOS of data can now be Incremented
dec hl ;; Again 16bit Value means Incrementing
dec hl ;; it Twice
ld (ypos),hl ;; And put that value into YPOS.
ld hl,(resxpos) ;; Need to restore the value of XPOS.
ld (xpos),hl ;; New Value goes into XPOS.
ld a,(scount) ;; Second counter goes into A
inc a ;; Increase it.
ld (scount),a ;; Place back into Second Counter
ld b,a ;; Put value of Second counter into B
ld a,(ylcount) ;; Place Y-counting position into A
cp b ;; Compare A to value of B
jr nz,plotimg ;; If reached exit, otherwise return
ld a,0 ;; \
ld hl,fcount ;; \\
ld (hl),a ;; Returns loop values back to 0 (important)
ld hl,scount ;; //
ld (hl),a ;; /
ret ;; Program exits here.
.do_colour
call &bbde ;; GRA SET PEN - A = Pen Colour
ld hl,(addrcolour) ;; Take address of address colour
inc hl ;; Increment it by 1
ld (addrcolour),hl ;; Put this value into Address Colour
ret ;; Return to Main Loop Routine.
.fcount defb 0
.scount defb 0
.xlcount
defb 8 ;; Number of times to loop across.
.ylcount
defb 8 ;; Number of times to loop down
.xpos defw 0 ;; Left Position the image
.ypos defw 0 ;; Bottom Position of the image.
.resxpos
defw 0 ;; This is used to Restore Xpos.
.data_colour
defb 0,0,0,0,0,0,0,0
defb 0,0,1,1,1,1,0,0
defb 0,1,3,3,3,3,1,0
defb 0,1,3,3,3,3,1,0
defb 0,1,3,3,3,3,1,0
defb 0,1,3,3,3,3,1,0
defb 0,0,1,1,1,1,0,0
defb 0,0,0,0,0,0,0,0
.addrcolour
defw 0 ;; This points to the address position
;; within the data colour.
It's not the fastest thing around, and certainly other proper Sprite Routines could be used, to show how to Incorporate other RSX routines into Hisoft Pascal.
I've been using Winape and for the Assembly Examples I've been using Winape Assembler, though my routines should work with Maxam too.
Once it's been Assembled into Memory the next phase is to disassemble it in BASIC. Because I'm using Winape, I can print the code to printer file:
for num=0 to 231:print#8,num;" ";peek(32768+num):next num
Unfortunately, I have to do this to get the code into a file that Hisoft Pascal 4T can read, though in the source, I have numbered the values for reference, so it makes it easier to key in each opcode.
It should produce something like this (as long as the program is in memory):
0 33
1 15
2 128
3 1
4 10
5 128
6 205
7 209
8 188
9 201
10 19
11 128
12 195
13 29
14 128
15 0
16 0
17 0
18 0
19 80
20 76
21 79
22 84
23 73
24 77
25 65
26 71
27 197
28 0
29 221
30 110
31 0
32 221
33 102
34 1
35 34
36 229
37 128
38 221
39 110
40 4
41 221
42 102
43 5
44 34
45 159
46 128
47 34
48 163
49 128
50 221
51 110
52 2
53 221
54 102
55 3
56 34
57 161
58 128
59 42
60 229
61 128
62 126
63 205
64 144
65 128
66 237
67 91
68 159
69 128
70 42
71 161
72 128
73 205
74 234
75 187
76 42
77 159
78 128
79 35
80 35
81 34
82 159
83 128
84 58
85 155
86 128
87 60
88 50
89 155
90 128
91 71
92 58
93 157
94 128
95 184
96 32
97 217
98 58
99 155
100 128
101 175
102 50
103 155
104 128
105 42
106 161
107 128
108 43
109 43
110 34
111 161
112 128
113 42
114 163
115 128
116 34
117 159
118 128
119 58
120 156
121 128
122 60
123 50
124 156
125 128
126 71
127 58
128 158
129 128
130 184
131 32
132 182
133 62
134 0
135 33
136 155
137 128
138 119
139 33
140 156
141 128
142 119
143 201
144 205
145 222
146 187
147 42
148 229
149 128
150 35
151 34
152 229
153 128
154 201
155 0
156 0
157 8
158 8
159 0
160 0
161 0
162 0
163 0
164 0
165 0
166 0
167 0
168 0
169 0
170 0
171 0
172 0
173 0
174 0
175 1
176 1
177 1
178 1
179 0
180 0
181 0
182 1
183 3
184 3
185 3
186 3
187 1
188 0
189 0
190 1
191 3
192 3
193 3
194 3
195 1
196 0
197 0
198 1
199 3
200 3
201 3
202 3
203 1
204 0
205 0
206 1
207 3
208 3
209 3
210 3
211 1
212 0
213 0
214 0
215 1
216 1
217 1
218 1
219 0
220 0
221 0
222 0
223 0
224 0
225 0
226 0
227 0
228 0
229 0
230 0
231 0
For this example and for it to work in the following program which was written in Hisoft Pascal, the code has to be in decimal.
10 PROGRAM SaveData2;
20
30 VAR
40 data : ARRAY[0..231] OF INTEGER;
50 count : integer;
60
70 BEGIN
80 WRITELN('Enter Data:');
90 FOR count:=0 TO 231 DO
100 BEGIN
110 WRITE(count);
120 write(' : ');
130 read(data[count]);
140 END;
150
160 writeln('Entering Complete Saving Data.');
170 TOUT('SPREBALL.DAT',ADDR(data),SIZE(data));
180 END.
In order to use other routines, modifications would have to be made to the size of the array which is 232 bytes for my example along with adjustments to the size of the loop which has been custom made for handling my routine. Running this program in Hisoft Pascal it will display a counter along with a spot to enter the appropriate value, once it's reach the end with all the values entered it will save the file using it's own TOUT command with the address pointing to where the data array is and the size of it.
And now the final program with Demo. When running Hisoft Pascal, it will prompt you where to set the RAM Top, in this example I say &7FFF because that's where my routine will be going. I've thrown in a number of procedures which is what Hisoft Pascal 4T encourages which was done to help minimise the size of the code.
10 PROGRAM BOUNCY;
20 { *** Written IN Hisoft Pascal 4T *** }
30 { *** Public Domain *** }
40 { *** Save PROGRAM BEFORE Running *** }
50 { *** Now Using External M/C FOR *** }
60 { *** Sprite Routine! *** }
70
80 VAR
90 Prog : ARRAY [0..231] OF integer;
100 Xpos, Xdir, Ypos, Ydir,
110 Width, Length : integer;
120 Loop : Boolean;
130
140 PROCEDURE LoadSprite;
150 VAR
160 loop : integer;
170
180 BEGIN
190 tin('spreball.dat',addr(Prog));
200 FOR loop:=0 TO 231 DO
210 poke(#8000+loop,prog[loop]);
220 user(#8000);
230 END;
240
250 Procedure mode(mo:integer);
260 begin
270 RA:=chr(mo);
280 USER(#BC0E);
290 end;
300
310 PROCEDURE Ink(no,col : integer);
320 BEGIN
330 RA:=chr(no);
340 RBC:=col;
350 USER(#BC32);
360 END;
370
380 Procedure Draw(Xpos, Ypos : Integer);
390 begin
400 RDE:=Xpos;
410 RHL:=Ypos;
420 USER(#BBF6);
430 end;
440
450 Procedure Move(Xpos, Ypos : Integer);
460 begin
470 RDE:=Xpos;
480 RHL:=Ypos;
490 USER(#BBC0);
500 end;
510
520 Procedure resetcolor;
530 begin
540 USER(#BC02);
550 end;
560
570 Procedure grapen(col:integer);
580 begin
590 RA:=chr(col);
600 USER(#BBDE);
610 end;
620
630 Procedure PlotPoint(xpos,ypos:integer);
640 begin
650 RDE:=xpos;
660 RHL:=ypos;
670 USER(#BBEA);
680 end;
690
700 Procedure Frame;
710 begin
720 USER(#BD19);
730 end;
740
750 { Main Procedures }
760
770 PROCEDURE PlotImage(Xpos, Ypos, Adr : integer);
780 BEGIN
790 external('plotimage',xpos,ypos,adr);
800 END;
810
820 Procedure DrawBox;
830 Begin
840 Grapen(2);
850 Move(200,300);
860 Draw(470,300);
870 Draw(470,100);
880 Draw(200,100);
890 Draw(200,300);
900 End;
910
920 begin { Main Routine }
930 ResetColor;
940 LoadSprite;
950 Mode(1);
960 ink(0,#0000);
970 ink(1,#0202);
980 ink(3,#0b0b);
990 DrawBox;
1000 Loop:=True;
1010 Xpos:=205;
1020 Ypos:=281;
1030 Xdir:=1;
1040 Ydir:=-1;
1050 REPEAT
1060 Xpos:=Xpos+Xdir;
1070 Ypos:=Ypos+Ydir;
1080 Frame;
1090 Frame;
1100 PlotImage(Xpos,Ypos,#80A5);
1110 Case Xpos of
1120 454 : Xdir:=-1;
1130 202 : Xdir:=1
1140 end;
1150 Case Ypos of
1160 298 : Ydir:=-1;
1170 118 : Ydir:=1
1180 end;
1190 UNTIL Loop=False;
1200 { This is an Infinate Loop }
1210 END.
In relation to the M/C I've produced, I'm using the LoadSprite procedure to load the code using TIN. Because I was using a Tape Version of Hisoft Pascal 4T <- presumibly 4T means 4 Tape

if the filename was less than 8 Characters then spaces need to be inserted, though because my filename is 8 characters along with the 4 for the extension they aren't shown. A shorter filename would have spaces to bring it upto the 8 characters and then followed by the ".EXT" bit.
In this example you'll noticed I've called the data array from the last program -> "prog" instead though still with the same size. What TIN does is load the contents into the Array - prog, but then I need to Poke those contents into Memory for where it should go, which is what the loop after that is doing and then it does a USER(#8000) which is a "CALL &8000" in BASIC to activate the RSX and from there I can use that RSX in my own program.
In my example what's happened is I've setup a routine which plots a specific image, the RSX has parameters associated with it which ask what the XPOS, YPOS and the address of the Image.
The address of the Image in my case is where I setup ".data_colour" in my Assembly code, so I've got that address from when I assembled the code.
In my final code these lines:
770 PROCEDURE PlotImage(Xpos, Ypos, Adr : integer);
780 BEGIN
790 external('plotimage',xpos,ypos,adr);
800 END;
deal with the setting up that Procedure which I've called in line 1100 to display the correct image. The important thing to note in Hisoft Pascal is Hexadecimal numbers being with the hash "#" otherwise the compiler it spits the dummy.
Well after all that I hope this encourages those not to do it!