home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
s
/
swiftjpeg
/
!SwiftJPEG
/
Resources
/
Source
(
.txt
)
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
RISC OS BBC BASIC V Source
|
1995-11-27
|
29.8 KB
|
1,185 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
closechoices:
restoremode:
"Hourglass_Smash":
exit:
$+" (at line "+
)+")":
choicefh%=0
returnto%=-1
b% 256
!b%=3
b%!4=5
b%!8=&400C1
b%!12=0
"Wimp_Initialise",350,&4B534154,"SwiftJPEG",b%
wimp%,task%
wimp%<350
490,"SwiftJPEG requires RISC OS 3.50 or later to run"
"Hourglass_Start",50
version$="0.07 (27 Nov 95)"
initialisemain
iconbar
"Hourglass_Off"
getp(a$)
a$<>""
!b%=-1
b%!40=
filetype(a$)
$(b%+44)=a$
loadpicture
quit%
-- General WIMP procedures
"XWimp_CloseDown",task%,&4B534154
memusage
"Memory free : ";
"Could decrease slot by: ";(((
4096)*4);"K"
"That would leave free : ";(
)-(((
4096)*4096);" bytes"
"OS_ReadMonotonicTime"
"Wimp_PollIdle",1,b%,a%+10000
reason%
(returnto%<>-1)
(reason%=1)
restoremode
abortmul%=
closedis%=0
!fr%=displayh%
"Wimp_GetWindowInfo",,fr%
fr%!4=0
fr%!8=0
fr%!12=&7FFFFFF
fr%!16=&7FFFFFF
"Wimp_OpenWindow",,fr%
opencentered(displayh%)
reason%=3
!b%=displayh%
reason%
redraw
"Wimp_OpenWindow",,b%
!b%
displayh%
"OS_Byte",121
(a%<>0)
"Wimp_CloseWindow",,b%
setslotsize(basislot%,a%)
greyoutmenu(mainmenuaddr%,2)
greyoutmenu(mainmenuaddr%,3)
a%,c%,d%
(d%
a$=jpegname$
(a$)
a$,a%,1)="."
a$,a%-1):a%=0:c%=
c%<>
a$<>""
"XOS_CLI","Filer_OpenDir "+a$
choicesh%
iconh%=12
adju%=0
setopt(choicesh%,iconh%,
choicesclick
setopt(choicesh%,iconh%,
"Wimp_CloseWindow",,b%
click
keyboard
menuselect
17,18,19:
message
click
windh%=b%!12
iconh%=b%!16
adju%=(b%!8)
menu%=(b%!8)
sele%=(b%!8)
windh%
open(displayh%)
adju%<>0
fullscreen
openmainmenu(
displayh%:
openmainmenu(
zoomh%:
zoomclick
choicesh%:
choicesclick
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
"Wimp_SetCaretPosition",zoomh%,4,b%!8,b%!12,b%!16,
textuntil(!(zow%+236),33))
iconh%=2
"Wimp_CreateMenu",-1
keyzoom
iconh%=4
"Wimp_GetCaretPosition",,fr%
showmenu(topmenu%,topx%,topy%)
"Wimp_SetCaretPosition",!fr%,fr%!4,fr%!8,fr%!12,fr%!16,fr%!20
"Wimp_ProcessKey",b%!24
message
b%!16
0:quit%=
3,5:
loadpicture
&400C1:
open(displayh%)
resizemainwindow
setslotsize(a%,
Pass the absolute slot size you want to set, and a variable
into which the slot size on exit from the procedure
is passed.
c%,d%
Read the size of the Current slot and Free pool. The total
free space is then in d% since the Free pool is the global
free space rather than the Wimp definition which is the
global free space minus the space in the Next slot.
"Wimp_SlotSize",-1,-1
c%,,d%
If the current slot isn't the size requested already, and if the
size of the free memory plus the basic slot is greater than or
equal to the amount we want to claim (i.e., if there is enough free!)
then the memory is claimed.
"Wimp_SlotSize",a%,-1
Now read the Current slot again. This will return either an amount
greater than basislot% in which case the allocation was successful, or
it will return basislot% directly, in which case there was not enough
memory. The error for this is handled by the caller of the procedure.
"Wimp_SlotSize",-1,-1
redraw
"Wimp_RedrawWindow",,b%
SYS "JPEG_PlotScaled",basememo%,b%!4-b%!20,b%!16-windheig%-b%!24,0,jpegleng%,df%
"JPEG_PlotScaled",basememo%,b%!4-b%!20,b%!16-windheig%-b%!24,sc%,jpegleng%,df%
"Wimp_GetRectangle",,b%
forceredraw(a%,c%)
Pass a window and icon handle. Performs a 'true' redraw
of the icon (so it might flicker a bit).
!fr%=a%
fr%!4=c%
"Wimp_GetIconState",,fr%
"Wimp_ForceRedraw",!fr%,fr%!8,fr%!12,fr%!16,fr%!20
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
initialisemain
Initialise fundamental variables and dimension arrays.
quit%=
returnto%=-1
abortmul%=
isp%=1280
ib% 32
s% 1024,fr% 1024
i% isp%,m% 512,mi% 1024
inw% 768,diw% 256,zow% 768,jiw% 512,chw% 1280
mos% 128,sc% 16
Load choices and sprites relevant to current display
resolution.
loadchoices
loadsprites
xbig%, ybig% and bbpp% are eventually set globally to the
x and y size of the largest available screenmode; xclr%,
yclr% AND cbpp% to the most colourful. This can be done
here, or when the actual function is requested (the check
is made to see if xbig% or xclr% are zero, and if so, work
out the biggest or most colourful).
xbig%=0
ybig%=0
bbpp%=0
xclr%=0
yclr%=0
cbpp%=0
modesons%<>0
findbiggest(xbig%,ybig%,bbpp%)
findcolours(xclr%,yclr%,cbpp%)
Find out Current slot size and record it in
basislot% for use by the wimp slot sizing procedure.
"Wimp_SlotSize",-1,-1
basislot%
Now the usual initialisation, loading
templates, making menus, adding submenus
and so on.
templates
zoomm%=1
zoomd%=1
$(!(zow%+172))="1"
$(!(zow%+236))="1"
createmainmenu
attach(mainmenuaddr%,0,infoh%)
attach(mainmenuaddr%,1,zoomh%)
attach(mainmenuaddr%,2,jpeginfoh%)
greyoutmenu(mainmenuaddr%,2)
greyoutmenu(mainmenuaddr%,3)
setopt(choicesh%,2+ditherit%,
fullscrn%>0
setopt(choicesh%,6+fullscrn%,
autofull%<>0
setopt(choicesh%,16,
modesons%<>0
setopt(choicesh%,17,
closedis%<>0
setopt(choicesh%,18,
loadchoices
a%,c%,a$
"XOS_ReadVarVal","SwiftJPEG$Dir",fr%,256
,,a%
a%=0
490,"System variable 'SwiftJPEG$Dir' not defined; ensure you double-click on !SwiftJPEG to run it, and not one of its component files"
W1choipath$=
textuntil(fr%,32),a%)+".!Choices"
choicefh%=
(choipath$)
choicefh%=0
490,"Can't find the !Choices file"
getchoice("Dithering","012",ditherit%)
df%=ditherit%-(ditherit%=2)
getchoice("Full Screen","0123",fullscrn%)
getchoice("Auto Full Screen","01",autofull%)
getchoice("Modes On Startup","01",modesons%)
getchoice("Close Display","01",closedis%)
#choicefh%
choicefh%=0
closechoices
choicefh%<>0
#choicefh%
restoremode
returnto%<>-1
"Wimp_SetMode",returnto%
returnto%=-1
getchoice(b$,a$,
c%,c$
upper(
#choicefh%)=
upper(b$)
(c%=
#choicefh%)
490,"Can't find '"+b$+"' entry in !Choices file"
#choicefh%
a$,c$)=0)
(c$)<>1)
490,b$+" option not understood in !Choices file"
putchoice(a$,a%)
c%,b$
upper(
#choicefh%)
upper(a$)
(c%=
#choicefh%)
490,"Can't find 'Dithering' entry in !Choices file"
#choicefh%,a%+48
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$,
"Wimp_LoadTemplate",,a%,i%,io%+isp%,-1,a$,0
,,i%
a%!64=sprites%
"Wimp_CreateWindow",,a%
templates
"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%)
"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+68
(fr%!32)
&4000000
ypo%-=20
(fr%!32)
&40000000
ypo%+=20
(fr%!32)
&10000000
xpo%-=20
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.
!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.
c$,4)="...."
c$,2)
$(fr%!76)=c$+
redrawtitlebar(a%)
zoomclick
a%,c%
a%=zoomm%
c%=zoomd%
adju%
iconh%
0:iconh%=1
1:iconh%=0
5:iconh%=6
6:iconh%=5
iconh%
*zoomm%=
textuntil(!(zow%+172),33))+1
zoomm%>20
zoomm%=20
textuntil(!(zow%+172),33)<>
(zoomm%)
$(!(zow%+172))=
(zoomm%):
forceredraw(zoomh%,2)
*zoomm%=
textuntil(!(zow%+172),33))-1
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
textuntil(!(zow%+236),33)<>
(zoomd%)
$(!(zow%+236))=
(zoomd%):
forceredraw(zoomh%,4)
"*zoomd%=
textuntil(!(zow%+236),33))-1
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(topmenu%,topx%,topy%)
keyzoom
a%,c%
a%=zoomm%
c%=zoomd%
8(zoomm%=
textuntil(!(zow%+172),33))
9(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%):
forceredraw(zoomh%,2)
zoomd%<>c%
$(!(zow%+236))=
(zoomd%):
forceredraw(zoomh%,4)
a%<>zoomm%
c%<>zoomd%
open(displayh%)
resizemainwindow
!fr%=displayh%
"Wimp_CloseWindow",,fr%
"Wimp_GetWindowState",,fr%
"Wimp_OpenWindow",,fr%
choicesclick
a%,c%,a$
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%,
setopt(choicesh%,iconh%,
'Save'; store the choices *as displayed in the window* -
an 'OK' is needed to make those the current internal
choices.
choicefh%=
(choipath$)
choicefh%=0
490,"Can't find the !Choices file"
getopt(choicesh%,2)
a%=0
getopt(choicesh%,3)
a%=1
getopt(choicesh%,4)
a%=2
putchoice("Dithering",a%)
getopt(choicesh%,7)
a%=1
getopt(choicesh%,8)
a%=2
getopt(choicesh%,9)
a%=3
putchoice("Full Screen",a%)
getopt(choicesh%,16)
a%=1
a%=0
putchoice("Auto Full Screen",a%)
getopt(choicesh%,17)
a%=1
a%=0
putchoice("Modes On Startup",a%)
getopt(choicesh%,18)
a%=1
a%=0
putchoice("Close Display",a%)
#choicefh%
choicefh%=0
'Default' (Accurate dithering and Best Fit for
Full Screen option).
getopt(choicesh%,4)=
getopt(choicesh%,2)
setopt(choicesh%,2,
getopt(choicesh%,3)
setopt(choicesh%,3,
getopt(choicesh%,4)
setopt(choicesh%,4,
setopt(choicesh%,4,
getopt(choicesh%,7)=
getopt(choicesh%,7)
setopt(choicesh%,7,
getopt(choicesh%,8)
setopt(choicesh%,8,
getopt(choicesh%,9)
setopt(choicesh%,9,
setopt(choicesh%,7,
getopt(choicesh%,16)
setopt(choicesh%,16,
getopt(choicesh%,17)
setopt(choicesh%,17,
getopt(choicesh%,18)
setopt(choicesh%,18,
'Cancel'; reset choices to as they were when
the window opened.
getopt(choicesh%,ditherit%+2)=
getopt(choicesh%,2)
setopt(choicesh%,2,
getopt(choicesh%,3)
setopt(choicesh%,3,
getopt(choicesh%,4)
setopt(choicesh%,4,
setopt(choicesh%,ditherit%+2,
fullscrn%>0
getopt(choicesh%,fullscrn%+6)=
getopt(choicesh%,7)
setopt(choicesh%,7,
getopt(choicesh%,8)
setopt(choicesh%,8,
getopt(choicesh%,9)
setopt(choicesh%,9,
setopt(choicesh%,fullscrn%+6,
getopt(choicesh%,7)
setopt(choicesh%,7,
getopt(choicesh%,8)
setopt(choicesh%,8,
getopt(choicesh%,9)
setopt(choicesh%,9,
autofull%=0
getopt(choicesh%,16)
setopt(choicesh%,16,
autofull%=1
getopt(choicesh%,16)=
setopt(choicesh%,16,
modesons%=0
getopt(choicesh%,17)
setopt(choicesh%,17,
modesons%=1
getopt(choicesh%,17)=
setopt(choicesh%,17,
closedis%=0
getopt(choicesh%,18)
setopt(choicesh%,18,
closedis%=1
getopt(choicesh%,18)=
setopt(choicesh%,18,
adju%=0
waitforrelease
!fr%=choicesh%
"Wimp_CloseWindow",,fr%
'OK'; store choices internally and force the display window
to redraw if it is open, if the dithering method has changed.
a%=ditherit%
getopt(choicesh%,2)
ditherit%=0
getopt(choicesh%,3)
ditherit%=1
getopt(choicesh%,4)
ditherit%=2
df%=ditherit%-(ditherit%=2)
fullscrn%=0
getopt(choicesh%,7)
fullscrn%=1
getopt(choicesh%,8)
fullscrn%=2
getopt(choicesh%,9)
fullscrn%=3
getopt(choicesh%,16)
autofull%=1
autofull%=0
getopt(choicesh%,17)
modesons%=1
modesons%=0
getopt(choicesh%,18)
closedis%=1
closedis%=0
waitforrelease
!fr%=choicesh%
"Wimp_CloseWindow",,fr%
open(displayh%)
(a%<>ditherit%)
!fr%=displayh%
"Wimp_GetWindowState",,fr%
"Wimp_CloseWindow",,fr%
"Wimp_OpenWindow",,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%
-- Menu handling procedures
createmainmenu
datapntr%=s%
$s%="SwiftJPEG"
$(s%+10)="Info"
$(s%+15)="Zoom"
$(s%+20)="Picture"
$(s%+28)="Full screen..."
$(s%+43)="Choices...
$(s%+56)="Quit"
$(s%+61)="*"+
(0)+"*"
#mainmenuaddr%=
makemenu(m%,mi%)
openmainmenu(a%)
showmenu(mainmenuaddr%,!b%-116,140+5*44+24)
showmenu(mainmenuaddr%,!b%-116,b%!4+22)
attach(a%,c%,d%)
!(a%+28+c%*24+4)=d%
showmenu(a%,x%,y%)
!topmenu%=a%:topx%=x%:topy%=y%
"Wimp_CreateMenu",,a%,x%,y%
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",,topmenu%,b%,s%
$s%
"Info"
"Wimp_GetPointerInfo",,fr%
"Wimp_CreateMenu",,infoh%,!fr%-22,fr%!4-22
"Zoom"
"Wimp_GetPointerInfo",,fr%
showmenu(zoomh%,!fr%-30,fr%!4+36)
"Picture"
"Wimp_GetPointerInfo",,fr%
"Wimp_CreateMenu",,jpeginfoh%,!fr%-20,fr%!4-20
"Choices..."
opencentered(choicesh%)
"Full screen..."
fullscreen
"Quit"
quit%=
adju%
showmenu(topmenu%,topx%,topy%)
-- Full Screen handling procedures
fullscreen
a%,c%,x%,y%,x1%,y1%
x1%=xpic%*zoomm%/zoomd%
y1%=ypic%*zoomm%/zoomd%
returnto%=-1
returnto%=-1
returnto%=
returnto%>127
a%=0
127
mos%!a%=returnto%!a%
returnto%=mos%
"Hourglass_Start",5
fullscrn%
"OS_ReadModeVariable",-1,11
,,x%
"OS_ReadModeVariable",-1,12
,,y%
X x%+=1
Y y%+=1
findbestfit(x1%,y1%,x%,y%,a%)
xbig%=0
findbiggest(xbig%,ybig%,bbpp%)
x%=xbig%
y%=ybig%
a%=bbpp%
xclr%=0
findcolours(xclr%,yclr%,cbpp%)
x%=xclr%
y%=yclr%
a%=cbpp%
"Wimp_SetColour",7
0,0,32767
"Hourglass_Off"
fullscrn%<>0
!fr%=1
fr%!4=x%
fr%!8=y%
fr%!12=a%
fr%!16=-1
fr%!20=-1
>127
fr%!4<>!(
fr%!8<>!(
fr%!12<>!(
+12)
"Wimp_SetPalette"
"Wimp_SetPalette"
"Wimp_SetColour",7
0,0,32767
x%=x%-x1%
y%=y%-y1%
!fr%=zoomm%
fr%!4=zoomm%
fr%!8=zoomd%
fr%!12=zoomd%
"XJPEG_PlotScaled",basememo%,x%,y%,fr%,jpegleng%,df%
"OS_Byte",121
a%=255
"OS_Byte",121
a%<>255
(a%=112)
(autofull%<>0)
abortmul%=
0,0,32767
"Hourglass_Start",15
d%,d%,a%
a%=0
"XOS_CLI","FX 15"
"Hourglass_Off"
Force a redraw of the display window. Even if it's subsequently
closed before we get back to polling, this will force just one
return from the Wimp with reason code 1. If you don't do this,
then since Wimp_PollIdle is used, the polling code doesn't get
called for ages, and the Desktop screen mode isn't returned to.
Yes, I know, it's a horrible kludge. Well, sort of; it isn't
that bad really, and the benefits of Wimp_PollIdle outweigh
this little stumbling block...
!fr%=displayh%
"Wimp_GetWindowState",,fr%
"Wimp_CloseWindow",,fr%
"Wimp_OpenWindow",,fr%
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
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%
"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%
x2%=0
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%
-- Miscellaneous procedures
readscreensize(
a%,c%
"OS_ReadModeVariable",-1,11
,,d%
"OS_ReadModeVariable",-1,12
,,e%
# d%+=1
$ e%+=1
"OS_ReadModeVariable",-1,4
,,a%
"OS_ReadModeVariable",-1,5
,,c%
d%=d%<<a%
e%=e%<<c%
read(
a%,b$
- b$=""
a%=?datapntr%
a%>31
b$+=
datapntr%+=1
a%<32
3 a$=b$
waitforrelease
a%,c%,d%
"Hourglass_On"
a%,c%,d%
d%=0
"Hourglass_Off"
wait(a%)
a%>0
B 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$
T 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 b$=""
c 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$
o b$=""
a%=1
a$,a%,1)>="a"
a$,a%,1)<="z"
b$+=
a$,a%,1))-32)
b$+=
a$,a%,1)
-- Icon handling functions
getopt(a%,c%)
!fr%=a%:fr%!4=c%
"Wimp_GetIconState",,fr%
=((fr%!24)
(1<<21))<>0
-- Menu handling functions
makemenu(p1%,p2%)
a%,c%,d%,e%,a$,b$,c$
p1%=m%
p2%=mi%
a%=p1%
read(a$)
$(a%)=a$
a%?12=7
a%?13=2
a%?14=7
a%?15=0
a%!20=44
a%!24=0
(a$)-3
p1%+=28
read(c$)
c$<>"*"
p1%!8=&07000021
!p1%=0
ul%
(c$)-ul%)
b$,"T")
!p1%=!p1%
b$,"D")
!p1%=!p1%
b$,"W")
!p1%=!p1%
read(a$)
buffer%=
read(a$)
buflen%=
b$,"M")
!p1%=!p1%
c$,ul%-1)
c$>d%
p1%!4=-1
p1%!8=&0700F121
p1%!12=buffer%
p1%!16=-1
p1%!20=buflen%
$buffer%=c$
c$<12
p1%!8=&07000021
$(p1%+12)=c$
p1%!8=&07000121
p1%!12=p2%
p1%!16=-1
p1%!20=
$p2%=c$
p2%+=
p1%+=24
c$="*"
a%!16=d%*16+32
!(p1%-24)=!(p1%-24)
m%=p1%:mi%=p2%
readtick(a%,c%)
a%!(28+c%*24)=a%!(28+c%*24)
&FFFFFFFE
-- 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
-- JPEG handling procedures
loadpicture
a%,c%
abortmul%=
Only start a load if the file is settyped as a JPEG.
b%!40=&C85
"jpegname$=
textuntil(b%+44,33)
$jpegleng%=
filelength(jpegname$)
Send DataLoadAck message, if !b%<>-1 (in which case
this routine was called because the entire application
was launched from a double-click on a JPEG file, and
there is no DataLoad message to reply to.
!b%<>-1
a%=b%!4
b%!4=task%
b%!12=b%!8
b%!16=4
"Wimp_SendMessage",17,b%,a%
workspce%=256
setslotsize(basislot%+jpegleng%+workspce%,a%)
a%>=basislot%+jpegleng%+workspce%
"Hourglass_On"
basememo%=
sc%=basememo%+jpegleng%+16
"Load "+jpegname$+" "+
~basememo%
titlebarchange(displayh%,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
!fr%=displayh%
"Wimp_GetWindowInfo",,fr%
fr%!4=0
fr%!8=0
fr%!12=&7FFFFFF
fr%!16=&7FFFFFF
"Wimp_OpenWindow",,fr%
opencentered(displayh%)
fillininfo
autofull%<>0
fullscreen
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).
ELSE from check to see if abortmul% was FALSE; if the below
code is executed it was.
Send DataLoadAck if the file was a JPEG, but don't
actually do anything with it.
b%!40=&C85
a%=b%!4
b%!4=task%
b%!12=b%!8
b%!16=4
"Wimp_SendMessage",17,b%,a%
ENDIF from check to see if abortmul% was TRUE or not.
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",,basememo%,jpegleng%
,,xpic%,ypic%,xdpi%,ydpi%,mem%
IF mem%<>0 THEN ERROR 490,"JPEG requires extra workspace to plot - can't allocate it"
!fr%=0
Y$fr%!4=((-ypic%*2)*zoomm%)/zoomd%
Z#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
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)