home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 4
/
AUCD4.iso
/
utils
/
programing
/
babe
/
!Babe
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1998-03-28
|
15KB
|
610 lines
Babe
David Sharp 1998
Project Commenced: 11/1/98
version$="v0.04 (28/3/1998)"
Qv$="Babe SSEM Emulator by David Sharp (DavidSharp@ThePentagon.com) "+version$
debug%=
Start_Error
infile$=""
outfile$=""
"<Babe$Dir>.emu"
"<Babe$Dir>.asm"
"<Babe$Dir>.WimpLib"
Initialise_Variables
"Wimp_Initialise",200,&4B534154,taskname$
,taskhandle%
Initialise_Program
CheckInitLoad
"Wimp_Poll",poll_mask%,wimp%
reason%
reason%
0 :
Poll_Null
$
2 :
Poll_WindowOpen
%
3 :
Poll_WindowClose
$
6 :
Poll_MouseClick
#
7 :
Poll_DragEnded
"
8 :
Poll_KeyPress
$
9 :
Poll_MenuChoice
"
17,18 :
Poll_Messages
quit%=
************************ Initialise Routines ****************************
these routines are called before the Wimp poll loop begins
Initialise_Variables
variables
*0 taskname$="Babe" :
task name
+> iconsprite$="!babe" :
the main program sprite
,5 quit%=
:
should I quit?
-D poll_mask%=0 :
poll codes not to request
windows opened before
0D opened_field%=
:
has field_Window% been opened
1B dragging%=
:
no drag currently happening
area sizes
4: wimp_length%=10000 :
work area size
5E indr_length%=10000 :
indirected data area size
set up areas
88
wimp% wimp_length% :
setup work area
9C
indr% indr_length% :
setup indirected data area
:9
font_buffer% 256 :
window font area
;I indr_end%=indr%+indr_length% :
End of indirected icons buffer
<8
icon_block% &400 :
icon block area
=>
ret% 256,t% 256,l% 256 :
for FNEVALSysVariable
type$=""
Clear font buffer
I%=0
font_buffer%?I%=0
Wimp_GetScreenVariables
FF SolidDrag% =
_gen_solid_drag :
Is solid drag enabled ??
assembler information
asmopt% 10
J6 asmopt%?0=0 :
convert SB5 to SUB on assembling
K=
obj$(31) :
hold assembled code max 32 lines anyway.
actlin$(31)
M%
read in actline lookup table
x%=0
actlin$(x%)
Q2
binstring% 33 :
buffer for binary string
emulator information
xcycle%=0
mode%=0
X4
code% 5*1024 :
area for assembled code
Y5
sprites% 64*2 :
sprite area for graphics
ZB
"OS_File",16,"<Babe$Dir>.raw",sprites% :
load graphics
\8
data for actline conversion from number 0 to 31
"00000","10000","01000","11000","00100","10100","01100","11100","00010"
"10010","01010","11010","00110","10110","01110","11110","00001","10001"
"01001","11001","00101","10101","01101","11101","00011","10011","01011"
"11011","00111","10111","01111","11111"
_gen_solid_drag
"OS_Byte",161,28
,,A%
=((A%
2)=2)
Initialise_Program
kO iconbar%=
Wimp_CreateIconBar(iconsprite$,-1) :
create bar icon on right
lE
Load_Templates :
load predefined windows from templates
m,
Initialise_Windows :
setup windows
n+
SetUp_Menus :
define menus
Initialise_Emu
Disable
Disable
t+
Wimp_IconDisable(options_Window%,0)
u+
Wimp_IconDisable(options_Window%,1)
v+
Wimp_IconDisable(options_Window%,4)
w+
Wimp_IconDisable(options_Window%,5)
y*
Wimp_IconDisable(notify_Window%,5)
{%
Wimp_MenuDisable(bar_Menu%,2)
|%
Wimp_MenuDisable(bar_Menu%,3)
Load_Templates
"Wimp_OpenTemplate",,"<Babe$Dir>.Templates"
( info_Window%=
Load_Window("info")
( save_Window%=
Load_Window("save")
* savet_Window%=
Load_Window("savet")
, notify_Window%=
Load_Window("notify")
& dis_Window%=
Load_Window("dis")
& asm_Window%=
Load_Window("asm")
. options_Window%=
Load_Window("options")
_Window%=FNLoad_Window("")
"Wimp_CloseTemplate"
Initialise_Windows
set text, sprites and selected etc. for windows
Wimp_IconPutText(info_Window%,3,version$)
Load_Window(window$)
window%
"Wimp_LoadTemplate",,wimp%,indr%,indr_end%,font_buffer%,window$,0
,,indr%
"Wimp_CreateWindow",,wimp%
window%
=window%
SetUp_Menus
iconbar menu
bar_Menu% 28+(4*24)
Wimp_MenuStart("Babe",bar_Menu%,12*18)
Wimp_MenuAddString("Info",info_Window%)
Wimp_MenuAddString("Assembler",-1)
Wimp_MenuAddString("Disassembler",-1)
Wimp_MenuAddString("Options",-1)
Wimp_MenuAddString("Quit",-1)
Wimp_MenuEnd
Wimp_MenuDottedLine(bar_Menu%,1)
Wimp_MenuDottedLine(bar_Menu%,4)
******************************** Miscellaneous ****************************
Start_Error
debug%
"Edit:Throwback"
"XHourglass_Smash"
!
$+" at line "+
************************************* Polling *****************************
all 1st level administration of wimp polling
Poll_Null
Poll_WindowOpen
"Wimp_OpenWindow",,wimp%
Poll_WindowClose
"Wimp_CloseWindow",,wimp%
Poll_MouseClick
buttons%=wimp%!8
window%=wimp%!12
icon%=wimp%!16
mousex%=wimp%!0
mousey%=wimp%!4
buttons%
!
2 :
Poll_OpenMenu
Poll_WindowClick
***** PROCPoll_DragEnded is moved to the 'Dragging' section
Poll_KeyPress
Poll_Messages
sender%=wimp%!4
myref%=wimp%!8
wimp%!16
<
0 : quit%=
:
quit requested
<
1 :
DataSave :
save to window
D
2 :
DataSaveAck :
acknowledge save to me
>
3 :
DataLoad :
load from a file
D
4 :
DataLoadAck :
acknowledge load to me
?
5 :
DataOpen :
double-click file
C
8 : quit%=
:
taskman quit/shutdown
>
&502 :
InteractiveHelp :
interactive help
G
&400CC :
WindowInfo :
handle shift-close of win
***************************** Window Click *******************************
Poll_WindowClick
set click-defining variables
mousex%=wimp%!0
mousey%=wimp%!4
buttons%=wimp%!8
window%=wimp%!12
icon%=wimp%!16
decide next procedure depending on which window was clicked on
window%
'
-2 :
MouseBar
1
notify_Window% :
MouseNotify(icon%)
/
save_Window% :
MouseSave(icon%)
0
savet_Window% :
MouseSaveT(icon%)
MouseBar
buttons%
4 :
Wimp_Notify("Double-click or drag to this icon either an SSEM assembly text file, or an SSEM object code file.")
2
1 :
Wimp_WindowToTop(options_Window%)
MouseNotify(icon%)
wimp%!0=128
wimp%!4=129
wimp%!8=130
wimp%!12=131
wimp%!16=4
wimp%!20=5
wimp%!24=-1
49,wimp%,wimp%
wimp%!0*2*wimp%!16,wimp%!4*2*wimp%!20,wimp%!8*2*wimp%!16,wimp%!12*2*wimp%!20
Wimp_WindowClose(notify_Window%)
MouseSave(icon%)
icon%
;
0 :
buttons%
&50
StartDrag(save_Window%)
B
2 :
SaveObjectCode(
Wimp_IconGetText(save_Window%,1))
MouseSaveT(icon%)
icon%
<
0 :
buttons%
&50
StartDrag(savet_Window%)
E
2 :
SaveAssemblyCode(
Wimp_IconGetText(savet_Window%,1))
InteractiveHelp
WindowInfo
Handles special iconising information (ROS 3 only)
window%=wimp%!20
sprite$=""
window%
7
: text$="Babe":sprite$="babe"
sprite$=""
sprite$="babe" :
*** dummy until proper sprites drawn
! wimp%!0=(36+
(text$)+4)
wimp%!12=myref%
wimp%!16=&400CC
$(wimp%+28)=sprite$+
$(wimp%+36)=text$+
%-
"Wimp_SendMessage",17,wimp%,sender%
&!
Wimp_WindowClose(window%)
iconised%=
****************************** Dragging **********************************
StartDrag(window%)
wimp%!0=window%
window%
0-
save_Window% : savetype$="BAB"
1-
savet_Window% : savetype$="FFF"
3&
"Wimp_GetWindowState",,wimp%
x%=wimp%!4-wimp%!20
y%=wimp%!16-wimp%!24
wimp%!4=0
7$
"Wimp_GetIconState",,wimp%
!wimp%=window%
92 wimp%!4 =5 :
drag type
:% wimp%!8+= x% :
min x
;% wimp%!12+=y% :
min y
<% wimp%!16+=x% :
max x
=% wimp%!20+=y% :
max y
>A
above vars must be in this order because they interelate
wimp%!24=-1
wimp%!28=-1
wimp%!32=&7FFFFFFF
wimp%!36=&7FFFFFFF
SolidDrag%
EO
"DragASprite_Start",%11000101,1,"file_"+savetype$,wimp%+8,wimp%+28
G"
"Wimp_DragBox",,wimp%
Poll_DragEnded
file$
SolidDrag%
"DragASprite_Stop" :
free solid drag workspace
N6 file$=
GetLeafName(
Wimp_IconGetText(window%,1))
"Wimp_GetPointerInfo",,wimp%
P, wimp%!20=wimp%!12 :
window handle
Q* wimp%!24=wimp%!16 :
icon number
R2 wimp%!28=wimp%!0 :
destination x coord
S2 wimp%!32=wimp%!4 :
destination y coord
T@ wimp%!12=0 :
marks original message, not reply
U- wimp%!16=1 :
message action
V= wimp%!36=0 :
estimated size of data (bytes)
W, wimp%!40=
("&"+savetype$) :
filetype
X' $(wimp%+44)=file$ :
leafname
Y6 wimp%!0=60 :
length of message block
"Wimp_SendMessage",18,wimp%,wimp%!20 :
send datasave message
DataSave
^$ type$=
GiveFileType(wimp%!40)
_7 fileleafname$=
Wimp_GetStringAtAddress(wimp%+44)
wimp%!4=myref%
aI
"Wimp_SendMessage",19,wimp%,wimp%!20,wimp%!24
,,dest_thandle%
bH
get destinations file handle, to check not saving into outself!
c%
dest_thandle%<>taskhandle%
d'
type$="FFF"
type$="BAB"
eA $(wimp%+44)="<Wimp$Scrap>" :
filename in Scrap area
f2 wimp%!16=2 :
message number
g3 wimp%!0=256 :
length of block
h0 wimp%!12=myref% :
my reference
i8 wimp%!36=-1 :
'unsafe' file marker
jO
"Wimp_SendMessage",18,wimp%,sender% :
send datasaveack message
DataSaveAck
p/ file$=
Wimp_GetStringAtAddress(wimp%+44)
qL
savetype$="BAB"
SaveObjectCode(file$)
SaveAssemblyCode(file$)
r2
"OS_File",17,file$
obj_type%,,,,fsize%
sA
check that it is a file, not a directory nor application
obj_type%=1
wimp%!16=3
wimp%!0=256
wimp%!12=myref%
wimp%!36=fsize%
yI
"Wimp_SendMessage",17,wimp%,sender% :
send dataload message
{M
if it is a transferred file then don't put Wimp$Scrap in save window
|C
file$<>"<Wimp$Scrap>"
Wimp_IconPutText(window%,1,file$)
DataLoad
/ file$=
Wimp_GetStringAtAddress(wimp%+44)
type$=
~(wimp%!40)
type$="BAB"
type$="FFF"
Load(file$)
A
file$="<Wimp$Scrap>"
("*WIPE "+file$+" F ~V ~C R")
. wimp%!0=256 :
length of block
< wimp%!12=myref% :
my ref from data load message
- wimp%!16=4 :
message number
L
"Wimp_SendMessage",17,wimp%,sender% :
send dataloadack message
\
Wimp_Notify("This filetype if not supported by Babe, &FFF and &BAB only please.")
DataLoadAck
save and load has been successfully completed!
DataOpen
type$=
~(wimp%!40)
/ file$=
Wimp_GetStringAtAddress(wimp%+44)
type$="BAB"
wimp%!12=wimp%!8
1
"Wimp_SendMessage",17,wimp%,wimp%!20
Load(file$)
***************************** Menu Click *********************************
Which menu should be opened on a window click
Poll_OpenMenu
window%
;
Wimp_IconBarMenuPos(bar_Menu%,iconbar%,x%,y%)
,
Wimp_OpenMenu(bar_Menu%,x%,y%)
Which menu has the choice been made from
Poll_MenuChoice
menu%
)
bar_Menu% :
MenuChoiceBar
if adjust used then reopen menu
"Wimp_GetPointerInfo",,wimp%
wimp%!8=1
"Wimp_CreateMenu",,menu%,wimp%!0,wimp%!4
MenuChoiceBar
Menu_ItemNumber(0)
.
2 :
Wimp_WindowToTop(asm_Window%)
.
3 :
Wimp_WindowToTop(dis_Window%)
2
4 :
Wimp_WindowToTop(options_Window%)
5 : quit%=
*************************** file handling ****************************
CheckInitLoad
* file$=
EvalSYSVariable("Babe$File")
file$<>"xxx"
type$="BAB"
LoadObjectCode(file$)
("Set Babe$File xxx")
Load(file$)
type$
*
"BAB" :
LoadObjectCode(file$)
,
"FFF" :
LoadAssemblyCode(file$)
a
Wimp_Notify("This filetype if not supported by Babe, &FFF and &BAB only please.")
LoadObjectCode(file$)
get emu options
mode%=0
Wimp_IconSelected(options_Window%,6)
mode%=1
Wimp_IconSelected(options_Window%,7)
mode%=2
Wimp_IconSelected(options_Window%,8)
mode%=3
Wimp_IconSelected(options_Window%,9)
mode%=4
: xcycle%=
Wimp_IconGetText(options_Window%,10))
oldmode%=
Initialise_Emu
LoadObjectFile(file$)
start
"Press any key to return to the desktop"
key=
MODE oldmode%
SYS "Wimp_ForceRedraw",-1,0,0,&7FFFFFFF,&7FFFFFFF
OSCLI("WIMPMODE "+STR$oldmode%)
*POINTER
"Wimp_SetMode",oldmode%
LoadAssemblyCode(file$)
infile$=file$
Wimp_WindowToTop(save_Window%)
Save(file$)
Wimp_Notify("save type: "+savetype$)
SaveAssemblyCode(file$)
B=
(file$)
("SETTYPE "+file$+" FFF")
SaveObjectCode(outfile$)
Wimp_IconSelected(options_Window%,11)
log%=1
log%=0
Assembler(infile$,outfile$)