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

  1. e
  2. _*********************************************************
  3. _*                                                       *
  4. _*       module name :  TAB.ASM                          *
  5. _*                                                       *
  6. _*                Maintenance log                        *
  7. _*                ---------------                        *
  8. _*                                                       *
  9. _*   date      time                     action           *
  10. _*   ----      ----                     ------           *
  11. _* 24/02/89    21:55                initial coding       *
  12. _* 28/03/89    16:25    change location addresses        *
  13. _* 05/04/89    18:30        fix table bug and RTS bit    *
  14. _* 06/04/89    23:00        Move zero page definition    *
  15. _* 29/04/89    9:30       changed the brackets           *
  16. _* 05/05/89    17:40    corrected endadd length bug      *
  17. _* 19/05/89    18:00    added nextloc logic and fixed    *
  18. _*                      locname bug                      *
  19. _* 18/06/89    18:45    remove register area             *
  20. _* 04/07/89    18:45    added ram areas for page 0 & 1   *
  21. _*********************************************************
  22.  
  23.  
  24. _Table Definition
  25.  
  26. flag      = 0                 _ Mode of entry in table
  27. name      = flag + 1            _ Program name
  28. ramprg    = name + maxlen                  _ program ram block ( 0 or 1 )
  29. strtadd   = ramprg + 1            _ program start address
  30. endadd    = strtadd +2            _ program end address
  31. zeroram   = endadd + 2            _ ram of zero page
  32. zerooff   = zeroram + 1            _ address of zero page
  33. oneram    = zerooff + 1            _ ram of page one
  34. oneoff    = oneram + 1            _ address of page one
  35. priority  = oneoff + 1            _ program priority
  36. regsp     = priority + 1                _ Stack pointer
  37. tablen    = regsp + 1
  38.  
  39. _ flag modes 
  40.  
  41. noprog    = 0                _ free entry 
  42. prgnorun  = 1                _ program but not running
  43. prgrun    = 2                _ program running
  44.  
  45.  
  46. _ locations used
  47.  
  48.  
  49. prgname    res 16            _ program name
  50. namelen    db 0                _ name length
  51.  
  52. _ To allow for more programs, you have to increase the amount of reserved
  53. _ area and define an exact table end value as shown below.
  54.  
  55. table     res 256             _ enough for 8 programs
  56. tabend    = table + tablen*8
  57.  
  58. _*********************************************************
  59. _*                                                       *
  60. _*       routine : SETTAB - initialise program table     *
  61. _*                                                       *
  62. _*   entry                                               *
  63. _*   -----                                               *
  64. _*   none                                                *
  65. _*.......................................................*
  66. _*   used                                                *
  67. _*   ----                                                *
  68. _*   A,X                                                 *
  69. _*.......................................................*
  70. _*   exit                                                *
  71. _*   ----                                                *
  72. _*   none                                                *
  73. _*********************************************************
  74.  
  75.  
  76. settab    equ *    
  77.     £ inittab        _ initialise table scan 
  78.  
  79. _ set all flags in table to zero
  80.  
  81.     ƒ #flag
  82. initlop1  equ *
  83.     ¥ #noprog
  84.           » [tabpntr],y
  85.     £ incloc        _ point to next entry
  86.     £ checkend
  87.     â initlop1
  88.     ¬
  89.  
  90.  
  91. _*********************************************************
  92. _*                                                       *
  93. _*       routine : INITTAB - initialise table pointers   *
  94. _*                 to start of the table                 *
  95. _*   entry                                               *
  96. _*   -----                                               *
  97. _*   none                                                *
  98. _*.......................................................*
  99. _*   used                                                *
  100. _*   ----                                                *
  101. _*   A                                                   *
  102. _*.......................................................*
  103. _*   exit                                                *
  104. _*   ----                                                *
  105. _*   TABPNTR                                             *
  106. _*********************************************************
  107.  
  108. inittab    equ *
  109.     ¥ #>table
  110.     » tabpntr
  111.     ¥ #<table
  112.     » tabpntr+1
  113.     ¬
  114.  
  115. _*********************************************************
  116. _*                                                       *
  117. _*       routine : CHECKEND - check for end of table in  *
  118. _*                 table pointers                        *
  119. _*   entry                                               *
  120. _*   -----                                               *
  121. _*   TABPNTR (2 bytes)                                   *
  122. _*.......................................................*
  123. _*   used                                                *
  124. _*   ----                                                *
  125. _*   A                                                   *
  126. _*.......................................................*
  127. _*   exit                                                *
  128. _*   ----                                                *
  129. _*   c   0 = no end, 1 = end                             *
  130. _*********************************************************
  131.                                    
  132.  
  133. checkend  equ *
  134.  
  135.     ¥ tabpntr+1
  136.           æ #<tabend
  137.     â exitchck
  138.     ¥ tabpntr
  139.     æ #>tabend
  140. exitchck  equ *
  141.     ¬
  142.  
  143. _*********************************************************
  144. _*                                                       *
  145. _*       routine : INCLOC - increment the table pointers *
  146. _*                                                       *
  147. _*   entry                                               *
  148. _*   -----                                               *
  149. _*   TABPNTR                                             *
  150. _*.......................................................*
  151. _*   used                                                *
  152. _*   ----                                                *
  153. _*   A                                                   *
  154. _*.......................................................*
  155. _*   exit                                                *
  156. _*   ----                                                *
  157. _*   TABPNTR                                             *
  158. _*********************************************************
  159.                          
  160.  
  161. incloc     equ *
  162.     ¥ tabpntr
  163.     ì
  164.     Ç #tablen
  165.     » tabpntr
  166.     ¥ tabpntr+1
  167.     Ç #0
  168.     » tabpntr+1
  169.     ¬
  170.                              
  171. _*********************************************************
  172. _*                                                       *
  173. _*       routine : LOCNAME - locate an entry in the table*
  174. _*                 based on name                         *
  175. _*   entry                                               *
  176. _*   -----                                               *
  177. _*   PRGNAME - name of program                           *
  178. _*   NAMELEN - length of the name in PRGNAME             *
  179. _*.......................................................*
  180. _*   used                                                *
  181. _*   ----                                                *
  182. _*   A,X,Y                                               *
  183. _*.......................................................*
  184. _*   exit                                                *
  185. _*   ----                                                *
  186. _*   c  0=not found, 1=found                             *
  187. _*********************************************************
  188.                            
  189. locname    equ *
  190.     £ inittab
  191. locloop2    equ *
  192.     ₧ #0
  193.     ƒ #flag        _ see if entry in table.
  194.     ¥ [tabpntr],y
  195.     æ #noprog
  196.     à notit
  197.     ƒ #name
  198. locloop1    equ *
  199.     ¥ [tabpntr],y
  200.     æ prgname,x
  201.     ê notit
  202.     Æ namelen
  203.     ä fndit
  204.     Ü
  205.     Ö
  206.     ê locloop1
  207. fndit    equ *
  208.     ¼            _ c=1 means found it
  209.     ¬
  210.  
  211. notit    equ *
  212.     £ incloc
  213.     £ checkend
  214.     â locloop2
  215.  
  216. notfnd    equ *
  217.     ì            _ c=0, name not found
  218.     ¬
  219.  
  220.                              
  221. _*********************************************************
  222. _*                                                       *
  223. _*       routine : LOCFREE - locate a free entry in the  *
  224. _*                 table                                 *
  225. _*   entry                                               *
  226. _*   -----                                               *
  227. _*   None                                                *
  228. _*.......................................................*
  229. _*   used                                                *
  230. _*   ----                                                *
  231. _*   A,X,Y                                               *
  232. _*.......................................................*
  233. _*   exit                                                *
  234. _*   ----                                                *
  235. _*   c  0=found, 1=not found                             *
  236. _*********************************************************
  237.                            
  238. locfree    equ *
  239.     £ inittab                     
  240.     ƒ #flag
  241. freloop1    equ *
  242.     ¥ [tabpntr],y
  243.     æ #noprog  
  244.     ê notfree                                         
  245.  
  246.     ì            _ c=0 means found it
  247.     ¬
  248.  
  249. notfree    equ *
  250.     £ incloc
  251.     £ checkend
  252.     â freloop1
  253.  
  254.     ¬            _ c=1 here
  255.  
  256.  
  257. _*********************************************************
  258. _*                                                       *
  259. _*       routine : LOCNEXT - locate the next program to  *
  260. _*                 to run. This routine must always an   *
  261. _*                 entry. The routine will loop if       *
  262. _*                 called when no progs are running.     *
  263. _*   entry                                               *
  264. _*   -----                                               *
  265. _*   CURRENT - Current program that was running          *
  266. _*.......................................................*
  267. _*   used                                                *
  268. _*   ----                                                *
  269. _*   A,Y                                                 *
  270. _*.......................................................*
  271. _*   exit                                                *
  272. _*   ----                                                *
  273. _*   CURRENT - next program that will run.               *
  274. _*********************************************************
  275.  
  276.  
  277.  
  278. _ locate the next program to run. This routine must always return
  279. _ an entry. The routine must never be run if no programs are running
  280.  
  281. locnext    equ *
  282.  
  283. _ point to next entry in the table
  284.  
  285.           ¥ current
  286.           ì
  287.           Ç #tablen
  288.           » tabpntr
  289.     ¥ current+1
  290.     Ç #0
  291.     » tabpntr+1
  292.  
  293. loccont    equ *
  294.  
  295.     £ checkend        _ see if we must start at the top again
  296.     â nochange
  297.  
  298. _ point to start of table again
  299.  
  300.     £ inittab   
  301.  
  302. nochange  equ *
  303.  
  304.     ƒ #flag          _ get flag entry and see if program is running
  305.     ¥ [tabpntr],y
  306.     æ #prgrun
  307.     ê notloc
  308.     ¥ tabpntr
  309.     » current
  310.     ¥ tabpntr+1
  311.     » current+1
  312.     ¬
  313.  
  314. notloc    equ *
  315.     £ incloc         _ point to next entry
  316.     ¢ loccont
  317.     
  318.  
  319.  
  320.  
  321.     IEND
  322.  
  323.