Advertisement
acadiel

128K ROM Header

Apr 9th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. * THREE PROGRAM HEADER FOR 128K BANKED
  2. * SWITCHED CART
  3. * 2010-2014 hexbus.com, Stuart, and Tursi, please feel free to use and adapt as long as you leave this line in.
  4. DEF SFIRST,SLAST,SLOAD
  5. UNL
  6.  
  7. * ROM HEADER
  8. AORG >6000
  9.  
  10. SFIRST EQU $
  11. SLOAD EQU $
  12.  
  13. GRMHDR BYTE >AA,1,1,0,0,0
  14. DATA PROG3
  15. BYTE 0,0,0,0,0,0,0,0
  16.  
  17.  
  18. PROG3 DATA PROG2
  19. DATA DU2K
  20. BYTE 8
  21. TEXT 'DU2K 2.0'
  22. EVEN
  23.  
  24. PROG2 DATA PROG
  25. DATA DM2K
  26. BYTE 8
  27. TEXT 'DM2K 2.4'
  28. EVEN
  29.  
  30. PROG DATA 0
  31. DATA CF2K
  32. BYTE 8
  33. TEXT 'CF2K 1.4'
  34. EVEN
  35.  
  36. ***************
  37. * Copy Data for Modules *
  38. * Format is:
  39. * First, the address to load for the first source bank.
  40. * Number of 32-bit words, source address, target address
  41. * To end list, provide a start address greater than >8000
  42. * (This means you can't start in the low RAM bank)
  43. ***************
  44. CF2KDT DATA >6000
  45. DATA >076A,>6258,>A000,>076A,>6258,>BDA8
  46. DATA >076A,>6258,>DB50,>04C0,>6D00,>2000
  47. DATA >A000
  48.  
  49. DM2KDT DATA >6008
  50. DATA >072A,>6358,>A000,>072A,>6358,>BCA8
  51. DATA >072A,>6358,>D950,>0300,>7400,>2000
  52. DATA >A000
  53.  
  54. DU2KDT DATA >6010
  55. DATA >0794,>61B0,>A000,>0794,>61B0,>BE50
  56. DATA >0794,>61B0,>DCA0,>0400,>7000,>2000
  57. DATA >A000
  58.  
  59. ***************
  60. * CF2K Module *
  61. ***************
  62. CF2K LWPI >8300
  63. LI R14,CF2KDT * address of copy table
  64. JMP COPYLP
  65.  
  66. ***************
  67. * DM2K Module *
  68. ***************
  69. DM2K LWPI >8300
  70. LI R14,DM2KDT * address of copy table
  71. JMP COPYLP
  72.  
  73. ***************
  74. * DU2K Module *
  75. ***************
  76. DU2K LWPI >8300
  77. LI R14,DU2KDT * address of copy table
  78. JMP COPYLP
  79.  
  80. ***************
  81. * Common Code *
  82. ***************
  83. COPYLP BL @GOGO * Set up Char Sets
  84.  
  85. MOV *R14+,R7 * get bank
  86.  
  87. ONEBLK MOV *R14+,R4 * Get bytes divided by 4
  88. JGT CONT * Branch if positive (less than >8000)
  89. B *R4 * Else it's the jump address, so start the program
  90.  
  91. CONT MOV *R14+,R9 * Address to copy from
  92. MOV *R14+,R10 * Address to copy to
  93. BL @COPYME * COPY IT!
  94.  
  95. INCT R7 * Next Bank
  96.  
  97. JMP ONEBLK
  98.  
  99. ****************
  100. * Copy Routine *
  101. ****************
  102. * R4 - Bytes Div 4
  103. * R7 - Bank switch address
  104. * R9 - Address to copy from
  105. * R10 - Address to copy to
  106. * R11 - Return spot
  107.  
  108. COPYME
  109. MOV R0,*R7 * Do the bank switch
  110. LOOPIT
  111. MOV *R9+,*R10+
  112. MOV *R9+,*R10+
  113. DEC R4
  114. JNE LOOPIT
  115. B *R11 * We're done.
  116.  
  117. ****************************
  118. * Load lower case charsets *
  119. ****************************
  120. * Note, if you still need space, you can remove support for the
  121. * 99/4 by deleting the code marked between * +++ 99/4 support +++ begin/end
  122. * blocks
  123.  
  124. GOGO
  125. MOV R11,R9 * Save our return spot
  126.  
  127. * +++ 99/4 support begin +++
  128.  
  129. * load R3 with 6 for 99/4, or 7 for 99/4A
  130. CLR R0
  131. BL @GPLSET
  132. BL @GETGPL * read GROM >0000
  133. LI R3,7
  134. CI R0,>AA01 * 99/4 is AA01, all versions of 99/4A seem to be AA02 (even 2.2!)
  135. JNE IS4A * note we also assume unknown is 99/4A just to be safe
  136. DEC R3
  137.  
  138. * make a copy of the capitals for the 99/4 to 'support' lowercase
  139. * this will be partially overwritten by the main set, but it works!
  140.  
  141. LI R0,>0018 * GPL vector address
  142. LI R1,>4A00 * dest in VDP - must OR with >4000 for write
  143. LI R2,>0040 * how many chars
  144. BL @GPLVDP * this function goes somewhere later in your ROM
  145. JMP MNSET
  146.  
  147. * +++ 99/4 support end +++
  148. * If you delete the above block, replace with
  149. * LI R3,7
  150. * so that the character size counter is still valid
  151.  
  152. IS4A
  153. * 'lowercase' letters
  154. LI R0,>004A * GPL vector address (not available for 99/4)
  155. LI R1,>4B00 * dest in VDP - must OR with >4000 for write
  156. LI R2,>001F * how many chars
  157. BL @GPLVDP * this function goes somewhere later in your ROM
  158.  
  159. * main set
  160. MNSET
  161. LI R0,>0018 * GPL vector address
  162. LI R1,>4900 * dest in VDP - must OR with >4000 for write
  163. LI R2,>0040 * how many chars
  164. BL @GPLVDP * this function goes somewhere later in your ROM
  165. B *R9 * RETURN TO CALLER
  166.  
  167. *****************
  168. * GROM routines *
  169. *****************
  170.  
  171. * Set GROM address
  172. GPLSET
  173. MOVB R0,@>9C02
  174. SWPB R0
  175. MOVB R0,@>9C02
  176. B *R11
  177.  
  178. * Get a word from GPL
  179. GETGPL
  180. MOVB @>9800,R0
  181. SWPB R0
  182. MOVB @>9800,R0
  183. SWPB R0
  184. B *R11
  185.  
  186. * Copy R2 characters from a GPL copy function vectored at
  187. * R0 to VDP R1. GPL vector must be a B or BR and
  188. * the first actual instruction must be a DEST with an
  189. * immediate operand. Set R3 to 6 for 99/4 (6 byte characters)
  190. * or 7 for a 99/4A (7 byte characters)
  191. GPLVDP
  192. MOV R11,R10 * save return address
  193. BL @GPLSET * set GROM address
  194. BL @GETGPL * Get branch instruction (not verified!)
  195. ANDI R0,>1FFF * mask out instruction part
  196. AI R0,3 * skip instruction and destination
  197. BL @GPLSET * set new GROM address
  198. BL @GETGPL * get actual address of the table
  199. BL @GPLSET * and set that GROM address - GROM is now ready!
  200.  
  201. SWPB R1 * assume VDP is already prepared for write to save space
  202. MOVB R1,@>8C02
  203. SWPB R1
  204. MOVB R1,@>8C02 * VDP is now ready!
  205.  
  206. CLR R0
  207. LP8
  208. MOVB R0,@>8C00 * pad the top of the char with a space
  209. MOV R3,R0 * then copy 7 (or 6) bytes
  210.  
  211. * +++ 99/4 support begin +++
  212.  
  213. CI R3,6 * check for 99/4
  214. JNE LP9
  215. MOVB R0,@>8C00 * extra blank line for 99/4
  216.  
  217. * +++ 99/4 support end +++
  218. * no changes needed if this block removed
  219.  
  220. LP9
  221. MOVB @>9800,@>8C00 * copy a byte (both sides autoincrement)
  222. DEC R0
  223. JNE LP9
  224.  
  225. DEC R2 * next character
  226. JNE LP8
  227.  
  228. B *R10
  229.  
  230. FINISH EQU $
  231. SLAST END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement