home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 1
/
ARM_CLUB_CD.iso
/
contents
/
sillies
/
silly10
/
!Yow
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1994-01-11
|
6KB
|
237 lines
> !RunImage for !Yow Copyright Denis Howe 1992
You may copy this program freely as long as this notice is
retained and you don't charge for it. Please send comments,
bugs and suggestions to Denis Howe <dbh@doc.ic.ac.uk>.
Pick a random word from the Index file and use it as the byte
offset of the start of a text in the YowLines file. Click
SELECT in the window to dismiss it or ADJUST to get another.
1.00 12-Aug-1990 Original program by Ian Rawlings
1.01 Rewritten by Denis Howe <dbh@doc.ic.ac.uk>
1.02 08-Sep-1991 Multiline texts terminated by a line containing
just a CHR$0 (and a newline character).
1.03 12-Nov-1991 Merged in Unix fortune.dat. Adjust for new text.
1.04 27-Dec-1991 Test if running under WIMP. More from fortune.dat.
1.05 04-Nov-1992 Adapt to current screen mode.
1.06 10-Dec-1992 Fix garfield sprite width.
1.07 16-Jun-1993 Added Index file.
Task$="Yow"
LF%=10:CR%=13
@Dir$="<Yow$Dir>":File$=Dir$+".YowLines":Index$=Dir$+".Index"
HMaxLen%=55 :
Max chars per output line before \n.
$;" @";
WindB% 512, Message% 2048
b% 256 :
For Wimp_Poll returns
blk% 256
"Wimp_ReadSysInfo",0
Wimp%
$b%="TASK"
Wimp%
"Wimp_Initialise",200,!b%,Task$
,TaskHandle%
Seed random numbers
$+?b%=3:
"OS_Word",14,b%:C%=
(b%!1))
NewText
Wimp%=0
"Wimp_Poll",1,b%
reason%
reason%
Redraw
-(
"Wimp_OpenWindow",,WindB%
.
(b%!8
1)=0
/6 !b%=WindowHandle%:
"Wimp_DeleteWindow",,b%
"Hourglass_On"
NewText
"Hourglass_Off"
17,18
b%!16
0 :
&400C1 :
&400C2
8A
b%!4<>TaskHandle%
$(b%+28),
(Task$))=Task$
Pick a random text from the file.
NewText
C%,F%,I%,P%
B1F%=
(Index$):
F%=0
0, "Can't open "+Index$
Point to random word in the Index file.
4)*4-4
Read four-byte word lsb 1st - the offset into YowLines.
F'P%=0:
I%=0
8:P%+=
#F%<<I%:
Read the text.
I/F%=
(File$):
F%=0
0, "Can't open "+File$
#F%=P%
P%=Message%
#F%:?P%=C%:P%+=1:
C%=0
Break any line longer than MaxLen%
Q!P%=Message%:Space%=0:Line%=P%
R!Lines%=0 :
Lines in original
?P%=
" " Space%=P%
?P%=LF% Line%=P%:Lines%+=1
P%-Line%>MaxLen%
W2
Space% ?Space%=LF%:Line%=Space%:Space%=0
P%+=1
See if last word of longest line would fit better on the following line
but only if the original was all one or two lines. Ie. don't reformat
multi-line input.
Lines%<3
b* P%=Message%:Space%=0:LineStart%=P%
cG LongStart%=0:LongEnd%=0 :
Start & end of longest line.
dB WordStart%=0 :
Start of its last word.
Reformat%=
f
g$ P%+=1:
?P%=
" " Space%=P%
?P%=LF%
L%=P%-LineStart%
j&
L%>LongEnd%-LongStart%
k/ LongStart%=LineStart%:LongEnd%=P%
WordStart%=Space%
m$ Reformat%=
:PrevMax%=
o?
PrevMax% Reformat%=(WordStart%-LongStart% > L%)
PrevMax%=
LineStart%=P%
?P%=0
u2
Reformat% ?WordStart%=LF%:?LongEnd%=
Reformat%
Replace LF with CRLF and find length of longest line.
{1P%=Message%:LineStart%=P%:LongLen%=0:Lines%=0
C%=?P%
C%=LF%
2 L%=P%-LineStart%:
L%>LongLen% LongLen%=L%
5 ?P%=CR%:Q%=P%:
Q%+=1:
C%,?Q%:
?Q%=0:P%+=1
LineStart%=P%:Lines%+=1
P%+=1
?P%=0
Wimp%
CreateWindow
"OS_Write0",Message%
End of NewText
CreateWindow
GSprW%=170*2:SprH%=184*2 :
Sprite size, pix*OS/pix
LCharH%=36 :
Vert. spacing between lines.
<LeftMargin%=SprW%+20:TopMargin%=36 :
Text offsets
)WinWidth%=16*(LongLen%+2)+LeftMargin%
WinHeight%=CharH%*(Lines%+2)
WinHeight%<SprH% WinHeight%=SprH%
Wind%=WindB%+4
0Wind%!28=1<<31 :
OR 1<<10 for 256 colours
Wind%?32=7
IWind%?35=7+
(8) :
work backgnd (WIMP colours)
Wind%?35=8
Wind%?35=11
Wind%?35=13 Wind%?34=0
Wind%?34=7
K :
work foregnd (WIMP colours)
Wind%?35=191+RND(64) :REM work backgnd (256 colours)
Wind%?34=RND(64)-1 :REM work foregnd (256 colours)
#Wind%!40=0 :
wk area coords
Wind%!44=-9999
Wind%!48=9999
Wind%!52=0
Wind%!60=3<<12
"Wind%!64=1 :
Wimp sprite area
Wind%!68=&10001
Wind%!84=1
7Icon%=Wind%+88 :
Sprite icon at bot left of window
;Icon%!0=0:Icon%!4=16-WinHeight% :
icon bounds
0Icon%!8=Icon%!0+SprW%:Icon%!12=Icon%!4+SprH%
<Icon%!16=1<<1
3<<12 :
sprite, click
$(Icon%+20)="garfield"
"Wimp_CreateWindow",,Wind%
WindowHandle%
!WindB%=WindowHandle%
Mode :
Sets mode dependent parts and opens win
Each line ends with CR LF. Text ends with CR LF NUL
Redraw
P%,Y%
"Wimp_RedrawWindow",,b%
more%
more%
P%=Message%:Y%=Ytop%
Xleft%,Y%:Y%-=36
.
"OS_WriteC",?P%:P%+=1:
P%?-1=LF%
?P%=0
"Wimp_GetRectangle",,b%
more%
L%,N%
"OS_ReadModeVariable",-1,4
"OS_ReadModeVariable",-1,11
ScreenWidth%=(N%+1)<<L%
"OS_ReadModeVariable",-1,5
"OS_ReadModeVariable",-1,12
ScreenHeight%=(N%+1)<<L%
&Wind%!0=(ScreenWidth%-WinWidth%)/2
(Wind%!4=(ScreenHeight%-WinHeight%)/2
Wind%!8=Wind%!0+WinWidth%
Wind%!12=Wind%!4+WinHeight%
Wind%!16=0
Wind%!20=0
Wind%!24=-1
"Wimp_OpenWindow",,WindB%
;Xleft%=Wind%!0+LeftMargin% :
Text origin
Ytop%=Wind%!12-TopMargin%
"Wimp_CloseDown"