home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / hearsay / !Hearsay / Libraries / NewsBase (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1996-12-17  |  25KB  |  915 lines

  1.  > NewsBase library
  2.  Chris Rutter, 1995
  3. broadcast_startup_message
  4. ael("broadcast_startup_message")
  5.  debugmode% 
  6. debug_message("Broadcasting NewsBase startup message...")
  7. mpad(0)
  8. wbk2%!16=&feed10
  9. wbk2%!20=0
  10. wbk2%!24=0.54*100
  11.  "Wimp_SendMessage",17,wbk2%,0
  12. mpad(0)
  13. wbk2%!16=NewsBase_Command%
  14. wbk2%!20=0
  15. wbk2%!24=0.54*100
  16.  "Wimp_SendMessage",17,wbk2%,0
  17. broadcast_shutdown_message
  18. ael("broadcast_shutdown_message")
  19.  debugmode% 
  20. debug_message("Sending NewsBase shutdown message...")
  21. mpad(0)
  22. wbk2%!16=NewsBase_Command%
  23. wbk2%!20=10
  24.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  25. Cinitialised_functions%=initialised_functions% 
  26.  (&ffffffff 
  27. newsbase_receivemessage
  28. ael("newsbase_receivemessage")
  29.  debugmode% 
  30. verbose 
  31. debug_message("Incoming newsbase message...["+
  32. (block%!20)+"]")
  33.  newsbase_message%,main%,status%
  34. #'newsbase_message%=block%!20 
  35.  &ffff
  36. $4main%=newsbase_message%-(newsbase_message% 
  37. %#status%=newsbase_message%-main%
  38.  main% 
  39.  0   : 
  40. newsbase_startupreply
  41.  10  : 
  42. newsbase_shutdown
  43.  100 : 
  44. newsbase_loggroup
  45.  200 : 
  46. newsbase_logarticle
  47.  220 : 
  48. newsbase_articlearrived
  49.  400 : 
  50. newsbase_loguser
  51. newsbase_updatemessage
  52. ael("newsbase_updatemessage")
  53.  block%!20 
  54.  debugmode% 
  55. debug_message("Group "+
  56. ct(block%+32)+" created")
  57.  debugmode% 
  58. debug_message("Group "+
  59. ct(block%+32)+" deleted")
  60.  4,5,6
  61.  debugmode% 
  62. debug_message("User added/deleted/modified...")
  63. initialise_userscan
  64. notify(
  65. ct(block%+32))
  66. newsbase_startupreply
  67.  status%=0 
  68.  (initialised_functions% 
  69.  8) <> 342 
  70. D6 initialised_functions%=initialised_functions% 
  71. E  newsbase_version%=block%!24
  72.  newsbase_task%=block%!4
  73.  debugmode% 
  74. debug_message("Newsbase acknowledged startup, version="+
  75. (newsbase_version%/100))
  76. initialise_userscan
  77. change_user("postmaster")
  78. newsbase
  79.  (initialised_functions% 
  80.  8)=8 
  81. newsbase_shutdown
  82. ael("newsbase_shutdown")
  83.  debugmode% 
  84. debug_message("Newsbase is shutting down...")
  85. UCinitialised_functions%=initialised_functions% 
  86.  (&ffffffff 
  87. initialise_userscan
  88. ael("initialise_userscan")
  89.  debugmode% 
  90. debug_message("Scanning for users...")
  91. npad(0)
  92. wbk2%!20=400
  93. wbk2%!24=0
  94. wbk2%!28=wbk2%!24
  95. $(wbk2%+&20)=""
  96.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  97. active_users%=0
  98. users_writeto%=0
  99. users_scanning%=
  100. newsbase_loguser
  101. ael("newsbase_loguser")
  102.  users_scanning% 
  103.  user$
  104.  user$=
  105. ct(block%+&20)
  106.  user$<>"" 
  107.  debugmode% 
  108. debug_message("Received information about user "+user$+", flags="+
  109. hexadecimal(block%!28))
  110.  (users_writeto%+
  111. (user$)+1)>heap_size%(
  112. heap_from_anchor(anchor_users%)) 
  113. pS   
  114.  debugmode% 
  115. debug_message("Not enough space in users heap, increasing...")
  116.  dummy%
  117. resize_heap(
  118. heap_from_anchor(anchor_users%),heap_size%(
  119. heap_from_anchor(anchor_users%))+
  120. (user$)+5)
  121. t.  $((!anchor_users%)+users_writeto%)=user$
  122. u   users_writeto%+=
  123. (user$)+1
  124.   active_users%+=1
  125.  debugmode% 
  126. debug_message("Finished users scan")
  127.   users_scanning%=
  128. enumerate_users
  129.  active_users%>0 
  130.  users_scanning%=
  131. debug_message("")
  132. debug_message("Cached users list:")
  133.  read%,user%
  134.  read%=!anchor_users%
  135.  user%=1 
  136.  active_users%
  137. debug_message(" "+
  138. ct(read%))
  139.   read%+=
  140. ct(read%))+1
  141.  user%
  142. enumerate_newslist
  143.  newslist_groups%>0 
  144.  newslist_scanning%=
  145. debug_message("")
  146. debug_message("Cached newslist:")
  147.  read%,item%
  148.  read%=!anchor_newslist%
  149.  item%=0 
  150.  newslist_groups%-1
  151. debug_message(" "+
  152. ct(read%)+": folding="+
  153. (group_expanded%?item%))
  154.   read%+=
  155. ct(read%))+1
  156.  item%
  157. enumerate_articles
  158.  group%,read%,item%
  159. debug_message("")
  160.  group%=0 
  161.  group_expanded%?group%=2 
  162. debug_message("Group "+
  163. (group%)+" cached article list: ["+
  164. group_received(group%))+" articles]")
  165. )  read%=!(
  166. group_anchor_full(group%))
  167.  item%=1 
  168.  !((!anchor_newslistinfo%)+(group%*24)+8)
  169. debug_message(" "+
  170. ct(read%))
  171.    read%+=
  172. ct(read%))+1
  173.  item%
  174. prepare_usersmenu
  175. ael("prepare_usersmenu")
  176.  debugmode% 
  177. verbose 
  178. debug_message("Preparing menu of users...")
  179.  (initialised_functions% 
  180.  8)=0 
  181. broadcast_startup_message
  182.  active_users%=0
  183.  menu_users%,menu_users_pointer%,user%,user_text%
  184. #menu_users%=!anchor_menu_users%
  185. $menu_users%="Users"
  186. menu_users_longest%=5
  187. menu_users%?12=7
  188. menu_users%?13=2
  189. menu_users%?14=7
  190. menu_users%?15=0
  191. menu_users%!20=44
  192. menu_users%!24=0
  193. &menu_users_pointer%=menu_users%+28
  194. user_text%=0
  195.  active_users%>0 
  196.  user%=1 
  197.  active_users%
  198.   menu_users_pointer%!0=0
  199.  user%=active_users% 
  200.  menu_users_pointer%!0=1<<7
  201.   menu_users_pointer%!4=-1
  202. C  menu_users_pointer%!8=(7<<24) 
  203.  (3<<12) 
  204.  (1<<4) 
  205.  (1<<8)
  206. 8  menu_users_pointer%!12=(!anchor_users%)+user_text%
  207. \  menu_users_pointer%!16=(!anchor_users%)+user_text%+
  208. ct((!anchor_users%)+user_text%))
  209. @  menu_users_pointer%!20=
  210. ct((!anchor_users%)+user_text%))
  211. ct((!anchor_users%)+user_text%))>menu_users_longest% 
  212.  menu_users_longest%=
  213. ct((!anchor_users%)+user_text%))
  214.   menu_users_pointer%+=24
  215. 7  user_text%+=
  216. ct((!anchor_users%)+user_text%))+1
  217.  user%
  218. / menu_users%!16=(menu_users_longest%*16)+14
  219.  menu_users_pointer%!0=1<<7
  220.  menu_users_pointer%!4=-1
  221. C menu_users_pointer%!8=(7<<24) 
  222.  (3<<12) 
  223.  (1<<4) 
  224.  (1<<22)
  225. ) $(menu_users_pointer%+12)="No users"
  226. change_user(user$)
  227. ael("change_user")
  228.  debugmode% 
  229. debug_message("Changing user to "+user$+"...")
  230. npad(0)
  231. wbk2%!20=20
  232. wbk2%!24=0
  233. wbk2%!28=0
  234. $(wbk2%+32)=user$
  235. $(wbk2%+32+
  236. (user$)+1)=""
  237.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  238. set_icon(newspane_window%,newspane_user%,user$)
  239. set_icon(newspane_window%,newspane_status%,"Changed user to "+user$+"...")
  240. current_user$=user$
  241.  (initialised_functions% 
  242.  8)=8 
  243. initiate_newslist_scan
  244. open_window(news_window%)
  245. initiate_newslist_scan
  246. ael("initiate_newslist_scan")
  247.  debugmode% 
  248. debug_message("Scanning for groups...")
  249. npad(0)
  250. wbk2%!20=100
  251. wbk2%!&18=0
  252. $(wbk2%+&20)="*"
  253.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  254. newslist_scanning%=
  255. newslist_writeto%=0
  256. newslist_textwriteto%=0
  257. newslist_groups%=0
  258. #newslist_unread$=
  259. msg("Unread")
  260. set_icon(newspane_window%,newspane_status%,
  261. msg("ReadingGroups"))
  262. newsbase_loggroup
  263.  debugmode% 
  264. ael("newsbase_loggroup")
  265.  group$
  266. group$=
  267. ct(block%+&24)
  268.  newslist_scanning% 
  269.  (block%!24<>0 
  270.  block%!28<>0 
  271.  group$<>"") 
  272.  status%=0 
  273.  debugmode% 
  274. verbose 
  275. debug_message("Received information about group "+group$)
  276.   newslist_groups%+=1
  277.  (newslist_groups% 
  278.  10)=0 
  279. set_icon(newspane_window%,newspane_status%,
  280. msg("ReadingGroups")+" ("+
  281. (newslist_groups%)+" "+
  282. msg("Groups")+")")
  283. check_heap_limits(anchor_newslistinfo%,newslist_groups%*24,60)
  284. check_heap_limits(anchor_newslist%,newslist_writeto%+
  285. (group$)+1,60)
  286. check_heap_limits(anchor_newslisttext%,newslist_textwriteto%+
  287. (group$)+30,30)
  288. 5  $((!anchor_newslist%)+newslist_writeto%)=group$
  289.   $wbk3%=
  290. (block%!32)
  291. h  $((!anchor_newslisttext%)+newslist_textwriteto%)=group$+" ("+(
  292. ct(wbk3%))+" "+newslist_unread$+")"
  293. A  !((!anchor_newslistinfo%)+(newslist_groups%*24))=block%!&18
  294. C  !((!anchor_newslistinfo%)+(newslist_groups%*24)+4)=block%!&1C
  295. C  !((!anchor_newslistinfo%)+(newslist_groups%*24)+8)=block%!&20
  296.  $(block%+36+
  297. ct(wbk3%))+1)="L0" 
  298. <   !((!anchor_newslistinfo%)+(newslist_groups%*24)+12)=0
  299. <   !((!anchor_newslistinfo%)+(newslist_groups%*24)+12)=1
  300. $  newslist_writeto%+=
  301. (group$)+1
  302. P  newslist_textwriteto%+=
  303. (group$)+2+
  304. ct(wbk3%))+1+
  305. (newslist_unread$)+1+1
  306.  debugmode% 
  307. debug_message("Received end of list")
  308. resize_heap(
  309. heap_from_anchor(anchor_groupanchor%),newslist_groups%*16)
  310.   newslist_scanning%=
  311. set_icon(newspane_window%,newspane_status%,
  312. (newslist_groups%)+
  313. msg("GroupsRead"))
  314.    newspane_status_timeout%=
  315. create_newslist_window
  316.  debugmode% 
  317. wipe_news_window
  318. ael("wipe_news_window")
  319.  wbk%
  320. wbk%=wbk2%
  321.  "Wimp_WhichIcon",news_window%,wbk2%,0,0
  322.  !wbk%<>-1
  323.  wbk4%!0=news_window%
  324.  wbk4%!4=!wbk%
  325.  "Wimp_DeleteIcon",,wbk4%
  326.  wbk%+=4
  327. create_newslist_window
  328. set_article_window_extent
  329.  newslist_groups%>0 
  330.  "Wimp_ForceRedraw",news_window%,-1<<29,-1<<29,1<<29,1<<29
  331. expand_group(group%,group$)
  332. ael("expand_group")
  333.  newslist_scanning%) 
  334.  article_scanning%) 
  335.  debugmode% 
  336. debug_message("Expanding group "+group$+"...[{group%}]")
  337. set_newsgroup_subject_cache(group%,
  338. claim_heap_commented(8192,group$+" full subject cache"))
  339. set_newsgroup_display_cache(group%,
  340. claim_heap_commented(8192,group$+" display cache"))
  341. set_newsgroup_newsinfo_cache(group%,
  342. claim_heap_commented(8192,group$+" news info cache"))
  343.  group_expanded%?group%=1
  344.  article_scanning%=
  345.  article_writeto_full%=0
  346.  article_writeto_display%=0
  347. 85 anchor_articles_full%=
  348. group_anchor_full(group%)
  349. 9; anchor_articles_display%=
  350. group_anchor_display(group%)
  351. :5 anchor_articles_info%=
  352. group_anchor_info(group%)
  353.  cached_articles_full%=0
  354.  cached_articles_display%=0
  355.  article_group%=group%
  356. >E article_heap_full%=
  357. heap_from_anchor(
  358. group_anchor_full(group%))
  359. ?K article_heap_display%=
  360. heap_from_anchor(
  361. group_anchor_display(group%))
  362. @E article_heap_info%=
  363. heap_from_anchor(
  364. group_anchor_info(group%))
  365.  article_groupname$=group$
  366. npad(0)
  367.  wbk2%!20=200
  368.  wbk2%!24=0
  369.  wbk2%!28=0
  370.  $(wbk2%+32)=group$
  371.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  372. collapse_group(group%,group$)
  373. ael("collapse_group")
  374.  debugmode% 
  375. debug_message("Collapsing group {group$}...[{group%}]")
  376.  group_expanded%?group%=2 
  377. enumerate_groupanchors
  378.  group_expanded%?group%=0
  379. delete_heap(
  380. heap_from_anchor(
  381. group_anchor_info(group%)))
  382. delete_heap(
  383. heap_from_anchor(
  384. group_anchor_display(group%)))
  385. delete_heap(
  386. heap_from_anchor(
  387. group_anchor_full(group%)))
  388. set_newsgroup_subject_cache(group%,0)
  389. set_newsgroup_display_cache(group%,0)
  390. set_newsgroup_newsinfo_cache(group%,0)
  391. create_newslist_window
  392. compact_heaps
  393.  debugmode% 
  394. debug_message("{error$}.collapse_group: illegal delete request (group={group%},{group$})")
  395. newsbase_logarticle
  396.  debugmode% 
  397. ael("newsbase_logarticle")
  398.  status%<>0 
  399. newsbase_logarticle_end:
  400.  article_scanning% 
  401.  article$
  402. d, !wbk3%=(block%+&20+
  403. ct(block%+32))+1)
  404.  block%!4=!wbk3%
  405.  block%!24<>0 
  406.   article$=
  407. ct(!wbk3%)
  408. h(  block%!0=!anchor_articles_display%
  409. i?  ?((!anchor_articles_display%)+article_writeto_display%)=0
  410. (article_checkpresence%)=0 
  411.  (article_writeto_display%+
  412. (article$)+1)>heap_size%(article_heap_display%) 
  413. resize_heap(article_heap_display%,heap_size%(article_heap_display%)+
  414. (article$)+2048)
  415. nG   $((!anchor_articles_display%)+article_writeto_display%)=article$
  416. o.   article_writeto_display%+=
  417. (article$)+1
  418. p"   cached_articles_display%+=1
  419.  cached_articles_display%*4>heap_size%(article_heap_info%) 
  420. resize_heap(article_heap_info%,cached_articles_display%*4+256)
  421. sJ   !(!anchor_articles_info%+(cached_articles_display%-1)*4)=block%!&18
  422.  (article_writeto_full%+
  423. (article$)+1)>heap_size%(article_heap_full%) 
  424. resize_heap(article_heap_full%,heap_size%(article_heap_full%)+
  425. (article$)+2048)
  426. x@  $((!anchor_articles_full%)+article_writeto_full%)=article$
  427. y*  article_writeto_full%+=
  428. (article$)+1
  429.   cached_articles_full%+=1
  430.  (cached_articles_full% 
  431.  30)=0 
  432. set_icon(newspane_window%,newspane_status%,"<ReceivingArticleList> ({cached_articles_full%} <Articles>)")
  433. newsbase_logarticle_end
  434.  debugmode% 
  435. newsbase_logarticle_end
  436. ael("newsbase_logarticle_end")
  437.  debugmode% 
  438. debug_message("Finished article scan")
  439.  debugmode% 
  440. verbose 
  441. debug_message("article group is {article_group%}")
  442. article_scanning%=
  443. $group_expanded%?article_group%=2
  444. =?((!anchor_articles_display%)+article_writeto_display%)=0
  445. 7?((!anchor_articles_full%)+article_writeto_full%)=0
  446. resize_heap(article_heap_full%,article_writeto_full%+2)
  447. resize_heap(article_heap_display%,article_writeto_display%+2)
  448. resize_heap(article_heap_info%,cached_articles_display%*4)
  449.  cached_articles_full%>0 
  450. set_icon(newspane_window%,newspane_status%,"{cached_articles_full%} <ArticlesRead>")
  451. set_icon(newspane_window%,newspane_status%,"{article_groupname$} <NoArticles>")
  452. newspane_status_timeout%=
  453. J!((!anchor_newslistinfo%)+(article_group%*24)+8)=cached_articles_full%
  454. N!((!anchor_newslistinfo%)+(article_group%*24)+16)=cached_articles_display%
  455.  cached_articles_full%=0 
  456. % group_expanded%?article_group%=0
  457. delete_heap(
  458. heap_from_anchor(
  459. group_anchor_info(article_group%)))
  460. delete_heap(
  461. heap_from_anchor(
  462. group_anchor_display(article_group%)))
  463. delete_heap(
  464. heap_from_anchor(
  465. group_anchor_full(article_group%)))
  466. 4 !((!anchor_groupanchor%)+(article_group%*16))=0
  467. 6 !((!anchor_groupanchor%)+(article_group%*16)+4)=0
  468. 6 !((!anchor_groupanchor%)+(article_group%*16)+8)=0
  469. create_newslist_window
  470. compact_heaps
  471. compile_newsbase_stubs
  472.  code%,pass%
  473. Wanchor_newslist_workspace%=
  474. claim_heap_commented(48,"Newslist displayer workspace")
  475.  code% 1280:memory_needed%+=1280
  476.  pass%=0 
  477. P%=code%
  478. [ Opt     pass%
  479. .stack
  480.   Equd    0
  481. .poll_redraw%
  482.   Str     r13,stack
  483.   Adr     r13,full_stack
  484.   StmFd   r13!,{r0-r12,r14}
  485.   Ldr     r1,wimp_block
  486. !  Swi     "Wimp_RedrawWindow"
  487. .poll_redraw_loop
  488.   Teq     r0,#0
  489.   BEq     poll_redraw_exit
  490.   Ldr     r0,[r1]
  491.   ;Teq     r0,#viewer_window%
  492.   Teq     r0,#1
  493. #  BEq     create_viewer_window%
  494. %  BNe     create_newslist_window%
  495. .poll_redraw_return_point
  496.   Ldr     r1,wimp_block
  497. !  Swi     "Wimp_GetRectangle"
  498.   B       poll_redraw_loop
  499. .poll_redraw_exit
  500.   LdmFd   r13!,{r0-r12,r14}
  501.   Ldr     r13,stack
  502.   Mov     Pc,r14
  503. .create_newslist_window%
  504. "  Ldr     r0,[r1,#24] ;scrolly
  505.   Ldr     r2,[r1,#16] ;maxy
  506. &  Ldr     r3,[r1,#40] ;redraw maxy
  507.   Sub     r2,r2,r0
  508.   Sub     r3,r3,r0
  509. !  Sub     r4,r3,r2 ;max limit
  510. &  Ldr     r2,[r1,#32] ;redraw miny
  511. %  Sub     r3,r3,r2 ;redraw height
  512. %  Sub     r3,r4,r3 ;minimum limit
  513.   Add     r4,r4,#44
  514.   Sub     r3,r3,#44
  515.   Adr     r0,newslist_info
  516.   LdmIa   r0,{r8-r12}
  517.   Ldr     r11,[r11]
  518.   Ldr     r12,[r12]
  519. .newslist_create
  520.    Mov     r6,#0 ;item number
  521.   Sub     r5,r6,#64 ;y
  522. .newslist_create_loop
  523. &  Bl      newslist_get_item_length
  524.   Mov     r7,r0 ;length
  525.   Cmp     r5,r4
  526.   BGt     newslist_plotskip
  527.   Cmp     r5,r3
  528.   BLt     newslist_plotskip
  529.   Str     r10,[r11,#0]
  530.   Mov     r0,#4
  531.   Str     r0,[r11,#4]
  532.   Sub     r0,r5,#44
  533.   Str     r0,[r11,#8]
  534.   Mov     r0,#800
  535.   Str     r0,[r11,#12]
  536.   Str     r5,[r11,#16]
  537.   Ldr     r0,newslist_flags
  538.   Str     r0,[r11,#20]
  539.   Str     r12,[r11,#24]
  540. "  Ldr     r0,newslist_expanded
  541.   LdrB    r1,[r0,r6]
  542.   Teq     r1,#0
  543.   StrEq   r9,[r11,#28]
  544.   AddNe   r0,r9,#8
  545.   StrNe   r0,[r11,#28]
  546. $  BNe     newslist_directorystub
  547.   Str     r7,[r11,#32]
  548.   Add     r1,r11,#4
  549.   Swi     "Wimp_PlotIcon"
  550.   Add     r12,r12,r7
  551.   Sub     r5,r5,#44
  552. .newslist_increment_item
  553.   Add     r6,r6,#1
  554.   Teq     r6,r8
  555. "  BNe     newslist_create_loop
  556. &  B       poll_redraw_return_point
  557. .newslist_plotskip
  558.   Add     r12,r12,r7
  559.   Sub     r5,r5,#44
  560. "  Ldr     r0,newslist_expanded
  561.  ;Sub     r0,r0,#1
  562.   LdrB    r1,[r0,r6]
  563.   Teq     r1,#2
  564. *  BEq     newslist_create_article_list
  565. %  B       newslist_increment_item
  566. .newslist_get_item_length
  567.   Mov     r0,#0
  568. ".newslist_get_item_length_loop
  569.   LdrB    r1,[r12,r0]
  570.   Cmp     r1,#32
  571.   Add     r0,r0,#1
  572.   MovLt   Pc,r14
  573. +  B       newslist_get_item_length_loop
  574. .newslist_directorystub
  575.   Str     r7,[r11,#32]
  576.   Add     r12,r12,r7
  577.   Add     r1,r11,#4
  578.   Swi     "Wimp_PlotIcon"
  579.   Sub     r5,r5,#44
  580. !.newslist_create_article_list
  581.   StmFd   r13!,{r9,r12}
  582. '  Ldr     r12,newslist_groupanchors
  583.   Ldr     r12,[r12]
  584.   Add     r12,r12,r6,Lsl#4
  585.   Ldr     r12,[r12,#4]
  586. 5  Ldr     r12,[r12] ;pointer to strings of titles
  587. "  Adr     r9,newslist_textfile
  588. &.newslist_create_article_list_loop
  589. &  Bl      newslist_get_item_length
  590.   Mov     r7,r0 ;length
  591.   Cmp     r0,#1
  592. 9  BLe     newslist_create_article_list_increment_item
  593.   Cmp     r5,r3
  594. !3  BLt     newslist_create_article_list_plotskip
  595.   Cmp     r5,r4
  596. #3  BGt     newslist_create_article_list_plotskip
  597.   Str     r10,[r11,#0]
  598.   Mov     r0,#44
  599.   Str     r0,[r11,#4]
  600.   Sub     r0,r5,#44
  601.   Str     r0,[r11,#8]
  602.   Mov     r0,#844
  603.   Str     r0,[r11,#12]
  604.   Str     r5,[r11,#16]
  605.   Ldr     r0,newslist_flags
  606.   Str     r0,[r11,#20]
  607.   Str     r12,[r11,#24]
  608.   LdrB    r0,[r12,#0]
  609.   Teq     r0,#
  610. ("R")
  611. 12  BNe     newslist_create_article_list_skip_Re
  612.   LdrB    r0,[r12,#1]
  613.   LdrB    r1,[r12,#2]
  614.   LdrB    r2,[r12,#3]
  615.   Teq     r0,#
  616. ("e")
  617.   TeqEq   r1,#
  618. (":")
  619.   TeqEq   r2,#
  620. (" ")
  621.   AddEq   r0,r12,#4
  622.   StrEq   r0,[r11,#24]
  623. :).newslist_create_article_list_skip_Re
  624.   Str     r9,[r11,#28]
  625.   Str     r7,[r11,#32]
  626.   Add     r1,r11,#4
  627.   Swi     "Wimp_PlotIcon"
  628. ?*.newslist_create_article_list_plotskip
  629.   Sub     r5,r5,#44
  630.   Add     r12,r12,r7
  631. B0.newslist_create_article_list_increment_item
  632.   Cmp     r7,#1
  633. D/  BGt     newslist_create_article_list_loop
  634.   LdmFd   r13!,{r9,r12}
  635. F%  B       newslist_increment_item
  636. .wimp_block
  637.   Equd    block%
  638. .newslist_info
  639.   Equd    0
  640. K   Equd    newslist_directory
  641.   Equd    news_window%
  642. M(  Equd    anchor_newslist_workspace%
  643. N"  Equd    anchor_newslisttext%
  644. .newslist_flags
  645. PC  Equd    1 
  646.  (1<<4) 
  647.  (1<<8) 
  648.  (7<<24) 
  649.  (3<<12) 
  650.  (1<<28)
  651. .newslist_minextent
  652.   Equd    -(1<<29)
  653. .newslist_maxextent
  654.   Equd    1<<29
  655. .newslist_groupanchors
  656. V!  Equd    anchor_groupanchor%
  657. .newslist_expanded
  658.   Equd    group_expanded%
  659. .newslist_article_info
  660. Z"  Equd    anchor_newslistinfo%
  661. .newslist_textfile
  662.   Equs    "Ssmall_fff"
  663.   Equb    0
  664.   Align
  665. .newslist_directory
  666.   Equs    "Sgroup"
  667.   Equb    0
  668.   Align
  669.   Equs    "Sgroupopen"
  670.   Equb    0
  671.   Align
  672. fP  Equs    "                                                                "
  673. gP  Equs    "                                                                "
  674. hP  Equs    "                                                                "
  675. iP  Equs    "                                                                "
  676. jP  Equs    "                                                                "
  677. kP  Equs    "                                                                "
  678.   Align
  679. .full_stack
  680. .article_checkpresence%
  681.   StmFd   r13!,{r14}
  682.   Ldr     r0,wimp_block
  683.   Ldr     r10,[r0,#0] ;heap
  684. s)  Ldr     r11,[r0,#4] ;string to test
  685. .article_checkpresence_loop
  686.   Bl      article_teq
  687.   Teq     r0,#1
  688.   BEq     article_found
  689.   Bl      article_length
  690.   Add     r10,r10,r1
  691.   LdrB    r0,[r10]
  692.   Cmp     r0,#32
  693. |(  BGe     article_checkpresence_loop
  694.   Ldr     r0,wimp_block
  695.   Mov     r1,#0
  696.   Str     r1,[r0]
  697.   Mov     r0,#0
  698.   LdmFd   r13!,{Pc}
  699. .article_found
  700.   Ldr     r0,wimp_block
  701.   Str     r10,[r0]
  702.   Mov     r0,#1
  703.   LdmFd   r13!,{Pc}
  704. .article_teq
  705.   Mov     r9,#0
  706. .article_teq_loop
  707.   LdrB    r0,[r10,r9]
  708.   LdrB    r1,[r11,r9]
  709.   Cmp     r0,#32
  710.   MovLt   r0,#0
  711.   Cmp     r1,#32
  712.   MovLt   r1,#0
  713.   Teq     r0,r1
  714.   BNe     article_teq_false
  715.   Add     r9,r9,#1
  716.   Teq     r0,#0
  717.   BNe     article_teq_loop
  718. .article_teq_true
  719.   Mov     r0,#1
  720.   Mov     Pc,r14
  721. .article_teq_false
  722.   LdrB    r0,[r11,#0]
  723.   LdrB    r1,[r11,#1]
  724.   LdrB    r2,[r11,#2]
  725.   LdrB    r3,[r11,#3]
  726.   Teq     r0,#
  727. ("R")
  728.   TeqEq   r1,#
  729. ("e")
  730.   TeqEq   r2,#
  731. (":")
  732.   TeqEq   r3,#
  733. (" ")
  734.   MovNe   r0,#0
  735.   MovNe   Pc,r14
  736.   StmFd   r13!,{r14}
  737.   Add     r11,r11,#4
  738.   Bl      article_teq
  739.   Sub     r11,r11,#4
  740.   LdmFd   r13!,{Pc}
  741. .article_length
  742.   Mov     r1,#0
  743. .article_length_loop
  744.   LdrB    r0,[r10,r1]
  745.   Add     r1,r1,#1
  746.   Cmp     r0,#32
  747. !  BGe     article_length_loop
  748.   Mov     Pc,r14
  749. .create_viewer_window%
  750.   Adr     r0,viewer_anchor
  751.   Ldr     r0,[r0]
  752. .viewer_anchor
  753.   Equd    viewer_anchor
  754.  pass%
  755. group_anchor_full(group%)
  756. *=!((!anchor_groupanchor%)+(group%*16))
  757. group_anchor_display(group%)
  758. ,=!((!anchor_groupanchor%)+(group%*16)+4)
  759. group_anchor_info(group%)
  760. ,=!((!anchor_groupanchor%)+(group%*16)+8)
  761. group_received(group%)
  762. -=!((!anchor_newslistinfo%)+(group%*24)+8)
  763. group_received_display(group%)
  764. .=!((!anchor_newslistinfo%)+(group%*24)+16)
  765. news_window_click
  766.  group%
  767. !block%=news_window%
  768.  "Wimp_GetWindowState",,block%
  769. *window%=(block%!16-block%!24)-mouse_y%
  770. icon%=(window%-64) 
  771.  debugmode% 
  772. debug_message("Click on news item "+
  773. (icon%))
  774. *group%=
  775. group_from_window_index(icon%)
  776.  group% 
  777.  article%
  778. 0  article%=
  779. article_from_window_index(icon%)
  780. .  group%=
  781. ingroup_from_window_index(icon%)
  782.  button% 
  783.  4 : 
  784. open_article(group%,article%)
  785.  -1 : 
  786.  invalid
  787.  button% 
  788. :    
  789.  article_scanning%) 
  790.  newslist_scanning%) 
  791. $     
  792.  group_expanded%?group% 
  793. H      
  794.  0 : 
  795. expand_group(group%,
  796. ct_text(!anchor_newslist%,group%))
  797. J      
  798.  2 : 
  799. collapse_group(group%,
  800. ct_text(!anchor_newslist%,group%))
  801.      
  802. group_from_window_index(icon%)
  803.  group%,min%,max%,answer%,index%
  804.  group%=0 
  805.  group_expanded%?group%=2 
  806.   min%=index%+1
  807. 1  max%=index%+
  808. group_received_display(group%)
  809.  icon%>=min% 
  810.  icon%<=max% 
  811.  answer%=-2
  812.  icon%=index% 
  813.  answer%=group%
  814.   index%=max%+1
  815.  icon%=index% 
  816.  answer%=group%
  817.   index%+=1
  818.  group%
  819.  answer%>=newslist_groups% 
  820.  answer%=-1
  821.  answer%<-2 
  822.  answer%=-1
  823. =answer%
  824. ingroup_from_window_index(icon%)
  825.  group%,min%,max%,answer%,index%
  826.  group%=0 
  827.  group_expanded%?group%=2 
  828.   min%=index%+1
  829. 1  max%=index%+
  830. group_received_display(group%)
  831.  icon%>=min% 
  832.  icon%<=max% 
  833.  answer%=group%
  834.  icon%=index% 
  835.  answer%=group%
  836.   index%=max%+1
  837.  icon%=index% 
  838.  answer%=group%
  839.   index%+=1
  840.  group%
  841.  answer%>=newslist_groups% 
  842.  answer%=-1
  843.  answer%<-2 
  844.  answer%=-1
  845. =answer%
  846. article_from_window_index(icon%)
  847.  group%,min%,max%,answer%,index%
  848. answer%=-1
  849.  group%=0 
  850.  group_expanded%?group%=2 
  851.   min%=index%+1
  852. 1  max%=index%+
  853. group_received_display(group%)
  854.  icon%>=min% 
  855.  icon%<=max% 
  856.    index%=icon%-min%
  857. <   answer%=!((!(
  858. group_anchor_info(group%)))+(index%*4))
  859.  icon%=index% 
  860.  answer%=-1
  861.   index%=max%+1
  862.   index%+=1
  863.  group%
  864. =answer%
  865. articles_in_window
  866.  group%,answer%
  867.  newslist_groups%=0 
  868. answer%=0
  869.  group%=0 
  870.  group_expanded%?group%=2 
  871. )0  answer%+=
  872. group_received_display(group%)+1
  873.  group%<=newslist_groups% 
  874.  answer%+=1
  875.  group%
  876. =answer%
  877. set_article_extent
  878. wbk%!0=0
  879. 2)wbk%!4=-(24+(
  880. articles_in_window*44))
  881. wbk%!8=1040
  882. wbk%!12=0
  883.  "Wimp_SetExtent",news_window%,wbk%
  884. set_article_window_extent
  885. !wbk2%=news_window%
  886. set_article_extent
  887.  "Wimp_GetWindowState",,wbk2%
  888.  "Wimp_OpenWindow",,wbk2%
  889. open_article(group%,article%)
  890.  group$
  891. A-group$=
  892. ct_text(!anchor_newslist%,group%)
  893.  debugmode% 
  894. debug_message("Opening article "+
  895. (article%)+" in group "+group$)
  896. npad(0)
  897. wbk2%!20=220
  898. wbk2%!24=article%
  899. wbk2%!28=0
  900. $(wbk2%+32)=group$
  901. ?(wbk2%+32+
  902. (group$)+1)=0
  903.  "Wimp_SendMessage",17,wbk2%,newsbase_task%
  904. newsbase_articlearrived
  905.  article at block%+32
  906.  status%=0 
  907. viewer_opendocument(
  908. ct(block%+32))
  909. set_newsgroup_subject_cache(group%,anchor%)
  910. U3!((!anchor_groupanchor%)+(group%*16)+0)=anchor%
  911. set_newsgroup_display_cache(group%,anchor%)
  912. Y3!((!anchor_groupanchor%)+(group%*16)+4)=anchor%
  913. set_newsgroup_newsinfo_cache(group%,anchor%)
  914. ]3!((!anchor_groupanchor%)+(group%*16)+8)=anchor%
  915.