home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 13
/
AUCD13.iso
/
argonet
/
swiftjpeg.spk
/
!SwiftJPEG
/
Resources
/
SourceBas
(
.txt
)
< prev
Wrap
RISC OS BBC BASIC V Source
|
1996-04-25
|
74KB
|
2,606 lines
> !RunImage for !SwiftJPEG
A fast JPEG viewer using Acorn's
SpriteExtend module from RISC OS
v3.6 or later (module version
0.99 or later).
This source code may not run with
the WimpSlot allocated to the
crunched !RunImage; you may need
to increase the slot by the
difference in file size, rounded
up to a 4K block.
(C) Hipposoft 1995,1996
closeopenfiles:
(1<<30),"Fatal startup error: "+
$+" at line "+
)+", click on Cancel to exit":
openfh%=0
returnto%=-1
allfatal%=
picareah%=0
picsdone%=0
lisareah%=0
listfull%=0
barmin%=12
barmax%=96
loaderro% holds a value of 0 most of the time. If it has a higher
value, it refers to an offset from the pointer in the dynamic area
holding the list of files to load - namely, it points to the
byte terminator of the filename that generated the error. In this
case, FNerror will set that byte to 1. This can be used by other
routines to then skip that file should they come across it again,
rather than repeatedly generate errors.
loaderro%=0
displayh% is set to -1 to signal that FNerror is not to check to
see if the display window needs remembering as it hasn't even been
created yet (when it is created, displayh% will acquire a
meaningful value in passing).
displayh%=-1
fbl% ('fade block') holds variables as words, meaning -
-------+-------------------------+-------------------------
Offset | Contents | Values
-------+-------------------------+-------------------------
0 | Fade picture in | 0=no, 1=fade, 2=flash
4 | Fade picture out | 0=no, 1=fade, 2=flash
8 | Fade-in speed | barmin% to barmax% incl.
12 | Fade-out speed | barmin% to barmax% incl.
16 | Choices store offset 12 | As offset 12
20 | Choices store offset 16 | As offset 16
-------+-------------------------+-------------------------
The Choices stores are variables which hold the values
reflected in an open Choices window, which can't be directly
read from that window (this allows OK and Cancel buttons to
operate correctly with relative ease from a code viewpoint).
fbl% 24
!fbl%=0
fbl%!4=0
b% 256,s% 256,fr% 512,lca% 64
H !b%=1
b%!4=2
b%!8=3
b%!12=4
b%!16=5
b%!20=&400C0
b%!24=&400C1
b%!28=&400C9
b%!32=0
"Wimp_Initialise",350,&4B534154,"SwiftJPEG",b%
a%,task%
error
exit:
a%<350
490,"SwiftJPEG requires RISC OS 3.50 or later to run"
"OS_CLI","RMEnsure SpriteExtend 0.99 ERROR 490 Can't find JPEG plotting SWIs - is SpriteExtend 0.99 or later running?"
"XOS_ReadVarVal","SwiftJPEG$Dir",fr%,256
,,a%
a%=0
490,"'SwiftJPEG$Dir' not defined - ensure you double-click on !SwiftJPEG to run it"
Z1choipath$=
textuntil(fr%,32),a%)+".!Choices"
initialisecode
"Hourglass_Start",1
version$="1.00 (25 Apr 96)"
initialisemain
iconbar
"Hourglass_Off"
During the routine to find if the application was launched by
double-clicking on a JPEG file, and if so loading that file,
we need to ensure that should an error occur, the routine won't
just be run again because the error will then be regenerated.
This isn't a problem with the above code because all errors
are forced to be fatal.
Hence allfatal% is set to FALSE if the routine is to be run,
or is given a value of 1 if an error occurs. The long IF
around the routine sets allfatal% back to FALSE if it wasn't
FALSE on entry to ensure that further errors aren't forced
to be fatal.
allfatal%=
error
exit:
allfatal%=1
allfatal%=
getp(a$)
a$<>""
!b%=-1
b%!40=
filetype(a$)
$(b%+44)=a$
storefilename
allfatal%=
error
exit:
quit%
-- General WIMP procedures
removearea(picareah%)
picareah%=0
removearea(lisareah%)
lisareah%=0
"XWimp_CloseDown",task%,&4B534154
PROCmemusage
DEFPROCmemusage
MODE MODE
PRINT "Memory free : ";HIMEM-END
PRINT "Could decrease slot by: ";(((HIMEM-END) DIV 4096)*4);"K"
PRINT "That would leave free : ";(HIMEM-END)-(((HIMEM-END) DIV 4096)*4096);" bytes"
ENDPROC
"OS_ReadMonotonicTime"
"Wimp_PollIdle",29368369,b%,a%+10000
reason%
reason%
redraw
"Wimp_OpenWindow",,b%
!b%=-1
lisareah%<>0
showbatch(autofull%)
closewindow
click
dragended
keyboard
menuselect
"Wimp_GetCaretPosition",,fr%:
!fr%<>lastmenh%
!lca%=-1
17,18,19:
message
closewindow
!b%
displayh%
"OS_Byte",121
(a%<>0)
"Wimp_CloseWindow",,b%
removearea(picareah%)
picareah%=0
greyoutmenu(mainmenuaddr%,2)
greyoutmenu(mainmenuaddr%,3)
jpegname$<>"<Wimp$Scrap>"
ungreymenu(mainmenuaddr%,4)
a%,c%,d%
(d%
a$=jpegname$
(a$)
a$,a%,1)="."
a$,a%-1):a%=0:c%=
c%<>
a$<>""
"XOS_CLI","Filer_OpenDir "+a$
jpegname$="<Wimp$Scrap>"
"XOS_CLI","Filer_OpenDir <Wimp$ScrapDir>"
saveash%
restorecaret
"Wimp_CloseWindow",,b%
"Wimp_CloseWindow",,b%
click
windh%=b%!12
iconh%=b%!16
adju%=(b%!8)
menu%=(b%!8)
sele%=(b%!8)
windh%
open(displayh%)
adju%<>0
showcurrent
open(displayh%)
sele%<>0
!fr%=displayh%
"Wimp_GetWindowState",,fr%
fr%!28=-1
"Wimp_OpenWindow",,fr%
openmainmenu(
displayh%:
openmainmenu(
zoomh%:
zoomclick
choicesh%:
choicesclick
saveash%:
saveasclick
keyboard
windh%=!b%
iconh%=b%!4
windh%
zoomh%
b%!24=&00D
textuntil(!(zow%+108+32*iconh%),33))>20
$(!(zow%+108+32*iconh%))="20":
forceredraw(zoomh%,iconh%)
textuntil(!(zow%+108+32*iconh%),33))<1
$(!(zow%+108+32*iconh%))="1":
forceredraw(zoomh%,iconh%)
iconh%=2
iconh%=4:
placecaretinicon(zoomh%,4,-2)
iconh%=2:
"Wimp_CreateMenu",-1
keyzoom
choicesh%
b%!24=&00D
iconh%=13:a%=
b%!24=&01B
iconh%=12:a%=
adju%=0:
choicesclick
saveash%
b%!24=&00D
iconh%=3:a%=
b%!24=&01B
iconh%=2:a%=
dragging%=
"DragASprite_Stop":adju%=0:
saveasclick
"Wimp_ProcessKey",b%!24
message
b%!16
0:quit%=
datasave
datasaveack
storefilename
dataloadack
b%!40=&C85
storefilename
&400C0:
b%!20=zoomh%
checkzoomfraction:
"Wimp_CreateSubMenu",,b%!20,b%!24,b%!28
&400C1:
open(displayh%)
resizemainwindow
modeinfo(
&400C9:
dragging%
"DragASprite_Stop"
redraw
"Wimp_RedrawWindow",,b%
!b%=displayh%
"XJPEG_PlotScaled",picareab%,b%!4-b%!20,b%!16-windheig%-b%!24,sc%,jpegleng%,df%
!b%=choicesh%
redrawslider(choicesh%,40,barmin%,barmax%,fbl%!16):
redrawslider(choicesh%,41,barmin%,barmax%,fbl%!20)
"Wimp_GetRectangle",,b%
redrawslider(a%,c%,d%,e%,f%)
Pass a window and icon handle, minimum, maximum, and current value.
Draws the interior of a slider based on those values.
CORRUPTS BOTH s% AND fr%.
!fr%=a%
fr%!4=c%
"Wimp_GetIconState",,fr%
!s%=a%
"Wimp_GetWindowState",,s%
s%!64=fr%!8+s%!4-s%!20
s%!68=fr%!12+s%!16-s%!24
s%!72=fr%!16+s%!4-s%!20
s%!76=fr%!20+s%!16-s%!24
D1x%=((s%!72-s%!64-16)/(e%-d%))*(f%-d%)+s%!64+8
x%=((x%+1)
2)*2
"Wimp_SetColour",1
s%!64+4,s%!68+4,s%!72-s%!64-9,3
s%!64+4,s%!76-8,s%!72-s%!64-9,3
s%!64+4,s%!68+4,3,s%!76-s%!68-9
s%!72-8,s%!68+4,3,s%!76-s%!68-9
"Wimp_SetColour",4
x%-s%!64-9>0
s%!64+8,s%!68+8,x%-s%!64-9,s%!76-s%!68-17
"Wimp_SetColour",0
s%!72-x%-11>0
x%,s%!68+8,s%!72-x%-9,s%!76-s%!68-17
forceredraw(a%,c%)
Pass a window and icon handle. Performs a 'true' redraw
of the icon (so it might flicker a bit). Minimises this
by checking if the icon has a border, and if so, tries
not to redraw it.
!fr%=a%
fr%!4=c%
"Wimp_GetIconState",,fr%
(fr%!24)
"Wimp_ForceRedraw",!fr%,fr%!8+4,fr%!12+4,fr%!16-4,fr%!20-4
"Wimp_ForceRedraw",!fr%,fr%!8,fr%!12,fr%!16,fr%!20
redrawwindow(a%)
Pass a window handle. Performs a 'true' redraw of the
window (so it will flicker a little).
!fr%=a%
"Wimp_GetWindowState",,fr%
"Wimp_ForceRedraw",-1,fr%!4,fr%!8,fr%!12,fr%!16
redrawtitlebar(a%)
open(a%)
!s%=a%
"Wimp_GetWindowState",,s%
c%=s%!16
!s%=a%
"Wimp_GetWindowOutline",,s%
s%!8<c%
s%!8=c%
"Wimp_ForceRedraw",-1,s%!4,s%!8,s%!12,s%!16
-- Initialisation procedures
initialisecode
Load pre-assembled ARM code routine(s) and link
various parts as necessary.
a%,c%
~(openfh%=
("<SwiftJPEG$Dir>.ARMcode")
getword(openfh%)
mc% a%-4
"OS_GBPB",4,openfh%,mc%,a%-4
,,,c%
gar% 256,gag% 256,gab% 256
c%<>0
(1<<30)+2,"ARMcode file is too short or file pointers are too large"
DO NOT FORGET that words obtained from the rest of the file
are pointer OFFSETS - reference with mc% added!
!!(mc%+
getword(openfh%))=gar%
!!(mc%+
getword(openfh%))=gag%
!!(mc%+
getword(openfh%))=gab%
%gammawrite%=mc%+
getword(openfh%)
#openfh%
openfh%=0
initialisemain
General initialisation.
Initialise general global variables and arrays
quit%=
returnto%=-1
abortmul%=
dragging%=
picareab%=0
lisareab%=0
lisloadp%=0
lisnextp%=0
lismaxsi%=&80000
inw%, diw% etc. all store window definitions (see
PROCloadtemplates for which block holds which window).
isp%=1856
i% isp%,ib% 32,m% 576,mi% 160
inw% 576,diw% 160,zow% 512,jiw% 448,chw% 2584,sav% 576
mos% stores the Desktop mode selector block for new-style
modes. 128 bytes is overkill but it helps future-proof
things should the maximum length of a selector block
increase in later OS versions. sc% stores the scaling
block for plotting the JPEG; mbu% stores a mode definition
string for the Full Screen Mode menu (fullmode$ holds the
string that's currently in use), and dst% stores the
basic information on position and size of the Display
window for the duration of Full Screen viewing of a
picture/several pictures so it can be correctly restored
afterwards.
mos% 128,sc% 16,mbu% 64,dst% 64
Is the Compo_ReadGamma SWI available? If so, fade routines
will read current values and take them into account. Otherwise,
if someone set up their Gamma values with !Gamma they'd have to
turn off all the fades as it would reset their gamma settings.
This isn't done through extra code in SwiftJPEG as you can only
'read' the values by sitting on the palette vector and waiting
for someone to issue new gamma settings. So if someone set up
custom gamma settings at start up and later loaded SwiftJPEG,
it couldn't know about those new settings. The !Gamma application
is the only front-end I know of that allows such things to be
done easily, so SwiftJPEG explicitly supports it. Otherwise -
no fades, I'm afraid, though you can always hack the source...
"XOS_SWINumberFromString",,"XCompo_ReadGamma"
cgamread%;a%
(a%
cgamread%=
pgr% 256,pgg% 256,pgb% 256
cgamread%=
a%=0
pgr%?a%=a%
pgg%?a%=a%
pgb%?a%=a%
cgamread%,pgr%,pgg%,pgb%
Load choices and sprites relevant to current display
resolution.
loadchoices
loadsprites
xbig%, ybig% and bbpp% are eventually set globally to the
x size, y size and colour depth of the largest available
screenmode; xclr%, yclr% and cbpp% to the most colourful.
xbig%=0
ybig%=0
bbpp%=0
xclr%=0
yclr%=0
cbpp%=0
Now the usual initialisation, loading
templates, making menus, adding submenus
and so on.
templates
zoomm%=1
zoomd%=1
$(zow%!172)="1"
$(zow%!236)="1"
menudata
%mainmenuaddr%=
makemenu(m%,mi%,1)
attach(mainmenuaddr%,0,infoh%)
attach(mainmenuaddr%,1,zoomh%)
+picturesubmenuaddr%=
makemenu(m%,mi%,1)
attach(mainmenuaddr%,2,picturesubmenuaddr%)
attach(picturesubmenuaddr%,0,jpeginfoh%)
attach(picturesubmenuaddr%,1,saveash%)
greyoutmenu(mainmenuaddr%,2)
greyoutmenu(mainmenuaddr%,3)
greyoutmenu(mainmenuaddr%,4)
(ditheringmethod%=
makemenu(m%,mi%,1)
'fullscreenmode%=
makemenu(m%,mi%,1)
loadchoices
openfh%=
(choipath$)
openfh%=0
490,"Can't find the !Choices file"
getchoice("Dithering","012",ditherit%)
df%=ditherit%-(ditherit%=2)
getchoice("Full Screen","01234",fullscrn%)
getchoice("Special Mode","*",a%)
fullmode$=
#openfh%,64)
fullmode$,1)="."
fullmode$=
fullmode$,2)
getchoice("Auto Full Screen","01",autofull%)
getchoice("Modes Once Only","01",modesonc%)
getchoice("Close Display","01",closedis%)
getchoice("Auto Filetype","01",autofilt%)
getchoice("Slideshow wait","!",sldswait%)
getchoice("Always 1:1","01",fixdzoom%)
getchoice("Repeat pictures","01",reptpics%)
getchoice("Fade-in","012",!fbl%)
getchoice("Fade-in speed","!",fbl%!8)
fbl%!16=fbl%!8
getchoice("Fade-out","012",fbl%!4)
getchoice("Fade-out speed","!",fbl%!12)
fbl%!20=fbl%!12
#openfh%
openfh%=0
closeopenfiles
openfh%<>0
#openfh%
openfh%=0
restoremode
returnto%<>-1
"Wimp_SetMode",returnto%:returnto%=-1:
gammanormal
getchoice(b$,a$,
Pass the title of the entry in the Choices file;
if a single digit is to be returned, pass all the
digits in the second parameter as a string (e.g.
'0123') or '!' for no check, and pass a variable
into which the VAL of the string obtained from
the Choices file is placed. If '*' is given as
second parameter, then the returned number will
be irrelevant (it can be discarded) and the file
pointer will be on the line immediately after
the title. This allows text strings, rather than
numbers, to be loaded - call PROCgetchoice and
then do variable$=GET$#filehandle%.
c%,c$
upper(
#openfh%)=
upper(b$)
(c%=
#openfh%)
490,"Can't find '"+b$+"' entry in !Choices file"
a$,1)<>"*"
#openfh%
a$,1)<>"!")
a$,1)<>"*")
a$,c$)=0)
(c$)<>1)
490,b$+" option not understood in !Choices file"
a$,1)<>"*"
putchoice(a$,a%)
Pass the title of the entry in the Choices file;
if a single digit is to be stored, pass the
digit as a number in the second parameter,
or for numbers between 0 and 9999 to be stored
in four digit string form (e.g. '0045'), give,
if n is the number, -(n+1) as the value. If a%
is >9 and positive it is taken as a pointer to
a control terminated string in memory.
c%,b$
upper(
#openfh%)
upper(a$)
(c%=
#openfh%)
490,"Can't find '"+a$+"' entry in !Choices file"
(a%>=0)
(a%<=9)
#openfh%,a%+48
a%<0
b$="0000":
(-(a%+1)):
#openfh%,b$
a%>9
64,"."):
textuntil(a%,32):
#openfh%,b$
loadsprites
a%,a$
"OS_ReadModeVariable",-1,4
,,xeig%
"OS_ReadModeVariable",-1,5
,,yeig%
a$="<SwiftJPEG$Dir>."
xeig%>1
yeig%>1
a$+="Sprites"
a$+="Sprites22"
filetype(a$)
a%<0
(1<<30)+2,"Can't find Sprites file"
a%<>&FF9
(1<<30)+2,"Sprites file doesn't have Sprite filetype &FF9"
filelength(a$)
a%=-1
(1<<30)+2,"Can't find the Sprites file"
sprites% a%+1024
!sprites%=0
sprites%!4=16
"OS_SpriteOp",265,sprites%
"OS_SpriteOp",266,sprites%,a$
iconbar
$(ib%)="iconbar"
!b%=-1
b%!4=0
b%!8=0
b%!12=68
b%!16=68
b%!20=&3102
b%!24=ib%
b%!28=sprites%
b%!32=11
"Wimp_CreateIcon",,b%
iconbarh%
getp(
"OS_GetEnv"
textuntil(a%,32)
a$,"""")
a%<>0
a$,a%+1)
a$,""" ")
a%<>0
a$,a%+2)
a$=""
-- Template and window handling procedures
open(a%)
a%=-1
!fr%=a%
"Wimp_GetWindowState",,fr%
((fr%!32)
&10000)<>0
loadtemp(a%,a$,
Pass a block to load the main data into, the template name
to load, and a variable into which the created window
handle is to be placed. Requires i% as a block for
indirected data, isp% as the length of the block, and io%
as the value of i% on entry to the procedure (i% will
be changed to point to the first free space in the block,
io% stays as a reference) - these must be global.
"Wimp_LoadTemplate",,a%,i%,io%+isp%,-1,a$,0
,,i%
a%!64=sprites%
"Wimp_CreateWindow",,a%
templates
Reads in and creates window definitions through PROCloadtemp.
a%,c%,d%,a$
"Wimp_OpenTemplate",,"<SwiftJPEG$Dir>.Templates"
io%=i%
loadtemp(inw%,"Info",infoh%)
$(inw%!332)=version$
loadtemp(diw%,"Display",displayh%)
loadtemp(zow%,"Zoom",zoomh%)
loadtemp(jiw%,"JPEG info",jpeginfoh%)
loadtemp(chw%,"Choices",choicesh%)
loadtemp(sav%,"SaveAs",saveash%)
a$="file_c85"
"Wimp_BaseOfSprites"
a%,c%
"XOS_SpriteOp",296,a%,a$
(d%
"XOS_SpriteOp",296,c%,a$
(d%
a$="file_xxx"
)$(sav%!112)="Pptr_hand,9,5;S"+a$+
"Wimp_CloseTemplate"
opencentered(f%)
a%,c%,d%,e%
readscreensize(a%,c%)
!fr%=f%
"Wimp_GetWindowState",,fr%
d%=fr%!12-fr%!4
e%=fr%!16-fr%!8
xpo%=(a%-d%)/2
ypo%=(c%-e%)/2
(fr%!32)
&4000000
ypo%-=19
(fr%!32)
&40000000
ypo%+=19
(fr%!32)
&10000000
xpo%-=19
fr%!4=xpo%
fr%!8=ypo%
fr%!12=xpo%+d%
fr%!16=ypo%+e%
fr%!28=-1
"Wimp_OpenWindow",,fr%
titlebarchange(a%,a$)
Pass a window handle, and a string to put in the
title bar. This is truncated to 48 characters,
with any string greater than 45 having '...' placed
in front.
!fr%=a%
"Wimp_GetWindowInfo",,fr%
(a$)>48
c$="..."+
a$,45)
c$=a$
Line below - If the pathname is >48 characters, then the '...' is put
in front of the last 45. But what happens if those 45, by chance,
start with a '.' of a directory separator? The line below should remove
one dot should the string start with four of them, which indicates
that the used 45 characters did indeed start with a dot. In this case,
only 47 characters will appear in the title bar.
c$,4)="...."
c$,2)
$(fr%!76)=c$+
redrawtitlebar(a%)
zoomclick
a%,c%
a%=zoomm%
c%=zoomd%
getopt(zoomh%,0)
iconh%<>0
setopt(zoomh%,0,
getopt(zoomh%,1)
iconh%<>1
setopt(zoomh%,1,
getopt(zoomh%,5)
iconh%<>5
setopt(zoomh%,5,
getopt(zoomh%,6)
iconh%<>6
setopt(zoomh%,6,
adju%
iconh%
0:iconh%=1
1:iconh%=0
5:iconh%=6
6:iconh%=5
The double range checking implemented here may seem unnecessary (why
check for a value too low when it is being incremented rather than
decremented?) but because the user may have typed in some very odd
value first, it is still necessary to ensure that even after adding
or subtracting 1 from the value in the icon, the resulting number is
within the allowed range.
iconh%
'zoomm%=
textuntil(zow%!172,33))+1
zoomm%>20
zoomm%=20
zoomm%<1
zoomm%=1
textuntil(zow%!172,33)<>
(zoomm%)
$(zow%!172)=
(zoomm%):
forceredraw(zoomh%,2)
'zoomm%=
textuntil(zow%!172,33))-1
zoomm%>20
zoomm%=20
zoomm%<1
zoomm%=1
textuntil(zow%!172,33)<>
(zoomm%)
$(zow%!172)=
(zoomm%):
forceredraw(zoomh%,2)
'zoomd%=
textuntil(zow%!236,33))+1
zoomd%>20
zoomd%=20
zoomd%<1
zoomd%=1
textuntil(zow%!236,33)<>
(zoomd%)
$(zow%!236)=
(zoomd%):
forceredraw(zoomh%,4)
'zoomd%=
textuntil(zow%!236,33))-1
zoomd%>20
zoomd%=20
zoomd%<1
zoomd%=1
textuntil(zow%!236,33)<>
(zoomd%)
$(zow%!236)=
(zoomd%):
forceredraw(zoomh%,4)
a%<>zoomm%
c%<>zoomd%
open(displayh%)
resizemainwindow
!fr%=displayh%
"Wimp_CloseWindow",,fr%
"Wimp_GetWindowState",,fr%
"Wimp_OpenWindow",,fr%
showmenu(lastmena%,lastmenx%,lastmeny%)
keyzoom
a%,c%
a%=zoomm%
c%=zoomd%
4%zoomm%=
textuntil(zow%!172,33))
5%zoomd%=
textuntil(zow%!236,33))
zoomm%<1
zoomm%=1
zoomm%>20
zoomm%=20
zoomd%<1
zoomd%=1
zoomd%>20
zoomd%=20
zoomm%<>a%
$(zow%!172)=
(zoomm%)
zoomd%<>c%
$(zow%!236)=
(zoomd%)
a%<>zoomm%
c%<>zoomd%
open(displayh%)
resizemainwindow
!fr%=displayh%
"Wimp_CloseWindow",,fr%
"Wimp_GetWindowState",,fr%
"Wimp_OpenWindow",,fr%
setupchoices
Sets up, but does not open, the General Choices window,
and any items attached to it (e.g. menus). Will update
any Choices store variables with the global, applied
values. (So this can be used to implement a Cancel
button with or without window closure, or be called
generally before opening the window).
a%,a$
readtick(ditheringmethod%,ditherit%)=
a%=0
settick(ditheringmethod%,a%,
settick(ditheringmethod%,ditherit%,
ditherit%
0:a$="No dithering"
1:a$="Fast but inaccurate"
2:a$="Slow but accurate"
:a$="Unknown!"
$(chw%!1260)=a$
forceredraw(choicesh%,36)
$mbu%=fullmode$
readtick(fullscreenmode%,fullscrn%)=
a%=0
settick(fullscreenmode%,a%,
settick(fullscreenmode%,fullscrn%,
fullscrn%
0:a$="Use current mode"
1:a$="Best fit to picture"
2:a$="Use biggest"
3:a$="Use most colourful"
4:a$=
textuntil(mbu%,32):
(a$)>20
a$,17)="..."
:a$="Unknown!"
$(chw%!1356)=a$
forceredraw(choicesh%,39)
getopt(choicesh%,!fbl%)=
a%=0
a%<>!fbl%
setopt(choicesh%,a%+2,
setopt(choicesh%,a%+2,
getopt(choicesh%,fbl%!4)=
a%=0
a%<>fbl%!4
setopt(choicesh%,a%+7,
setopt(choicesh%,a%+7,
fbl%!16<>fbl%!8
fbl%!16=fbl%!8:
forceredraw(choicesh%,40)
fbl%!20<>fbl%!12
fbl%!20=fbl%!12:
forceredraw(choicesh%,41)
-autofull%<>
getopt(choicesh%,16)
setopt(choicesh%,16,-autofull%)
-modesonc%<>
getopt(choicesh%,17)
setopt(choicesh%,17,-modesonc%)
-closedis%<>
getopt(choicesh%,18)
setopt(choicesh%,18,-closedis%)
-autofilt%<>
getopt(choicesh%,19)
setopt(choicesh%,19,-autofilt%)
textuntil(chw%!876,33)<>
(sldswait%)
$(chw%!876)=
(sldswait%)
forceredraw(choicesh%,24)
adju%<>0
"Wimp_GetCaretPosition",,fr%
!fr%=choicesh%
placecaretinicon(choicesh%,24,-1):
placecaretinicon(choicesh%,24,-2)
-fixdzoom%<>
getopt(choicesh%,27)
setopt(choicesh%,27,-fixdzoom%)
-reptpics%<>
getopt(choicesh%,42)
setopt(choicesh%,42,-reptpics%)
choicesclick
a%,c%,d%,e%,a$
iconh%=10
iconh%=11
iconh%=12
iconh%=13
slab(choicesh%,iconh%)
iconh%=25
iconh%=26
getopt(choicesh%,25)
iconh%<>25
setopt(choicesh%,25,
getopt(choicesh%,26)
iconh%<>26
setopt(choicesh%,26,
adju%<>0
iconh%
25:iconh%=26
26:iconh%=25
iconh%
2,3,4
getopt(choicesh%,iconh%)=
getopt(choicesh%,2)
setopt(choicesh%,2,
getopt(choicesh%,3)
setopt(choicesh%,3,
getopt(choicesh%,4)
setopt(choicesh%,4,
setopt(choicesh%,iconh%,
7,8,9
getopt(choicesh%,iconh%)=
getopt(choicesh%,7)
setopt(choicesh%,7,
getopt(choicesh%,8)
setopt(choicesh%,8,
getopt(choicesh%,9)
setopt(choicesh%,9,
setopt(choicesh%,iconh%,
'Save'; store the choices as displayed in the Choices
window and OK them.
openfh%=
(choipath$)
openfh%=0
490,"Can't find the !Choices file"
"Hourglass_Start",1
c%=0
readtick(ditheringmethod%,c%)=
a%=c%
putchoice("Dithering",a%)
c%=0
readtick(fullscreenmode%,c%)=
a%=c%
putchoice("Full Screen",a%)
putchoice("Special Mode",mbu%)
putchoice("Auto Full Screen",-
getopt(choicesh%,16))
putchoice("Modes Once Only",-
getopt(choicesh%,17))
putchoice("Close Display",-
getopt(choicesh%,18))
putchoice("Auto Filetype",-
getopt(choicesh%,19))
putchoice("Slideshow wait",-(
textuntil(chw%!876,33))+1))
putchoice("Always 1:1",-
getopt(choicesh%,27))
putchoice("Repeat pictures",-
getopt(choicesh%,42))
putchoice("Fade-in",-
getopt(choicesh%,3)-2*
getopt(choicesh%,4))
putchoice("Fade-in speed",-fbl%!16-1)
putchoice("Fade-out",-
getopt(choicesh%,8)-2*
getopt(choicesh%,9))
putchoice("Fade-out speed",-fbl%!20-1)
"Hourglass_Off"
#openfh%
openfh%=0
iconh%=13
choicesclick
'Default'.
readtick(ditheringmethod%,2)=
settick(ditheringmethod%,0,
settick(ditheringmethod%,1,
settick(ditheringmethod%,2,
$$(chw%!1260)="Slow but accurate"
forceredraw(choicesh%,36)
readtick(fullscreenmode%,1)=
a%=0
settick(fullscreenmode%,a%,
settick(fullscreenmode%,1,
&$(chw%!1356)="Best fit to picture"
forceredraw(choicesh%,39)
$mbu%="X800 Y600 C16M"
getopt(choicesh%,2)=
getopt(choicesh%,3)
setopt(choicesh%,3,
setopt(choicesh%,4,
setopt(choicesh%,2,
getopt(choicesh%,7)=
getopt(choicesh%,8)
setopt(choicesh%,8,
setopt(choicesh%,9,
setopt(choicesh%,7,
fbl%!16<>48
fbl%!16=48:
forceredraw(choicesh%,40)
fbl%!20<>48
fbl%!20=48:
forceredraw(choicesh%,41)
getopt(choicesh%,16)
setopt(choicesh%,16,
getopt(choicesh%,18)
setopt(choicesh%,18,
getopt(choicesh%,17)=
setopt(choicesh%,17,
getopt(choicesh%,19)=
setopt(choicesh%,19,
textuntil(chw%!876,33)<>"0"
$(chw%!876)="0"
forceredraw(choicesh%,24)
"Wimp_GetCaretPosition",,fr%
!fr%=choicesh%
placecaretinicon(choicesh%,24,-2)
getopt(choicesh%,27)=
setopt(choicesh%,27,
getopt(choicesh%,42)
setopt(choicesh%,42,
'Cancel'; reset choices to as they were when
the window opened.
adju%=0
restorecaret:!fr%=choicesh%:
"Wimp_CloseWindow",,fr%
setupchoices
'OK'; store choices internally and force the display window
to redraw if it is open, if the dithering method has changed.
a%=ditherit%
c%=0
readtick(ditheringmethod%,c%)
ditherit%=c%
df%=ditherit%-(ditherit%=2)
c%=0
readtick(fullscreenmode%,c%)
fullscrn%=c%
+!fullmode$=
textuntil(mbu%,32)
c%=0
getopt(choicesh%,c%+2)
!fbl%=c%
c%=0
getopt(choicesh%,c%+7)
fbl%!4=c%
5$autofull%=-
getopt(choicesh%,16)
6$modesonc%=-
getopt(choicesh%,17)
7$closedis%=-
getopt(choicesh%,18)
8$autofilt%=-
getopt(choicesh%,19)
:(sldswait%=
textuntil(chw%!876,33))
;$fixdzoom%=-
getopt(choicesh%,27)
<$reptpics%=-
getopt(choicesh%,42)
fbl%!8=fbl%!16
fbl%!12=fbl%!20
restorecaret
!fr%=choicesh%
"Wimp_CloseWindow",,fr%
open(displayh%)
(a%<>ditherit%)
redrawwindow(displayh%)
25,26
H!a%=
textuntil(chw%!876,33))
iconh%=25
a%-=1
a%+=1
a%<0
a%=0
a%>9999
a%=9999
$(chw%!876)=
forceredraw(choicesh%,24)
"Wimp_GetCaretPosition",,fr%
!fr%=choicesh%
placecaretinicon(choicesh%,24,-2)
Dithering Method menu button
"Wimp_GetPointerInfo",,fr%
showmenu(ditheringmethod%,!fr%-16,fr%!4+22)
Full Screen mode menu button
readtick(fullscreenmode%,4)=0
$mbu%=fullmode$
"Wimp_GetPointerInfo",,fr%
showmenu(fullscreenmode%,!fr%-16,fr%!4+22)
40,41
Generalised slider code. Should have an icon with a slabbed
border, unfilled; the twotone slider will be drawn inside it
with a 4 OS unit gap between it and the icon's border. The
4 OS unit gap will be filled in with colour 1 (to obscure any
textures plotted in the window with appropriate patches or OS
versions, as it looks bad if this isn't done).
The routine *single tasks* during the slider drag. The part
that extracts a numerical equivalent of the bar's position
requires barmin% and barmax% to be set to the value the
bar should have when dragged to the far left and far right
respectively (may want to change this if different bars
have different ranges, of course).
Redraw is done by working out the value that the slider
represents and sending this to PROCredrawslider. This ensures
that this procedure never draws a bar in a way that is
different from PROCredrawslider and means that should the
whole bar width represent only a few values, it's movement
will be quantized to certain positions. This looks better
overall, in practice, to smooth movement.
Because PROCredrawslider (which this calls) corrupts both
s% and fr%, it is necessary to use b% for a local redraw
loop - so...
*CORRUPTS b%*
!fr%=choicesh%
fr%!4=iconh%
"Wimp_GetIconState",,fr%
!s%=choicesh%
"Wimp_GetWindowState",,s%
s%!64=fr%!8+s%!4-s%!20
s%!68=fr%!12+s%!16-s%!24
s%!72=fr%!16+s%!4-s%!20
s%!76=fr%!20+s%!16-s%!24
s%!64+8,s%!68+8,s%!72-s%!64-16,s%!76-s%!68-16
c%,c%,a%
e%=s%!72-s%!64-16
d%=c%-s%!64-8
d%<0
d%=0
d%>e%
d%=e%
(d%=barmin%+((barmax%-barmin%)/e%)*d%
!b%=choicesh%
b%!4=fr%!8+4
b%!8=fr%!12+4
b%!12=fr%!16-4
b%!16=fr%!20-4
"Wimp_UpdateWindow",,b%
redrawslider(choicesh%,iconh%,barmin%,barmax%,d%)
"Wimp_GetRectangle",,b%
a%=0
readscreensize(a%,c%)
0,0,a%-1,c%-1
Now set the relevant variable.
iconh%=40
fbl%!16=d%
fbl%!20=d%
saveasclick
iconh%=2
iconh%=3
slab(saveash%,iconh%)
iconh%
makedragbox(saveash%,0,"file_c85")
"Wimp_CreateMenu",,-1
!fr%=saveash%
"Wimp_CloseWindow",,fr%
textuntil(sav%!140,33),".")=0)
textuntil(sav%!140,33),"<")=0)
(1<<30)+3,"To save, drag the file icon to a directory display."
savefile(
textuntil(sav%!140,33))
"Wimp_CreateMenu",,-1
!fr%=saveash%
"Wimp_CloseWindow",,fr%
-- Icon handling procedures
setopt(a%,c%,d%)
getopt(a%,c%)<>d%
!s%=a%
s%!4=c%
"Wimp_GetIconState",,s%
s%!8=0
s%!8=&200000
!s%=a%
s%!4=c%
s%!12=&200000
"Wimp_SetIconState",,s%
slab(a%,c%)
Pass a window and icon handle. Briefly sets that icon
as selected then unselected. With buttons, this will
have the effect of slabbing them in temporarily.
getopt(a%,c%)=
setopt(a%,c%,
setopt(a%,c%,
waitforrelease
storecaret
Gets the current caret position and stores it in lca%, but only if
the caret isn't lost. This allows e.g. a prequit window to be
opened several times in a row and the caret will not be lost, by
storing it after it was lost when the first prequit window got
deleted.
"Wimp_GetCaretPosition",,fr%
!fr%<>-1
"Wimp_GetCaretPosition",,lca%
restorecaret
Puts the caret into a window using information in the lca% block,
checking that lca% holds valid information. Don't forget to
invalidate lca% with !lca%=-1 on Wimp reason code 11 (LoseCaret).
!fr%=!lca%
"XWimp_GetWindowState",,fr%
(a%
1)=0
open(!lca%)
"Wimp_SetCaretPosition",!lca%,lca%!4,lca%!8,lca%!12,lca%!16,lca%!20
placecaretinicon(a%,c%,d%)
Pass window handle, icon handle, index into string. Passing -1 puts the
caret to the Wimp default position (wherever that might be...); passing
-2 puts it to the end of the string in the icon; passing -3 puts it to
the middle.
!fr%=a%
fr%!4=c%
"Wimp_GetIconState",,fr%
!e%=(fr%!12-fr%!20)
&1000000
d%=-2
textuntil(fr%!28,32))
d%=-3
d%=(
textuntil(fr%!28,32)))
"Wimp_GetCaretPosition",,fr%+32
fr%!32<>a%
fr%!36<>c%
fr%!52<>d%
"Wimp_SetCaretPosition",a%,c%,fr%!8+16*d%,fr%!12+8,e%,d%
-- Menu handling procedures
menudata
"SwiftJPEG","Info","Zoom@M","Picture","Full screen...","Reload image","Next image","Choices...@D","Quit","*"
"Picture","Info","Save","*"
"Dithering","No dithering","Fast but inaccurate","Slow but accurate","*"
"Full screen","Use current mode","Best fit to picture","Use biggest","Use most colourful@D","@W","mbu%","64","*"
openmainmenu(a%)
lisareah%=0
greyoutmenu(mainmenuaddr%,5)
ungreymenu(mainmenuaddr%,5)
showmenu(mainmenuaddr%,!b%-116,140+7*44+24)
showmenu(mainmenuaddr%,!b%-116,b%!4+22)
attach(a%,c%,d%)
!(a%+28+c%*24+4)=d%
showmenu(a%,x%,y%)
a%=fullscreenmode%
textuntil(mbu%,32):$mbu%=
*lastmena%=a%:lastmenx%=x%:lastmeny%=y%
"Wimp_CreateMenu",,a%,x%,y%
lastmenh%
a%=fullscreenmode%
$mbu%=a$
settick(a%,c%,d%)
a%!(28+c%*24)=a%!(28+c%*24)
a%!(28+c%*24)=a%!(28+c%*24)
&FFFFFFFE
greyoutmenu(a%,c%)
&/a%!(28+c%*24+8)=(a%!(28+c%*24+8))
(1<<22)
ungreymenu(a%,c%)
*3a%!(28+c%*24+8)=(a%!(28+c%*24+8))
(1<<22))
menuselect
a%,c%,d%,a$
"Wimp_GetPointerInfo",,s%
adju%=(s%!8
"Wimp_DecodeMenu",,lastmena%,b%,s%
$s%
"Info"
"Wimp_GetPointerInfo",,fr%
"Wimp_CreateMenu",,infoh%,!fr%-22,fr%!4-22
"Zoom"
checkzoomfraction
"Wimp_GetPointerInfo",,fr%
showmenu(zoomh%,!fr%-30,fr%!4+36)
"Picture","Picture.Info"
"Wimp_GetPointerInfo",,fr%
"Wimp_CreateMenu",,jpeginfoh%,!fr%-20,fr%!4-20
"Picture.Save"
"Wimp_GetPointerInfo",,fr%
a%=!fr%
c%=fr%!4
!fr%=saveash%
"Wimp_GetWindowState",,fr%
fr%!12=fr%!12-fr%!4+a%-20
fr%!4=a%-20
fr%!8=fr%!8-fr%!16+c%-20
fr%!16=c%-20
fr%!28=-1
"Wimp_OpenWindow",,fr%
"Wimp_GetCaretPosition",,fr%
!fr%<>saveash%
storecaret
placecaretinicon(saveash%,1,-2)
"Full screen..."
showcurrent
"Reload image"
loadpicture(jpegname$)
autofull%
showcurrent
"Next image"
showbatch(autofull%)
"Choices..."
"Wimp_GetCaretPosition",,fr%
!fr%<>choicesh%
storecaret
setupchoices
opencentered(choicesh%)
placecaretinicon(choicesh%,24,-2)
"Quit"
quit%=
"No dithering","Fast but inaccurate","Slow but accurate"
textuntil(chw%!1260,32)<>$s%
a%=0
settick(ditheringmethod%,a%,
settick(ditheringmethod%,!b%,
$(chw%!1260)=$s%
forceredraw(choicesh%,36)
"Best fit to picture","Use biggest","Use most colourful","Use current mode"
textuntil(chw%!1356,32)<>$s%
a%=0
settick(fullscreenmode%,a%,
settick(fullscreenmode%,!b%,
$(chw%!1356)=$s%
forceredraw(choicesh%,39)
(lastmena%=fullscreenmode%)
(!b%=4)
textuntil(mbu%,32)
buildmode(a$,fr%)
a%=-1
$mbu%=fullmode$:
(1<<30)+1,"The specified Full Screen mode is invalid"
a%<>0
"OS_ReadModeVariable",a%-1,4
,,!fr%
"OS_ReadModeVariable",a%-1,5
,,fr%!4
!fr%<>fr%!4
$mbu%=fullmode$:
(1<<30)+1,"You can only use square pixel modes, such as 13 or 20"
fr%!20=-1
"OS_ReadModeVariable",fr%,4
,,fr%!128
"OS_ReadModeVariable",fr%,5
,,fr%!132
fr%!128<>fr%!132
(1<<30)+1,"You can only use square pixel modes, such as 'X800 Y600 C32K'"
&a$="X"+
(fr%!4)+" Y"+
(fr%!8)+" C"
fr%!12
0:a$+="2"
1:a$+="4"
2:a$+="16"
3:a$+="256"
4:a$+="32K"
5:a$+="16M"
fr%!16<>-1
a$+=" F"+
(fr%!16)
a%=0
settick(fullscreenmode%,a%,
settick(fullscreenmode%,4,
$mbu%=a$
(a$)>20
a$,17)+"..."
$(chw%!1356)=a$
forceredraw(choicesh%,39)
adju%
showmenu(lastmena%,lastmenx%,lastmeny%)
-- Full Screen handling procedures
fullscreen(c%)
Plots a picture Full Screen, handling changes *into* the
required mode and gamma changes where appropriate. Single
tasks until the user requests it continue or it times out
(as someone has set up some delay for the slideshow).
Sets abortmul% as TRUE if the user pressed Escape.
Does NOT do anything else - doesn't store the current
Desktop mode, doesn't restore it or prompt for that to
happen... etc - that must all be handled externally.
Pass TRUE if you want an hourglass whilst the display
screen mode is worked out, else FALSE.
a%,d%,e%,x%,y%,x1%,y1%
Read the current gamma values if Compo_ReadGamma is present.
"XOS_SWINumberFromString",,"XCompo_ReadGamma"
cgamread%;a%
(a%
cgamread%=
cgamread%<>0
cgamread%,pgr%,pgg%,pgb%
!fbl%=0
gammanormal
gammablack
fixdzoom%
d%=1:e%=1
d%=zoomm%:e%=zoomd%
x1%=xpic%*d%/e%
y1%=ypic%*d%/e%
"Hourglass_Start",5
fullscrn%
"OS_ReadModeVariable",-1,11
,,x%
"OS_ReadModeVariable",-1,12
,,y%
x%+=1
y%+=1
findbestfit(x1%,y1%,x%,y%,a%)
xbig%=0
modesonc%=0
findbiggest(xbig%,ybig%,bbpp%)
x%=xbig%
y%=ybig%
a%=bbpp%
xclr%=0
modesonc%=0
findcolours(xclr%,yclr%,cbpp%)
x%=xclr%
y%=yclr%
a%=cbpp%
buildmode(fullmode$,fr%)
a%=-1
(1<<30)+1,"The specified Full Screen mode is invalid"
a%=0
"OS_CheckModeValid",fr%
"OS_CheckModeValid",a%-1
!fr%=-1
(1<<30)+1,"The specified Full Screen mode is not available"
a%=0
"OS_ReadModeVariable",fr%,4
,,fr%!128
"OS_ReadModeVariable",fr%,5
,,fr%!132
fr%!128<>fr%!132
(1<<30)+1,"You can only use square pixel modes, such as 'X800 Y600 C32K'"
x%=fr%!4
y%=fr%!8
a%=fr%!12
"OS_ReadModeVariable",a%-1,4
,,!fr%
"OS_ReadModeVariable",a%-1,5
,,fr%!4
!fr%<>fr%!4
(1<<30)+1,"You can only use square pixel modes, such as 13 or 20"
"OS_ReadModeVariable",a%-1,3
,,fr%!12
"OS_ReadModeVariable",a%-1,11
,,fr%!4
"OS_ReadModeVariable",a%-1,12
,,fr%!8
x%=fr%!4+1
y%=fr%!8+1
0a%=-1*(fr%!12=3)-2*(fr%!12=15)-3*(fr%!12=63)
fr%!16=-1
0,0,0,0
0,0,32767
"Hourglass_Off"
Change to the relevant screen mode. A mode selection block
is built, and the mode is changed into if it looks different
to the current one.
fullscrn%<>0
!fr%=1
fr%!4=x%
fr%!8=y%
fr%!12=a%
fullscrn%<>4
fr%!16=-1
fr%!20=-1
<=127
(fr%!4<>!(
fr%!8<>!(
fr%!12<>!(
+12))
((fullscrn%=4)*(fr%!16<>!(
+16)))
"Wimp_SetPalette"
0,0,0,0
0,0,32767
x%=x%-x1%
y%=y%-y1%
!fr%=d%
fr%!4=d%
fr%!8=e%
fr%!12=e%
"XJPEG_PlotScaled",picareab%,x%,y%,fr%,jpegleng%,df%
!fbl%
gammafadeinflatten
gammaflashinbycosine
gammanormal
abortmul%=
"OS_Byte",121
a%=255
a%=112
a%=112
abortmul%=
abortmul%=
"OS_Byte",121
(a%<>255)
>=sldswait%*100)
(sldswait%<>0))
a%=112
abortmul%=
(((a%=11)
(sldswait%<>0))
(a%=37))
(abortmul%=
overlaypausesymbol
a%=37
overlaypictureinfo
waitfornokeys
"OS_Byte",121
(a%<>255)
(a%<>37)
(c%=
a%=112
abortmul%=
ENDIF from check to see if right hand button was pressed when
slideshow delays were turned on, or if 'I' was pressed, and that
in any case abortmul% was FALSE, and if so overlay the pause
symbol and/or the picture info and wait for more keys.
abortmul%=
waitfornokeys
fbl%!4
gammafadeoutbycosine
gammaflashoutlinear
ENDIF from check after fading in to see if abortmul% was set to TRUE
0,0,0,0
0,0,32767
gammanormal
waitforrelease
"XOS_CLI","FX 15"
showbatch(c%)
Pass a flag. If the flag is non-zero, then all the pictures
in the file list (if present) will be shown full screen, one
after another, with all the handling of the display window and
restoration etc. of screen modes handled here (though the
PROCfullscreen procedure handles storing the Desktop mode
ready for an external call to PROCrestoremode).
If the flag is zero, then a picture from the file list (again,
if present) will be loaded and the pointer in the file list
advanced.
The idea is that a user can drag on a group of pictures and
view them in the Desktop, one by one, or all Full Screen.
(lisareah%<>0)
showbatchfull
showbatchdesktop
showbatchfull
See PROCshowbatch for details.
a%,c%,d%,a$
Full screen views of all pictures in file list...
open(choicesh%)
iconh%=13:adju%=0:
choicesclick
open(displayh%)
!dst%=displayh%:
"Wimp_GetWindowState",,dst%:dst%!28=-1
!dst%=-1
returnto%=
mos%!124=returnto%
returnto%>127
a%=0
123
mos%!a%=returnto%!a%
returnto%=mos%
lisareah%<>0
abortmul%=
(lisloadp%>=lisnextp%)
reptpics%
lisloadp%=lisareab%
textuntil(lisloadp%,32)
a%=?(lisloadp%+
(a$))
a%=0
lisloadp%+=
(a$)+1
lisloadp%>=lisnextp%
lisloadp%=lisareab%
removearea(lisareah%)
lisareah%=0
(1<<30)+1,"None of the pictures in the group can be displayed! So can't move to another image"
textuntil(lisloadp%,32)
a%=?(lisloadp%+
(a$))
lisloadp%+=
(a$)+1
(lisloadp%>=lisnextp%)
(reptpics%=0)
removearea(lisareah%):lisareah%=0
a%=0
loadpicture(a$)
fullscreen(d%)
abortmul%
reptpics%
removearea(lisareah%):lisareah%=0
returnto%<>-1
restoremode
abortmul%=
closedis%<>0
!b%=displayh%:
closewindow
!dst%=-1
opencentered(displayh%)
"Wimp_OpenWindow",,dst%
showbatchdesktop
See PROCshowbatch for details.
a%,d%,a$
textuntil(lisloadp%,32)
a%=?(lisloadp%+
(a$))
lisloadp%+=
(a$)+1
lisloadp%>=lisnextp%
removearea(lisareah%):lisareah%=0
a%=0
loadpicture(a$)
showcurrent
Shows the currently loaded picture Full Screen,
handling storing and restoring the Display window
position and restoring the previous Desktop screen
mode.
open(choicesh%)
iconh%=13:adju%=0:
choicesclick
open(displayh%)
!dst%=displayh%:
"Wimp_GetWindowState",,dst%:dst%!28=-1
!dst%=-1
returnto%=
mos%!124=returnto%
returnto%>127
a%=0
123
mos%!a%=returnto%!a%
returnto%=mos%
fullscreen(
restoremode
abortmul%=
closedis%<>0
!b%=displayh%:
closewindow
!dst%=-1
opencentered(displayh%)
"Wimp_OpenWindow",,dst%
findbiggest(
Pass three variables into which will be
passed the x and y sizes of a screen mode,
and it's colour depth (as in a mode selector
block; 0=1 bpp, 1=2bpp, 2=4bpp, 3=8bpp etc).
The routine passes the largest mode, with
the best colour depth available for the
size.
Modes where the y size is bigger than the
x size, or where the y size when doubled is
larger than the x size are not chosen as
these are assumed to be in the first case,
of undesirable aspect ratio and in the
second case, of medium resolution (like
mode 12, 640x256x16 colours).
To avoid stupid resolutions like 320x250,
which for many people will have no advantages
over, say, 320x256 though at least the
latter may have a 100Hz equivalent for those
with monitors that would otherwise letterbox
things, the x and y coordinates must both
be divisible by 4.
a%,d%,e%
"OS_ScreenMode",2
,,d%
e%=0
(-d%)-1
"OS_ScreenMode",2,,e%,,,,b%,64
(b%!8>b%!12)
((b%!12)*2>b%!8)
(b%!8
4=0)
(b%!12
4=0)
(b%!8>=x%)
(b%!12>=y%)
x%=b%!8:y%=b%!12:c%=b%!16
overlaypausesymbol
4,255,255,255
a%=1
64,64,12,24
84,64,12,24
64,64,12,24
84,64,12,24
overlaypictureinfo
0,0,0,0
62,62,270,74
0,255,255,255
64,64,266,70
68,124
16," ")
jpegname$,16)
a$,1)<>" "
a$,1,3)="..."
a$,4)="...."
a$,1)=" "
68,104
16," ")
(xpic%)+"x"+
(ypic%),16)
a$,1)<>" "
16," "):
a$)="Very big picture"
68,86
16," ")
(jpegleng%)+" bytes",16)
a$,1)<>" "
16," "):
a$)="Very large file"
findcolours(
As PROCbiggest, but returns the largest mode
available from the list of those with the
highest colour depth available (e.g. 640x480
by 16.7M with 1Mb VRAM, 800x600 by 16.7M with
2Mb).
a%,d%,e%
"OS_ScreenMode",2
,,d%
e%=0
(-d%)-1
"OS_ScreenMode",2,,e%,,,,b%,64
(b%!8>b%!12)
((b%!12)*2>b%!8)
(b%!8
4=0)
(b%!12
4=0)
(b%!16>=c%)
(b%!8>=x%)
(b%!12>=y%)
x%=b%!8:y%=b%!12:c%=b%!16
findbestfit(x1%,y1%,
Pass an x and y size and three variables as for
PROCbiggest and PROCcolours. This routine returns
the mode which is of greater or equal size to the
x and y coordinates you pass.
If no mode will is big enough, PROCbiggest is called
and those values returned. If it's important, then,
check that the returned x and y sizes really are both
bigger than the passed x and y sizes.
a%,d%,e%,x2%,y2%
"OS_ScreenMode",2
,,d%
K x2%=0
L y2%=0
x%=1E9
y%=1E9
e%=0
(-d%)-1
"OS_ScreenMode",2,,e%,,,,b%,64
(b%!8>b%!12)
((b%!12)*2>b%!8)
(b%!8
4=0)
(b%!12
4=0)
(b%!8>=x1%)
(b%!12>=y1%)
((b%!8-x1%)<=x%)
((b%!12-y1%)<=y%)
x2%=b%!8:y2%=b%!12:x%=x2%-x1%:y%=y2%-y1%:c%=b%!16
x2%=0
findbiggest(x2%,y2%,c%)
x%=x2%
y%=y2%
-- JPEG handling procedures
storefilename
a$,a%,c%
If there was an error flagged by a call to this procedure, listfull% will be
non-zero, so we don't want do do much of the below code.
listfull%=0
If a dynamic area already exists but the flag picsdone% says some pictures have
been loaded (or have been attempted to be loaded) then remove the file list;
apart from anything else if one picture is causing a repeated error and the
user tries to drag on a different one, it would just get appended to the file
list unless this removal was done.
(lisareah%<>0)
(picsdone%<>0)
removearea(lisareah%):lisareah%=0
If no dynamic area exists, create one, set all block pointers to its
base address and set c% to TRUE (see later - if c% is TRUE a message
will be sent back to this task by itself to prompt loading of the
first picture).
lisareah%=0
claimarea(0,lismaxsi%,"SwiftJPEG file list",lisareah%,lisareab%):lisloadp%=lisareab%:lisnextp%=lisareab%:c%=
:picsdone%=0
If there is still no existing area the claim failed, so flag an
appropriate error through listfull%.
lisareah%=0
listfull%=2
If there is no error flagged, get the filename and store it in the
file list dynamic area, extending the area if necessary. If the
extension claim fails, an appropriate error is flagged in listfull%.
listfull%=0
textuntil(b%+44,33)
"OS_ReadDynamicArea",lisareah%
lisnextp%-lisareab%+
(a$)+1>a%
changearea(lisareah%,a%+
(a$)+2,a%)
a%=-1
Memory claim failed - flag an error and if this was the very first
claim (the area is 0 bytes in size) remove the area.
listfull%=1
"OS_ReadDynamicArea",lisareah%
a%=0
removearea(lisareah%):lisareah%=0
If both the dynamic area and any extensions to it have proceeded
without error, store the filename in the area and update the store
pointer.
listfull%=0
$lisnextp%=a$
?(lisnextp%+
(a$))=0
lisnextp%=lisnextp%+
(a$)+1
ENDIF from overall check to see if listfull% was non-zero near the
start ofthis procedure.
Reply to the DataLoad message with a DataLoadAck message, if
!b%<>-1 (this routine might be called without actually
having a real DataLoad message, in which case !b% will be
set to -1).
We want to reply even if the routine fails for some reason
as otherwise multiple copies of SwiftJPEG may end up being
launched.
!b%<>-1
a%=b%!4
b%!4=task%
b%!12=b%!8
b%!16=4
"Wimp_SendMessage",17,b%,a%
If we couldn't even create a dynamic area we don't want to then
prompt the Poll loop to start displaying pictures listed in it! So
give an error (and therefore exit) before the prompt is given (see
below).
listfull%=1
(1<<30)+1,"Not enough memory to load picture, or to queue it for loading later"
listfull%=2
(1<<30)+1,"Can't create an area of memory to store picture names in"
If c% was set to true, the routine had to create a dynamic
area before it could start storing pictures. In this case, we
now want to send one message back to this task so that after
all the DataLoad messages have finished coming in (as they'll
be at the front of the queue) the Poll loop gets another
special message which it interprets as the que to start
displaying the picture(s).
!fr%=-1:
"Wimp_SendMessage",3,fr%,task%
loadpicture(a$)
a%,c%
loaderro%=0
picsdone%=1
filelength(a$)
a%<1
loaderro%=lisloadp%-1:
(1<<30)+1,"File not found"
Check that the file contents indicate a JPEG.
a%>4
openfh%=
c%+=(
#openfh%=&FF)
c%+=(
#openfh%=&D8)
c%+=(
#openfh%=&FF)
c%+=(
#openfh%=&E0)
#openfh%
openfh%=0
c%<>-4
loaderro%=lisloadp%-1:
(1<<30)+1,"This is not a JPEG file"
c%=-4
If you want to allow Reload Image when the image is
still loaded, change the PROCgreyoutmenu line to
grey the item if the filename is <Wimp$Scrap> or
ungrey it (PROCungreymenu) if not.
jpegname$=a$
jpegname$="<Wimp$Scrap>"
greyoutmenu(mainmenuaddr%,4)
ungreymenu(mainmenuaddr%,4)
jpegleng%=a%
filetype(jpegname$))
(autofilt%=1)
"XOS_CLI","SetType "+jpegname$+" C85"
removearea(picareah%)
claimarea(jpegleng%+256,jpegleng%+256,"SwiftJPEG picture",picareah%,picareab%)
picareah%<>0
Load the file - done with OS_Find and OS_GBPB to avoid
potential problems with OS_File and memory access to
dynamic areas on large memory machines (an OS bug).
"Hourglass_On"
"OS_Find",&4F,jpegname$
openfh%
"OS_GBPB",4,openfh%,picareab%,
#openfh%
"OS_Find",,openfh%:openfh%=0
jpegname$="<Wimp$Scrap>"
jpegname$="ScrapFile"
$(sav%!140)=jpegname$
"Hourglass_Off"
Kill scrapfile if it was used.
textuntil(b%+44,33)="<Wimp$Scrap>"
"XOS_File",6,"<Wimp$Scrap>"
open(displayh%)
!fr%=displayh%
"Wimp_CloseWindow",,fr%
resizemainwindow
titlebarchange(displayh%,jpegname$+" ("+
(xpic%)+"x"+
(ypic%)+")")
!fr%=displayh%
"Wimp_GetWindowInfo",,fr%
fr%!4=0
fr%!8=0
fr%!12=&7FFFFFF
fr%!16=&7FFFFFF
"Wimp_OpenWindow",,fr%
opencentered(displayh%)
fillininfo
ELSE from check to see if there was enough memory
to load the file
(1<<30)+1,"There is not enough free memory to load the picture"
ENDIF from check to see if there was enough memory
to load the file.
ENDIF from check to see if the file had the JPEG
filetype (&C85).
resizemainwindow
"OS_ReadModeVariable",-1,4
,,xeig%
"OS_ReadModeVariable",-1,5
,,yeig%
xeig%>0
!sc%=1
sc%!8=xeig%
!sc%=2
sc%!8=1
yeig%>0
sc%!4=1
sc%!12=yeig%
sc%!4=2
sc%!12=1
!sc%=(!sc%)*zoomm%
sc%!4=(sc%!4)*zoomm%
sc%!8=(sc%!8)*zoomd%
sc%!12=(sc%!12)*zoomd%
"XJPEG_Info",,picareab%,jpegleng%
,,xpic%,ypic%,xdpi%,ydpi%
!fr%=0
E$fr%!4=((-ypic%*2)*zoomm%)/zoomd%
F#fr%!8=((xpic%*2)*zoomm%)/zoomd%
fr%!12=0
((fr%!4)
2)<>0
fr%!4=(((fr%!4)
2)-1)*2
((fr%!8)
2)<>0
fr%!8=(((fr%!8)
2)+1)*2
"Wimp_SetExtent",displayh%,fr%
windheig%=-fr%!4
modeinfo(a%)
When passed a screen mode number, this sets the
globals xeig% and yeig% to the number of OS units
per pixel in the x and y directions respectively.
"OS_ReadModeVariable",a%,4
,,xeig%
"OS_ReadModeVariable",a%,5
,,yeig%
xeig%=xeig%*2
yeig%=yeig%*2
fillininfo
(jpegname$)>27
a$="..."+
jpegname$,24)
a$=jpegname$
Line below - If the pathname is >27 characters, then the '...' is put
in front of the last 24. But what happens if those 24, by chance,
start with a '.' of a directory separator? The line below should remove
one dot should the string start with four of them, which indicates
that the used 24 characters did indeed start with a dot.
a$,4)="...."
a$,2)
$(jiw%!108)=a$
(jpegleng%)
(a$)>7
a$=">9.5Mb!"
$(jiw%!236)=a$
(xpic%)
(a$)>6
a$="V.Wide"
$(jiw%!268)=a$
(ypic%)
(a$)>6
a$="V.Tall"
$(jiw%!300)=a$
ungreymenu(mainmenuaddr%,2)
ungreymenu(mainmenuaddr%,3)
savefile(a$)
Pass a full pathname. Saves the JPEG. It is done through OS_Find and OS_GBPB
to prevent any potential problems with OS_File and memory access in dynamic
areas on large memory machines (an OS bug).
"OS_Find",&8F,a$
openfh%
"OS_GBPB",2,openfh%,picareab%,jpegleng%
,,,a%
"OS_Find",,openfh%:openfh%=0
a%<>0
(1<<30)+1,"Unknown error whilst saving - the JPEG has not been saved correctly"
"OS_File",18,a$,&C85
datasave
Call on reception of a DataSave message. Replies with the appropriate
DataSaveAck. Only does this if the window handle isn't SwiftJPEG's
Save box (in which case we assume the user dropped the file back to
abort the save).
b%!20<>saveash%
!b%=60
a%=b%!4
b%!4=task%
b%!12=b%!8
b%!16=2
b%!36=-1
$(b%+44)="<Wimp$Scrap>"+
"Wimp_SendMessage",17,b%,a%
datasaveack
On receipt of a DataSaveAck message, reply with a DataLoad
message, first saving the picture in the path specified
by the message.
savefile(
textuntil((b%+44),33))
b%!12=0
b%!16=3
"Wimp_SendMessage",17,b%,b%!4
dataloadack
On receipt of a DataLoadAck message, the save has been
completed, so write the full pathname (assuming it wasn't
just <Wimp$Scrap>, in which case write 'Untitled') back
into the save box, and update the title bar and jpegname$
variable. Close any menus open, and close the Save As
window (this ensures that wherever the Save As window
came from, it will be closed at this point).
"jpegname$=
textuntil(b%+44,33)
jpegname$="<Wimp$Scrap>"
jpegname$="ScrapFile"
$(sav%!140)=jpegname$
titlebarchange(displayh%,jpegname$+" ("+
(xpic%)+"x"+
(ypic%)+")")
"Wimp_CreateMenu",,-1
!fr%=saveash%
"Wimp_CloseWindow",,fr%
-- Gamma alteration procedures
gammanormal
!fbl%
fbl%!4
a%=0
gar%?a%=pgr%?a%
gag%?a%=pgg%?a%
gab%?a%=pgb%?a%
gammawrite%
gammablack
!fbl%
fbl%!4
a%=0
gar%?a%=0
gag%?a%=0
gab%?a%=0
gammawrite%
gammafadeoutspecial
a%,c%,d%
fbl%!4
c%=fbl%!12
a%=0
d%=a%*c%/(fbl%!12)
gar%?a%=d%
gag%?a%=d%
gab%?a%=d%
gammawrite%
"OS_Byte",121
d%=112
d%=16
c%=-1:
gammablack:
d%=112
abortmul%=
waitfornokeys
gammafadeinflatten
a%,c,d%,d,e%
!fbl%
e%=fbl%!8
d=c/e%
a%=0
gar%?a%=(pgr%?a%)*d
gag%?a%=(pgg%?a%)*d
gab%?a%=(pgb%?a%)*d
gammawrite%
"OS_Byte",121
d%=112
d%=16
c=(fbl%!8)+1:
gammanormal:
d%=112
abortmul%=
c+=(1/c)*(16+(15-c)*(c<15))
waitfornokeys
gammafadeoutbycosine
a%,c%,c,d%,e%
fbl%!4
e%=fbl%!12
c%=0
e%*2
c=(1+
((90/e%)*c%))/2
a%=0
gar%?a%=(pgr%?a%)*c
gag%?a%=(pgg%?a%)*c
gab%?a%=(pgb%?a%)*c
gammawrite%
"OS_Byte",121
d%=112
d%=16
c%=e%*2+1:
gammablack:
d%=112
abortmul%=
waitfornokeys
gammaflashoutlinear
a%,c%,c,d%
fbl%!4
c%=fbl%!12
a%=0
c=c%/(fbl%!12)
gar%?a%=255-(255-pgr%?a%)*c
gag%?a%=255-(255-pgg%?a%)*c
gab%?a%=255-(255-pgb%?a%)*c
gammawrite%
"OS_Byte",121
d%=112
d%=16
c%=-1:
gammablack:
d%=112
abortmul%=
d%<>112
d%<>16
a%=fbl%!12
fbl%!12=16
0,255,255,255
gammafadeoutspecial
fbl%!12=a%
waitfornokeys
gammaflashinbycosine
a%,c%,c,d%
!fbl%
c%=(fbl%!8)*2
- c=(1+
((90/(fbl%!8))*c%))/2
a%=0
gar%?a%=255-(255-pgr%?a%)*c
gag%?a%=255-(255-pgg%?a%)*c
gab%?a%=255-(255-pgb%?a%)*c
gammawrite%
"OS_Byte",121
d%=112
d%=16
c%=-1:
gammanormal:
d%=112
abortmul%=
waitfornokeys
-- Miscellaneous procedures
readscreensize(
a%,c%
"OS_ReadModeVariable",-1,11
,,d%
"OS_ReadModeVariable",-1,12
,,e%
D d%+=1
E e%+=1
"OS_ReadModeVariable",-1,4
,,a%
"OS_ReadModeVariable",-1,5
,,c%
d%=d%<<a%
e%=e%<<c%
compile(a%)
c%,a$
datapntr%=a%
$(datapntr%+c%)=a$
c%+=(
(a$)+1)
a$="*"
$(datapntr%+c%-1)=
(0)+"*"
read(
a%,b$
Z b$=""
a%=?datapntr%
a%>31
b$+=
datapntr%+=1
a%<32
` a$=b$
waitforrelease
a%,c%,d%
"Hourglass_On"
a%,c%,d%
d%=0
"Hourglass_Off"
makedragbox(a%,c%,a$)
Pass a window and icon handle. Calculates the appropriate
drag box and uses DragASprite to initiate a solid drag
(DragASprite will use a dotted outline drag box if the
relevant CMOS RAM bit says solid drags are turned off).
d%,e%
!s%=a%
"Wimp_GetWindowState",,s%
d%=s%!4-s%!20
e%=s%!16-s%!24
!s%=a%
s%!4=c%
"Wimp_GetIconState",,s%
!fr%=a%
fr%!4=5
fr%!8=s%!8+d%
fr%!12=s%!12+e%
fr%!16=s%!16+d%
fr%!20=s%!20+e%
fr%!24=0
fr%!28=0
readscreensize(d%,e%)
fr%!32=d%
fr%!36=e%
"DragASprite_Start",133,1,a$,fr%+8
dragging%=
dragended
On receiving a reason code of 7 from Wimp_Poll, calling this procedure
will send a DataSave message to whatever the pointer was over.
"Wimp_GetPointerInfo",,s%
dragging%=
(s%!12<>saveash%)
textuntil(sav%!140,33)+
a$,".")
a$,".")+1)
a$,".")=0
(a$)
4)<>0
!fr%=44+
fr%!4=task%
fr%!8=0
fr%!12=0
fr%!16=1
fr%!20=s%!12
fr%!24=s%!16
fr%!28=!s%
fr%!32=s%!4
fr%!36=30178
fr%!40=&C85
$(fr%+44)=a$
"Wimp_SendMessage",17,fr%,s%!12,s%!16
dividezoom(
Designed to take a 'Zoom box'-style pair
of numbers (e.g. 1,1 as in 1:1 or 2,1 as
in 2:1) and divide them down to the lowest
possible number; i.e., 4:2 would become
2:1 but 8:3 would stay 8:3. Nothing really
more than aesthetics within the zoom box,
but worth it all in all.
So pass the two variables holding the
numbers from the zoom box; the divided
form is returned in the two variables.
d%,e%
d%=a%
e%=c%
d%<e%
d%,e%
d%=d%
d%=0
a%=a%
c%=c%
checkzoomfraction
Looks in the zoom box and ensures the numbers
within have been divided down as far as possible
(see PROCdividezoom). Intended to be run before
the zoom box is opened, for example by use of a
MenuWarning message.
a%,c%
textuntil(zow%!172,33))
textuntil(zow%!236,33))
dividezoom(a%,c%)
$(zow%!172)=
(a%):zoomm%=a%
$(zow%!236)=
(c%):zoomd%=c%
waitfornokeys
"XOS_CLI","FX 15"
"Hourglass_On"
"OS_Byte",121
(a%=255)
"Hourglass_Off"
-- Memory Management
claimarea(a%,f%,a$,
Pass the current and maxium size and name of the area, and
two variables into which the area handle and base address
are returned.
Creates a Dynamic Area of the requested minimum size, or
returns with 0 as the area handle and -1 as the base address
if the claim fails.
"XOS_DynamicArea",,-1,a%,-1,%10000000,f%,,,a$
,c%,,d%;e%
d%=-1
"XOS_ReadDynamicArea",c%
e%<a%
removearea(c%):c%=0:d%=-1
removearea(a%)
Pass a Dynamic Area handle.
Removes the specified Dynamic Area, provided the handle was non-zero.
You *should usually set the handle to zero after calling this
procedure*, to flag it as closed.
a%<>0
"XOS_DynamicArea",1,a%
changearea(a%,c%,
Pass an area handle and size and a variable for a returned value. Sets
the specified area to the specified size, returning the actual
claimed size (it will be rounded to a page boundary) if the claim
results in an area bigger than or equal to the amount specified, or
returns -1 if the claim fails. This can be used to extend or shrink
an area.
"XOS_ReadDynamicArea",a%
"XOS_ChangeDynamicArea",a%,c%-e%
"XOS_ReadDynamicArea",a%
e%<c%
d%=-1
d%=e%
-- General WIMP functions
error
gammanormal
"Hourglass_Smash"
closeopenfiles
restoremode
listfull%=0
picareah%=0
displayh%<>-1
open(displayh%)
!fr%=displayh%:
"Wimp_CloseWindow",,fr%
picareah%<>0
closedis%
!b%=displayh%:
closewindow
(loaderro%<>0)
(lisareah%<>0)
loaderro%<lisareab%
exit:
"WARNING!"'loaderro%:
?loaderro%=1
2 !b%=
allfatal%=
!b%=(1<<30)+2
!b%
(1<<30)+1
a$="Warning from SwiftJPEG"
9-$(b%+4)=
$+". Click OK to continue."+
: a%=17
(1<<30)+2
<#a$="Fatal error from SwiftJPEG"
=_$(b%+4)=
$+" (encountered at line "+
+"). SwiftJPEG must quit; click CANCEL to exit."+
> a%=18
(1<<30)+3
@#a$="Information from SwiftJPEG"
$(b%+4)=
B a%=17
a$="Error from SwiftJPEG"
$)<200
$(b%+4)=
$+" at line "+
)+": click OK to continue, CANCEL to quit program"+
$(b%+4)=
F a%=19
"Wimp_ReportError",b%,a%,a$
a%=(a%=2)
-- Icon handling functions
getopt(a%,c%)
!fr%=a%:fr%!4=c%
"Wimp_GetIconState",,fr%
=((fr%!24)
(1<<21))<>0
-- Menu handling functions
makemenu(x%,y%,e%)
Before calling there must be two blocks to hold menu data
and menu indirected data, called m% and mi%. You also need
to have a list of DATA statements with the menu items in,
terminated by a '*'. There must also be a block called s%
which will be temporarily used for storing the DATA
statements compiled into a form readable by PROCread.
On calling, pass a pointer to the first free byte in an area
to hold the menu data, and a pointer to the first free byte
for the indirected data. The third thing to pass is flags -
bit 0 of these should be reset or set; if it is set, it
is assumed that the DATA statements should be compiled into
s%. If the bit is unset it is assumed that this has been
done already and this compilation stage is omitted.
Before exiting m% and mi% are both incremented to point to
the first free byte in each block after the new menu data has
been added. This allows successive calls to FNmakemenu with
m% and mi% passed every time as pointers, assuming that the
calls are in order of the relevant DATA statements holding
the menu contents. If you don't want m% and mi% to be changed,
then set bit 1 of the flags. If x%<>m% or y%<>mi%, then m%
or mi% are not changed regardless of this bit - it's only here
to force m% or mi% to be left alone if they were passed as
parameters. (You don't want to increment m% or mi% if m% or
mi% weren't used to hold the menu definition or data!).
The function returns the address of the menu definition (i.e.
the value required by Wimp_CreateMenu).
So for normal use, have a list of DATA statements with, say,
each menu's data on a single line. Call with m% and mi% as
pointers and %01 for the flags repeatedly.
Note that *no* check is made to ensure m% and mi% are not
incremented past the end of any space originally allocated
to them.
a%,c%,d%,f%,a$,b$,c$
(e%
compile(s%)
x%=m%
f%=f%
y%=mi%
f%=f%
a%=x%
read(a$)
$(a%)=a$
a%?12=7
a%?13=2
a%?14=7
a%?15=0
a%!20=44
a%!24=0
(a$)-3
x%+=28
read(c$)
c$<>"*"
x%!8=&07000021
!x%=0
c$,"@")
ul%
(c$)-ul%)
b$,"T")
!x%=!x%
b$,"D")
!x%=!x%
b$,"W")
!x%=!x%
read(a$)
a$="mbu%"
buffer%=mbu%
read(a$)
buflen%=
b$,"M")
!x%=!x%
c$,ul%-1)
c$>d%
x%!4=-1
x%!8=&0700F121
x%!12=buffer%
x%!16=-1
x%!20=buflen%
$buffer%=c$
c$<12
x%!8=&07000021
$(x%+12)=c$
x%!8=&07000121
x%!12=y%
x%!16=-1
x%!20=
$y%=c$
x%+=24
c$="*"
a%!16=d%*16+32
!(x%-24)=!(x%-24)
(e%
2)=0
(f%
m%=x%
(f%
mi%=y%
readtick(a%,c%)
(a%!(28+c%*24))
-- File I/O functions
filetype(a$)
a%,c%,d%
"OS_File",17,a$
c%,,a%
c%<>1
d%=-2
(a%>>>20)=&FFF
d%=(a%>>>8)
&FFF
d%=-1
filelength(a$)
filetype(a$)<>-2
"OS_File",5,a$
,,,,a%
a%=-1
-- Miscellaneous functions
text(c%,d%,f%)
Pass an address, a text string length, and
a threshold. A string is returned of the specified
length minus characters omitted which had an ASCII
code LESS THAN the threshold. That is, pass 32 to
include spaces and anything with higher codes, say.
a%,b$
b$=""
a%=c%
c%+d%-1
?a%>=f%
b$=b$+
(?a%)
textuntil(c%,d%)
Pass an address, and a threshold. A string
is returned of consecutive bytes from the
address. The function exits when a byte LESS
THAN the threshold you specified.
a%,b$
b$=""
a%=c%
?a%>=d%
b$=b$+
(?a%):a%+=1
?a%<d%
b$=255
upper(a$)
Pass a string; returns the same string, all
in upper case characters.
a%,b$
b$=""
a%=1
a$,a%,1)>="a"
a$,a%,1)<="z"
b$+=
a$,a%,1))-32)
b$+=
a$,a%,1)
getword(a%)
Pass a file handle; gets four bytes from the
file handle, and returns their value as a 32-bit
word.
#a%)+((
#a%)<<8)+((
#a%)<<16)+((
#a%)<<24)
buildmode(a$,a%)
Pass a mode identifier string and an address. Builds
an appropriate mode selector block at the address,
returning -1 if there was a problem, 0 if everything
was OK, or a mode number plus one if a mode number was
present (done with 'plus one' so that mode 0 is
possible and not interpreted externally as a sucessful
compilation of a mode string!). So if you get 0, use
the block you passed, if you get >0, use the returned
value minus 1 directly.
Multiple instances of any value are rejected with a
return code of -1.
c%,d%,e%,x%,y%,b$,c$
/ !a%=0
a%!4=-1
a%!8=-1
a%!12=-1
a%!16=-1
e%=a%+20
upper(a$)
a$,",")
a$,","),1)=" "
a$," "))
a$," ")
a$,c%-1)+
a$,c%+1)
(a$))=a$
c%<0
c%=-1
c%+=1
c%<=
Q c%+=1
"XYCGEF",
a$,c%,1))=0)
(c%<=
(a$))
S c%+=1
a$,c%,1)
((b$="E")
"XY",
a$,c%+1,1))<>0))
"XY",b$)<>0)
a$,c%-1,1)<>"E"))
"CGF",b$)<>0)
(c%>
(a$))
"EX EY ",
a$,c%,2)+" ")
a$,c%+2))
a$,c%+1))
a$,c%+1,3)
"X":
a%!4=-1
a%!4=d%
?a%=1
"Y":
a%!8=-1
a%!8=d%
a%?1=1
"C","G"
a%!12=-1
2:a%!12=0
4:a%!12=1
c$="16M"
a%!12=5
a%!12=2
(c$="32K")
(c$="32T")
a%!12=4
256:a%!12=3
(b$="G")
(a%!12>3)
a%!12=-1
!e%=0:e%!4=128:e%!8=3:e%!12=255:e%+=16
a%?2=1
a$,c%+1,1)="X"
!e%=4:x%+=1
d%<0
d%>3
x%+=1
!e%=5:y%+=1
d%<0
d%>3
y%+=1
e%!4=d%
w e%+=8
"F":
a%!16=-1
a%!16=d%
a%?3=1
!e%=-1
(a%!4<1)
(a%!8<1)
(a%!12=-1)
(!a%>0)
(x%>1)
(y%>1)
c%=-1
(a%!4>32767)
(a%!8>32767)
c%=-1
!a%=1