home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / commodore-scene-files / Coverdisks / CDU / V4D03.D64 / display.asm < prev    next >
Encoding:
Assembly Source File  |  2019-04-13  |  5.5 KB  |  429 lines

  1. e
  2. _ Program to list lazy greenius assembler programs
  3.  
  4. _ Define a start location
  5.  
  6.     org $1350
  7.  
  8. _ define the storage locations used
  9.  
  10. loadaddr     = $2000
  11. bsout    = $ffd2
  12. po    = $fa
  13. lo        = $fc
  14. en    res 2
  15. ct    res 2
  16. cb    res 2 
  17. savepo    res 2
  18.  
  19. _ Code start
  20. _ input is A=filename length
  21. _          X=filename address low
  22. _          Y=filename address high
  23. _ bank will have been set before this program was called
  24.  
  25.     £ $ffbd        _ set name
  26.     ¥ #0
  27.     ₧ #0
  28.     £ $ff68        _ set bank
  29.     ¥ #0
  30.     ₧ #8
  31.     ƒ #0
  32.     £ $ffba        _ set lfs
  33.     ¥ #0
  34.     ₧ #>loadaddr
  35.     ƒ #<loadaddr
  36.     £ $ffd5        _ load 
  37.     ä error
  38.     ░ en
  39.     ▒ en+1
  40.     ¢ display
  41. error    ¬            _ return error in A
  42.  
  43. _
  44. _ Now we display the screen
  45. _
  46. display    equ *
  47.     ¥ #147
  48.     £ bsout
  49.     ₧ #1
  50.     ¥ #>loadaddr
  51.     » po
  52.     » ct
  53.     ¥ #<loadaddr
  54.     » po+1
  55.     » ct+1
  56.     ƒ #0
  57. dispscr    equ *
  58.     ¥ [po],y
  59.     æ #13
  60.     ê nocheck
  61.     Ö
  62.     Æ #26
  63.     à exitline
  64. nocheck    equ *
  65.     £ outchar
  66.     ÿ po
  67.     ê noinc9
  68.     ÿ po+1
  69. noinc9    equ *
  70.     ¥ po+1        _ assume that there is at least one character
  71.     æ en+1        _ in the file and that en is the position 
  72.     ê dispscr        _ after this character so po could equal en
  73.     ¥ po        _ at some point if we reach the end before
  74.     æ en        _ before the end of the screen
  75.     ê dispscr
  76. exitline    equ *        _ end of file or last CR would mean 26th line          
  77.     ¥ po
  78.     ì
  79.     Ç #1
  80.     » cb
  81.     ¥ po+1
  82.     Ç #0
  83.     » cb+1
  84. _
  85. _ control the input
  86. _
  87. loopkey    equ *
  88.     ₧ #3
  89. loopdel1    equ *
  90.     ƒ #0
  91. loopdel2    equ *
  92.     û
  93.     ê loopdel2
  94.     ò
  95.     ê loopdel1
  96.     ¥ $d4
  97.     æ #83
  98.     à scrdown
  99.     æ #84
  100.     à scrup
  101.     æ #7
  102.     à shift
  103.     æ #41
  104.     à prt
  105.     æ #57
  106.     ê loopkey
  107.     ¥ #0
  108.     ¬
  109. shift    ¥ $d3
  110.     à scrup
  111.     æ #1
  112.     à scrdown
  113.     ê loopkey
  114. prt    ¢ print
  115. scrup    equ *
  116.     ¥ cb+1        _ if cb < en then scroll up
  117.     æ en+1
  118.     à extra3
  119.     ä loopkey
  120.     ¢ scrollup
  121. extra3    ¥ cb
  122.     æ en
  123.     ä loopkey
  124.     ¢ scrollup
  125. _
  126. _ do the scroll down logic
  127. scrdown    equ *        _ if ct > loadaddr then continue
  128.     ¥ ct+1
  129.     æ #<loadaddr
  130.     â loopkey        _ if ct(high) < loadaddr then ct < loadaddr
  131.     à possible        _ if ct(high) = loadaddr then possible
  132.     ä dodown        _ definite
  133. possible  equ *
  134.     ¥ #>loadaddr
  135.     æ ct
  136.     ä loopkey
  137. dodown    equ *
  138.     ¥ #27
  139.     £ bsout
  140.     ¥ #87
  141.     £ bsout        _ scroll the screen down
  142.     ¥ #19        _ home the cursor
  143.     £ bsout
  144. _
  145. _ start of the logic to scan for the previous line
  146. _
  147.     ¥ ct
  148.     ¼
  149.     ½ #2
  150.     » po
  151.     » savepo
  152.     ¥ ct+1
  153.     ½ #0
  154.     » po+1        _ po=ct-2 point past last cr
  155.     » savepo+1        _ save ct-2
  156.     ƒ #0
  157. loopup1    equ *        _ locate the start of the line
  158.     ¥ [po],y
  159.     æ #13        _ have we found a CR
  160.     à fndup1        _ yes so stop
  161.     ö po        _ po=po-1
  162.     ¥ po
  163.     æ #$ff
  164.     ê nodec1
  165.     ö po+1
  166. nodec1    equ *
  167.     ¥ po+1        _ if po <= loadaddr then stop 
  168.     æ #<loadaddr    
  169.     â setstart
  170.     à extra1
  171.     ä loopup1
  172. extra1    equ *
  173.     ¥ po
  174.     æ #>loadaddr
  175.     ä loopup1
  176. setstart  equ *
  177.     ¥ #>loadaddr
  178.     » po
  179.     ¥ #<loadaddr
  180.     » po+1
  181.     ¢ noinc1
  182.  
  183. fndup1    equ *        _ found either the CR or start of text
  184.     ÿ po        _ point to next char if CR found
  185.     ê noinc1        _ if start of text then we would have gone
  186.     ÿ po+1        _ gone past the start by 1 so increment
  187. _
  188. _ if po > ct-2 then all we found was a carriage return on the  last line
  189. _ so don't display anything
  190. _
  191. noinc1    equ *
  192.     ¥ po
  193.     » ct
  194.     ¥ po+1
  195.     » ct+1        _ this will be the new current top
  196.     ¥ savepo+1
  197.     æ po+1
  198.     â leave1
  199.     à extra2
  200.     ¢ disp
  201. extra2    equ *
  202.     ¥ savepo
  203.     æ po
  204.     â leave1
  205. disp     equ *
  206.     ¥ [po],y
  207.     £ outchar
  208.     ¥ po
  209.     æ savepo
  210.     ê incpo
  211.     ¥ po+1
  212.     æ savepo+1
  213.     à leave1
  214. incpo    equ *
  215.     ÿ po
  216.     ê disp
  217.     ÿ po+1
  218.     ê disp
  219. _
  220. _ displayed the line if >40 then we would have had to scroll down twice
  221. _
  222. leave1    equ *
  223. _
  224. _ This logic just looks for the current bottom start of line
  225. _
  226.     ¥ cb
  227.     ¼
  228.     ½ #2
  229.     » po
  230.     ¥ cb+1
  231.     ½ #0
  232.     » po+1        _ po=ct-2 point past last cr
  233.     ƒ #0
  234. loopup2    equ *        _ locate the start of the line
  235.     ¥ [po],y
  236.     æ #13
  237.     à fndup2
  238.     ö po
  239.     ¥ po
  240.     æ #$ff
  241.     ê loopup2
  242.     ö po+1
  243.     ê loopup2
  244. fndup2    equ *
  245.     ÿ po
  246.     ê noinc2
  247.     ÿ po+1
  248. noinc2    equ *
  249.     ¥ po
  250.     » cb
  251.     ¥ po+1
  252.     » cb+1
  253.     ¢ loopkey
  254.  
  255. _
  256. _ here is the logic to scroll up.
  257. _
  258. scrollup    equ *
  259.     ¥ #27
  260.     £ bsout
  261.     ¥ #86
  262.     £ bsout        _ scroll up
  263.     ¥ #19
  264.     £ bsout        _ home cursor
  265.     ₧ #24        _ 24 cursor downs
  266.     ¥ #17
  267. loopcur    equ *
  268.     £ bsout
  269.     ò
  270.     ê loopcur
  271. _
  272. _ here we go...
  273.     ¥ cb
  274.     » po
  275.     ¥ cb+1
  276.     » po+1
  277.     ƒ #0
  278. loopit    equ *
  279.     ¥ [po],y
  280.     æ #13
  281.     à leave4
  282.     £ outchar
  283.     ÿ po
  284.     ê check2
  285.     ÿ po+1
  286. check2    equ *
  287.     ¥ po+1
  288.     æ en+1
  289.     â loopit
  290.     à extra4
  291.     ä leave4
  292. extra4    equ *
  293.     ¥ po
  294.     æ en
  295.     â loopit
  296. leave4    equ *
  297.     ÿ po
  298.     ê noinc4
  299.     ÿ po+1
  300. noinc4    equ *
  301.     ¥ po
  302.     » cb
  303.     ¥ po+1
  304.     » cb+1
  305. _
  306. _ line now displayed so lets locate the current top
  307. _
  308.     ¥ ct
  309.     » po
  310.     ¥ ct+1
  311.     » po+1
  312. loop5    equ *
  313.     ¥ [po],y
  314.     ÿ po
  315.     ê forward
  316.     ÿ po+1
  317. forward    equ *
  318.     æ #13
  319.     ê loop5
  320.     ¥ po
  321.     » ct
  322.     ¥ po+1
  323.     » ct+1
  324.     ¢ loopkey
  325. _
  326. _ Now output characters and convert the tokens
  327. _
  328. outchar    equ *
  329.     ░ savex
  330.     ▒ savey
  331.     æ #128
  332.     ä convert
  333.     £ bsout
  334. exitchar    equ *
  335.     ₧ savex
  336.     ƒ savey
  337.     ¬
  338. convert    equ *
  339.     ¼
  340.     ½ #128
  341.     ▓
  342.     ¥ #>table
  343.     » lo
  344.     ¥ #<table
  345.     » lo+1
  346.     Æ #0
  347.     à outit
  348. loop9    equ *
  349.     ¥ lo
  350.     ì
  351.     Ç #3
  352.     » lo
  353.     ¥ lo+1
  354.     Ç #0
  355.     » lo+1
  356.     ò
  357.     ê loop9
  358. outit    equ *
  359.     ƒ #0
  360. loop8    equ *
  361.     ¥ [lo],y
  362.     £ bsout
  363.     ä exitchar
  364.     Ü
  365.     ô #3
  366.     â loop8
  367.           ì        _ set a good return code
  368.     ¢ exitchar
  369. table     equ *
  370.     db  "adcandaslbccbcsbeqbitbmibnebplbrkbvcbvsclccldcliclvcmpcpxcpy"
  371.     db  "decdexdeyeorincinxinyjmpjsrldaldxldylsrnoporaphaphpplaplprol"
  372.     db  "rorrtirtssbcsecsedseistastxstytaxtaytsxtxatxstya"
  373. savex    res 1
  374. savey    res 1
  375.  
  376. _
  377. _ routine to print from loadaddr to en
  378. _
  379. print    equ *
  380.     ¥ #0        _ set length to zero
  381.     £ $ffbd
  382.     ¥ #1
  383.     ₧ #4
  384.     ƒ #7
  385.     £ $ffba        _ set LFS
  386.     £ $ffc0        _ open the file
  387.     â prtcont1
  388. prterror1    equ *
  389.     ¢ loopkey
  390. prtcont1    equ *
  391.     ₧ #1
  392.     £ $ffc9        _ BSOUT routed the logical file number def
  393.     â prtcont2
  394. prterror2 equ *
  395.     ¥ #1
  396.     £ $ffc3        _ close the LA
  397.     ¢ prterror1
  398. prtcont2  equ *
  399.     ¥ #>loadaddr
  400.     » po
  401.     ¥ #<loadaddr
  402.     » po+1
  403.     ƒ #0
  404. loopprt    equ *
  405.     ¥ po
  406.     æ en
  407.     ê incloop
  408.     ¥ po+1
  409.     æ en+1
  410.     à prtfin
  411. incloop   equ *
  412.     ¥ [po],y
  413.     £ outchar
  414.     ä prtfin
  415.     ¥ $d4
  416.     æ #13        _ s key pressed ?
  417.     à prtfin
  418.     ÿ po
  419.     ê loopprt
  420.     ÿ po+1
  421.     ê loopprt
  422. prtfin    equ *
  423.     £ $ffcc        _ reset the channels
  424.     ¢ prterror2        _ reset bsout and close the file and exit    
  425.  
  426.  
  427. o