Advertisement
Guest User

Untitled

a guest
Sep 24th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. ;This is a modified version of code created by DaMarsMan in 2006 for his Intro tutorial
  2. ;Clarifications and additions made by DackR in 2018
  3. ;Thanks to MrRichard for asking me to take a closer look
  4.  
  5. lorom
  6.  
  7. ;***************************VARIABLE LOCATIONS**********************************
  8. ;these are LoROM addresses
  9.  
  10. ;(original code) start of reset vector, often $00FF00 if it's HiROM, or commonly $008000 for LoROM
  11. !OriginalCodeOffset = $00D452
  12. !NewCodeOffset = $408000 ;the compiled code will take up less than 0x300 (768) bytes
  13. !ReturnCodeOffset = $00D456
  14.  
  15. ;change this to where the palette data should be stored (takes up about 0x200 bytes)
  16. org $408300
  17. incbin image/intro.col
  18.  
  19. ;essentially the same as the above org, only the bank and the offset are separated
  20. !ColBank = #$40
  21. !ColOffset = #$8300
  22.  
  23. ;change this to the desired location of the tilemap (takes up about 0x800 bytes)
  24. org $408500
  25. incbin image/intro.map
  26.  
  27. ;essentially the same as the above org, only the bank and the offset are separated
  28. !MapBank = #40
  29. !MapOffset = #$8500
  30.  
  31. ;change this org to the offset of the raw image data (bitplane data)
  32. org $418000
  33. incbin image/intro.set
  34.  
  35. ;essentially the same as the above org, only the bank and the offset are separated
  36. !SetBank = #$41 ;(the raw image data takes up two banks)
  37. !SetBank2 = #$42 ;usually 1 more than SetBank unless you manually split up the image :p
  38. !SetOffset = #$8000
  39.  
  40. ;***************************CHANGE ABOVE FIRST**********************************
  41.  
  42. ;***********************OPTIONAL VARIABLE CHANGES*******************************
  43. !FadeSpeed = #$6FFF ;Changing this directly effects the Fade Speed (Higher==Slower)
  44. !IntroDelay = #$0013 ;make larger to increase pause, smaller for short pause
  45. !MosaicEnable = #$00 ;#$01 is enabled, #$00 is disabled
  46. ;*********************END OPTIONAL VARIABLE CHANGES*****************************
  47.  
  48. ;this is where we are hijacking the original initialization routine (about 4 bytes)
  49. org !OriginalCodeOffset
  50. JMP !NewCodeOffset
  51.  
  52. ;start initialization
  53. org !NewCodeOffset
  54. SEI
  55. CLC
  56. XCE
  57. SEP #$30
  58. PHB
  59. LDA #$00
  60. PHA
  61. PLB
  62. LDA #$80
  63. STA $2100
  64. LDA #$00
  65. STA $2101
  66. STA $2102
  67. STA $2103
  68. STA $2105
  69. STA $2106
  70. STA $2107
  71. STA $2108
  72. STA $2109
  73. STA $210A
  74. STA $210B
  75. STA $210C
  76. STA $210D
  77. STA $210D
  78. STA $210E
  79. STA $210E
  80. STA $210F
  81. STA $210F
  82. STA $2110
  83. STA $2110
  84. STA $2111
  85. STA $2111
  86. STA $2112
  87. STA $2112
  88. STA $2113
  89. STA $2113
  90. STA $2114
  91. STA $2114
  92.  
  93. LDA #$80
  94. STA $2115
  95. LDA #$00
  96. STA $2116
  97. STA $2117
  98. STA $211A
  99. STA $211B
  100. LDA #$01
  101. STA $211B
  102. LDA #$00
  103. STA $211C
  104. STA $211C
  105. STA $211D
  106. STA $211D
  107. STA $211E
  108. LDA #$01
  109. STA $211E
  110. LDA #$00
  111. STA $211F
  112. STA $211F
  113. STA $2120
  114. STA $2120
  115. STA $2121
  116. STA $2123
  117. STA $2124
  118. STA $2125
  119. STA $2126
  120. STA $2127
  121. STA $2128
  122. STA $2129
  123. STA $212A
  124. STA $212B
  125. LDA #$01
  126. STA $212C
  127. LDA #$00
  128. STA $212D
  129. STA $212E
  130. STA $212F
  131. LDA #$30
  132. STA $2130
  133. LDA #$00
  134. STA $2131
  135. LDA #$E0
  136. STA $2132
  137. LDA #$00
  138. STA $2133
  139. LDA #$01 ;auto read joypads
  140. STA $4200
  141. LDA #$FF
  142. STA $4201
  143. LDA #$00
  144. STA $4202
  145. STA $4203
  146. STA $4204
  147. STA $4205
  148. STA $4206
  149. STA $4207
  150. STA $4208
  151. STA $4209
  152. STA $420A
  153. STA $420B
  154. STA $420C
  155. STA $420D
  156. REP #$30
  157. SEP #$20
  158. LDA #$03
  159. STA $2105
  160. LDA #$01
  161. STA $212C
  162. LDA #$00
  163. STA $2107
  164. LDA #$01
  165. STA $210B
  166. JSR Jump1
  167.  
  168. ;DMA color stuff
  169. LDX #$8000
  170. STX $2116
  171. LDX #$1801
  172. STX $4300
  173. LDX !MapOffset
  174. STX $4302
  175. LDA !MapBank
  176. STA $4304
  177. LDX #$0C00
  178. STX $4305
  179. LDA #$01
  180. STA $420B
  181. LDA #$00
  182. STA $2121
  183. LDX #$2200
  184. STX $4300
  185. LDX !ColOffset
  186. STX $4302
  187. LDA !ColBank
  188. STA $4304
  189. LDX #$0200 ;512 colors
  190. STX $4305
  191. LDA #$01
  192. STA $420B
  193. JSR Jump1 ;await vblank
  194.  
  195.  
  196. ;DMA transfer data for "set"
  197. ;copy first half #$8000
  198. LDX #$1000
  199. STX $2116
  200. LDX #$1801
  201. STX $4300
  202. LDX !SetOffset
  203. STX $4302
  204. LDA !SetBank
  205. STA $4304
  206. LDX #$8000
  207. STX $4305
  208. LDA #$01
  209. STA $420B
  210. JSR Jump1 ;await vblank
  211.  
  212. ;DMA transfer data for second half of the image
  213. ;copy bottom half #$6000 in size
  214. LDX !SetOffset
  215. STX $4302
  216. LDA !SetBank2
  217. STA $4304
  218. LDX #$6000
  219. STX $4305
  220. LDA #$01
  221. STA $420B
  222. Jump9:
  223. JSR mosaic
  224. STA $2100 ;setting the screen brightness (fade in)
  225. INA
  226. JSR Jump2 ;fade delay
  227.  
  228. CMP #$10
  229. BCC Jump9 ; keep fading in if A is less than 0x10
  230.  
  231. FadeRoutine:
  232. CLI
  233. LDX !IntroDelay ;make larger to increase pause, smaller for short pause
  234.  
  235. Jump3:
  236. SEP #$20
  237. LDY #$FFFF
  238.  
  239. Jump4:
  240. DEY
  241. BNE Jump4
  242.  
  243. Jump5:
  244. LDA $4212
  245. AND #$80
  246. BEQ Jump5
  247.  
  248. Jump6:
  249. LDA $4212 ;check vblank
  250. AND #$01
  251. BNE Jump6
  252.  
  253. REP #$20
  254. LDA $4218
  255. AND #$F0F0
  256. BNE Jump7
  257. DEX
  258.  
  259. ;****************************OPTIONAL CODE CHANGE*******************************
  260. ;SHOULD WE STAY OR SHOULD WE GO NOW?
  261. ;BNE Jump3 ;don't wait for keypress
  262. BRA Jump3 ;wait for keypress
  263. ;***************************END OF OPTIONAL CHANGE******************************
  264.  
  265. Jump7:
  266. SEP #$20
  267. LDA $4210
  268. AND #$80
  269. BEQ Jump7
  270. LDA #$0F ;0F
  271.  
  272. Jump10:
  273. JSR mosaic
  274. STA $2100 ;fading out
  275. DEC A
  276. PHA
  277. JSR Jump2 ;once again, using this routine for fade delay
  278. ;END OF FADE ROUTINE
  279.  
  280.  
  281.  
  282. PLA
  283. CMP #$00
  284. BNE Jump10
  285.  
  286.  
  287. LDX #$0000
  288.  
  289. ;THIS CONTAINS CODE FROM THE ORIGINAL RESET VECTOR
  290. ;****************************CHANGE THE CODE BELOW******************************
  291. CLC
  292. XCE
  293. SEP #$20
  294. ;****************************CHANGE THE CODE ABOVE******************************
  295. JMP.l !ReturnCodeOffset
  296.  
  297.  
  298. Jump1:
  299. PHA
  300. Jump11:
  301. LDA $4210 ;checking the nmi flag
  302. AND #$80 ;the flag is on the first bit (0x80 == 0b10000000)
  303. BEQ Jump11
  304. PLA
  305. RTS
  306.  
  307.  
  308. Jump2:
  309. LDY !FadeSpeed ; each time the brightness is changed, we delay this amount
  310. Jump8:
  311. DEY
  312. BNE Jump8 ; while y is not zero
  313. RTS
  314.  
  315.  
  316.  
  317. vblank:
  318. PHA
  319. PHP
  320. SEP #$20
  321.  
  322. Vloop:
  323. LDA.l $4210
  324. AND #$80
  325. BEQ Vloop
  326.  
  327. PLP
  328. PLA
  329. RTS
  330.  
  331. mosaic:
  332. PHA
  333. ASL A
  334. ASL A
  335. ASL A
  336. ASL A
  337. EOR #$F0
  338. ORA !MosaicEnable
  339. STA $2106
  340. PLA
  341. RTS
  342.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement