home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / games / mzx / !MZXiface / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1995-02-18  |  6KB  |  259 lines

  1.  MZXiface version 0.01 by Andrew Clover
  2.  Well dang my poons, it's a BASIC program!
  3.  Haven't done one of these for ages!
  4.  0,"Fatal error: "+
  5. $+" (internal code "+
  6. +")."
  7. Xerror_noaddress$="Oh dear, you appear to have forgotten to type an address to poke."
  8. berror_badaddress$="That address cannot be right - Spectrum RAM only goes from 16384 to 65535."
  9.     aerror_novalue$="Erk! You appear to have forgotten to type an value to poke the address with."
  10. Yerror_badvalue$="That value is surely wrong - byte values must be between 0 and 255."
  11. Lerror_notask$="I can hardly hack MZX when you haven't loaded it, can I?"
  12. Nerror_novar$="Sorry, I can't hack this version of MZX, only release 1.10."
  13. icon_action=4
  14. icon_address=5
  15. icon_value=7
  16. indirlen=512
  17. scratchlen=512
  18. taskbuflen=1024
  19. mzxfind$="z80mem%="
  20. mzxtask$="MZX"
  21. taskname$="MZXiface"
  22. pollflags=%1100000110001
  23. message_quit=0
  24. iconflag_selected=21
  25. key_return=73
  26.  poll 256, indir indirlen, scratch scratchlen, taskbuf taskbuflen
  27.  "Wimp_Initialise",200,&4B534154,taskname$ 
  28.  wimpver,tfootle
  29.  "Wimp_OpenTemplate",,"<Obey$Dir>.Templates"
  30. $poll="MZXiface"
  31.  "Wimp_LoadTemplate",,scratch,indir,indir+indirlen,-1,poll,0
  32.  "Wimp_CloseTemplate"
  33.  "Wimp_CreateWindow",,scratch 
  34.  wfootle
  35. !scratch=wfootle
  36.  "Wimp_GetWindowState",,scratch
  37. scratch!28=-1
  38.  "Wimp_OpenWindow",,scratch
  39. mequit=
  40. error(
  41. $+" (internal code "+
  42. )+").",
  43.  "Wimp_Poll",pollflags,poll 
  44.  reason
  45.  reason 
  46. 0'      
  47. redraw_window_request(!poll)
  48. 2$      
  49. open_window_request(poll)
  50. 4%      
  51. close_window_request(poll)
  52.       
  53. mouse_click(poll)
  54.       
  55. key_pressed(poll)
  56.  17,18:
  57.       
  58. user_message(poll)
  59.  mequit
  60.  "Wimp_CloseDown"
  61. error(a,b$,c)
  62.  errornumber, error$, providequit, result, errorflags, errortitle$, extrabuttons$
  63. errornumber=a
  64. error$=b$
  65. providequit=c
  66. !scratch=errornumber
  67. $(scratch+4)=error$+
  68.  providequit 
  69.   errortitle$=taskname$
  70. M+  errortitle$="Warning from "+taskname$
  71.  wimpver<322 
  72.  providequit 
  73. R     errorflags=%000000000011
  74. T     errorflags=%000000010001
  75.  "Wimp_ReportError",scratch,errorflags,errortitle$ 
  76.  ,result
  77.  providequit 
  78. Y     errorflags=%011100000001
  79. Z]    
  80.  "Wimp_ReportError",scratch,errorflags,errortitle$,"!"+taskname$,1,"Quit" 
  81.  ,result
  82. \     errorflags=%010100010001
  83. ]X    
  84.  "Wimp_ReportError",scratch,errorflags,errortitle$,"!"+taskname$,1,0 
  85.  ,result
  86. !scratch=wfootle
  87. scratch!4=icon_action
  88. scratch!8=0
  89. d#scratch!12=1<<iconflag_selected
  90.  "Wimp_SetIconState",,scratch
  91. =(result>1)
  92. redraw_window_request(a)
  93.  footle, more
  94. footle=a
  95. !scratch=footle
  96.  "Wimp_RedrawWindow",,scratch 
  97.  more
  98.  more
  99.  "Wimp_GetRectangle",,scratch 
  100.  more
  101. open_window_request(a)
  102.  block
  103. block=a
  104.  "Wimp_OpenWindow",,block
  105. close_window_request(a)
  106.  block, footle
  107. block=a
  108. footle=!block
  109.  "Wimp_CloseWindow",,block
  110. mequit=(footle=wfootle)
  111. mouse_click(a)
  112.  block, buttons, window, icon
  113. block=a
  114. buttons=block!8
  115. window=block!12
  116. icon=block!16
  117.  window 
  118.  wfootle:
  119.  icon 
  120.       
  121.  icon_action:
  122. !        
  123.  (buttons 
  124.  2)) 
  125.           
  126. pokeloke
  127.         
  128.         
  129. key_pressed(a)
  130.  block, key, window
  131. block=a
  132. key=block!24
  133. window=!block
  134.  window=wfootle 
  135.  key=13 
  136. simulatepokepress
  137.  "Wimp_ProcessKey",key
  138. user_message(a)
  139.  block, message
  140. block=a
  141. message=block!16
  142.  message 
  143.  message_quit: mequit=
  144. simulatepokepress
  145.  keypressed
  146. !scratch=wfootle
  147. scratch!4=icon_action
  148. "scratch!8=1<<iconflag_selected
  149. #scratch!12=1<<iconflag_selected
  150.  "Wimp_SetIconState",,scratch
  151. pokeloke
  152.  "OS_Byte",121,key_return 
  153.  &80 
  154.  ,keypressed
  155.  (keypressed<>&FF 
  156. (0)=13)
  157. !scratch=wfootle
  158. scratch!4=icon_action
  159. scratch!8=0
  160. #scratch!12=1<<iconflag_selected
  161.  "Wimp_SetIconState",,scratch
  162. pokeloke
  163.  icon$, address, value, taskloop, last, ptr, poked
  164. !scratch=wfootle
  165. scratch!4=icon_address
  166.  "Wimp_GetIconState",,scratch
  167. icon$=
  168. getzero(scratch!28)
  169.  icon$="" 
  170. *  address=
  171. error(0,error_noaddress$,
  172. address=
  173. (icon$)
  174.  address<16384 
  175.  address>65535 
  176. +  address=
  177. error(0,error_badaddress$,
  178. !scratch=wfootle
  179. scratch!4=icon_value
  180.  "Wimp_GetIconState",,scratch
  181. icon$=
  182. getzero(scratch!28)
  183.  icon$="" 
  184. &  value=
  185. error(0,error_novalue$,
  186. value=
  187. (icon$)
  188.  value<0 
  189.  value>255 
  190. '  value=
  191. error(0,error_badvalue$,
  192. taskloop=0
  193. poked=
  194.  "TaskManager_EnumerateTasks",taskloop,scratch,scratchlen 
  195.  taskloop,last
  196.  last>scratch 
  197.     ptr=scratch
  198.         
  199. &      
  200. getzero(ptr!4)=mzxtask$ 
  201.         
  202.  ptr!8>0 
  203. +          
  204. poketask(!ptr,address,value)
  205.           poked=
  206.         
  207.       
  208.       ptr+=16
  209.  ptr>=last
  210.     taskloop=-1
  211.  taskloop<0
  212.  poked 
  213. %  poked=
  214. error(0,error_notask$,
  215. getzero(a)
  216.  address, result$
  217. address=a
  218. result$=""
  219.  ?address>32
  220.   result$+=
  221. (?address)
  222.   address+=1
  223. =result$
  224. poketask(a,b,c)
  225.  mzxtask, address, value, mzxbase, loop
  226. mzxtask=a
  227. address=b
  228. value=c
  229. loop=0
  230. mzxbase=0
  231.  "Wimp_TransferBlock",mzxtask,&8F00,tfootle,taskbuf,1024
  232.  mzxbase=0 
  233.  loop<=1024-
  234. (mzxfind$)-10
  235. getlen(taskbuf+loop,
  236. (mzxfind$))=mzxfind$ 
  237. D    
  238.  "OS_ReadUnsigned",10,taskbuf+loop+
  239. (mzxfind$) 
  240.  ,,mzxbase
  241.   loop+=1
  242.  mzxbase=0 
  243. &  mzxbase=
  244. error(0,error_novar$,
  245.   ?taskbuf=value
  246.  "Wimp_TransferBlock",tfootle,taskbuf,mzxtask,mzxbase+address,1
  247. getlen(a,b)
  248.  address, length, result$
  249. address=a
  250. length=b
  251. result$=""
  252.  ?address>32 
  253.  length>0
  254.   result$+=
  255. (?address)
  256.   address+=1
  257.   length-=1
  258. =result$
  259.