00001. ; Super Mario Bros. 3 Full Disassembly by Southbird 2012 
00002. ; For more info, see http://www.sonicepoch.com/sm3mix/ 
00003. ; 
00004. ; PLEASE INCLUDE A CREDIT TO THE SOUTHBIRD DISASSEMBLY 
00005. ; AND THE ABOVE LINK SOMEWHERE IN YOUR WORKS :) 
00006. ; 
00007. ; Original disassembler source generated by DCC6502 version v1.4 
00008. ; (With labels, comments, and some syntax corrections for nesasm by Southbird) 
00009. ; For more info about DCC6502, e-mail veilleux@ameth.org 
00010. ; 
00011. ; This source file last updated: 2012-06-03 20:10:40.000000000 -0500 
00012. ; Distribution package date: Sun Jun 10 18:22:15 UTC 2012 
00013. ; 
00014. ;--------------------------------------------------------------------------- 
00015.  
00016. ;--------------------------------------------------------------------------- 
00017. ; THE [LOST] BONUS GAMES! 
00018. ;--------------------------------------------------------------------------- 
00019. ; 
00020. ; If you don't know about it: http://themushroomkingdom.net/smb3_lost.shtml 
00021. ; 
00022. ; While in previous exploits I did find traces of the "lost" Bonus Games, 
00023. ; the translation efforts on various sites (e.g. The Mushroom Kingdom) 
00024. ; and the game "restoring" patch by BMF54123 makes some of this clear. 
00025. ; It should be noted that BMF54123's patch works by constructing a custom 
00026. ; pattern bank to replace the missing sprites so it's unknown how much of 
00027. ; it is truly accurate (except for the alternate game hosts, which still 
00028. ; exist in stock SMB3), but for now I'll have faith in his reproduction. 
00029. ; 
00030. ; The only thing we really have to go on with the "lost" Bonus Games are 
00031. ; some scattered graphics and the string translations. During this work 
00032. ; I formulated a few theories, although all of it is ultimately speculation. 
00033. ; 
00034. ; There appeared to have been at least four Bonus Games planned, and they 
00035. ; are vaguely described as follows: 
00036. ; 
00037. ; The Key/Coin Game 
00038. ; "If 1 appears, 1 (?) 
00039. ; If 2 appears, I'll give you a key 
00040. ; Otherwise, I'll give you coins." 
00041. ; 
00042. ; The Odd Game 
00043. ; "If an odd number appears, I'll let you play the Roulette Game." 
00044. ; 
00045. ; The Even Game  
00046. ; "If an even number appears, I'll let you play the Card Game." 
00047. ; 
00048. ; Koopa Troopa's "Prize" Game 
00049. ; No text to describe this one, but pictures speak louder than words 
00050. ; (More below...) 
00051. ; 
00052. ; All of these games were powered by a rotating die (as it is displayed in 
00053. ; BMF54123's patch.) What the die face values meant are determined by the 
00054. ; bonus game type (Bonus_GameType.) 
00055. ; 
00056. ; While in fact none of the prizes stated in these messages can be obtained, 
00057. ; they allude to a completely different bonus game structure and another 
00058. ; perhaps lost SMB3 gameplay device, the "key." 
00059. ; 
00060. ; Bearing in mind this is only speculation, it would make sense that the 
00061. ; "Roulette" game mentioned in the text is in fact what we now know as 
00062. ; the "Spade" game from the World Map, where you line up the three rows of 
00063. ; images to form the picture. The "Card" game then is most likely what 
00064. ; we now know as "N-Spade", the memory card matching game. Thus it can 
00065. ; be suggested that direct access to either was not the original intention, 
00066. ; they were "prizes" for a lucky roll of the die. 
00067. ; 
00068. ; However, it is not as easy to determine the purpose of two other glaring 
00069. ; omissions -- the alternate game hosts (Koopa Troopa and Hammer Bro) as 
00070. ; well as the mysterious "key." Why the villains would EVER host the game 
00071. ; has no clear rhyme or reason. The "key" could perhaps once have been the 
00072. ; means of unlocking the "locks" on the World Map, instead of the present 
00073. ; day means of unlocking via the Mini-Fortress. Whether this would have 
00074. ; been an item the Player carried to use at his whim or whether the lock 
00075. ; would automatically clear like it does now is also indeterminable. 
00076. ; 
00077. ; The current state as it exists in the code: 
00078. ; 
00079. ;--------------------------------------------------------------------------- 
00080. ; Die Face 1: "If 1 appears, 1 (?)" 
00081. ;--------------------------------------------------------------------------- 
00082. ; This currently actually gives you an extra life, but does not play the 
00083. ; 1-Up sound or worry about a 99 lives cap. Like Die Face 1, it is quite 
00084. ; possible that this extra life is also not the intended prize. Perhaps 
00085. ; either a placeholder or a last ditch effort to spare the die games when 
00086. ; it became apparent they were potentially to be cut... 
00087. ; 
00088. ; 
00089. ;--------------------------------------------------------------------------- 
00090. ; Die Face 2: "If 2 appears, I'll give you a key" 
00091. ;--------------------------------------------------------------------------- 
00092. ; This attempts to give you "something." Literally what it does is add 1 
00093. ; to the lowest byte of the Player-specific score storage. But not in an 
00094. ; appropriate way with carry-arithmetic. So most likely this was not  
00095. ; really what was supposed to be getting incremented; it likely was giving 
00096. ; you one more of "something." Whether or not that "something" was 
00097. ; actually obtained is unclear, especially since the incomplete messsage 
00098. ; does not allude to what it was supposed to be, if it was ever even known. 
00099. ; But since it effects Player-specific memory, it can at least be assumed 
00100. ; that they intended to give the current Player one of "something." 
00101. ; 
00102. ; 
00103. ;--------------------------------------------------------------------------- 
00104. ; Die Face 3-6: "Otherwise, I'll give you coins." 
00105. ;--------------------------------------------------------------------------- 
00106. ; Visually, this promise is held true; "coins" will pop out in a confetti 
00107. ; like motion for Die Face 3-6. Code-wise, however, it actually ends up 
00108. ; giving you (Face Value * 10) points. Don't let the multiplication lead 
00109. ; you on too far, because SMB3 uses a fake leading zero on the score, so 
00110. ; it's really only adding the face value of the die to your score variable. 
00111. ; It is quite easy to believe that there is simply a mistake in the code 
00112. ; or that this code is old and unmaintained, and in fact what is now the 
00113. ; earned score used to be the earned coins. In any case, this is the only 
00114. ; segment of the Die Game that seems to be almost at its intended form. 
00115. ; 
00116. ; The final note that should be made here is that coins have no purpose on 
00117. ; the world map. Your coin total is changed to bonus at the end of every 
00118. ; level, or lost upon death. So this further suggests that there was once 
00119. ; a persistence of coin count on the world map, perhaps to purchase items 
00120. ; (maybe Toad House would have been a shop?) or gamble with. 
00121. ; 
00122. ;--------------------------------------------------------------------------- 
00123. ; The Odd/Even Games 
00124. ; "If an odd number appears, I'll let you play the Roulette Game." 
00125. ; "If an even number appears, I'll let you play the Card Game." 
00126. ;--------------------------------------------------------------------------- 
00127. ; This one is interesting and, as suggested above, most likely connected 
00128. ; you to the now-known-as Spade and N-Spade games respectively. What's 
00129. ; also interesting is the code for playing the Odd/Even game is still 
00130. ; present but logically inaccessible; the values that originally selected 
00131. ; to play the Odd/Even games have now actually been replaced by the Spade 
00132. ; and N-Spade respectively! (Further suggesting the connection.)  
00133. ; 
00134. ; But the code and lookup tables that make the game possible still exist,  
00135. ; and the way they play out now is that "winning" the Odd game sets  
00136. ; Bonus_DieCnt to 5 and the Even game forces it to 6. This would be used 
00137. ; to determine which game you got to play after that... 
00138. ; 
00139. ; It seems that the Odd/Even games were refactored to slot 5 and 6 after 
00140. ; formerly occupying slot 1 and 2, respectively. This is further suggested 
00141. ; by the fact that the "Round 2" strings for Bonus_Round2 1 and 2 are 
00142. ; duplicated for Bonus_GameType 5 and 6. 
00143. ; 
00144. ; 
00145. ;--------------------------------------------------------------------------- 
00146. ; "Round 2" 
00147. ;--------------------------------------------------------------------------- 
00148. ; What I refer to as "Round 2" in the code was where apparently the Die game 
00149. ; could transition into another bonus game. The only place this is apparently 
00150. ; set up to work are the Odd/Even Games, which intended to proceed to the 
00151. ; Roulette (Spade) or Card (N-Spade) games in "Round 2." 
00152. ; 
00153. ; At the end of all the "Host Greet" strings, there is a value that gets  
00154. ; pushed into Bonus_Round2. This determines what Round 2 will be! 
00155. ; 
00156. ; In summary (example for Odd/Even): 
00157. ; Round 1: Get instructed and play Odd/Even Game; if you win... 
00158. ; Round 2: Previous dialog is erased, get instructed and play Roulette/Card Game 
00159. ; 
00160. ; The code was likely possibly considering that other games would have a  
00161. ; "Round 2" component, but this never materialized... but some hints of what 
00162. ; other "Round 2" things may have occurred are hinted by some of the strings 
00163. ; 
00164. ; 
00165. ;--------------------------------------------------------------------------- 
00166. ; Koopa Troopa's "Prize" Game 
00167. ;--------------------------------------------------------------------------- 
00168. ; This is the most incomplete of all of the games. There is no definite string 
00169. ; of text to hint what the rules might have been. The only things known are: 
00170. ; 1) A big [?] appears when Bonus_GameHost = 1 (Koopa Troopa with "Prize") 
00171. ; 2) A "prize" emerges from it and sits atop of the box 
00172. ; 3) There is code reference to these first two things (Bonus_KTPrizeGame) 
00173. ; 4) Bonus_Return2_SetMapPos can set your map position partly by Bonus_KTPrizeGame 
00174. ; 
00175. ; There is no way to absolutely determine how this game worked, but most likely 
00176. ; it would start up with you and the Koopa Troopa with a box in the middle. 
00177. ; The "prize" would remain inside the box until you did whatever it took to 
00178. ; "win" the prize, at which point it would rise up and presumably you'd get it. 
00179. ; The reason for it rising immediately is most likely a programmer's test and 
00180. ; it simply wasn't very far along yet. 
00181. ; 
00182. ; The big [?] that appears covers over the Die, although the die is still in 
00183. ; operation behind it and for all intents and purposes, the engine is still 
00184. ; running the die game. The die game should probably be disabled in this 
00185. ; case, but there's just no logic for that. 
00186. ; 
00187. ; A possible suggestion is that this was a trading game (using the unknown  
00188. ; "Round 2" string which is loosely translated as "Give Something?"), where 
00189. ; you gave the Koopa Troopa an item and you got whatever was in the 
00190. ; "Mystery Box", perhaps to your benefit or chagrin. But this is only a guess. 
00191. ; 
00192. ; If bonus loop is exited and Bonus_GameType = BONUS_UNUSED_2RETURN, 
00193. ; the Player is forced to a map position based on their last movement 
00194. ; and the Bonus_KTPrizeGame value! (See Bonus_Return2_SetMapPos) 
00195. ; So perhaps BONUS_UNUSED_2RETURN MAY have been Koopa Troopa's "Prize" Game? 
00196. ; 
00197. ; 
00198. ; P.S. 
00199. ; 
00200. ; Bonus_GameType = BONUS_UNUSED_DDDD actually sets a special variable 
00201. ; Bonus_DDDD = 1 when you exit the bonus loop... interesting!! 
00202. ;  
00203. ; There is an unused variable Roulette_Turns which when greater than zero, 
00204. ; gives you additional spins if you should lose the Roulette game! This is 
00205. ; likely the unused "Play three times" message (BonusGame_UNUSED_Etc1) 
00206. ;  
00207. ; "Hey you! How about lending me your clothes? 
00208. ; No dice? 
00209. ; What a drag" 
00210. ; -- Possible in-joke no one got after all these years? :P 
00211.  
00212.  
00213. Tile_Layout_TS15_TS16_TS17: 
00214. ; This defines the individual 8x8 blocks used to construct one of the tiles 
00215. ; Referenced by Address_Per_Tileset, addressed by Level_Tileset 
00216. ; Stored by upper left, then lower left, then upper right, then lower right 
00217.  
00218. ; Remember that palette is determined by the upper 2 bits of a TILE (not the PATTERN) 
00219. ; I.e. tiles starting at index $00, $40, $80, $C0 are each on that respective palette 
00220.  
00221. ; Upper left 8x8 pattern per tile 
00222. .byte $FD, $FD, $FD, $A6, $A7, $A8, $A4, $A5, $FE, $FF, $FD, $FF, $FF, $FF, $FF, $FF ; Tiles $00 - $0F 
00223. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $10 - $1F 
00224. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $20 - $2F 
00225. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $30 - $3F 
00226. .byte $72, $50, $54, $FD, $58, $5C, $FD, $40, $44, $FD, $74, $08, $0A, $28, $2A, $48 ; Tiles $40 - $4F 
00227. .byte $4A, $68, $6A, $FE, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $50 - $5F 
00228. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $60 - $6F 
00229. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $70 - $7F 
00230. .byte $FD, $60, $64, $68, $6C, $46, $78, $20, $24, $21, $2C, $FF, $FF, $FF, $FF, $FF ; Tiles $80 - $8F 
00231. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $90 - $9F 
00232. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $A0 - $AF 
00233. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $B0 - $BF 
00234. .byte $70, $FF, $FF, $FF, $FF, $70, $FF, $07, $07, $80, $82, $84, $86, $72, $10, $12 ; Tiles $C0 - $CF 
00235. .byte $12, $17, $1F, $1B, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $D0 - $DF 
00236. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $E0 - $EF 
00237. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $F0 - $FF 
00238.  
00239. ; Lower left 8x8 pattern per tile 
00240. .byte $A0, $A1, $A2, $A6, $A7, $FD, $FD, $FD, $FE, $FF, $FD, $FF, $FF, $FF, $FF, $FF ; Tiles $00 - $0F 
00241. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $10 - $1F 
00242. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $20 - $2F 
00243. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $30 - $3F 
00244. .byte $73, $51, $55, $FD, $59, $5D, $FD, $41, $55, $FD, $75, $18, $1A, $38, $3A, $58 ; Tiles $40 - $4F 
00245. .byte $5A, $78, $7A, $FE, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $50 - $5F 
00246. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $60 - $6F 
00247. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $70 - $7F 
00248. .byte $FD, $61, $65, $69, $6D, $69, $79, $21, $25, $29, $2B, $FF, $FF, $FF, $FF, $FF ; Tiles $80 - $8F 
00249. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $90 - $9F 
00250. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $A0 - $AF 
00251. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $B0 - $BF 
00252. .byte $71, $FF, $FF, $FF, $01, $04, $02, $07, $05, $90, $92, $94, $96, $73, $11, $14 ; Tiles $C0 - $CF 
00253. .byte $13, $18, $FD, $1C, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $D0 - $DF 
00254. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $E0 - $EF 
00255. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $F0 - $FF 
00256.  
00257. ; Upper right 8x8 pattern per tile  
00258. .byte $FD, $FD, $FD, $FE, $FD, $A4, $A4, $FD, $FE, $FF, $FD, $FF, $FF, $FF, $FF, $FF ; Tiles $00 - $0F 
00259. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $10 - $1F 
00260. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $20 - $2F 
00261. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $30 - $3F 
00262. .byte $73, $52, $FD, $56, $5A, $FD, $66, $42, $FD, $45, $76, $09, $0B, $29, $2B, $49 ; Tiles $40 - $4F 
00263. .byte $4B, $69, $6B, $FE, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $50 - $5F 
00264. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $60 - $6F 
00265. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $70 - $7F 
00266. .byte $5E, $62, $FD, $6A, $FD, $6A, $7A, $22, $26, $2A, $27, $FF, $FF, $FF, $FF, $FF ; Tiles $80 - $8F 
00267. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $90 - $9F 
00268. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $A0 - $AF 
00269. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $B0 - $BF 
00270. .byte $71, $FF, $06, $06, $FF, $71, $FF, $FF, $FF, $81, $83, $85, $87, $73, $12, $12 ; Tiles $C0 - $CF 
00271. .byte $15, $19, $1F, $1D, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $D0 - $DF 
00272. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $E0 - $EF 
00273. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $F0 - $FF 
00274.  
00275. ; Lower right 8x8 pattern per tile 
00276. .byte $A1, $A1, $FD, $FE, $FD, $FD, $FD, $FD, $FE, $FF, $FD, $FF, $FF, $FF, $FF, $FF ; Tiles $00 - $0F 
00277. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $10 - $1F 
00278. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $20 - $2F 
00279. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $30 - $3F 
00280. .byte $72, $53, $FD, $57, $5B, $FD, $67, $43, $FD, $FD, $77, $19, $1B, $39, $3B, $59 ; Tiles $40 - $4F 
00281. .byte $5B, $79, $7B, $FE, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $50 - $5F 
00282. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $60 - $6F 
00283. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $70 - $7F 
00284. .byte $5F, $63, $FD, $6B, $FD, $6B, $7B, $23, $27, $2B, $2F, $FF, $FF, $FF, $FF, $FF ; Tiles $80 - $8F 
00285. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $90 - $9F 
00286. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $A0 - $AF 
00287. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $B0 - $BF 
00288. .byte $70, $00, $06, $03, $01, $04, $FF, $FF, $FF, $91, $93, $95, $97, $72, $13, $14 ; Tiles $C0 - $CF 
00289. .byte $16, $1A, $FD, $1E, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $D0 - $DF 
00290. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $E0 - $EF 
00291. .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Tiles $F0 - $FF 
00292.  
00293.  
00294. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00295. ; LevelLoad_TS9 
00296. ; 
00297. ; Entry point for loading level layout data for Level_Tileset = 15-17 
00298. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00299. LevelLoad_TS15_TS16_TS17: 
00300. LDY #$00 
00301. PRG022_C402: 
00302. LDA #TILE15_BLACK 
00303. JSR Tile_Mem_ClearB 
00304. JSR Tile_Mem_ClearA 
00305. CPY #$40 
00306. BNE PRG022_C402 
00307.  
00308. PRG022_C40E: 
00309. LDA #TILE15_BRICKBG 
00310. JSR Tile_Mem_ClearB 
00311. LDA #TILE15_BLACK 
00312. JSR Tile_Mem_ClearA 
00313. CPY #$f0 
00314. BNE PRG022_C40E 
00315.  
00316. JMP LevelLoad ; Begin actual level loading! 
00317.  
00318.  
00319. ; The bonus room is typical level layout data... 
00320. ; Only BonusLayout_Typical is ever possibly loaded, the other ones are never touched. 
00321. ; See PRG012 for the indexing instruction; too bad it's fixed at Y = 0... 
00322. Bonus_LayoutData: 
00323. .word BonusLayout_Typical ; 0: Mario and Table; The only bonus game we ever saw  
00324. .word BonusLayout_NoTable ; 1: Mario only; for the die game perhaps? 
00325. .word BonusLayout_BlueBox ; 2: Mario and blue box; maybe Koopa Troopa's prize game? 
00326. .word BonusLayout_Empty1 ; 3: Empty/unused, who knows 
00327. .word BonusLayout_Empty2 ; 4: Empty/unused, who knows 
00328.  
00329. ; Broken into another file for ease of integration in NoDice editor 
00330. .include "PRG/levels/Bonus.asm" 
00331.  
00332. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00333. ; LoadLevel_Generator_TS151617 
00334. ; 
00335. ; Based on the values in Temp_Var15 and LL_ShapeDef, chooses an 
00336. ; appropriate generator function to builds this piece of the 
00337. ; level. Tedious, but saves space and is paper-design friendly. 
00338. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00339. LoadLevel_Generator_TS151617: 
00340.  
00341. ; NOTE: This is not a "complete" Generator as in the other level banks, 
00342. ; but that's because of the simplicity (there's only one!) 
00343.  
00344. LDA LL_ShapeDef 
00345. LSR A  
00346. LSR A  
00347. LSR A  
00348. LSR A  
00349. TAX 
00350.  
00351. DEX 
00352. TXA ; X = (LL_ShapeDef >> 4) - 1 
00353.  
00354. JSR DynJump 
00355.  
00356. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
00357. .word LoadLevel_BonusFloor ; 0 - Brick tiles that make up the floor 
00358.  
00359. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00360. ; LeveLoad_FixedSizeGen_TS151617 
00361. ; 
00362. ; Much simpler generators that are fixed-size, commonly used for  
00363. ; just single tile placement styles (although a couple relatively  
00364. ; complex ones exist in here as well) 
00365. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
00366. LeveLoad_FixedSizeGen_TS151617: 
00367.  
00368. ; It is verified before calling this function that all of 
00369. ; the upper 4 bits of LL_ShapeDef are ZERO 
00370.  
00371. ; So the upper 3 bits of Temp_Var15 serve as the most significant bits 
00372. ; to a value where LL_ShapeDef provide the 4 least significant bits 
00373.  
00374. ; NOTE: This is not a "complete" Generator as in the other level banks, 
00375. ; but that's because of the simplicity... so only the 4 LSb do anything! 
00376.  
00377. LDA LL_ShapeDef 
00378. JSR DynJump 
00379.  
00380. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
00381. .word LoadLevel_BonusPlayer ; 0 - Inserts the appropriate Player based on power up level 
00382. .word LoadLevel_UNKTALL ; 1 - Unknown tall something? 
00383. .word LoadLevel_Border ; 2 - Outside host border 
00384. .word LoadLevel_QBoxOrange ; 3 - "Orange" box, maybe once was a ? block (??) 
00385. .word LoadLevel_Table ; 4 - The table in the center of the bonus room 
00386. .word LoadLevel_Background ; 5 - Background setup (a smattering of brick tiles or whitespace behind where sprites are) 
00387. .word LoadLevel_QBoxBlue ; 6 - Blue ? block 
00388.  
00389. BonusTable_Tiles: 
00390. .byte TILE15_TABLE_UL, TILE15_TABLE_UM, TILE15_TABLE_UR 
00391. .byte TILE15_TABLE_LL, TILE15_TABLE_LM, TILE15_TABLE_LR 
00392.  
00393.  
00394. LoadLevel_Table: 
00395.  
00396. ; Temp_Var1 = 0 
00397. LDA #$00 
00398. STA <Temp_Var1 
00399. PRG022_C4B2: 
00400. LDX <Temp_Var1 ; X = Temp_Var1 
00401.  
00402. ; Left table tile -> Temp_Var2 
00403. LDA BonusTable_Tiles,X 
00404. STA <Temp_Var2  
00405.  
00406. ; Middle table tile -> Temp_Var3 
00407. LDA BonusTable_Tiles+1,X 
00408. STA <Temp_Var3  
00409.  
00410. ; Right table tile -> Temp_Var4 
00411. LDA BonusTable_Tiles+2,X 
00412. STA <Temp_Var4  
00413.  
00414. ; Temp_Var1 += 3 
00415. TXA 
00416. ADD #$03 
00417. STA <Temp_Var1 
00418.  
00419. LDX #$00 ; X = 0 
00420. LDY TileAddr_Off ; Y = TileAddr_Off 
00421.  
00422. ; Place left tile 
00423. LDA <Temp_Var2 
00424. STA [BonusText_BaseL],Y 
00425.  
00426. PRG022_C4D2: 
00427. INY ; Y++ (next grid tile, DANGEROUS!) 
00428. INX ; X++ 
00429.  
00430. ; Place middle tile (repeated) 
00431. LDA <Temp_Var3 
00432. STA [BonusText_BaseL],Y 
00433.  
00434. TXA 
00435. AND #$07 
00436. CMP #$05 
00437. BNE PRG022_C4D2 ; If X is not at the fifth iteration, loop! 
00438.  
00439. ; Place right tile 
00440. LDA <Temp_Var4 
00441. STA [BonusText_BaseL],Y 
00442.  
00443. ; TileAddr_Off += 16 (next row) 
00444. LDA TileAddr_Off 
00445. ADD #16 
00446. STA TileAddr_Off 
00447.  
00448. LDA <Temp_Var1 
00449. CMP #$06 
00450. BNE PRG022_C4B2 ; While Temp_Var1 <> 6, loop! 
00451.  
00452. RTS ; Return 
00453.  
00454. Background_Layout: 
00455. ; $80 works as a "line break" 
00456. ; $FF is the terminator 
00457. ; For everything else: Upper 4 bits index a tile from Background_Tiles and lower 4 bits are a repeat count (base value 1) 
00458. .byte $00, $80 
00459. .byte $00, $80 
00460. .byte $00, $10, $80 
00461. .byte $10, $03, $10, $23, $10, $80 
00462. .byte $14, $23, $00, $23, $80 
00463. .byte $13, $01, $21, $00, $23, $10, $80 
00464. .byte $23, $10, $00, $21, $10, $21, $00 
00465. .byte $FF 
00466.  
00467. Background_Tiles: 
00468. .byte TILE15_WHITESPACE_PAL3, TILE15_BRICKBG, TILE15_WHITESPACE_PAL0 
00469.  
00470.  
00471. LoadLevel_Background: 
00472. LDY TileAddr_Off ; Y = TileAddr_Off 
00473.  
00474. ; Temp_Var12 = 0 
00475. LDX #$00 
00476. STX <Temp_Var12 
00477. PRG022_C51E: 
00478. LDX <Temp_Var12  
00479.  
00480. LDA Background_Layout,X 
00481. STA <Temp_Var1  
00482.  
00483. CMP #$ff 
00484. BNE PRG022_C52A ; If not yet hit $FF value, jump to PRG022_C52A 
00485.  
00486. ; Terminated! 
00487. RTS ; Return 
00488.  
00489. PRG022_C52A: 
00490. CMP #$80 
00491. BNE PRG022_C53D ; If not hit $80 value, jump to PRG022_C53D 
00492.  
00493. ; Next tile row 
00494. LDA TileAddr_Off 
00495. ADD #16 
00496. STA TileAddr_Off 
00497. TAY ; -> 'Y' 
00498.  
00499. INC <Temp_Var12 ; Temp_Var12++ 
00500.  
00501. JMP PRG022_C51E ; Jump to PRG022_C51E 
00502.  
00503. PRG022_C53D: 
00504. LSR A 
00505. LSR A 
00506. LSR A 
00507. LSR A 
00508. TAX ; X = upper 4 bits, shifted down 
00509.  
00510. ; Lower 4 bits -> Temp_Var11 
00511. LDA <Temp_Var1 
00512. AND #$0f 
00513. STA <Temp_Var11 
00514.  
00515. PRG022_C548: 
00516. LDA Background_Tiles,X 
00517. STA [BonusText_BaseL],Y 
00518.  
00519. INY ; Y++ (next tile, DANGEROUS) 
00520.  
00521. DEC <Temp_Var11 ; Temp_Var11-- (repeat) 
00522. BPL PRG022_C548 ; While Temp_Var11 >= 0, loop! 
00523.  
00524. INC <Temp_Var12 ; Temp_Var12++ 
00525.  
00526. JMP PRG022_C51E ; Jump to PRG022_C51E 
00527.  
00528.  
00529. ; The 16x16 tiles that make up Player when he is Big (or other not supported power up) 
00530. Player_BonusTiles_Big: 
00531. .byte TILE15_BRICKBG, TILE15_PLAYERBIG_TOPM, TILE15_PLAYERBIG_TOPR 
00532. .byte TILE15_PLAYERBIG_HEADL, TILE15_PLAYERBIG_HEADM, TILE15_PLAYERBIG_HEADR 
00533. .byte TILE15_PLAYERBIG_TORL, TILE15_PLAYERBIG_TORM, TILE15_PLAYERBIG_TORR 
00534. .byte TILE15_PLAYERBIG_BOTL, TILE15_PLAYERBIG_BOTM, TILE15_PLAYERBIG_BOTR 
00535.  
00536. ; The 16x16 tiles that make up Player when he is Raccoon 
00537. Player_BonusTiles_Raccoon: 
00538. .byte TILE15_BRICKBG, TILE15_PLAYERRAC_TOPM, TILE15_PLAYERRAC_TOPR 
00539. .byte TILE15_PLAYERBIG_HEADL, TILE15_PLAYERBIG_HEADM, TILE15_PLAYERBIG_HEADR 
00540. .byte TILE15_PLAYERBIG_TORL, TILE15_PLAYERBIG_TORM, TILE15_PLAYERBIG_TORR 
00541. .byte TILE15_PLAYERBIG_RACL, TILE15_PLAYERBIG_RACM, TILE15_PLAYERBIG_BOTR 
00542.  
00543. ; The 16x16 tiles that make up Player when he is Small 
00544. Player_BonusTiles_Small: 
00545. .byte TILE15_BRICKBG, TILE15_BRICKBG, TILE15_BRICKBG 
00546. .byte TILE15_BRICKBG, TILE15_BRICKBG, TILE15_BRICKBG 
00547. .byte TILE15_BRICKBG, TILE15_PLAYERSM_TOP, TILE15_BRICKBG 
00548. .byte TILE15_BRICKBG, TILE15_PLAYERSM_BOTTOM, TILE15_BRICKBG 
00549.  
00550. PlayerSuit_ToIndex: 
00551. .byte PLAYERSUIT_BIG ; 0 (Default when all else fails) 
00552. .byte PLAYERSUIT_RACCOON ; 1 
00553. .byte PLAYERSUIT_SMALL ; 2 
00554. PlayerSuit_ToIndex_End 
00555.  
00556. PlayerSuit_TileBaseIndex: 
00557. .byte (Player_BonusTiles_Big - Player_BonusTiles_Big) 
00558. .byte (Player_BonusTiles_Raccoon - Player_BonusTiles_Big) 
00559. .byte (Player_BonusTiles_Small - Player_BonusTiles_Big) 
00560.  
00561.  
00562. LoadLevel_BonusPlayer: 
00563.  
00564. ; This loop tries to match the Player's power up with an index 
00565. ; If nothing else, X = 0, which uses "Big" 
00566. LDX #(PlayerSuit_ToIndex_End - PlayerSuit_ToIndex - 1) 
00567. LDY Player_Current ; Y = Player_Current 
00568. LDA World_Map_Power,Y ; Get current Player's power 
00569. PRG022_C589: 
00570. CMP PlayerSuit_ToIndex,X 
00571. BEQ PRG022_C591 ; If this is the Player's current power up, jump to PRG022_C591 
00572.  
00573. DEX ; X-- 
00574. BNE PRG022_C589 ; While X > 0, loop! 
00575.  
00576. PRG022_C591: 
00577.  
00578. ; Get starting tile for Player 
00579. LDA PlayerSuit_TileBaseIndex,X 
00580. TAX ; -> 'X' 
00581.  
00582. ; Temp_Var3 = 0 
00583. LDA #$00 
00584. STA <Temp_Var3 
00585.  
00586. LDY TileAddr_Off ; Y = TileAddr_Off 
00587.  
00588. PRG022_C59C: 
00589. ; Temp_Var1 = 2 
00590. LDA #$02 
00591. STA <Temp_Var1 
00592.  
00593. PRG022_C5A0: 
00594. ; Get tile for Player -> grid 
00595. LDA Player_BonusTiles_Big,X 
00596. STA [BonusText_BaseL],Y 
00597.  
00598. INY ; Y++ (next grid tile, DANGEROUS!) 
00599. INX ; X++ (next Player tile) 
00600.  
00601. INC <Temp_Var3 ; Temp_Var3++ 
00602. DEC <Temp_Var1 ; Temp_Var1-- 
00603.  
00604. BPL PRG022_C5A0 ; While Temp_Var1 >= 0, loop 
00605.  
00606. ; Go to next row of tiles 
00607. LDA TileAddr_Off 
00608. ADD #16 
00609. STA TileAddr_Off 
00610. TAY ; -> 'Y' 
00611.  
00612. LDA <Temp_Var3 
00613. CMP #(Player_BonusTiles_Raccoon - Player_BonusTiles_Big) 
00614. BNE PRG022_C59C ; If we have more tiles to go, loop! 
00615.  
00616. RTS ; Return 
00617.  
00618.  
00619. BonusUNKTALL_Tiles: 
00620. .byte TILE15_UNKTALL_UL, TILE15_UNKTALL_UR 
00621. .byte TILE15_UNKTALL_R1L, TILE15_UNKTALL_R1R 
00622. .byte TILE15_UNKTALL_R2L, TILE15_UNKTALL_R2R  
00623. .byte TILE15_UNKTALL_LL, TILE15_UNKTALL_LR 
00624. BonusUNKTALL_Tiles_End 
00625.  
00626. LoadLevel_UNKTALL: 
00627. LDX #$00 ; X = 0  
00628. LDY TileAddr_Off ; Y = TileAddr_Off 
00629.  
00630. PRG022_C5CB: 
00631. ; Temp_Var1 = 1 
00632. LDA #$01 
00633. STA <Temp_Var1 
00634.  
00635. PRG022_C5CF: 
00636. LDA BonusUNKTALL_Tiles,X 
00637. STA [BonusText_BaseL],Y  
00638.  
00639. INY ; Y++ (next grid tile, DANGEROUS!) 
00640. INX ; X++ 
00641.  
00642. DEC <Temp_Var1 ; Temp_Var1-- 
00643. BPL PRG022_C5CF ; While Temp_Var1 >= 0, loop 
00644.  
00645. ; Next tile row 
00646. LDA TileAddr_Off 
00647. ADD #16 
00648. STA TileAddr_Off 
00649. TAY ; -> 'Y' 
00650.  
00651. CPX #(BonusUNKTALL_Tiles_End - BonusUNKTALL_Tiles) 
00652. BNE PRG022_C5CB ; While X < number of tiles, loop! 
00653.  
00654. RTS ; Return 
00655.  
00656.  
00657. LoadLevel_Border: 
00658. LDY TileAddr_Off ; Y = TileAddr_Off 
00659.  
00660. ; Border upper left 
00661. LDA #TILE15_BORDER_UL 
00662. STA [BonusText_BaseL],Y 
00663.  
00664. ; Run of 14 middle tiles 
00665. PRG022_C5F0: 
00666. INY ; Y++ 
00667.  
00668. LDA #TILE15_BORDER_UM 
00669. STA [BonusText_BaseL],Y 
00670.  
00671. CPY #$0f 
00672. BNE PRG022_C5F0 
00673.  
00674. ; Border upper right 
00675. LDA #TILE15_BORDER_UR 
00676. STA [BonusText_BaseL],Y 
00677.  
00678. PRG022_C5FD: 
00679. INY ; Y++ 
00680. TYA 
00681. AND #$0f 
00682. BNE PRG022_C607 ; If not time to place left border, jump to PRG022_C607 
00683.  
00684. LDA #TILE15_BORDER_ML 
00685. BNE PRG022_C60D ; Jump (technically always) to PRG022_C60D 
00686.  
00687. PRG022_C607: 
00688. CMP #$0f 
00689. BNE PRG022_C5FD ; If not time to place right border, jump to PRG022_C5FD 
00690.  
00691. LDA #TILE15_BORDER_MR 
00692.  
00693. PRG022_C60D: 
00694. STA [BonusText_BaseL],Y ; Store appropriate middle border 
00695.  
00696. CPY #$9f 
00697. BNE PRG022_C5FD ; If Y <> $9F, loop! 
00698.  
00699. INY ; Y++ 
00700.  
00701. ; Lower left border 
00702. LDA #TILE15_BORDER_LL 
00703. STA [BonusText_BaseL],Y 
00704.  
00705. ; Run of 14 middle tiles 
00706. PRG022_C618: 
00707. INY ; Y++ 
00708.  
00709. LDA #TILE15_BORDER_LM 
00710. STA [BonusText_BaseL],Y 
00711.  
00712. CPY #$af 
00713. BNE PRG022_C618 
00714.  
00715. ; Lower right border 
00716. LDA #TILE15_BORDER_LR 
00717. STA [BonusText_BaseL],Y 
00718.  
00719. RTS ; Return 
00720.  
00721. QBoxOrange_Tiles: 
00722. .byte $C9, $CA, $CB, $CC 
00723. QBoxOrange_Tiles_End 
00724.  
00725. LoadLevel_QBoxOrange: 
00726. LDX #$00 ; X = 0 
00727. LDY TileAddr_Off ; Y = TileAddr_Off 
00728. PRG022_C62F: 
00729.  
00730. ; Temp_Var1 = 1 
00731. LDA #$01 
00732. STA <Temp_Var1 
00733.  
00734. PRG022_C633: 
00735.  
00736. ; Add prize box tile 
00737. LDA QBoxOrange_Tiles,X 
00738. STA [BonusText_BaseL],Y 
00739.  
00740. INY ; Y++ (next tile, DANGEROUS) 
00741. INX ; X++ (next prize box tile) 
00742.  
00743. DEC <Temp_Var1 ; Temp_Var1-- 
00744. BPL PRG022_C633 ; While Temp_Var1 >= 0, loop! 
00745.  
00746. ; Next row 
00747. LDA TileAddr_Off 
00748. ADD #16 
00749. STA TileAddr_Off 
00750. TAY ; -> 'Y' 
00751.  
00752. CPX #(QBoxOrange_Tiles_End - QBoxOrange_Tiles) 
00753. BNE PRG022_C62F ; While tiles to go, loop! 
00754.  
00755. RTS ; Return 
00756.  
00757. QBoxBlue_Tiles: 
00758. .byte $87, $88, $89, $8A 
00759. QBoxBlue_Tiles_End 
00760.  
00761.  
00762. LoadLevel_QBoxBlue: 
00763. LDX #$00 ; X = 0 
00764. LDY TileAddr_Off ; Y = TileAddr_Off 
00765. PRG022_C656: 
00766.  
00767. ; Temp_Var1 = 1 
00768. LDA #$01 
00769. STA <Temp_Var1 
00770.  
00771. PRG022_C65A: 
00772.  
00773. ; Add prize box tile 
00774. LDA QBoxBlue_Tiles,X 
00775. STA [BonusText_BaseL],Y 
00776.  
00777. INY ; Y++ (next tile, DANGEROUS) 
00778. INX ; X++ (next prize box tile) 
00779.  
00780. DEC <Temp_Var1 ; Temp_Var1-- 
00781. BPL PRG022_C65A ; While Temp_Var1 >= 0, loop! 
00782.  
00783. ; Next row 
00784. LDA TileAddr_Off 
00785. ADD #16 
00786. STA TileAddr_Off 
00787. TAY ; -> 'Y' 
00788.  
00789. CPX #(QBoxBlue_Tiles_End - QBoxBlue_Tiles) 
00790. BNE PRG022_C656 ; While tiles to go, loop! 
00791.  
00792. RTS ; Return 
00793.  
00794.  
00795. LoadLevel_BonusFloor: 
00796.  
00797. ; Temp_Var1 = 1 
00798. LDA #$01 
00799. STA <Temp_Var1 
00800.  
00801. LDY TileAddr_Off ; Y = TileAddr_Off 
00802.  
00803. PRG022_C67B: 
00804. LDA LL_ShapeDef 
00805. AND #$0f 
00806. TAX ; X = lower 4 bits of LL_ShapeDef 
00807.  
00808. PRG022_C681: 
00809. LDA #TILE15_BRICKFLOOR 
00810. STA [Map_Tile_AddrL],Y 
00811.  
00812. INY ; Y++ (NOT SAFE!) 
00813.  
00814. DEX ; X-- 
00815. BPL PRG022_C681 ; While X >= 0, loop 
00816.  
00817. ; Next row 
00818. LDA TileAddr_Off 
00819. ADD #16 
00820. STA TileAddr_Off 
00821. TAY ; -> 'Y' 
00822.  
00823. DEC <Temp_Var1 ; Temp_Var1-- 
00824. BPL PRG022_C67B ; While Temp_Var1 >= 0, loop 
00825.  
00826. RTS ; Return 
00827.  
00828. ; FIXME: Anyone want to claim this? 
00829. ; $C698 
00830.  
00831. ; Y += 16 
00832. TYA 
00833. ADD #16 
00834. TAY 
00835.  
00836. LDA <BonusText_BaseH 
00837. ADC #$00 
00838. STA <BonusText_BaseH 
00839.  
00840. RTS ; Return 
00841.  
00842. ; FIXME: Anyone want to claim this? 
00843. ; $C6A4 
00844. LDA <Temp_Var6  
00845. STA <BonusText_BaseH 
00846.  
00847. LDY TileAddr_Off 
00848. INY 
00849. TYA 
00850. AND #$0f 
00851. BNE PRG022_C6E2 
00852.  
00853. LDY #$00 
00854.  
00855. LDA <Temp_Var15 
00856. AND #$10 
00857. BEQ PRG022_C6BA 
00858.  
00859. INY  
00860.  
00861. PRG022_C6BA: 
00862. STY <Temp_Var10 
00863.  
00864. LDA <BonusText_BaseL 
00865. ADD #$b0 
00866. STA <BonusText_BaseL 
00867. LDA <BonusText_BaseH 
00868. ADC <Temp_Var10  
00869. STA <BonusText_BaseH 
00870. STA <Temp_Var6 
00871.  
00872. LDA <Temp_Var16 
00873. AND #$f0 
00874. LSR A 
00875. LSR A 
00876. LSR A 
00877. TAY 
00878.  
00879. INY 
00880. INY 
00881.  
00882. LDA Tile_Mem_Addr+1,Y 
00883. STA <Temp_Var5 
00884.  
00885. INC <Temp_Var5 
00886.  
00887. LDA TileAddr_Off 
00888. AND #$f0 
00889. TAY 
00890.  
00891. PRG022_C6E2: 
00892. STY TileAddr_Off 
00893. RTS ; Return 
00894.  
00895.  
00896. BonusGame_HostDraw: 
00897. LDA Bonus_GameHost 
00898. JSR DynJump 
00899.  
00900. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
00901. .word HostToad_Draw ; 0: Standard Toad Host 
00902. .word HostTroopa_DrawWithGameBits ; 1: (Unused, glitched) Koopa Troopa Host w/ (unused, glitched) large [?] and card 
00903. .word HostTroopa_Draw ; 2: (Unused, glitched) Koopa Troopa Host w/o the other thing 
00904. .word HostHammerBro_Draw ; 3: (Unused, glitched) Hammer Bro Host 
00905.  
00906. HostToad_Draw: 
00907. JSR HostToad_DrawSprites 
00908. RTS ; Return 
00909.  
00910. HostTroopa_DrawWithGameBits: 
00911. JSR HostTroopa_DrawSprites 
00912.  
00913. LDA #$3f ; <-- denotes starting tile, for other prize boxes?? 
00914. JSR Draw_KTPrizeGameBox ; Draw the Koopa Troopa "Prize" Game box and the prize 
00915.  
00916. RTS ; Return 
00917.  
00918. HostTroopa_Draw: 
00919. JSR HostTroopa_DrawSprites 
00920. RTS ; Return 
00921.  
00922. HostHammerBro_Draw: 
00923. JSR HostHammerBro_DrawSprites 
00924. RTS ; Return 
00925.  
00926. HostToad_SpriteYs: 
00927. .byte $60, $60, $60, $60, $70, $70, $70, $70, $80, $80, $80 
00928. HostToad_SpriteYs_End 
00929.  
00930. HostToad_SpriteXs: 
00931. .byte $C0, $C8, $D0, $D8, $C0, $C8, $D0, $D8, $C0, $C8, $D0 
00932.  
00933. HostToad_DrawSprites: 
00934.  
00935. ; Temp_Var11 = $95 (starting pattern of Toad Host sprites) 
00936. LDA #$95  
00937. STA <Temp_Var11 
00938.  
00939. LDY #$00 ; Y = 0 
00940. LDX #(HostToad_SpriteYs_End - HostToad_SpriteYs - 1) 
00941. PRG022_C727: 
00942.  
00943. ; Set Sprite Y of this sprite of the Toad Host 
00944. LDA HostToad_SpriteYs,X 
00945. STA Sprite_RAM+$10,Y 
00946.  
00947. INY ; Y++ (next sprite RAM byte) 
00948.  
00949. ; Set pattern of this sprite of the Toad Host 
00950. LDA <Temp_Var11 
00951. STA Sprite_RAM+$10,Y 
00952.  
00953. INY ; Y++ (next sprite RAM byte) 
00954.  
00955. ; Set palette of this sprite of the Toad Host 
00956. LDA #SPR_PAL0 
00957. STA Sprite_RAM+$10,Y 
00958.  
00959. INY ; Y++ (next sprite RAM byte) 
00960.  
00961. ; Set Sprite X of this sprite of the Toad Host 
00962. LDA HostToad_SpriteXs,X 
00963. STA Sprite_RAM+$10,Y 
00964.  
00965. INY ; Y++ (next sprite RAM byte) 
00966.  
00967. ; Temp_Var11 -= 2 (two patterns backward) 
00968. DEC <Temp_Var11 
00969. DEC <Temp_Var11 
00970.  
00971. DEX ; X-- 
00972. BPL PRG022_C727 ; While X >= 0, loop 
00973.  
00974. RTS ; Return 
00975.  
00976. HostTroopa_SpriteYs: 
00977. .byte $60, $60, $60, $70, $70, $70, $70, $80, $80, $80 
00978. HostTroopa_SpriteYs_End 
00979.  
00980. HostTroopa_SpriteXs: 
00981. .byte $C0, $C8, $D0, $C0, $C8, $D0, $D8, $C8, $D0, $D8 
00982.  
00983. HostTroopa_DrawSprites: 
00984. ; Temp_Var11 = $99 (starting pattern of Koopa Troopa Host sprites) 
00985. LDA #$99 ; WRONG! Should be $A9, then he'll display correctly :D 
00986. STA <Temp_Var11 
00987.  
00988. LDY #$00 ; Y = 0 
00989. LDX #(HostTroopa_SpriteYs_End - HostTroopa_SpriteYs - 1) 
00990. PRG022_C765: 
00991.  
00992. ; Set Sprite Y of this sprite of the Koopa Troopa Host 
00993. LDA HostTroopa_SpriteYs,X 
00994. STA Sprite_RAM+$10,Y 
00995.  
00996. INY ; Y++ (next sprite RAM byte) 
00997.  
00998. ; Set pattern of this sprite of the Koopa Troopa Host 
00999. LDA <Temp_Var11 
01000. STA Sprite_RAM+$10,Y 
01001.  
01002. INY ; Y++ (next sprite RAM byte) 
01003.  
01004. ; Set palette of this sprite of the Koopa Troopa Host 
01005. LDA #SPR_PAL0 
01006. STA Sprite_RAM+$10,Y 
01007.  
01008. INY ; Y++ (next sprite RAM byte) 
01009.  
01010. ; Set Sprite X of this sprite of the Koopa Troopa Host 
01011. LDA HostTroopa_SpriteXs,X 
01012. STA Sprite_RAM+$10,Y 
01013.  
01014. INY ; Y++ (next sprite RAM byte) 
01015.  
01016. ; Temp_Var11 -= 2 (two patterns backward) 
01017. DEC <Temp_Var11 
01018. DEC <Temp_Var11 
01019.  
01020. DEX ; X-- 
01021. BPL PRG022_C765 ; While X >= 0, loop 
01022.  
01023. RTS ; Return 
01024.  
01025.  
01026. HostHammerBro_SpriteYs: 
01027. .byte $60, $60, $60, $70, $70, $70, $70, $80, $80, $80, $80 
01028. HostHammerBro_SpriteYs_End 
01029.  
01030. HostHammerBro_SpriteXs: 
01031. .byte $C0, $C8, $D0, $C0, $C8, $D0, $D8, $C0, $C8, $D0, $D8 
01032.  
01033.  
01034. HostHammerBro_DrawSprites: 
01035. ; Temp_Var11 = $AF (starting pattern of Koopa Troopa Host sprites) 
01036. LDA #$AF ; WRONG! Should be $BF, then he'll display correctly :D 
01037. STA <Temp_Var11 
01038.  
01039. LDY #$00 ; Y = 0 
01040. LDX #(HostHammerBro_SpriteYs_End - HostHammerBro_SpriteYs - 1) 
01041. PRG022_C7A5: 
01042. ; Set Sprite Y of this sprite of the Hammer Bro Host 
01043. LDA HostHammerBro_SpriteYs,X 
01044. STA Sprite_RAM+$10,Y 
01045.  
01046. INY ; Y++ (next sprite RAM byte) 
01047.  
01048. ; Set pattern of this sprite of the Hammer Bro Host 
01049. LDA <Temp_Var11 
01050. STA Sprite_RAM+$10,Y 
01051.  
01052. INY ; Y++ (next sprite RAM byte) 
01053.  
01054. ; Set palette of this sprite of the Hammer Bro Host 
01055. LDA #SPR_PAL0 
01056. STA Sprite_RAM+$10,Y 
01057.  
01058. INY ; Y++ (next sprite RAM byte) 
01059.  
01060. ; Set Sprite X of this sprite of the Hammer Bro Host 
01061. LDA HostHammerBro_SpriteXs,X 
01062. STA Sprite_RAM+$10,Y 
01063.  
01064. INY ; Y++ (next sprite RAM byte) 
01065.  
01066. ; Temp_Var11 -= 2 (two patterns backward) 
01067. DEC <Temp_Var11 
01068. DEC <Temp_Var11 
01069.  
01070. DEX ; X-- 
01071. BPL PRG022_C7A5 ; While X >= 0, loop 
01072. RTS ; Return 
01073.  
01074. BonusGameBox_SpriteYs: 
01075. .byte $70, $70, $70, $70, $80, $80, $80, $80 
01076. BonusGameBox_SpriteYs_End 
01077.  
01078. BonusGameBox_SpriteXs: 
01079. .byte $70, $78, $80, $88, $70, $78, $80, $88 
01080.  
01081. Bonus_KTPrizeFlipBits: .byte SPR_HFLIP, $00 
01082.  
01083. Bonus_KTPrizePattern: 
01084. .byte $21, $25, $23, $27 
01085.  
01086.  
01087.  
01088. ; Draws the box and the "prize" for Koopa Troopa's "Prize" Game 
01089. Draw_KTPrizeGameBox: 
01090. STA <Temp_Var11  
01091.  
01092.  
01093. ; Draw the game box first 
01094.  
01095. LDX #(BonusGameBox_SpriteYs_End - BonusGameBox_SpriteYs - 1) 
01096. PRG022_C7E1: 
01097.  
01098. ; Set Sprite Y of this sprite 
01099. LDA BonusGameBox_SpriteYs,X 
01100. STA Sprite_RAM+$10,Y 
01101.  
01102. INY ; Y++ (next sprite RAM byte) 
01103.  
01104. ; Set pattern of this sprite 
01105. LDA <Temp_Var11 
01106. STA Sprite_RAM+$10,Y 
01107.  
01108. INY ; Y++ (next sprite RAM byte) 
01109.  
01110. ; Set palette of this sprite  
01111. LDA #SPR_PAL0 
01112. STA Sprite_RAM+$10,Y 
01113.  
01114. INY ; Y++ (next sprite RAM byte) 
01115.  
01116. ; Set Sprite X of this sprite 
01117. LDA BonusGameBox_SpriteXs,X 
01118. STA Sprite_RAM+$10,Y 
01119.  
01120. INY ; Y++ (next sprite RAM byte) 
01121.  
01122. ; Temp_Var11 -= 2 (two patterns backward) 
01123. DEC <Temp_Var11 
01124. DEC <Temp_Var11 
01125.  
01126. DEX ; X-- 
01127. BPL PRG022_C7E1 ; While X >= 0, loop 
01128.  
01129. ; Koopa Troopa must be finished introducing the game before the "Prize" is even displayed! 
01130. LDA Bonus_GameState 
01131. CMP #$02 
01132. BLT PRG022_C852 ; If Bonus_GameState < 2, jump to PRG022_C852 (RTS) 
01133.  
01134. LDX Bonus_KTPrize ; X = Bonus_KTPrize 
01135.  
01136. ; Store pattern for prize -> Temp_Var11 
01137. LDA Bonus_KTPrizePattern,X 
01138. STA <Temp_Var11 
01139.  
01140. ; Temp_Var12 = Bonus_PrizeX 
01141. LDA Bonus_PrizeX 
01142. STA <Temp_Var12  
01143.  
01144. LDX #$01 ; X = 1 (the two sprites that make up the prize) 
01145. PRG022_C818: 
01146.  
01147. ; Store prize sprite Y 
01148. LDA Bonus_PrizeY 
01149. STA Sprite_RAM+$10,Y 
01150.  
01151. INY ; Y++ (next sprite byte) 
01152.  
01153. ; Store prize pattern 
01154. LDA <Temp_Var11 
01155. STA Sprite_RAM+$10,Y 
01156.  
01157. INY ; Y++ (next sprite byte) 
01158.  
01159. ; Store prize attributes 
01160. LDA Bonus_KTPrizeFlipBits,X 
01161. STA Sprite_RAM+$10,Y 
01162.  
01163. INY ; Y++ (next sprite byte) 
01164.  
01165. ; Store prize sprite X 
01166. LDA <Temp_Var12  
01167. STA Sprite_RAM+$10,Y 
01168.  
01169. INY ; Y++ (next sprite byte) 
01170.  
01171. ; Temp_Var12 += 8 
01172. LDA <Temp_Var12  
01173. ADD #$08 
01174. STA <Temp_Var12 
01175.  
01176. DEX ; X-- 
01177. BPL PRG022_C818 ; While X >= 0, loop 
01178.  
01179.  
01180. LDA Bonus_PrizeY 
01181. CMP #$60 
01182. BEQ PRG022_C852 ; If Bonus_PrizeY = $60 (Bonus prize rose to the top), jump to PRG022_C852 (RTS) 
01183.  
01184. ; NOTE: It is possible that the "prize" wasn't suppose to rise until you actually won it, so 
01185. ; there would be some kind of logic here to jump passed... of course, I don't know for sure. 
01186.  
01187. DEC Bonus_PrizeY ; Bonus_PrizeY-- 
01188.  
01189. LDA Bonus_PrizeY 
01190. CMP #$5f 
01191. BGE PRG022_C852 ; If Bonus_PrizeY >= $5F (not at the top), jump to PRG022_C852 
01192.  
01193. ; Otherwise, stop at the top (what, thought you'd miss this with your DEC Mr. Programmer?) 
01194. LDA #$60 
01195. STA Bonus_PrizeY 
01196.  
01197. PRG022_C852: 
01198. RTS ; Return 
01199.  
01200. BonusText_HostGreetPtrL: 
01201. .byte LOW(BonusGame_UNUSED0_Text) ; 0: UNUSED (Japanese) Give key / coins 
01202. .byte LOW(BonusGame_Spade_Text) ; 1: Standard Spade Game instruction (OLD position of "Odd" game) 
01203. .byte LOW(BonusGame_NSpade_Text) ; 2: N-Spade instruction (OLD position of "Even" Game) 
01204. .byte LOW(BonusGame_UNUSED3_Text) ; 3: UNUSED "CCCCCCC CCCCCCC" 
01205. .byte LOW(BonusGame_UNUSED4_Text) ; 4: UNUSED "DDDDDDD" 
01206. .byte LOW(BonusGame_UNUSED5_Text) ; 5: UNUSED (Japanese) "If an odd number appears, I'll let you play the Roulette Game." 
01207. .byte LOW(BonusGame_UNUSED6_Text) ; 6: UNUSED (Japanese) "If an even number appears, I'll let you play the Card Game." 
01208. .byte LOW(BonusGame_UNUSED7_Text) ; 7: UNUSED (Japanese) "2, return (?)" 
01209.  
01210. BonusText_HostGreetPtrH: 
01211. .byte HIGH(BonusGame_UNUSED0_Text) ; 0: UNUSED (Japanese) Give key / coins 
01212. .byte HIGH(BonusGame_Spade_Text) ; 1: Standard Spade Game instruction (OLD position of "Odd" game) 
01213. .byte HIGH(BonusGame_NSpade_Text) ; 2: N-Spade instruction (OLD position of "Even" game) 
01214. .byte HIGH(BonusGame_UNUSED3_Text) ; 3: UNUSED "CCCCCCC CCCCCCC" 
01215. .byte HIGH(BonusGame_UNUSED4_Text) ; 4: UNUSED "DDDDDDD" 
01216. .byte HIGH(BonusGame_UNUSED5_Text) ; 5: UNUSED (Japanese) "If an odd number appears, I'll let you play the Roulette Game." 
01217. .byte HIGH(BonusGame_UNUSED6_Text) ; 6: UNUSED (Japanese) "If an even number appears, I'll let you play the Card Game." 
01218. .byte HIGH(BonusGame_UNUSED7_Text) ; 7: UNUSED (Japanese) "2, return (?)" 
01219.  
01220. ; A whole bunch of unused, untranslated text only really hooked into the Odd/Even game 
01221. ; These would be used in "Round 2." 
01222. BonusText_Round2PtrL: 
01223. .byte LOW(BonusGame_UNUSED_Etc0) ; 0 
01224. .byte LOW(BonusGame_UNUSED_Etc1) ; 1: OLD position of Odd Game winner (string identical to 5) 
01225. .byte LOW(BonusGame_UNUSED_Etc2) ; 2: OLD position of Even Game winner (string identical to 6) 
01226. .byte LOW(BonusGame_UNUSED_Etc3) ; 3 
01227. .byte LOW(BonusGame_UNUSED_Etc4) ; 4 
01228. .byte LOW(BonusGame_UNUSED_Etc5) ; 5: Odd Game winner! (BONUS_UNUSED_ODDROULETTE) 
01229. .byte LOW(BonusGame_UNUSED_Etc6) ; 6: Even Game winner! (BONUS_UNUSED_EVENCARD) 
01230. .byte LOW(BonusGame_UNUSED_Etc7) ; 7 
01231.  
01232. BonusText_Round2PtrH: 
01233. .byte HIGH(BonusGame_UNUSED_Etc0) ; 0 
01234. .byte HIGH(BonusGame_UNUSED_Etc1) ; 1: OLD position of Odd Game winner (string identical to 5) 
01235. .byte HIGH(BonusGame_UNUSED_Etc2) ; 2: OLD position of Even Game winner (string identical to 6) 
01236. .byte HIGH(BonusGame_UNUSED_Etc3) ; 3 
01237. .byte HIGH(BonusGame_UNUSED_Etc4) ; 4 
01238. .byte HIGH(BonusGame_UNUSED_Etc5) ; 5: Odd Game winner! (BONUS_UNUSED_ODDROULETTE) 
01239. .byte HIGH(BonusGame_UNUSED_Etc6) ; 6: Even Game winner! (BONUS_UNUSED_EVENCARD) 
01240. .byte HIGH(BonusGame_UNUSED_Etc7) ; 7 
01241.  
01242.  
01243. BonusGame_Do: 
01244. JSR BonusGame_HostDraw ; Draw the Bonus Game host 
01245.  
01246. LDA Bonus_GameState 
01247. CMP #$04 
01248. BLS PRG022_C880 ; If Bonus_GameState < 4, jump to PRG022_C880 
01249.  
01250. ; Bonus_GameState >= 4 
01251.  
01252. JSR Bonus_DrawDie ; Draw the bonus die! 
01253.  
01254. PRG022_C880: 
01255. LDA Bonus_GameState 
01256. CMP #$07 
01257. BLT PRG022_C8A0 ; If Bonus_GameState < 7, jump to PRG022_C8A0 
01258.  
01259. LDA <Pad_Input 
01260. AND #(PAD_A | PAD_B) 
01261. BEQ PRG022_C8A0 ; If Player is pushing neither A nor B, jump to PRG022_C8A0 
01262.  
01263. ; Player pushing A or B... 
01264.  
01265. LDA SndCur_Music2 
01266. BNE PRG022_C897 ; If music is playing from set 2, jump to PRG022_C897 
01267.  
01268. ; Otherwise, start the Bonus Game music 
01269. LDA #MUS2A_BONUSGAME 
01270. STA Sound_QMusic2 
01271.  
01272. PRG022_C897: 
01273.  
01274. ; Bonus_GameState = 9 
01275. LDA #$09 
01276. STA Bonus_GameState 
01277.  
01278. ; Exit to map! (NOTE: Exits to either Spade/N-Spade game) 
01279. LDA #$01 
01280. STA <Level_ExitToMap 
01281.  
01282. PRG022_C8A0: 
01283. LDA Bonus_GameState 
01284. JSR DynJump 
01285.  
01286. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
01287. .word Bonus_Init ; 0: Draw the dialog box, initialize the greeting text,  
01288. .word Bonus_DoHostText ; 1: Giving instructions for ALL UNUSED GAMES (then initializing the "prize"!) 
01289. .word Bonus_DieRotate ; 2: Rotating die logic; press 'A' and you may get a prize by the game type (or so it was intended) 
01290. .word Bonus_GetDiePrize ; 3: Get your die prize! (If you "won") Includes the "coin confetti" 
01291. .word Bonus_Wait80 ; 4: Waits $80 ticks 
01292. .word Bonus_DieFlyAway ; 5: Die "flies away"; go to state 6 if you won the Odd/Even game and to state 8 otherwise 
01293. .word Bonus_InitRound2 ; 6: Initialize for Round 2 
01294. .word Bonus_DoHostText ; 7: Giving instructions for Spade/N-Spade (LEGACY: For "Round 2" game) 
01295. .word Bonus_WaitA0 ; 8: Wait $A0 ticks 
01296. .word Bonus_KTPrizeGame ; 9: Appears to be all that was implemented toward "winning" the Koopa Troopa "Prize" Game 
01297.  
01298.  
01299. Bonus_Init: 
01300. ; Graphics_Queue values $8 to $C, inclusive, build the dialog box 
01301. LDA Bonus_CurBufOffset 
01302. ADD #$08 
01303. STA <Graphics_Queue 
01304.  
01305. INC Bonus_CurBufOffset ; Bonus_CurBufOffset++ 
01306.  
01307. CMP #$0c 
01308. BNE PRG022_C8EF ; If we've still more to queue for the instruction box, jump to PRG022_C8EF 
01309.  
01310. ; Done queueing the instruction box... 
01311.  
01312. ; Bonus_UnusedFlag = 0 
01313. LDA #$00 
01314. STA Bonus_UnusedFlag 
01315.  
01316. INC Bonus_GameState ; Bonus_GameState = 1 
01317.  
01318. LDY Bonus_GameType ; Y = Bonus_GameType 
01319.  
01320. ; Load the pointer to the host's greeting/instructional text 
01321. LDA BonusText_HostGreetPtrL,Y 
01322. STA <BonusText_BaseL 
01323. LDA BonusText_HostGreetPtrH,Y 
01324. STA <BonusText_BaseH 
01325.  
01326.  
01327. ; NOTE: This breaks the original Odd/Even game! For Odd/Even to work the way 
01328. ; it was originally intended (sort of), always jump to PRG022_C8EF! 
01329.  
01330. CPY #BONUS_SPADE 
01331. BEQ PRG022_C8E6 ; If this is the Spade game, jump to PRG022_C8E6 
01332.  
01333. CPY #BONUS_NSPADE 
01334. BNE PRG022_C8EF ; If this is NOT the N-Spade game, jump to PRG022_C8EF (RTS) 
01335.  
01336. PRG022_C8E6: 
01337.  
01338. ; Spade / N-Spade 
01339.  
01340. ; BonusDie_Y = $F8 (hide the die) 
01341. LDA #$f8 
01342. STA <BonusDie_Y 
01343.  
01344. ; Bonus_GameState = 7 (give instructions to Spade/N-Spade game) 
01345. LDA #$07 
01346. STA Bonus_GameState 
01347.  
01348. PRG022_C8EF: 
01349. RTS ; Return 
01350.  
01351. Bonus_WaitA0: 
01352. LDA Bonus_Timer 
01353. BNE PRG022_C8FA ; If Bonus_Timer <> 0, jump to PRG022_C8FA 
01354.  
01355. ; Bonus_Timer = $A0 
01356. LDA #$a0 
01357. STA Bonus_Timer 
01358.  
01359. PRG022_C8FA: 
01360. DEC Bonus_Timer ; Bonus_Timer-- 
01361. BNE PRG022_C906 ; If Bonus_Timer not expired, jump to PRG022_C906 
01362.  
01363. INC Bonus_GameState ; Bonus_GameState = 9 (bad state but nothing really happens because we're exiting) 
01364.  
01365. ; Exit to map 
01366. LDA #$01 
01367. STA <Level_ExitToMap 
01368.  
01369. PRG022_C906: 
01370. RTS ; Return 
01371.  
01372.  
01373. Bonus_DoHostText: 
01374. DEC BonusText_CharPause ; BonusText_CharPause-- 
01375.  
01376. BNE PRG022_C970 ; If BonusText_CharPause <> 0, jump to PRG022_C970 (RTS) 
01377.  
01378. ; BonusText_CharPause = 4 
01379. LDA #$04 
01380. STA BonusText_CharPause 
01381.  
01382. PRG022_C911: 
01383. LDA BonusText_CPos 
01384. AND #$01 
01385. BEQ PRG022_C91D ; Every other character, jump to PRG022_C91D 
01386.  
01387. ; Every other character, play the "blip" sound 
01388. LDA #SND_LEVELBLIP 
01389. STA Sound_QLevel1 
01390.  
01391. PRG022_C91D: 
01392. LDY BonusText_CPos ; Y = BonusText_CPos 
01393.  
01394. LDA [BonusText_BaseL],Y 
01395. BNE PRG022_C941 ; If character is not $00 (line break), jump to PRG022_C941 
01396.  
01397. ; Line break hit.. 
01398.  
01399. LDA BonusText_VL 
01400. ADD #32 ; +32 to next row 
01401. TAY ; -> 'Y' 
01402.  
01403. LDA BonusText_VH 
01404. ADC #$00 ; Apply carry 
01405. STA BonusText_VH 
01406.  
01407. ; Return character to initial column 
01408. TYA 
01409. AND #$e0 
01410. ORA #$05 
01411. STA BonusText_VL 
01412.  
01413. INC BonusText_CPos ; BonusText_CPos++ 
01414. JMP PRG022_C911 ; Jump to PRG022_C911 
01415.  
01416. PRG022_C941: 
01417. CMP #$ff 
01418. BEQ PRG022_C971 ; If $FF character (terminator), jump to PRG022_C971 
01419.  
01420. LDX Graphics_BufCnt ; X = Graphics_BufCnt 
01421.  
01422. ; Store character into graphics buffer 
01423. STA Graphics_Buffer+$03,X 
01424.  
01425. ; Set current text VRAM address into graphics buffer 
01426. LDA BonusText_VH 
01427. STA Graphics_Buffer+$00,X 
01428. LDA BonusText_VL 
01429. STA Graphics_Buffer+$01,X 
01430.  
01431. ; Run length of 1 
01432. LDA #$01 
01433. STA Graphics_Buffer+$02,X 
01434.  
01435. ; Terminator 
01436. LDA #$00 
01437. STA Graphics_Buffer+$04,X 
01438.  
01439. ; Graphics_BufCnt += 4 
01440. LDA Graphics_BufCnt 
01441. ADD #$04 
01442. STA Graphics_BufCnt 
01443.  
01444. INC BonusText_VL ; BonusText_VL++ (next VRAM byte) 
01445. INC BonusText_CPos ; BonusText_CPos++ (next character of string) 
01446.  
01447. PRG022_C970: 
01448. RTS ; Return 
01449.  
01450.  
01451. PRG022_C971: 
01452. LDA Bonus_GameState 
01453. CMP #$07 
01454. BEQ PRG022_C980 ; If Bonus_GameState = 7 (instructions for Spade/N-Spade [Or Round 2]), jump to PRG022_C980 
01455.  
01456. ; Set Bonus Prize X/Y = $78 
01457. LDA #$78 
01458. STA Bonus_PrizeY 
01459. STA Bonus_PrizeX 
01460.  
01461. PRG022_C980: 
01462.  
01463. ; BonusText_CPos = 0 
01464. LDA #$00 
01465. STA BonusText_CPos 
01466.  
01467. INC Bonus_GameState ; Bonus_GameState = 2 or 8 (the latter ONLY in the final game) 
01468.  
01469. INY ; Y++ (byte after string terminator) 
01470.  
01471. ; Get this byte -> Bonus_Round2 
01472. LDA [BonusText_BaseL],Y 
01473. STA Bonus_Round2 
01474.  
01475. RTS ; Return 
01476.  
01477. ; High/Low VRAM address to blank out the dialog lines in preparation for Round 2 
01478. Round2LineBlank_VRAMH: .byte $28, $28, $29 
01479. Round2LineBlank_VRAML: .byte $CA, $EA, $0A 
01480.  
01481. Bonus_InitRound2: 
01482.  
01483. ; Reset the dialog address! 
01484. LDA #$28 
01485. STA BonusText_VH 
01486. LDA #$ca 
01487. STA BonusText_VL 
01488.  
01489. INC Bonus_GameState ; Bonus_GameState = 7 
01490.  
01491. LDY Bonus_Round2 ; Y = Bonus_Round2 
01492.  
01493. ; Set the "Round 2" Text pointer 
01494. LDA BonusText_Round2PtrL,Y 
01495. STA <BonusText_BaseL 
01496. LDA BonusText_Round2PtrH,Y 
01497. STA <BonusText_BaseH 
01498.  
01499.  
01500. ; Create a Graphics Buffer command set to clear the three lines of dialog... 
01501. ; It probably would have been simpler and more efficient just to store the 
01502. ; raw commands, but whatever... 
01503.  
01504. LDX Graphics_BufCnt ; X = Graphics_BufCnt 
01505. LDY #$02 ; Y = 2 (0, 1, 2; three lines of dialog) 
01506. PRG022_C9B4:  
01507. ; Set VRAM high for line blanking 
01508. LDA Round2LineBlank_VRAMH,Y 
01509. STA Graphics_Buffer+$00,X 
01510.  
01511. INX ; X++ (next graphics buffer byte) 
01512.  
01513. ; Set VRAM low for line blanking 
01514. LDA Round2LineBlank_VRAML,Y 
01515. STA Graphics_Buffer+$00,X 
01516.  
01517. INX ; X++ (next graphics buffer byte) 
01518.  
01519. ; Run length to blank a line of dialog 
01520. LDA #(VU_REPEAT | $12) 
01521. STA Graphics_Buffer+$00,X 
01522.  
01523. INX ; X++ (next graphics buffer byte) 
01524.  
01525. ; "Space" character pattern 
01526. LDA #$fe 
01527. STA Graphics_Buffer+$00,X 
01528.  
01529. INX ; X++ (next graphics buffer byte) 
01530.  
01531. DEY ; Y-- 
01532. BPL PRG022_C9B4 ; While Y >= 0, loop! 
01533.  
01534.  
01535. ; Terminator 
01536. LDA #$00 
01537. STA Graphics_Buffer+$00,X 
01538.  
01539. ; Graphics_BufCnt += $0C 
01540. LDA Graphics_BufCnt 
01541. ADD #$0c 
01542. STA Graphics_BufCnt 
01543.  
01544. RTS ; Return 
01545.  
01546. Bonus_KTPrizeGame: 
01547.  
01548. ; PAY ATTENTION: 
01549. ; 1) This actually cares about which host is running the game! 
01550. ; 2) This actually cares about what height the "powerup prize" is at! 
01551.  
01552. ; Also, there's no way out of this state (nothing changes Bonus_GameState!) 
01553. ; so you're kind of stuck if you get into this routine... 
01554. ; But incidentally, the game DOES put itself in here as it is exiting, but 
01555. ; since Level_ExitToMap is set, it's already on its way out... 
01556.  
01557. LDA Bonus_GameHost 
01558. CMP #$01 
01559. BNE PRG022_C9EE ; If this is NOT the Koopa Troopa host (!!), jump to PRG022_C9EE 
01560.  
01561. ; This IS the Koopa Troopa host... 
01562.  
01563. LDA Bonus_PrizeY 
01564. CMP #$60 
01565. BNE PRG022_C9F1 ; If Bonus_PrizeY <> $60 (Prize not fully raised), jump to PRG022_C9F1 (RTS) 
01566.  
01567. PRG022_C9EE: 
01568. JSR Bonus_DoNothing ; Who knows?? 
01569.  
01570. PRG022_C9F1: 
01571. RTS ; Return 
01572.  
01573. Bonus_DoNothing: 
01574.  
01575. ; WHAT WAS THIS? D: 
01576. ; Maybe you earned the prize? 
01577.  
01578. RTS ; Return 
01579.  
01580. Bonus_InstBoxTop: 
01581.  
01582. ; Left corner 
01583. vaddr $28A4 
01584. .byte $01, $94 
01585.  
01586. ; Bar 
01587. vaddr $28A5 
01588. .byte VU_REPEAT | $18, $90 
01589.  
01590. ; Right corner 
01591. vaddr $28BD 
01592. .byte $01, $96 
01593.  
01594. .byte $00 ; Terminator 
01595.  
01596. Bonus_InstBoxLine1: 
01597.  
01598. ; Left edge 
01599. vaddr $28C4 
01600. .byte $01, $92 
01601.  
01602. ; Middle 
01603. vaddr $28C5 
01604. .byte VU_REPEAT | $18, $FE 
01605.  
01606. ; Right edge 
01607. vaddr $28DD 
01608. .byte $01, $93 
01609.  
01610. .byte $00 ; Terminator 
01611.  
01612. Bonus_InstBoxLine2: 
01613.  
01614. ; Left edge 
01615. vaddr $28E4 
01616. .byte $01, $92 
01617.  
01618. ; Middle 
01619. vaddr $28E5 
01620. .byte VU_REPEAT | $18, $FE 
01621.  
01622. ; Right edge 
01623. vaddr $28FD 
01624. .byte $01, $93 
01625.  
01626. .byte $00 ; Terminator 
01627.  
01628. Bonus_InstBoxLine3: 
01629.  
01630. ; Left edge 
01631. vaddr $2904 
01632. .byte $01, $92 
01633.  
01634. ; Middle 
01635. vaddr $2905 
01636. .byte VU_REPEAT | $18, $FE 
01637.  
01638. ; Right edge 
01639. vaddr $291D 
01640. .byte $01, $93 
01641.  
01642. .byte $00 ; Terminator 
01643.  
01644.  
01645. Bonus_InstBoxBot: 
01646.  
01647. ; Left corner 
01648. vaddr $2924 
01649. .byte $01, $95 
01650.  
01651. ; Bar 
01652. vaddr $2925 
01653. .byte VU_REPEAT | $18, $91 
01654.  
01655. ; Right corner 
01656. vaddr $293D 
01657. .byte $01, $97 
01658.  
01659. .byte $00 ; Terminator 
01660.  
01661.  
01662. ; NOTE! Bonus_Round2 is actually set by a byte which follows the end of the text string! 
01663.  
01664. ; UNUSED (Japanese) If "1" appears, 1 (?) / If "2" appears, I'll give you a key / Otherwise, I'll give you coins. 
01665. ; English mangled display "1FnSnPg 1" / "2FnSnPg FGnp" / "OjBFnBZ JBmpAInfC" 
01666. BonusGame_UNUSED0_Text: 
01667.  
01668. ; 1 F n S n P g 1 
01669. .byte $9D, $B5, $DD, $C2, $DD, $BF, $D6, $FE, $9D, $00 
01670.  
01671. ; 2 F n S n P g F G n p 
01672. .byte $9E, $B5, $DD, $C2, $DD, $BF, $D6, $FE, $B5, $B6, $DD, $DF, $00 
01673.  
01674. ; O j B F n B Z J B m p A I n f C 
01675. .byte $BE, $D9, $B1, $B5, $DD, $B1, $C9, $FE, $B9, $B1, $DC, $DF, $B0, $B8, $DD, $D5, $B2 
01676.  
01677. ; (Terminator, value into Bonus_Round2) 
01678. .byte $FF, BONUS_UNUSED_KEYCOIN 
01679.  
01680. ; Spade Instruction 
01681. ; English: "Line up the pictures and" / "get a prize!" / "You only get one try." 
01682. BonusGame_Spade_Text: 
01683. ; L i n e u p t h e p i c t u r e s a n d 
01684. .byte $BB, $D8, $DD, $D4, $FE, $CE, $DF, $FE, $CD, $D7, $D4, $FE, $DF, $D8, $D2, $CD, $CE, $CB, $D4, $CC, $FE, $D0, $DD, $D3, $00 
01685.  
01686. ; g e t a p r i z e ! 
01687. .byte $D6, $D4, $CD, $FE, $D0, $FE, $DF, $CB, $D8, $8F, $D4, $EA, $00 
01688.  
01689. ; Y o u o n l y g e t o n e t r y . 
01690. .byte $C8, $DE, $CE, $FE, $DE, $DD, $DB, $8C, $FE, $D6, $D4, $CD, $FE, $DE, $DD, $D4, $FE, $CD, $CB, $8C, $E9 
01691.  
01692. ; (Terminator, value into Bonus_Round2) 
01693. .byte $FF, BONUS_SPADE 
01694.  
01695. ; N-Spade Instruction 
01696. ; English: "Flip over any two cards" / "and see if they match." / "You can only miss twice!" 
01697. BonusGame_NSpade_Text: 
01698. ; F l i p o v e r a n y t w o c a r d s 
01699. .byte $B5, $DB, $D8, $DF, $FE, $DE, $CF, $D4, $CB, $FE, $D0, $DD, $8C, $FE, $CD, $81, $DE, $FE, $D2, $D0, $CB, $D3, $CC, $00 
01700.  
01701. ; a n d s e e i f t h e y m a t c h . 
01702. .byte $D0, $DD, $D3, $FE, $CC, $D4, $D4, $FE, $D8, $D5, $FE, $CD, $D7, $D4, $8C, $FE, $DC, $D0, $CD, $D2, $D7, $E9, $00 
01703.  
01704. ; Y o u c a n o n l y m i s s t w i c e ! 
01705. .byte $C8, $DE, $CE, $FE, $D2, $D0, $DD, $FE, $DE, $DD, $DB, $8C, $FE, $DC, $D8, $CC, $CC, $FE, $CD, $81, $D8, $D2, $D4, $EA 
01706.  
01707. ; (Terminator, value into Bonus_Round2) 
01708. .byte $FF, BONUS_NSPADE 
01709.  
01710. ; UNUSED "CCCCCCC" / "CCCCCCC" 
01711. BonusGame_UNUSED3_Text: 
01712. ; C C C C C C C 
01713. .byte $B2, $B2, $B2, $B2, $B2, $B2, $B2, $00 
01714.  
01715. ; C C C C C C C 
01716. .byte $B2, $B2, $B2, $B2, $B2, $B2, $B2 
01717.  
01718. ; (Terminator, value into Bonus_Round2) 
01719. .byte $FF, BONUS_UNUSED_KEYCOIN 
01720.  
01721. ; UNUSED "DDDDDDD" 
01722. BonusGame_UNUSED4_Text: 
01723. ; D D D D D D D 
01724. .byte $B3, $B3, $B3, $B3, $B3, $B3, $B3 
01725.  
01726. ; (Terminator, value into Bonus_Round2) 
01727. .byte $FF, BONUS_UNUSED_KEYCOIN 
01728.  
01729. ; UNUSED (Japanese) "If an odd number appears, I'll let you play the Roulette Game." 
01730. ; English mangled display "GMCFn SnPg" / "i-j-TIn-ap" / "dgNS AInfC" 
01731. BonusGame_UNUSED5_Text: 
01732. ; G M C F n S n P g 
01733. .byte $B6, $BC, $B2, $B5, $DD, $FE, $C2, $DD, $BF, $D6, $00 
01734.  
01735. ; i - j - T I n - a p 
01736. .byte $D8, $E5, $D9, $E5, $C3, $B8, $DD, $E5, $D0, $DF, $00 
01737.  
01738. ; d g N S A I n f C 
01739. .byte $D3, $D6, $BD, $C2, $FE, $B0, $B8, $DD, $D5, $B2 
01740.  
01741. ; (Terminator, value into Bonus_Round2) 
01742. .byte $FF, BONUS_UNUSED_ODDROULETTE 
01743.  
01744. ; UNUSED (Japanese) "If an even number appears, I'll let you play the Card Game." 
01745. ; English mangled display "Hn-MCFnSnPg" / "F-TnIn-ap" / "KNS AInfC" 
01746. BonusGame_UNUSED6_Text: 
01747. ; H n - M C F n S n P g 
01748. .byte $B7, $DD, $E5, $BC, $B2, $B5, $DD, $C2, $DD, $BF, $D6, $00 
01749.  
01750. ; F - T n I n - a p 
01751. .byte $B5, $E5, $C3, $DD, $B8, $DD, $E5, $D0, $DF, $00 
01752.  
01753. ; K N S A I n f C 
01754. .byte $BA, $BD, $C2, $FE, $B0, $B8, $DD, $D5, $B2 
01755.  
01756. ; (Terminator, value into Bonus_Round2) 
01757. .byte $FF, BONUS_UNUSED_EVENCARD 
01758.  
01759. ; UNUSED (Japanese) "2, return (?)" 
01760. ; English mangled display "2 cTnj" 
01761. BonusGame_UNUSED7_Text: 
01762. ; 2 c T n j  
01763. .byte $9E, $FE, $D2, $C3, $DD, $D9 
01764.  
01765. ; (Terminator, value into Bonus_Round2) 
01766. .byte $FF, BONUS_UNUSED_KEYCOIN 
01767.  
01768.  
01769. ; The following strings are not in the "primary" set, so they would not have 
01770. ; been spoken by the host at first entrance; perhaps they were in response 
01771. ; to an action you would have taken within the game? 
01772.  
01773. ; I also notice that they used a shorter terminator... 
01774.  
01775.  
01776. ; UNUSED (Japanese) "Give something?" (Google translates as "I'll give you something?") 
01777. ; English mangled display " cYp dkC?" 
01778. BonusGame_UNUSED_Etc0: 
01779. ; c Y p d k C ? 
01780. .byte $FE, $D2, $C8, $DF, $FE, $D3, $DA, $B2, $EB 
01781.  
01782. ; (Terminator) 
01783. .byte $FF 
01784.  
01785. ; UNUSED (Japanese) "Play three times!" (This apparently was for the Roulette game; would set Roulette_Turns) 
01786. ; English mangled display "3FB rojBPnf" 
01787. BonusGame_UNUSED_Etc1: 
01788. ; 3 F B r o j B P n f  
01789. .byte $9F, $B5, $B1, $FE, $CB, $DE, $D9, $B1, $BF, $DD, $D5 
01790.  
01791. ; (Terminator) 
01792. .byte $FF 
01793.  
01794. ; UNUSED (Japanese) "Chance to twice" / "Set aside two identical cards" 
01795. ; English mangled display "QmyMZ 2FB" / "EULn F-Tnp" / "2uB ASSJngm" 
01796. BonusGame_UNUSED_Etc2: 
01797. ; Q m y M Z 2 F B  
01798. .byte $C0, $8C, $DC, $BC, $C9, $FE, $9E, $B5, $B1, $00 
01799.  
01800. ; E U L n F - T n p  
01801. .byte $B4, $C4, $BB, $DD, $FE, $B5, $E5, $C3, $DD, $DF, $00 
01802.  
01803. ; 2 u B A S S J n g m 
01804. .byte $9E, $CE, $B1, $FE, $B0, $C2, $C2, $B9, $DD, $D6, $DC 
01805.  
01806. ; (Terminator) 
01807. .byte $FF 
01808.  
01809. ; UNUSED "CCCC CCCC" 
01810. BonusGame_UNUSED_Etc3: 
01811. ; C C C C 
01812. .byte $B2, $B2, $B2, $B2, $00 
01813.  
01814. ; C C C C 
01815. .byte $B2, $B2, $B2, $B2 
01816.  
01817. ; (Terminator) 
01818. .byte $FF 
01819.  
01820. ; UNUSED "DDDD" 
01821. BonusGame_UNUSED_Etc4: 
01822. ; D D D D 
01823. .byte $B3, $B3, $B3, $B3 
01824.  
01825. ; (Terminator) 
01826. .byte $FF 
01827.  
01828. ; UNUSED (Japanese) "Play three times!" 
01829. ; English mangled display "3FB rojBPnf" 
01830. BonusGame_UNUSED_Etc5: 
01831. ; 3 F B r o j B P n f  
01832. .byte $9F, $B5, $B1, $FE, $CB, $DE, $D9, $B1, $BF, $DD, $D5 
01833.  
01834. ; (Terminator) 
01835. .byte $FF 
01836.  
01837. ; UNUSED (Japanese) "Chance to twice" / "Set aside two identical cards" 
01838. ; English mangled display "QmyMZ 2FB" / "EULn F-Tnp" / "2uB ASSJngm" 
01839. BonusGame_UNUSED_Etc6: 
01840. ; Q m y M Z 2 F B  
01841. .byte $C0, $8C, $DC, $BC, $C9, $FE, $9E, $B5, $B1, $00 
01842.  
01843. ; E U L n F - T n p  
01844. .byte $B4, $C4, $BB, $DD, $FE, $B5, $E5, $C3, $DD, $DF, $00 
01845.  
01846. ; 2 u B A S S J n g m 
01847. .byte $9E, $CE, $B1, $FE, $B0, $C2, $C2, $B9, $DD, $D6, $DC 
01848.  
01849. ; (Terminator) 
01850. .byte $FF 
01851.  
01852. ; UNUSED (Japanese) "2, return (?)" 
01853. ; English mangled display "2 cTnj" 
01854. BonusGame_UNUSED_Etc7: 
01855. ; 2 c T n j  
01856. .byte $9E, $FE, $D2, $C3, $DD, $D9 
01857.  
01858. ; (Terminator) 
01859. .byte $FF 
01860.  
01861.  
01862. ; Bonus_Return2_SetMapPos: 
01863. ; 
01864. ; A strange subroutine called for Bonus_GameType = BONUS_UNUSED_2RETURN!! 
01865. ; It forces the Player to a different map position ?? 
01866. ; And marks them as having died in the bonus game ??! 
01867. ; 
01868. ; Since it references Bonus_KTPrize, it MAY have been Koopa Troopa's  
01869. ; "Prize" Game... but death? I'm not sure the prize is worth it! D: 
01870.  
01871. Bonus_Return2Row: .byte $50, $40, $80, $60 ; Literally Map Y 
01872. Bonus_Return2Col: .byte $50, $A0, $40, $A0 ; Upper bits is column, lower bits is map screen i.e. XHi 
01873.  
01874. Bonus_Return2_SetMapPos: 
01875.  
01876. ; Temp_Var1 = Bonus_KTPrize * 2 
01877. LDA Bonus_KTPrize ; <-- !! A reference to Bonus_KTPrize 
01878. ASL A 
01879. STA <Temp_Var1 
01880.  
01881. LDY Player_Current ; Y = Player_Current 
01882.  
01883. LDA Map_Previous_Dir,Y 
01884. AND #$0a 
01885. BEQ PRG022_CBDD ; If Player didn't move up or left, jump to PRG022_CBDD 
01886.  
01887. INC <Temp_Var1 ; Temp_Var1++ 
01888.  
01889. PRG022_CBDD: 
01890. LDX <Temp_Var1 ; X = Temp_Var1 
01891.  
01892. LDA Bonus_Return2Row,X 
01893. STA Map_Previous_Y,Y 
01894.  
01895. LDA Bonus_Return2Col,X 
01896. AND #$f0 
01897. STA Map_Previous_X,Y 
01898.  
01899. LDA Bonus_Return2Col,X 
01900. AND #$0f 
01901. STA Map_Previous_XHi,Y 
01902.  
01903. ; Player "died" ?!! 
01904. LDA #$01 
01905. STA Map_ReturnStatus 
01906.  
01907. RTS ; Return 
01908.  
01909. Die_OddEven: .byte $00, $01 ; Match the odd/even (NOTE: Die face is 0 = 1, 1 = 2, etc. so odd first, then even, etc.) 
01910. Die_OddEvenMatch: .byte BONUS_UNUSED_ODDROULETTE, BONUS_UNUSED_EVENCARD ; Sets Bonus_DieCnt to this value! 
01911.  
01912. Bonus_DieRotate: 
01913. INC Bonus_DieCnt ; Bonus_DieCnt++ 
01914.  
01915. LDA Bonus_DieCnt 
01916. AND #$03 
01917. BNE PRG022_CC18 ; 1:4 ticks proceed, otherwise jump to PRG022_CC18 
01918.  
01919. INC Bonus_DiePos ; Bonus_DiePos++ 
01920.  
01921. ; Cap the die 0-5 
01922. LDA Bonus_DiePos 
01923. CMP #$06 
01924. BNE PRG022_CC18 ; If Bonus_DiePos <> $06, jump to PRG022_CC18 
01925.  
01926. ; Bonus_DiePos= 0 
01927. LDA #$00 
01928. STA Bonus_DiePos 
01929.  
01930. PRG022_CC18: 
01931. LDA <Pad_Input 
01932. AND #PAD_A 
01933. BEQ Bonus_DrawDie ; If Player is not pressing 'A', just go draw the Die 
01934.  
01935. ; Player pressed 'A'... 
01936.  
01937. LDA #$00 
01938. STA Bonus_DieCnt ; Bonus_DieCnt = 0  
01939. STA Bonus_UnusedFlag ; Bonus_UnusedFlag = 0 
01940.  
01941.  
01942. ; The following is WRONG, because the Spade/N-Spade Bonus Games will never use this state! 
01943.  
01944. ; This was the Odd/Even game as specified by the Japanese messages: 
01945. ; "If an odd number appears, I'll let you play the Roulette Game." 
01946. ; "If an even number appears, I'll let you play the Card Game." 
01947.  
01948. LDY #$00 ; Y = 0 (Odd die face value will "win") 
01949.  
01950. LDA Bonus_GameType 
01951. CMP #BONUS_SPADE ; <-- should be replaced by BONUS_UNUSED_ODDROULETTE 
01952. BEQ PRG022_CC34 ; If Bonus_GameType = BONUS_SPADE, jump to PRG022_CC34 
01953.  
01954. INY ; Y = 1 (Even die face value will "win") 
01955.  
01956. CMP #BONUS_NSPADE ; <-- should be replaced by BONUS_UNUSED_EVENCARD 
01957. BNE PRG022_CC4C ; If Bonus_GameType <> BONUS_NSPADE, jump to PRG022_CC4C 
01958.  
01959. PRG022_CC34: 
01960.  
01961. ; Even / Odd Bonus Game 
01962.  
01963. LDA Bonus_DiePos 
01964. AND #$01 ; Check odd/even of die 
01965. CMP Die_OddEven,Y 
01966. BNE PRG022_CC44 ; If die is not on proper odd/even, jump to PRG022_CC44 
01967.  
01968. ; Odd/Even matched win 
01969.  
01970. ; Set Bonus_DieCnt to the cooresponding Die_OddEvenMatch value 
01971. LDA Die_OddEvenMatch,Y 
01972. STA Bonus_DieCnt 
01973.  
01974. PRG022_CC44: 
01975.  
01976. ; End of the Odd or Even game! Whether you won or lost, the die will now fly away.  
01977. ; If you won, you go on to "Round 2"; if you lost, bail to world map. 
01978.  
01979. ; Bonus_GameState = 4 
01980. LDA #$04 
01981. STA Bonus_GameState 
01982.  
01983. JMP Bonus_DrawDie ; Draw Die and don't come back!! 
01984.  
01985. PRG022_CC4C: 
01986.  
01987. ; Not the Even / Odd game 
01988.  
01989. LDX Bonus_DiePos ; X = Bonus_DiePos 
01990. CPX #$02 
01991. BLT PRG022_CC57 ; If Bonus_DiePos < 2 (Die face value 3), jump to PRG022_CC57 
01992.  
01993. ; Die face value 3 or greater nets you (Face Value * 10) points 
01994.  
01995. ; NOTE: This was "probably" supposed to go to your coins if the Japanese message is correct 
01996. ; Further hinted because "coins" pop out... 
01997.  
01998. ; If "1" appears, 1 (?) 
01999. ; If "2" appears, I'll give you a key 
02000. ; Otherwise, I'll give you coins. 
02001.  
02002. INX ; X++ (because "pos 0" --> Face value 1, etc.) 
02003. STX Score_Earned ; -> Score_Earned 
02004.  
02005. PRG022_CC57: 
02006. INC Bonus_GameState ; Bonus_GameState = 3 
02007.  
02008.  
02009. Bonus_DrawDie: 
02010.  
02011. ; Set left/right die sprites Y 
02012. LDA <BonusDie_Y  
02013. STA Sprite_RAM+$F8 
02014. STA Sprite_RAM+$FC 
02015.  
02016. ; Set left/right die sprites patterns 
02017. LDA Bonus_DiePos 
02018. ASL A 
02019. ORA #$11 
02020. STA Sprite_RAM+$F9 
02021. STA Sprite_RAM+$FD 
02022.  
02023. ; Set left half of die attributes 
02024. LDA #SPR_PAL3 
02025. STA Sprite_RAM+$FA 
02026.  
02027. ; Set right half of die attributes 
02028. LDA #(SPR_PAL3 | SPR_HFLIP | SPR_VFLIP) 
02029. STA Sprite_RAM+$FE 
02030.  
02031. ; Set left half of die X 
02032. LDA <BonusDie_X 
02033. STA Sprite_RAM+$FB 
02034.  
02035. ; Set right half of die X 
02036. ADD #$08 
02037. STA Sprite_RAM+$FF 
02038.  
02039. RTS ; Return 
02040.  
02041. ; ?? Is this another message? 
02042. PRG022_CC84: 
02043. .byte $CB, $DE, $E5, $BB, $E7, $FE, $B3, $E5, $FF, $60 
02044.  
02045. ; FIXME: Anyone want to claim this? 
02046. ; Seems like it would display a short message maybe (above) 
02047. ; $CC8E 
02048. LDA Bonus_UnusedFlag 
02049. BNE PRG022_CCED ; If Bonus_UnusedFlag <> 0, jump to PRG022_CCED (RTS) 
02050.  
02051. INC BonusText_CharPause ; BonusText_CharPause++ 
02052.  
02053. LDA BonusText_CharPause 
02054. AND #$03 
02055. BNE PRG022_CCED ; 1:4 ticks proceed, otherwise jump to PRG022_CCED (RTS) 
02056.  
02057. PRG022_CC9D: 
02058. LDX BonusText_CPos ; X = BonusText_CPos 
02059.  
02060. LDA PRG022_CC84,X 
02061. BNE PRG022_CCB0 
02062.  
02063. ; Bonus_UnusedVL = $55 
02064. LDA #$55 
02065. STA Bonus_UnusedVL 
02066.  
02067. INC BonusText_CPos 
02068.  
02069. JMP PRG022_CC9D ; Jump to PRG022_CC9D 
02070.  
02071. PRG022_CCB0: 
02072. CMP #$ff 
02073. BNE PRG022_CCC2  
02074.  
02075. LDA #$35 
02076. STA Bonus_UnusedVL 
02077.  
02078. LDA #$00 
02079. STA BonusText_CPos 
02080.  
02081. INC Bonus_UnusedFlag 
02082.  
02083. RTS ; Return 
02084.  
02085.  
02086. PRG022_CCC2: 
02087. LDY Graphics_BufCnt 
02088. STA Graphics_Buffer+$03,Y 
02089.  
02090. LDA Bonus_UnusedVH 
02091. STA Graphics_Buffer+$00,Y 
02092. LDA Bonus_UnusedVL 
02093. STA Graphics_Buffer+$01,Y 
02094.  
02095. LDA #$01 
02096. STA Graphics_Buffer+$02,Y 
02097.  
02098. LDA #$00 
02099. STA Graphics_Buffer+$04,Y 
02100.  
02101. LDA Graphics_BufCnt 
02102. ADD #$04 
02103. STA Graphics_BufCnt 
02104.  
02105. INC Bonus_UnusedVL 
02106. INC BonusText_CPos 
02107.  
02108. PRG022_CCED: 
02109. RTS ; Return 
02110.  
02111.  
02112. Bonus_DieFlyAway: 
02113. LDA <Counter_1  
02114. AND #$01 
02115. BNE PRG022_CD03 ; Every other tick, jump to PRG022_CD03 
02116.  
02117.  
02118. ; The die rotates through its faces as it "flies away" 
02119.  
02120. INC Bonus_DiePos ; Bonus_DiePos++ 
02121.  
02122. ; Cap the die 0-5 
02123. LDA Bonus_DiePos 
02124. CMP #$06 
02125. BNE PRG022_CD03 ; If Bonus_DiePos <> $06, jump to PRG022_CD03 
02126.  
02127. ; Bonus_DiePos = 0 
02128. LDA #$00 
02129. STA Bonus_DiePos 
02130.  
02131. PRG022_CD03: 
02132. LDA <BonusDie_YVel 
02133. CMP #-$80 
02134. BEQ PRG022_CD0E ; If BonusDie_YVel = -$80, jump to PRG022_CD0E 
02135.  
02136. ; BonusDie_YVel -= $08 
02137. SUB #$08 
02138. STA <BonusDie_YVel 
02139.  
02140. PRG022_CD0E: 
02141. LDA <BonusDie_YVel ; Get die Velocity 
02142. ASL A  
02143. ASL A  
02144. ASL A  
02145. ASL A ; Fractional part shifted up 
02146. STA <Temp_Var1 ; -> Temp_Var1 
02147.  
02148. LDA <BonusDie_YVel ; Get Velocity 
02149. LSR A 
02150. LSR A 
02151. LSR A 
02152. LSR A ; Whole part shifted down (integer) 
02153. CMP #%00001000 ; Check the sign bit 
02154. BLT PRG022_CD22 ; If the value was not negatively signed, jump to PRG022_CD22 
02155. ORA #%11110000 ; Apply a sign extension 
02156. PRG022_CD22: 
02157. STA <Temp_Var2 ; -> Temp_Var2 
02158.  
02159. ; Add to die's velocity fractional accumulator 
02160. LDA <BonusDie_YVelFrac 
02161. ADD <Temp_Var1 
02162. STA <BonusDie_YVelFrac 
02163.  
02164. ; Add appropriately to die's Y 
02165. LDA <BonusDie_Y 
02166. ADC <Temp_Var2 
02167. STA <BonusDie_Y 
02168.  
02169. LDA <BonusDie_Y 
02170. CMP #$f8 
02171. BLT PRG022_CD50 ; If bonus die hasn't wrapped, jump to PRG022_CD50 
02172.  
02173. ; Hide bonus die 
02174. LDA #$f8 
02175. STA <BonusDie_Y 
02176.  
02177. ; Halt its velocity 
02178. LDA #$00 
02179. STA <BonusDie_YVel 
02180.  
02181. ; Bonus_UnusedFlag = 0  
02182. STA Bonus_UnusedFlag 
02183.  
02184. LDA Bonus_DieCnt 
02185. BEQ PRG022_CD4B ; If Bonus_DieCnt = 0 (not a winner of the Odd/Even game), jump to PRG022_CD4B 
02186.  
02187. ; Winners of Odd/Even Game only! 
02188. INC Bonus_GameState ; Bonus_GameState = 6 
02189.  
02190. ; NOTE: Bonus_Round2 (i.e. what game we're going to next) was set by the intro dialog text! 
02191.  
02192. RTS ; Return 
02193.  
02194. PRG022_CD4B: 
02195.  
02196. ; Bonus_GameState = 8 
02197. LDA #$08 
02198. STA Bonus_GameState 
02199.  
02200. PRG022_CD50: 
02201. RTS ; Return 
02202.  
02203.  
02204. Bonus_GetDiePrize: 
02205. LDA Bonus_DiePos 
02206. CMP #$02 
02207. BGE PRG022_CD6F ; If Bonus_DiePos >= 2 (Die face value of 3 or more, coin prizes), jump to PRG022_CD6F 
02208.  
02209. CMP #$01 
02210. BNE PRG022_CD65 ; If Die face value is NOT 2 (i.e. it is 1), jump to PRG022_CD65 
02211.  
02212. ; "If 2 appears, I'll give you a key" 
02213.  
02214. ; Ultimately it is unclear what this was INTENDED to do. It modifies the first 
02215. ; byte of the Player's "inventory" score (i.e. the backup used for Players 
02216. ; switching turns), but not in a "safe" way that carries through the other bytes. 
02217. ; That alone makes me believe that the memory in that area originally was for 
02218. ; "something else"... what exactly I can't say! I only know it presently makes 
02219. ; no sense and is -- in a small way -- corrupting memory and nothing more... 
02220.  
02221. ; This will increment the byte at Inventory_Cards + 3, which is the Player's score; but that 
02222. ; will be overwritten when the game exits with the "current" score) 
02223. ; In any case, not a "key" :( 
02224. LDX #$03 ; X = 3 
02225. JSR Bonus_Prize1 ; Get your prize? 
02226.  
02227. INC Bonus_GameState ; Bonus_GameState = 4 
02228.  
02229. RTS ; Return 
02230.  
02231. PRG022_CD65: 
02232.  
02233. ; "If 1 appears, 1 (?)" 
02234.  
02235. ; Give Player an extra life ... apparently 
02236. LDX Player_Current 
02237. INC Player_Lives,X 
02238.  
02239. INC Bonus_GameState ; Bonus_GameState = 4 
02240.  
02241. RTS ; Return 
02242.  
02243. PRG022_CD6F: 
02244.  
02245. ; Coin prizes 
02246.  
02247. LDA BonusCoins_State 
02248. JSR DynJump 
02249.  
02250. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
02251. .word BonusCoins_Init ; 0: Initializes bonus coins based on value of the Die (Bonus_DiePos) 
02252. .word BonusCoins_UpdateAndDraw ; 1: Update and draw bonus coins until they've all fallen off-screen 
02253.  
02254. BonusCoins_Init: 
02255. LDY Bonus_DiePos ; Y = Bonus_DiePos 
02256. PRG022_CD7C: 
02257.  
02258. ; Set coins to appear front and center! 
02259. LDA #$78 
02260. STA Bonus_CoinsY,Y 
02261. STA Bonus_CoinsX,Y 
02262.  
02263. LDX #-$10 ; X = -$10 
02264.  
02265. LDA RandomN,Y ; Get random value 
02266. ASL A ; Multiply by 2 
02267. PHA ; Save it 
02268. BCC PRG022_CD8F ; 50/50 chance jump to PRG022_CD8F 
02269.  
02270. LDX #$00 ; Otherwise, X = $00 
02271. PRG022_CD8F: 
02272.  
02273. ; Temp_Var1 = -$10 or $00 
02274. TXA 
02275. STA <Temp_Var1 
02276.  
02277. PLA ; Restore random value 
02278. AND #$0f ; Keep lower 4 bits 
02279. ORA <Temp_Var1 ; OR onto Temp_Var1 
02280. STA Bonus_CoinsXVel,Y ; -> Bonus_CoinsXVel 
02281.  
02282. LDA RandomN,Y 
02283. AND #$07 ; Random 0-7 
02284. ORA #-$40 ; Base -$40 
02285. STA Bonus_CoinsYVel,Y ; -> Bonus_CoinsYVel 
02286.  
02287. DEY ; Y-- 
02288. BPL PRG022_CD7C ; While Y >= 0, loop! 
02289.  
02290. INC BonusCoins_State ; BonusCoins_State = 1 
02291. RTS ; Return 
02292.  
02293. BonusCoins_UpdateAndDraw: 
02294. LDY Bonus_DiePos ; Y = Bonus_DiePos 
02295. PRG022_CDAE: 
02296. JSR BonusCoin_ApplyYVel ; Apply Y velocity to coin 
02297. JSR BonusCoin_ApplyXVel ; Apply X velocity to coin 
02298.  
02299. ; Coins fall rate 
02300. LDA Bonus_CoinsYVel,Y 
02301. ADD #$02 
02302. STA Bonus_CoinsYVel,Y 
02303.  
02304. DEY ; Y-- 
02305. BPL PRG022_CDAE ; While Y >= 0, loop 
02306.  
02307. JSR BonusCoins_Draw ; Draw the bonus coins 
02308.  
02309.  
02310. LDY Bonus_DiePos ; Y = Bonus_DiePos 
02311. PRG022_CDC6: 
02312. LDA Bonus_CoinsY,Y 
02313. CMP #$f8 
02314. BNE PRG022_CDD3 ; If this coin is not off-screen, jump to PRG022_CDD3 (RTS) 
02315.  
02316. DEY ; Y-- 
02317. BPL PRG022_CDC6 ; While Y >= 0, loop 
02318.  
02319. ; All coins are off-screen; proceed! 
02320. INC Bonus_GameState ; Bonus_GameState = 4 
02321.  
02322. PRG022_CDD3: 
02323. RTS ; Return 
02324.  
02325. BonusCoin_ApplyXVel: 
02326.  
02327. ; Offset to coin X velocity 
02328. TYA  
02329. ADD #(Bonus_CoinsXVelFrac - Bonus_CoinsYVelFrac) 
02330. TAY 
02331.  
02332. JSR BonusCoin_ApplyVel ; Apply X velocity to coin 
02333.  
02334. ; Offset back 
02335. TYA 
02336. SUB #(Bonus_CoinsXVelFrac - Bonus_CoinsYVelFrac) 
02337. TAY 
02338.  
02339. RTS ; Return 
02340.  
02341.  
02342. BonusCoin_ApplyYVel: 
02343. ; Note: This check is superfluous because of the following one! 
02344. LDA Bonus_CoinsYVel,Y  
02345. BMI BonusCoin_ApplyVel ; If coin is moving upward, apply velocity to coin and don't come back 
02346.  
02347. CMP #$40 
02348. BLS BonusCoin_ApplyVel ; If coin is moving downward < $40, apply velocity to coin and don't come back 
02349.  
02350. ; Max coin falling speed at $40 
02351. LDA #$40 
02352. STA Bonus_CoinsYVel,Y 
02353.  
02354. BonusCoin_ApplyVel: 
02355. LDA Bonus_CoinsYVel,Y ; Get coin Velocity 
02356. ASL A  
02357. ASL A  
02358. ASL A  
02359. ASL A ; Fractional part shifted up 
02360. STA <Temp_Var1 ; -> Temp_Var1 
02361.  
02362. LDX #$00 ; X = 0 (positive high part) 
02363.  
02364. LDA Bonus_CoinsYVel,Y ; Get Velocity 
02365. LSR A 
02366. LSR A 
02367. LSR A 
02368. LSR A ; Whole part shifted down (integer) 
02369. CMP #%00001000 ; Check the sign bit 
02370. BLT PRG022_CE09 ; If the value was not negatively signed, jump to PRG022_CE09 
02371. DEX ; X = $FF (negative high part) 
02372. ORA #%11110000 ; Apply a sign extension 
02373. PRG022_CE09: 
02374. STA <Temp_Var2 ; -> Temp_Var2 
02375.  
02376. ; Add to coin's velocity fractional accumulator 
02377. LDA Bonus_CoinsYVelFrac,Y 
02378. ADD <Temp_Var1 
02379. STA Bonus_CoinsYVelFrac,Y 
02380.  
02381. ; Add appropriately to coin's Y 
02382. LDA Bonus_CoinsY,Y 
02383. ADC <Temp_Var2 
02384. STA Bonus_CoinsY,Y 
02385.  
02386. RTS ; Return 
02387.  
02388.  
02389. BonusCoins_Draw: 
02390. LDY Bonus_DiePos ; Y = Bonus_DiePos 
02391.  
02392. PRG022_CE20: 
02393. TYA 
02394. ASL A 
02395. ASL A 
02396. TAX ; X = Y * 4 (offset in Sprite RAM to coin's sprite) 
02397.  
02398. LDA Bonus_CoinsY,Y 
02399. CMP #192 
02400. BLT PRG022_CE30 ; If coin Y < 192 (top of status bar), jump to PRG022_CE30 
02401.  
02402. ; Coin too low; set coin Y = $F8 (hide it!) 
02403. LDA #$f8 
02404. STA Bonus_CoinsY,Y 
02405.  
02406. PRG022_CE30: 
02407.  
02408. ; Set coin sprite Y 
02409. STA Sprite_RAM+$80,X 
02410.  
02411. ; Set coin sprite pattern 
02412. LDA #$61 
02413. STA Sprite_RAM+$81,X 
02414.  
02415. ; Set coin attribute 
02416. LDA #SPR_PAL1 
02417. STA Sprite_RAM+$82,X 
02418.  
02419. ; Set coin sprite X 
02420. LDA Bonus_CoinsX,Y 
02421. STA Sprite_RAM+$83,X 
02422.  
02423. DEY ; Y-- 
02424. BPL PRG022_CE20 ; While Y >= 0, loop 
02425. RTS ; Return 
02426.  
02427.  
02428. Bonus_Wait80: 
02429. LDA Bonus_Timer 
02430. BNE PRG022_CE51 ; If Bonus_Timer <> 0, jump to PRG022_CE51 
02431.  
02432. ; Bonus_Timer = $80 
02433. LDA #$80 
02434. STA Bonus_Timer 
02435.  
02436. PRG022_CE51: 
02437. DEC Bonus_Timer ; Bonus_Timer-- 
02438. BNE PRG022_CE64 ; If Bonus_Timer has not expired, jump to PRG022_CE64 
02439.  
02440. INC Bonus_GameState ; Bonus_GameState = 5/9 
02441.  
02442. LDA Bonus_GameState 
02443. CMP #$09 
02444. BNE PRG022_CE64 ; If Bonus_GameState <> 9, jump to PRG022_CE64 (RTS) 
02445.  
02446. ; Otherwise, exit to map 
02447. LDA #$01 
02448. STA <Level_ExitToMap 
02449.  
02450. PRG022_CE64: 
02451. RTS ; Return 
02452.  
02453.  
02454. Roulette_BorderSprites: 
02455. .byte $0F, $03, $00, $08 
02456. .byte $0F, $05, $00, $F0 
02457. .byte $0F, $0B, $00, $F8 
02458. .byte $AF, $09, $00, $08 
02459. .byte $AF, $07, $00, $F0 
02460. .byte $AF, $0B, $00, $F8 
02461.  
02462. Roulette_DrawBorderSprites: 
02463.  
02464. ; Temp_Var1 = 31 (Sprite Y start) 
02465. LDA #31 
02466. STA <Temp_Var1 
02467.  
02468. LDY #$60 ; Y = $60 (Sprite RAM offset) 
02469. PRG022_CE83: 
02470.  
02471. ; Set Sprite Ys 
02472. LDA <Temp_Var1  
02473. STA Sprite_RAM+$04,Y 
02474. STA Sprite_RAM+$08,Y 
02475. STA Sprite_RAM+$0C,Y 
02476.  
02477. ; Set border sprite patterns 
02478. LDA #$01 
02479. STA Sprite_RAM+$05,Y 
02480. STA Sprite_RAM+$09,Y 
02481.  
02482. ; Set right edge black sprite pattern 
02483. LDA #$0b 
02484. STA Sprite_RAM+$0D,Y 
02485.  
02486. ; Set sprite attributes 
02487. LDA #SPR_PAL0 
02488. STA Sprite_RAM+$06,Y 
02489. STA Sprite_RAM+$0A,Y 
02490. STA Sprite_RAM+$0E,Y 
02491.  
02492. ; Set sprite Xs 
02493. LDA #8 
02494. STA Sprite_RAM+$07,Y 
02495. LDA #240 
02496. STA Sprite_RAM+$0B,Y 
02497. LDA #248 
02498. STA Sprite_RAM+$0F,Y 
02499.  
02500. ; Temp_Var1 (Sprite Y) += 16 
02501. LDA <Temp_Var1 
02502. ADD #16 
02503. STA <Temp_Var1 
02504.  
02505. TYA 
02506. SUB #12 ; -12 (3 sprites prior) 
02507. TAY  
02508.  
02509. BPL PRG022_CE83 ; While Y >= 0, loop! 
02510.  
02511.  
02512. LDY #$17 
02513. PRG022_CEC5: 
02514. LDA Roulette_BorderSprites,Y 
02515. STA Sprite_RAM+$70,Y 
02516.  
02517. DEY ; Y-- 
02518. BPL PRG022_CEC5 ; While Y >= 0, loop 
02519.  
02520. RTS ; Return 
02521.  
02522.  
02523. UpdSel_Roulette: 
02524. ; Caution: You're on interrupt time here! 
02525.  
02526. ; Performing some work that got skipped because we diverted here in the interrupt 
02527.  
02528. LDA #$00 ; A = 0 
02529. STA PPU_CTL2 ; Hide sprites and bg (most importantly) 
02530. STA PPU_SPR_ADDR ; Resets to sprite 0 in memory 
02531.  
02532. LDA #$02 ; A = 2 
02533. STA SPR_DMA ; DMA sprites from RAM @ $200 (probably trying to blank them out) 
02534.  
02535. JSR PT2_Full_CHRROM_Switch ; Set up PT2 (Sprites) CHRROM 
02536.  
02537. LDA <Graphics_Queue 
02538. ASL A 
02539. TAX ; X = Graphics_Queue * 2 
02540.  
02541. ; Roulette maintains its own update table, though not really used 
02542. LDA Video_Upd_TableRoulette,X 
02543. STA <Video_Upd_AddrL 
02544. LDA Video_Upd_TableRoulette+1,X 
02545. STA <Video_Upd_AddrH 
02546.  
02547. JSR Video_Misc_Updates ; Various updates other than scrolling (palettes, status bar, etc.) 
02548.  
02549. ; Graphics_Queue = 0 
02550. LDA #$00 
02551. STA <Graphics_Queue 
02552.  
02553. STA Graphics_BufCnt ; Reset Graphics_Buffer counter 
02554. STA Graphics_Buffer+$00 ; Terminate it 
02555.  
02556. LDA PPU_STAT 
02557.  
02558. ; Unknown hardware thing? Is this for synchronization? 
02559. LDX #$3f ;  
02560. STX PPU_VRAM_ADDR ; Access PPU address #3Fxx 
02561. LDA #$00 ;  
02562. STA PPU_VRAM_ADDR ; Access PPU address #3F00 (palettes?) 
02563. STA PPU_VRAM_ADDR ;  
02564. STA PPU_VRAM_ADDR ; Now accessing $0000 (Pattern tables?) 
02565.  
02566. LDA <PPU_CTL2_Copy 
02567. ORA #%00011000 
02568. STA PPU_CTL2 ; Show BG+Sprites 
02569.  
02570. ; Generate VBlank Resets, use 8x16 sprites, sprites use PT2 
02571. LDA #$a8 
02572. STA PPU_CTL1 
02573.  
02574. LDA PPU_STAT 
02575.  
02576. LDA #$00 
02577. STA PPU_SCROLL 
02578. STA PPU_SCROLL 
02579.  
02580. LDA PPU_STAT 
02581.  
02582. LDA #$ff 
02583. STA MMC3_IRQCNT 
02584. STA MMC3_IRQLATCH 
02585.  
02586. ; Unknown hardware thing? Is this for synchronization? 
02587. LDA #$00 
02588. STA PPU_VRAM_ADDR 
02589. STA PPU_VRAM_ADDR 
02590. LDA #$10 
02591. STA PPU_VRAM_ADDR 
02592. STA PPU_VRAM_ADDR 
02593. LDA #$00 
02594. STA PPU_VRAM_ADDR 
02595. STA PPU_VRAM_ADDR 
02596. LDA #$10 
02597. STA PPU_VRAM_ADDR 
02598. STA PPU_VRAM_ADDR 
02599. LDA #$00 
02600. STA PPU_VRAM_ADDR 
02601. STA PPU_VRAM_ADDR 
02602.  
02603. ; Fire on scanline 32 
02604. LDA #$20 
02605. STA MMC3_IRQCNT 
02606. STA MMC3_IRQLATCH 
02607. STA MMC3_IRQENABLE 
02608.  
02609. CLI ; Enable maskable interrupts 
02610.  
02611. JSR Read_Joypads ; Updates both joypads in RAM 
02612.  
02613. LDX #$00 ; X = 0 
02614. LDY #$02 ; Y = 2 
02615.  
02616. ; Temp_Var1 = 0 or 2, random 
02617. LDA Random_Pool 
02618. AND #$02 
02619. STA <Temp_Var1 
02620.  
02621. ; Temp_Var1 = 0 or 2, random 
02622. LDA RandomN 
02623. AND #$02 
02624. EOR <Temp_Var1 
02625.  
02626. CLC ; Clear carry 
02627.  
02628. BEQ PRG022_CF7C ; If random result is zero, jump to PRG022_CF7C 
02629.  
02630. SEC ; Set carry if non-zero 
02631.  
02632. ; Rotates the first couple random values around 
02633. PRG022_CF7C: 
02634. ROR Random_Pool,X 
02635. INX ; X = 1 
02636. DEY ; Y-- 
02637. BNE PRG022_CF7C ; While Y >= 0, loop 
02638.  
02639. JSR Roulette_DoGame ; Actually run the Roulette game 
02640.  
02641. ; Switch to page 26 @ A000 
02642. LDA #MMC3_8K_TO_PRG_A000 
02643. STA MMC3_COMMAND 
02644. LDA #26  
02645. STA MMC3_PAGE  
02646.  
02647. JSR StatusBar_UpdateValues ; Update Status Bar (not really used) 
02648.  
02649. ; Switch to page 28 @ A000 
02650. LDA #MMC3_8K_TO_PRG_A000 
02651. STA MMC3_COMMAND 
02652. LDA #28  
02653. STA MMC3_PAGE  
02654.  
02655. ; Jump to the sound engine, newly inserted at page A000! 
02656. JSR Sound_Engine_Begin 
02657.  
02658. ; Change A000 back to whatever it was before the sound engine  
02659. JSR PRGROM_Change_A000 
02660.  
02661. INC <Counter_1 ; Simply increments every frame, used for timing 
02662.  
02663. ; Pull (pop) the three temp vars from the stack  
02664. PLA 
02665. STA <Temp_Var3 
02666. PLA 
02667. STA <Temp_Var2 
02668. PLA 
02669. STA <Temp_Var1 
02670.  
02671. ; This pulls (pops) all the registers from the stack... 
02672. PLA 
02673. TAY 
02674. PLA 
02675. TAX 
02676. PLA 
02677. PLP 
02678.  
02679. ; Fully cleaned up "NMI" interrupt 
02680. RTI 
02681.  
02682.  
02683. Video_Upd_TableRoulette: 
02684. .word Graphics_Buffer 
02685.  
02686. .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $BE, $07 
02687.  
02688. Video_RoulBordAttr: 
02689. vaddr $2020 
02690. .byte VU_REPEAT | $20, $FC 
02691.  
02692. vaddr $2040 
02693. .byte VU_REPEAT | $20, $FC 
02694.  
02695. vaddr $2061 
02696. .byte VU_REPEAT | $1E, $A1 
02697.  
02698. vaddr $22E0 
02699. .byte VU_REPEAT | $20, $FF 
02700.  
02701. vaddr $26E0 
02702. .byte VU_REPEAT | $20, $FF 
02703.  
02704. vaddr $23C8 
02705. .byte $20, $55, $55, $D5, $F5, $F5, $75, $55, $55, $55, $55, $DD, $FF, $FF, $77, $55 
02706. .byte $55, $55, $55, $DD, $FF, $FF, $77, $95, $A5, $55, $55, $DD, $FF, $FF, $77, $99, $AA 
02707.  
02708. vaddr $23E8 
02709. .byte VU_REPEAT | $08, $55 
02710.  
02711. vaddr $27C0 
02712. .byte VU_REPEAT | $08, $55 
02713.  
02714. vaddr $27C8 
02715. .byte $20, $55, $55, $D5, $F5, $F5, $75, $55, $55, $55, $55, $DD, $FF, $FF, $77, $55 
02716. .byte $55, $A5, $65, $DD, $FF, $FF, $77, $55, $55, $AA, $66, $DD, $FF, $FF, $77, $55, $55 
02717.  
02718. vaddr $27E8 
02719. .byte VU_REPEAT | $08, $55 
02720.  
02721. ; Terminator 
02722. .byte $00 
02723.  
02724. Roulette_DoGame: 
02725. LDA Roulette_ConfigRun 
02726. JSR DynJump 
02727.  
02728. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
02729. .word Roulette_Configure ; Configure Roulette game 
02730. .word Roulette_RunGame ; Run it! 
02731.  
02732. Roulette_Configure: 
02733. LDA Roulette_ConfigState 
02734. JSR DynJump 
02735.  
02736. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
02737. .word Roulette_ConfigPPUCTL2 ; Set up to show BG+Sprites 
02738. .word Roulette_ConfigTurns ; Set number of turns (always 0!) 
02739.  
02740. Roulette_ConfigPPUCTL2: 
02741.  
02742. ; Show BG+Sprites 
02743. LDA #$18 
02744. STA <PPU_CTL2_Copy 
02745.  
02746. INC Roulette_ConfigState ; Roulette_ConfigState = 1 
02747.  
02748. RTS ; Return  
02749.  
02750. Roulette_ConfigTurns: 
02751. INC Roulette_ConfigRun ; Roulette_ConfigRun = 1 
02752.  
02753. ; Roulette_Turns = 0 (No extra turns for you!) 
02754. LDA #$00 
02755. STA Roulette_Turns 
02756.  
02757. RTS ; Return 
02758.  
02759. Roulette_RunGame: 
02760. LDA Roulette_RunState 
02761. JSR DynJump 
02762.  
02763. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
02764. .word Roulette_Init ; 0: Initialize the game 
02765. .word Roulette_Run ; 1: Run the game 
02766. .word Roulette_FadeOut ; 2: Fade to black 
02767. .word Roulette_ExitToMap ; 3: Exit to map 
02768. .word Roulette_GiveReward ; 4: Get extra lives prize and display sprite 
02769.  
02770. Roulette_Init: 
02771. LDA #$00 
02772. STA Roulette_StopState ; Roulette_StopState = 0 
02773. STA Roulette_StopState+1 ; Roulette_StopState+1 = 0 
02774. STA Roulette_StopState+2 ; Roulette_StopState+2 = 0 
02775. STA Roulette_Lives ; Roulette_Lives = 0 
02776.  
02777. ; Roulette_Speed = $70 
02778. LDA #$70 
02779. STA Roulette_Speed 
02780.  
02781. ; Roulette_Speed+1 = $90 
02782. LDA #$90 
02783. STA Roulette_Speed+1 
02784.  
02785. ; Roulette_Speed+2 = $7F 
02786. LDA #$7f 
02787. STA Roulette_Speed+2 
02788.  
02789. ; Roulette_Unused7A5F_Delta = $30 
02790. LDA #$30 
02791. STA Roulette_Unused7A5F_Delta 
02792.  
02793. INC Roulette_RunState ; Roulette_RunState = 1 (Run game) 
02794.  
02795. JMP Roulette_DrawBorderSprites ; Draw border sprites and don't come back! 
02796.  
02797. Roulette_Run: 
02798. LDA <Pad_Input 
02799. AND #(PAD_A | PAD_B) 
02800. BEQ PRG022_D0DF ; If Player is NOT pressing A or B, jump to PRG022_D0DF 
02801.  
02802. ; Player is pressing A or B... 
02803.  
02804. LDA Roulette_StopState 
02805. BNE PRG022_D0A2 ; If row 1 is already stopping/stopped, jump to PRG022_D0A2 
02806.  
02807. ; Row 1 needs to be stopped... 
02808.  
02809. INC Roulette_StopState ; Row 1's stop state = 1 
02810.  
02811. ; Set Roulette_StopCnt = $20 to $2F, random 
02812. LDA RandomN 
02813. AND #$0f 
02814. ORA #$20 
02815. STA Roulette_StopCnt 
02816.  
02817. JMP PRG022_D0D7 ; Jump to PRG022_D0D7 
02818.  
02819. PRG022_D0A2: 
02820. LDA Roulette_StopState+1 
02821. BNE PRG022_D0BE ; If row 2 is already stopping/stopped, jump to PRG022_D0BE 
02822.  
02823. LDA Roulette_StopState 
02824. CMP #$02 
02825. BLT PRG022_D0BE ; If Row 1 is not close enough to stopping yet, jump to PRG022_D0BE 
02826.  
02827. INC Roulette_StopState+1 ; Row 2's stop state = 1 
02828.  
02829. ; Set Roulette_StopCnt+1 = $20 to $3F, random 
02830. LDA RandomN+1 
02831. AND #$1f 
02832. ORA #$20 
02833. STA Roulette_StopCnt+1 
02834.  
02835. JMP PRG022_D0D7 ; Jump to PRG022_D0D7 
02836.  
02837. PRG022_D0BE: 
02838. LDA Roulette_StopState+2 
02839. BNE PRG022_D0DF ; If row 3 is already stopping/stopped, jump to PRG022_D0DF 
02840.  
02841. LDA Roulette_StopState+1 
02842. CMP #$02 
02843. BLT PRG022_D0DF ; If Row 2 is not close enough to stopping yet, jump to PRG022_D0DF 
02844.  
02845. INC Roulette_StopState+2 ; Row 3's stop state = 1 
02846.  
02847. ; Set Roulette_StopCnt+2 = $40 to $7F, random 
02848. LDA RandomN+2 
02849. AND #$3f 
02850. ORA #$40 
02851. STA Roulette_StopCnt+2 
02852.  
02853. PRG022_D0D7: 
02854. ; Bleep sound 
02855. LDA Sound_QMap 
02856. ORA #SND_MAPPATHMOVE 
02857. STA Sound_QMap 
02858.  
02859. PRG022_D0DF: 
02860.  
02861. LDX #$02 
02862. PRG022_D0E1: 
02863. STX <Roulette_RowIdx ; Update Roulette_RowIdx 
02864.  
02865. LDA Roulette_StopCnt,X 
02866. BEQ PRG022_D0EB ; If this row's stop counter = 0, jump to PRG022_D0EB 
02867.  
02868. DEC Roulette_StopCnt,X ; Otherwise, decrement this row's stop counter 
02869.  
02870. PRG022_D0EB: 
02871. JSR RouletteRow_DoStopState ; Do the row's stop state code 
02872.  
02873. DEX ; X-- 
02874. BPL PRG022_D0E1 ; While X >= 0, loop! 
02875.  
02876. RTS ; Return 
02877.  
02878. RouletteRow_DoStopState: 
02879. LDA Roulette_StopState,X 
02880. JSR DynJump 
02881.  
02882. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
02883. .word RouletteRow_Move ; 0: Row is not stopping; it is running, if you will 
02884. .word RouletteRow_WaitToStop ; 1: Waits for specific Roulette_StopCnt to hit zero 
02885. .word RouletteRow_Slow ; 2: Slow down row 
02886. .word RouletteRow_HitLockPos ; 3: Slide row into lock position 
02887. .word RouletteRow_LockDecide ; 4: Lock, bounce, decide reward, if any 
02888. .word RouletteRow_EndTurn ; 5: End-of-turn logic (in modern game there are no more turns, Roulette_Turns = 0) 
02889.  
02890. RouletteRow_Move: 
02891. CPX #$02 
02892. BNE PRG022_D11C ; If this is NOT row 3, jump to PRG022_D11C 
02893.  
02894. ; On row 3 only... (basically stuff updated only once for all rows) 
02895.  
02896. ; Roulette_Unused7A5F (value never used for anything) += Roulette_Unused7A5F_Delta 
02897. LDA Roulette_Unused7A5F 
02898. ADD Roulette_Unused7A5F_Delta 
02899. STA Roulette_Unused7A5F 
02900.  
02901. ; Something removed? 
02902. NOP 
02903. NOP 
02904.  
02905. ; Play the "ringing" sound 
02906. LDA Sound_QPlayer 
02907. ORA #SND_PLAYERPOWER 
02908. STA Sound_QPlayer 
02909.  
02910. PRG022_D11C: 
02911. JMP Roulette_MoveRow ; Jump to Roulette_MoveRow 
02912.  
02913.  
02914. RouletteRow_WaitToStop: 
02915. LDA Roulette_StopCnt,X 
02916. BNE RouletteRow_Move ; If this row's stop counter is not zero, move the Roulette rows and don't come back... 
02917.  
02918. INC Roulette_StopState,X ; This row's stop state = 2 
02919.  
02920. JMP RouletteRow_Move ; Move the Roulette rows and don't come back... 
02921.  
02922.  
02923. RouletteRow_Slow: 
02924. LDA Roulette_Speed,X 
02925. ADD #$3f 
02926. CMP #$7f 
02927. BGE PRG022_D13A ; If we have not reached a stop speed, jump to PRG022_D13A 
02928.  
02929. INC Roulette_StopState,X ; This row's stop state = 3 
02930. JMP RouletteRow_Move ; Move the Roulette rows and don't come back... 
02931.  
02932. PRG022_D13A: 
02933. CPX #$02 
02934. BNE PRG022_D151 ; If this is not the third row, jump to PRG022_D151 
02935.  
02936. ; Roulette_Unused7A5F_Delta is added to Roulette_Unused7A5F, but Roulette_Unused7A5F itself is never used! 
02937.  
02938. LDA Roulette_Unused7A5F_Delta 
02939. CMP #$11 
02940. BLT PRG022_D151 ; If Roulette_Unused7A5F_Delta < $11, jump to PRG022_D151 
02941.  
02942. DEC Roulette_Unused7A5F_Delta ; Roulette_Unused7A5F_Delta-- 
02943.  
02944. LDA <Counter_1 
02945. AND #$01 
02946. BNE PRG022_D151 ; Every other tick, jump to PRG022_D151 
02947.  
02948. DEC Roulette_Unused7A5F_Delta ; Roulette_Unused7A5F_Delta-- 
02949.  
02950. PRG022_D151: 
02951. LDA Roulette_Speed,X 
02952. BPL PRG022_D15F ; If Roulette_Speed is positive, jump to PRG022_D15F 
02953.  
02954. ; Roulette_Speed += 4 
02955. LDA Roulette_Speed,X 
02956. ADD #$04 ; Really +2, but it hits the -2 after this 
02957. STA Roulette_Speed,X 
02958.  
02959. PRG022_D15F: 
02960. ; Roulette_Speed -= 2 
02961. LDA Roulette_Speed,X 
02962. SUB #$02 
02963. STA Roulette_Speed,X 
02964.  
02965. JMP RouletteRow_Move ; Move the Roulette rows and don't come back... 
02966.  
02967.  
02968. RouletteRow_HitLockPos: 
02969. LDA Roulette_Pos,X 
02970. AND #%01111100 
02971. BNE PRG022_D192 ; If this is not a lock position, jump to PRG022_D192 
02972.  
02973. ; "Swim" sound (row locking) 
02974. LDA #SND_PLAYERSWIM 
02975. STA Sound_QPlayer 
02976.  
02977. ; Roulette_StopCnt = $12 
02978. LDA #$12 
02979. STA Roulette_StopCnt,X 
02980.  
02981. ; Lock row position 
02982. LDA Roulette_Pos,X 
02983. ADD #$20 
02984. AND #$80 
02985. STA Roulette_Pos,X 
02986. LDA Roulette_PosHi,X 
02987. ADC #$00 
02988. STA Roulette_PosHi,X 
02989.  
02990. INC Roulette_StopState,X ; This row's stop state = 4 
02991.  
02992. PRG022_D192: 
02993. JMP RouletteRow_Move ; Move the Roulette rows and don't come back... 
02994.  
02995. Roulette_MatchSets: 
02996. .byte $00, $02 ; First row Mushroom (primary) alternating mushroom matches 
02997. .byte $01, $01 ; First row Flower (nothing special) 
02998. .byte $02, $00 ; First row Muchroom (secondary) alternating mushroom matches 
02999. .byte $03, $03 ; First row Star (nothing special) 
03000.  
03001. Roulette_MatchReward: 
03002. .byte $02, $03, $02, $05 ; Number of lives you get (Mushroom, Flower, Mushroom, Star) 
03003.  
03004. RouletteRow_LockDecide: 
03005. LDA Roulette_StopCnt,X 
03006. BNE PRG022_D20B ; If this row's stop counter is not zero, jump to PRG022_D20B 
03007.  
03008. ; Enforce the lock position 
03009. LDA Roulette_Pos,X 
03010. ADD #$20 
03011. AND #$80 
03012. STA Roulette_Pos,X 
03013. STA <Temp_Var1 ; -> Temp_Var1 
03014. LDA Roulette_PosHi,X 
03015. ADC #$00 
03016. STA Roulette_PosHi,X 
03017.  
03018. ASL <Temp_Var1 
03019. ROL A 
03020. AND #$03 
03021. STA Roulette_ShapeLock,X 
03022.  
03023. CPX #$02 
03024. BNE PRG022_D205 ; If this is not the third row, jump to PRG022_D205 
03025.  
03026. ; Roulette_StopCnt = $50 
03027. LDA #$50 
03028. STA Roulette_StopCnt,X 
03029.  
03030. LDA Roulette_ShapeLock 
03031. ASL A 
03032. TAY ; Y = Roulette_ShapeLock * 2 
03033.  
03034. LDX #$01 ; X = 1 (mainly for the dual mushroom, there is two possible matches) 
03035. PRG022_D1D3: 
03036. LDA Roulette_ShapeLock+1,X 
03037.  
03038. CMP Roulette_MatchSets,Y 
03039. BEQ PRG022_D1E0 ; If the first row locked shape matches this row, jump to PRG022_D1E0 
03040.  
03041. CMP Roulette_MatchSets+1,Y 
03042. BNE PRG022_D200 ; If we have a mismatch, jump to PRG022_D200 
03043.  
03044. PRG022_D1E0: 
03045. DEX ; X-- 
03046. BPL PRG022_D1D3 ; While X >= 0, loop 
03047.  
03048. LDY Roulette_ShapeLock ; Y = Roulette_ShapeLock 
03049.  
03050. LDA Roulette_MatchReward,Y 
03051. STA Roulette_Lives 
03052.  
03053. ; Roulette_RunState = 4 
03054. LDA #$04 
03055. STA Roulette_RunState 
03056.  
03057. ; Roulette_xUpY = 240 
03058. LDA #240 
03059. STA Roulette_xUpY 
03060.  
03061. ; Roulette_StopCnt = 0 
03062. LDA #$00 
03063. STA Roulette_StopCnt 
03064.  
03065. LDX <Roulette_RowIdx ; X = Roulette_RowIdx 
03066.  
03067. ; Do NOT return to caller 
03068. PLA 
03069. PLA 
03070.  
03071. RTS ; Return 
03072.  
03073. PRG022_D200: 
03074. ; Play mismatch sound 
03075. LDA #SND_MAPDENY 
03076. STA Sound_QMap 
03077.  
03078. PRG022_D205: 
03079. LDX <Roulette_RowIdx ; X = Roulette_RowIdx 
03080.  
03081. INC Roulette_StopState,X ; This row's stop state = 5 
03082.  
03083. RTS ; Return 
03084.  
03085. PRG022_D20B: 
03086. LDY #$10 ; Y = $10 
03087.  
03088. AND #$04 
03089. BNE PRG022_D213 ; 4 ticks on, 4 ticks off; jump to PRG022_D213 
03090.  
03091. LDY #-$10 ; Y = -$10 
03092.  
03093. PRG022_D213: 
03094.  
03095. ; Set Roulette_Speed = $10/-$10 ("bounce" effect as locking) 
03096. TYA 
03097. STA Roulette_Speed,X 
03098.  
03099. JMP RouletteRow_Move ; Move the Roulette rows and don't come back... 
03100.  
03101. RouletteRow_EndTurn: 
03102. CPX #$02 
03103. BNE PRG022_D223 ; If this is not the third row, jump to PRG022_D223 (RTS) (doesn't do anything) 
03104.  
03105. LDA Roulette_StopCnt,X 
03106. BEQ PRG022_D224 ; If the stop counter is zero, jump to PRG022_D224 
03107.  
03108. PRG022_D223: 
03109. RTS ; Return 
03110.  
03111. PRG022_D224: 
03112. LDA Roulette_Turns 
03113. BEQ PRG022_D238 ; If Roulette_Turns = 0 (out of turns), jump to PRG022_D238 
03114.  
03115. ; At least one turn remaining ... (this is UNUSED!) 
03116.  
03117. LDA <Pad_Holding 
03118. AND #(PAD_A | PAD_B | PAD_START) 
03119. BEQ PRG022_D237 ; If Player is not pressing A, B, or START, jump to PRG022_D237 
03120.  
03121. DEC Roulette_Turns ; Roulette_Turns-- 
03122.  
03123. ; Roulette_RunState = 0 (re-initialize for another round!) 
03124. LDA #$00 
03125. STA Roulette_RunState 
03126.  
03127. PRG022_D237: 
03128. RTS ; Return 
03129.  
03130. PRG022_D238: 
03131.  
03132. ; Do not return to caller 
03133. PLA 
03134. PLA 
03135.  
03136. PRG022_D23A: 
03137. ; Roulette_RunState = 2 
03138. LDA #$02 
03139. STA Roulette_RunState 
03140.  
03141. ; Roulette_StopState = 0 <-- Reusing it differently, as pal fadeout prep flag 
03142. LDA #$00 
03143. STA Roulette_StopState 
03144.  
03145. RTS ; Return 
03146.  
03147. Roulette_FadeOut: 
03148. LDA Roulette_StopState ; Being reused as a flag here 
03149. BNE PRG022_D250 ; If Roulette_StopState <> 0 (palette fade prepared), jump to PRG022_D250 
03150.  
03151. INC Roulette_StopState ; Roulette_StopState = 1 
03152.  
03153. JMP Palette_PrepareFadeOut ; Prepare to fade out 
03154.  
03155. PRG022_D250: 
03156. JSR Roulette_DoFadeOut ; Do palette fade out 
03157.  
03158. LDA Fade_Level 
03159. BNE PRG022_D52B ; If not completely faded out, jump to PRG022_D52B (RTS) 
03160.  
03161. INC Roulette_RunState ; Roulette_RunState = 3 
03162.  
03163. PRG022_D52B: 
03164. RTS ; Return 
03165.  
03166.  
03167. Roulette_ExitToMap: 
03168.  
03169. ; Cancel the natural fade out that comes from exiting to map 
03170. LDA #$01  
03171. STA FadeOut_Cancel 
03172.  
03173. ; Exit to map! 
03174. LDA #$01 
03175. STA <Level_ExitToMap 
03176.  
03177. LDA #$80 
03178. STA Update_Select 
03179.  
03180. LDA #$00 
03181. STA Update_Request 
03182.  
03183. RTS ; Return 
03184.  
03185. Roulette_RewardPattern: 
03186. ; 1 2 5 
03187. .byte $01, $F3, $F5, $01, $F7 ; $01 patterns are invalid 
03188.  
03189. Roulette_GiveReward: 
03190.  
03191. ; Load patterns for "x Up" 
03192. LDA #$32 
03193. STA PatTable_BankSel+4 
03194. LDA #$55 
03195. STA PatTable_BankSel+5 
03196.  
03197. LDA Roulette_StopCnt 
03198. BEQ PRG022_D2B4 ; If stop counter is zero, jump to PRG022_D2B4 
03199.  
03200. DEC Roulette_StopCnt ; Roulette_StopCnt-- 
03201.  
03202. BNE PRG022_D28C ; If Roulette_StopCnt <> 0, jump to PRG022_D28C 
03203.  
03204. JMP PRG022_D23A ; Jump to PRG022_D23A 
03205.  
03206. PRG022_D28C: 
03207. LDA SndCur_Level1 
03208. BNE PRG022_D2B1 ; If 1-Up sound is playing, jump to PRG022_D2B1 
03209.  
03210. LDA Roulette_LivesToGive 
03211. BEQ PRG022_D2B1 ; If no lives left to give, jump to PRG022_D2B1 
03212.  
03213. ; Roulette_StopCnt = $A0 
03214. LDA #$a0 
03215. STA Roulette_StopCnt 
03216.  
03217. DEC Roulette_LivesToGive ; Roulette_LivesToGive-- 
03218.  
03219. ; Play 1-up sound 
03220. LDA Sound_QLevel1 
03221. ORA #SND_LEVEL1UP 
03222. STA Sound_QLevel1 
03223.  
03224. ; Give life to appropriate Player 
03225. LDX Player_Current ; X = Player_Current 
03226.  
03227. LDA Player_Lives,X 
03228. BMI PRG022_D2B1 ; If this Player is not dead from game over (??), jump to PRG022_D2B1 
03229.  
03230. INC Player_Lives,X ; One more life 
03231.  
03232. PRG022_D2B1: 
03233. JMP Roulette_DrawXUpReward ; Jump to Roulette_DrawXUpReward 
03234.  
03235. PRG022_D2B4: 
03236. ; "x Up" Y -= 4 
03237. DEC Roulette_xUpY 
03238. DEC Roulette_xUpY 
03239. DEC Roulette_xUpY 
03240. DEC Roulette_xUpY 
03241.  
03242. LDA Roulette_xUpY 
03243. CMP #96 
03244. BGE Roulette_DrawXUpReward ; If Roulette_xUpY >= 96, jump to Roulette_DrawXUpReward 
03245.  
03246. ; Initialize Roulette_LivesToGive 
03247. LDA Roulette_Lives 
03248. STA Roulette_LivesToGive 
03249.  
03250. ; Roulette_StopCnt = $50 
03251. LDA #$50 
03252. STA Roulette_StopCnt 
03253.  
03254. Roulette_DrawXUpReward: 
03255.  
03256. ; Set "x Up" Sprite Y 
03257. LDA Roulette_xUpY 
03258. STA Sprite_RAM+$F0 
03259. STA Sprite_RAM+$F4 
03260. STA Sprite_RAM+$F8 
03261.  
03262. ; Set sprite 1 X 
03263. LDA #$70 
03264. STA Sprite_RAM+$F3 
03265.  
03266. ; Set sprite 2 X 
03267. LDA #$7c 
03268. STA Sprite_RAM+$F7 
03269.  
03270. ; Set sprite 3 X 
03271. LDA #$84 
03272. STA Sprite_RAM+$FB 
03273.  
03274. ; Set pattern by reward level 
03275. LDY Roulette_Lives ; Y = Roulette_Lives 
03276. LDA Roulette_RewardPattern-1,Y 
03277. STA Sprite_RAM+$F1 
03278.  
03279. ; 'U' 
03280. LDA #$ab 
03281. STA Sprite_RAM+$F5 
03282.  
03283. ; 'P' 
03284. LDA #$ad 
03285. STA Sprite_RAM+$F9 
03286.  
03287. ; Set attributes 
03288. LDA #SPR_PAL3 
03289. STA Sprite_RAM+$F2 
03290. STA Sprite_RAM+$F6 
03291. STA Sprite_RAM+$FA 
03292.  
03293. RTS ; Return 
03294.  
03295.  
03296. Roulette_DoFadeOut: 
03297.  
03298. ; Sort of a clone of Palette_DoFadeOut 
03299.  
03300. LDA Fade_Tick 
03301. BEQ PRG022_D314 ; If Fade_Tick = 0, jump to PRG022_D314 
03302.  
03303. DEC Fade_Tick ; Otherwise, Fade_Tick-- 
03304.  
03305. PRG022_D314: 
03306. LDA Fade_Level 
03307. BEQ PRG022_D33C ; If Fade_Level = 0, jump to PRG022_D33C (RTS) 
03308.  
03309. LDA Fade_Tick 
03310. BNE PRG022_D33C ; If Fade_Tick <> 0, jump to PRG022_D33C (RTS) 
03311.  
03312. ; Fade_Tick = 4 
03313. LDA #$04 
03314. STA Fade_Tick 
03315.  
03316. DEC Fade_Level ; Fade_Level-- 
03317.  
03318. ; For all palette colors... 
03319. LDY #31 
03320. PRG022_D328: 
03321. LDA Palette_Buffer,Y ; Get this color 
03322. SUB #16 ; Subtract 16 from it 
03323. BPL PRG022_D332 ; If we didn't go below zero, jump to PRG026_AC55 
03324.  
03325. LDA #$0f ; Otherwise, set it to safe minimum 
03326.  
03327. PRG022_D332: 
03328. STA Palette_Buffer,Y ; Update palette color 
03329. DEY ; Y-- 
03330. BPL PRG022_D328 ; While Y >= 0, loop! 
03331.  
03332.  
03333. ; Commit palette fade 
03334. LDA #$06 
03335. STA <Graphics_Queue 
03336.  
03337. PRG022_D33C: 
03338. RTS ; Return 
03339.  
03340. Roulette_MoveRow: 
03341.  
03342. LDA Roulette_Speed,X ; Get this Roulette row speed 
03343. ASL A  
03344. ASL A  
03345. ASL A  
03346. ASL A ; Fractional part shifted up 
03347. STA <Temp_Var2 ; -> Temp_Var2 
03348.  
03349. LDA Roulette_Speed,X ; Get this Roulette row speed 
03350. LSR A 
03351. LSR A 
03352. LSR A 
03353. LSR A ; Whole part shifted down (integer) 
03354. CMP #%00001000 ; Check the sign bit 
03355. BLT PRG022_D353 ; If the value was not negatively signed, jump to PRG000_DD19 
03356. ORA #%11110000 ; Otherwise, apply a sign extension 
03357. PRG022_D353: 
03358. STA <Temp_Var1 ; -> Temp_Var1 
03359.  
03360. ; NOTE: Other versions of the fractional accumulator usually merge this 
03361. ; part up with the sign extension application, which is probably better :) 
03362. LDY #$00 ; Y = 0 (positive high part) 
03363. CMP #$00  
03364. BPL PRG022_D35C ; If the whole part is positive, jump to PRG022_D35C 
03365. DEY ; Y = $FF (negative high part) 
03366. PRG022_D35C: 
03367. STY <Temp_Var3 ; -> Temp_Var3 
03368.  
03369. ; Fractional accumulation 
03370. LDA Roulette_PosFrac,X 
03371. ADD <Temp_Var2 
03372. STA Roulette_PosFrac,X 
03373.  
03374. ; Add to Pos/Hi 
03375. LDA Roulette_Pos,X 
03376. ADC <Temp_Var1 
03377. STA Roulette_Pos,X 
03378. LDA Roulette_PosHi,X 
03379. ADC <Temp_Var3 
03380. STA Roulette_PosHi,X 
03381.  
03382. RTS ; Return 
03383.  
03384. Roulette_Shapes: 
03385. .word Roulette_Star 
03386. .word Roulette_Mushroom 
03387. .word Roulette_Flower 
03388.  
03389. Roulette_Star: 
03390. .byte $FE, $FE, $FE, $FE, $FE, $9D, $9E, $FE, $FE, $FE, $FE, $FE 
03391. .byte $FE, $FE, $FE, $FE, $AC, $AD, $AE, $AF, $FE, $FE, $FE, $FE 
03392. .byte $FE, $FE, $FE, $FE, $BC, $FC, $FC, $BF, $FE, $FE, $FE, $FE 
03393. .byte $FE, $FE, $FE, $9C, $CC, $FC, $FC, $CF, $9F, $FE, $FE, $FE 
03394. .byte $96, $97, $97, $CD, $FC, $FC, $FC, $FC, $84, $97, $97, $C0 
03395. .byte $A6, $FC, $FC, $FC, $34, $FC, $FC, $37, $FC, $FC, $FC, $D0 
03396. .byte $BD, $BE, $FC, $FC, $44, $FC, $FC, $47, $FC, $FC, $F0, $E0 
03397. .byte $FE, $CE, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $ED, $B2, $FE 
03398. .byte $FE, $D1, $FC, $FC, $8C, $8D, $8E, $8F, $FC, $F8, $EE, $FE 
03399. .byte $FE, $E1, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $E3, $FE 
03400. .byte $E2, $FC, $FC, $FC, $FC, $CB, $FC, $FC, $FC, $FC, $F3, $E4 
03401. .byte $F2, $FC, $FC, $F9, $DC, $DD, $DE, $DF, $FC, $FC, $FC, $F4 
03402. .byte $E5, $FC, $E7, $E8, $DA, $FE, $FE, $DB, $E9, $EA, $FC, $EC 
03403. .byte $F5, $F6, $F7, $FE, $FE, $FE, $FE, $FE, $FE, $FA, $FB, $EF 
03404.  
03405. Roulette_Mushroom: 
03406. .byte $FC, $FC, $FC, $0A, $0B, $0C, $0D, $0E, $0F, $FC, $FC, $FC 
03407. .byte $FC, $FC, $1C, $1D, $FD, $FD, $06, $FE, $1E, $1F, $FC, $FC 
03408. .byte $FC, $13, $14, $15, $16, $17, $FE, $FE, $18, $00, $01, $FC 
03409. .byte $26, $2A, $FE, $FE, $FE, $FE, $FE, $FE, $2C, $FD, $2D, $2E 
03410. .byte $2F, $FE, $3C, $3D, $3E, $3F, $FE, $FE, $33, $FD, $FD, $36 
03411. .byte $31, $FE, $38, $FD, $FD, $3A, $FE, $FE, $4C, $4D, $4E, $4F 
03412. .byte $41, $FE, $43, $FD, $FD, $45, $FE, $FE, $FE, $FE, $FE, $46 
03413. .byte $5C, $5D, $5E, $5F, $48, $4A, $FE, $FE, $FE, $FE, $FE, $51 
03414. .byte $56, $5A, $FE, $62, $63, $64, $64, $65, $66, $FE, $FE, $67 
03415. .byte $6C, $6D, $6E, $6F, $34, $FC, $FC, $37, $7C, $7D, $7E, $7F 
03416. .byte $FC, $FC, $70, $FC, $44, $FC, $FC, $47, $FC, $71, $FC, $FC 
03417. .byte $FC, $FC, $7A, $FC, $FC, $FC, $FC, $FC, $FC, $7B, $FC, $FC 
03418. .byte $FC, $FC, $68, $FC, $8C, $8D, $8E, $8F, $FC, $76, $FC, $FC 
03419. .byte $FC, $FC, $89, $8A, $8B, $8B, $8B, $8B, $87, $88, $FC, $FC 
03420.  
03421. Roulette_Flower: 
03422. .byte $FE, $FE, $02, $03, $04, $05, $05, $07, $08, $09, $FE, $FE 
03423. .byte $10, $11, $12, $FD, $FD, $FD, $FD, $FD, $FD, $19, $1A, $1B 
03424. .byte $20, $21, $22, $23, $24, $25, $25, $27, $28, $29, $FD, $2B 
03425. .byte $30, $FD, $32, $FC, $34, $FC, $FC, $37, $FC, $39, $FD, $3B 
03426. .byte $40, $FD, $42, $FC, $44, $FC, $FC, $47, $FC, $49, $FD, $4B 
03427. .byte $50, $FD, $52, $53, $54, $55, $55, $57, $58, $59, $FD, $5B 
03428. .byte $60, $61, $FD, $FD, $FD, $FD, $FD, $FD, $FD, $69, $6A, $6B 
03429. .byte $FE, $FE, $72, $73, $74, $75, $75, $77, $78, $79, $FE, $FE 
03430. .byte $80, $81, $82, $83, $FC, $85, $86, $FC, $FC, $FC, $FC, $FC 
03431. .byte $90, $91, $92, $93, $94, $95, $FC, $FC, $98, $99, $9A, $9B 
03432. .byte $E6, $FE, $EB, $35, $A4, $A5, $FC, $A7, $A8, $A9, $AA, $AB 
03433. .byte $B0, $B1, $FE, $B3, $B1, $B5, $B6, $B7, $B8, $B9, $BA, $BB 
03434. .byte $FC, $C1, $FE, $C3, $C4, $C5, $C6, $C7, $C8, $C9, $CA, $FC 
03435. .byte $FC, $FC, $D2, $D3, $D4, $D5, $D6, $D7, $D8, $D9, $FC, $FC 
03436.  
03437.  
03438.  
03439. Roulette_DrawShapes: 
03440. ; The actual rendered pattern is Right Half Star, Mushroom, Flower, Mushroom, Left Half Star 
03441.  
03442. LDY #$20 ; Y = $20 (VRAM address high) 
03443.  
03444. JSR PRG022_D57D 
03445.  
03446. LDY #$24 ; Y = $24 (VRAM address high) 
03447.  
03448. PRG022_D57D: 
03449.  
03450. ; Temp_Var1 = $80 
03451. LDA #$80 
03452. STA <Temp_Var1 
03453. PRG022_D581: 
03454. LDA PPU_STAT 
03455.  
03456. ; Set VRAM address high 
03457. STY PPU_VRAM_ADDR 
03458.  
03459. ; Set VRAM address low 
03460. LDA <Temp_Var1 
03461. STA PPU_VRAM_ADDR 
03462.  
03463. ; Fills in a row with the pinkish "background" color 
03464. LDX #31 ; X = 31 (32 tiles per row) 
03465. PRG022_D58E: 
03466.  
03467. ; Insert a background tile 
03468. LDA #$fe 
03469. STA PPU_VRAM_DATA 
03470.  
03471. DEX ; X-- 
03472. BPL PRG022_D58E ; While X >= 0, loop! 
03473.  
03474.  
03475. ; Temp_Var1 += 32 (next row of patterns) 
03476. LDA <Temp_Var1 
03477. ADD #32 
03478. STA <Temp_Var1 
03479. BCC PRG022_D5A0 ; If no carry, jump to PRG022_D5A0 
03480. INY ; Otherwise, apply carry 
03481. PRG022_D5A0: 
03482. TYA ; -> 'A' 
03483.  
03484. AND #$03 
03485. CMP #$02 
03486. BNE PRG022_D581 ; If not on every third, jump to PRG022_D581 
03487.  
03488. LDA <Temp_Var1 
03489. CMP #$e0 
03490. BNE PRG022_D581 ; If not at end column, jump to PRG022_D581 
03491.  
03492. ; At end column... 
03493.  
03494. ; VRAM high address 
03495. LDA #$20 
03496. STA <Temp_Var1 
03497.  
03498. ; Temp_Var5 = 0 (current shape from Roulette_Shapes) 
03499. LDA #$00 
03500. STA <Temp_Var5 
03501.  
03502. PRG022_D5B5: 
03503.  
03504. ; VRAM low address 
03505. LDA #$c0 
03506. STA <Temp_Var2 
03507.  
03508. LDY #$06 
03509. PRG022_D5BB: 
03510.  
03511. ; X = Temp_Var5 * 2 (2 byte index for Roulette shape pointer) 
03512. LDA <Temp_Var5 
03513. ASL A 
03514. TAX 
03515.  
03516. ; Load starting address of Roulette shape  
03517. LDA Roulette_Shapes,X 
03518. STA <Temp_Var3 
03519. LDA Roulette_Shapes+1,X 
03520. STA <Temp_Var4 
03521.  
03522. PRG022_D5C9: 
03523. LDA PPU_STAT 
03524.  
03525. ; Set VRAM address 
03526. LDA <Temp_Var1 
03527. STA PPU_VRAM_ADDR 
03528. LDA <Temp_Var2 
03529. STA PPU_VRAM_ADDR 
03530.  
03531. LDX #$00 ; X = 0 
03532. PRG022_D5D8: 
03533. LDA [Temp_Var3],Y ; Get pattern for shape 
03534. STA PPU_VRAM_DATA ; Store into VRAM 
03535.  
03536. INY ; Y++ (next shape pattern) 
03537. INX ; X++ (column counter) 
03538.  
03539. CPX #$06 
03540. BNE PRG022_D5D8 ; While X <> 6, loop! 
03541.  
03542.  
03543. ; Y += 6 (jump to next row only halfway across) 
03544. TYA 
03545. ADD #$06 
03546. TAY 
03547.  
03548. ; Temp_Var1/2 += 32 (go to next row) 
03549. LDA <Temp_Var2 
03550. ADD #32 ; +32 next row 
03551. BCC PRG022_D5F1 ; If no carry, jump to PRG022_D5F1 
03552. INC <Temp_Var1 ; Apply carry 
03553. PRG022_D5F1: 
03554. STA <Temp_Var2 
03555.  
03556. AND #$e0 
03557. CMP #$80 
03558. BNE PRG022_D5C9 
03559.  
03560. LDA <Temp_Var1 
03561. AND #$03 
03562. CMP #$02 
03563. BNE PRG022_D5C9 
03564.  
03565. DEC <Temp_Var1 
03566. DEC <Temp_Var1 
03567.  
03568. LDA <Temp_Var2 
03569. ADD #$46 
03570. STA <Temp_Var2 
03571.  
03572. LDA <Temp_Var5 
03573. CMP #$01 
03574. BNE PRG022_D61A 
03575.  
03576. CPY #$ae 
03577. BEQ PRG022_D61A 
03578.  
03579. LDY #$06 
03580. BNE PRG022_D5C9 
03581. PRG022_D61A: 
03582. LDA <Temp_Var2 
03583. ADD #$04 
03584. STA <Temp_Var2 
03585.  
03586. LDY #$00 
03587.  
03588. LDA <Temp_Var1 
03589. CMP #$24 
03590. BEQ PRG022_D635 
03591.  
03592. INC <Temp_Var5 
03593. LDA <Temp_Var5 
03594. CMP #$03 
03595. BNE PRG022_D5BB 
03596.  
03597. LDA #$24 
03598. STA <Temp_Var1 
03599.  
03600. PRG022_D635: 
03601. DEC <Temp_Var5 
03602. BMI PRG022_D642 
03603.  
03604. LDA <Temp_Var5 
03605. CMP #$02 
03606. BEQ PRG022_D643 
03607.  
03608. JMP PRG022_D5BB ; Jump to PRG022_D5BB 
03609.  
03610. PRG022_D642: 
03611. RTS ; Return 
03612.  
03613. PRG022_D643: 
03614. JMP PRG022_D5B5 ; Jump to PRG022_D5B5 
03615.  
03616.  
03617. Card_InitGame: 
03618. LDA Card_InitState  
03619. JSR DynJump 
03620.  
03621. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
03622. .word Card_InitDeck ; 0: Initialize the card deck (if a game is not already in progress) 
03623. .word Card_RenderDeck ; 1: Renders the entire deck 
03624. .word Card_InitVars ; 2: Initializes game related memory 
03625.  
03626. Card_InitDeck: 
03627. LDA Map_NSpadeInProg 
03628. BNE PRG022_D668 ; If you already have an N-Spade game in progress from before, jump to PRG022_D668 
03629.  
03630. ; Load in the initial set of cards 
03631. LDY #(Card_InitialSet_End - Card_InitialSet - 1) 
03632. PRG022_D659: 
03633. LDA Card_InitialSet,Y ; Get initial card 
03634. STA Card_ActiveSet,Y ; Store into card memory 
03635.  
03636. DEY ; Y-- 
03637. BPL PRG022_D659 ; While Y >= 0, loop! 
03638.  
03639. JSR Card_Shuffle ; Shuffle some of the cards a bit 
03640.  
03641. INC Map_NSpadeInProg ; There is an N-Spade in progress, people! 
03642.  
03643. PRG022_D668: 
03644. INC Card_InitState ; Card_InitState = 1 
03645.  
03646. ; Card_Index = $11 
03647. LDA #$11 
03648. STA Card_Index 
03649.  
03650. RTS ; Return 
03651.  
03652. Card_RenderDeck: 
03653. ; Temp_Var11 = Card_Index 
03654. LDY Card_Index 
03655. STY <Temp_Var11  
03656.  
03657. LDA Card_ActiveSet,Y 
03658. AND #$80 
03659. BNE PRG022_D683 ; If card value bit 7 is set (card is already flipped over), jump to PRG022_D683 
03660.  
03661. JSR Card_RenderBack ; Render "N-Spade" back of this cards 
03662. JMP PRG022_D686 ; Jump to PRG022_D686 
03663.  
03664. PRG022_D683: 
03665. JSR Card_RenderFace ; Render the face of the card 
03666.  
03667. PRG022_D686: 
03668. DEC Card_Index ; Card_Index-- 
03669. BPL PRG022_D68E ; While Card_Index >= 0, loop 
03670.  
03671. INC Card_InitState ; Card_Index =2 
03672.  
03673. PRG022_D68E: 
03674. RTS ; Return 
03675.  
03676.  
03677. Card_InitVars: 
03678. INC Card_InitState ; Card_InitState = 3 (just used to break the loop) 
03679.  
03680. ; Clear some card variables 
03681. LDY #$19 ; Y = $19 
03682. PRG022_D694: 
03683. LDA #$00 
03684. STA Card_SelectX,Y 
03685.  
03686. DEY ; Y-- 
03687. BPL PRG022_D694 ; While Y >= 0, loop 
03688.  
03689. LDY #$03 ; Y = $03 
03690. PRG022_D69E: 
03691. LDA #$ff 
03692. STA Card_UnusedArray,Y 
03693.  
03694. DEY ; Y-- 
03695. BPL PRG022_D69E ; While Y >= 0, loop 
03696.  
03697. ; Card_UnusedVL = $20 
03698. LDA #$20 
03699. STA Card_UnusedVL 
03700.  
03701. ; Card_UnusedVH = $DA 
03702. LDA #$da 
03703. STA Card_UnusedVH 
03704.  
03705. ; Card_UnusedAttr = $CE 
03706. LDA #$ce 
03707. STA Card_UnusedAttr 
03708.  
03709. ; Card_TurnsRemain = $01 
03710. LDA #$01 
03711. STA Card_TurnsRemain 
03712.  
03713. RTS ; Return 
03714.  
03715. ; Sprite pattern and attributes per card selection sprite 
03716. Card_SelectPattern: 
03717. .byte $8B, $8D, $8D, $8B, $8F, $8F, $8B, $8D, $8D, $8B 
03718. Card_SelectAttribute: 
03719. .byte SPR_PAL1, SPR_PAL1, SPR_PAL1, SPR_PAL1 | SPR_HFLIP, SPR_PAL1, SPR_PAL1, SPR_PAL1 | SPR_VFLIP, SPR_PAL1 | SPR_VFLIP, SPR_PAL1 | SPR_VFLIP, SPR_PAL1 | SPR_HFLIP | SPR_VFLIP 
03720.  
03721. ; X position of card selector by Card_Index 
03722. Card_CursorXs: 
03723. .byte $18, $38, $58, $78, $98, $B8 
03724. .byte $18, $38, $58, $78, $98, $B8 
03725. .byte $18, $38, $58, $78, $98, $B8 
03726.  
03727. ; Y position of card selector by Card_Index 
03728. Card_CursorYs: 
03729. .byte $20, $20, $20, $20, $20, $20 
03730. .byte $50, $50, $50, $50, $50, $50 
03731. .byte $80, $80, $80, $80, $80, $80 
03732.  
03733. ; Attribute by frame of card flip 
03734. CardFlip_Attributes: 
03735. .byte SPR_PAL1, SPR_PAL1, SPR_PAL1, SPR_PAL3, SPR_PAL3 
03736.  
03737. ; Pattern per sprite per frame of card flip 
03738. CardFlip_FrameDefs: 
03739. CardFlip_Frame4: .byte $BD, $BD, $BF, $BF 
03740. CardFlip_Frame3: .byte $B1, $B1, $B1, $B1 
03741. CardFlip_Frame2: .byte $B5, $B5, $B5, $B5 
03742. CardFlip_Frame1: .byte $B7, $B7, $B7, $B7 
03743. CardFlip_Frame0: .byte $B7, $B7, $B7, $B7 
03744.  
03745. CardFlip_FrameDefOff: 
03746. .byte CardFlip_Frame0 - CardFlip_FrameDefs 
03747. .byte CardFlip_Frame1 - CardFlip_FrameDefs 
03748. .byte CardFlip_Frame2 - CardFlip_FrameDefs 
03749. .byte CardFlip_Frame3 - CardFlip_FrameDefs 
03750. .byte CardFlip_Frame4 - CardFlip_FrameDefs 
03751.  
03752. ; N-Spade game initial card deck 
03753. Card_InitialSet: 
03754. .byte CARD_MUSHROOM, CARD_FLOWER, CARD_1UP, CARD_MUSHROOM, CARD_10COIN, CARD_STAR 
03755. .byte CARD_20COIN, CARD_STAR, CARD_MUSHROOM, CARD_10COIN, CARD_1UP, CARD_FLOWER 
03756. .byte CARD_20COIN, CARD_FLOWER, CARD_STAR, CARD_MUSHROOM, CARD_FLOWER, CARD_STAR 
03757. Card_InitialSet_End 
03758.  
03759. ; N-Spade cards VRAM High address 
03760. Card_VRAMHi: 
03761. .byte $20, $20, $20, $20, $20, $20 
03762. .byte $21, $21, $21, $21, $21, $21 
03763. .byte $22, $22, $22, $22, $22, $22 
03764.  
03765. ; N-Spade cards VRAM Low address 
03766. Card_VRAMLo: 
03767. .byte $A3, $A7, $AB, $AF, $B3, $B7 
03768. .byte $63, $67, $6B, $6F, $73, $77 
03769. .byte $23, $27, $2B, $2F, $33, $37 
03770.  
03771. Card_FacePatterns: 
03772. ; CARD_MUSHROOM 
03773. .byte $58, $5A 
03774. .byte $59, $5B 
03775.  
03776. ; CARD_FLOWER 
03777. .byte $5C, $5E 
03778. .byte $5D, $5F 
03779.  
03780. ; CARD_STAR 
03781. .byte $AC, $AD 
03782. .byte $AE, $AF 
03783.  
03784. ; CARD_1UP 
03785. .byte $6C, $6E 
03786. .byte $6D, $6F 
03787.  
03788. ; CARD_10COIN 
03789. .byte $7C, $7E 
03790. .byte $7D, $7F 
03791.  
03792. ; CARD_20COIN 
03793. .byte $7C, $7E 
03794. .byte $7D, $7F 
03795.  
03796. Card_FaceAttribute: 
03797. .byte $FD ; CARD_MUSHROOM 
03798. .byte $FE ; CARD_FLOWER 
03799. .byte $FF ; CARD_STAR 
03800. .byte $FD ; CARD_1UP 
03801. .byte $FD ; CARD_10COIN 
03802. .byte $FD ; CARD_20COIN 
03803.  
03804. Card_VRAMAttrLo: 
03805. .byte $C9, $CA, $CB, $CC, $CD, $CE 
03806. .byte $D9, $DA, $DB, $DC, $DD, $DE 
03807. .byte $E1, $E2, $E3, $E4, $E5, $E6 
03808.  
03809.  
03810. PRG022_D777: 
03811. .byte $7F, $BF, $FF, $7F, $7F 
03812.  
03813. ; For the 1-up, 10 coin, and 20 coin cards that have additional text, patterns of the bottom row 
03814. Card_BottomLeft: .byte $78, $9D, $9E 
03815. Card_BottomRight: .byte $79, $7B, $7B 
03816.  
03817. NSpade_DoGame: 
03818. LDA Card_CoinsToGive 
03819. BEQ PRG022_D792 ; If there aren't any coins to give, jump to PRG022_D792 
03820.  
03821. ; You got a coin 
03822. INC Coins_Earned 
03823.  
03824. ; 100 points per coin 
03825. LDA #10 
03826. STA Score_Earned 
03827.  
03828. DEC Card_CoinsToGive ; Card_CoinsToGive-- 
03829.  
03830. PRG022_D792: 
03831. LDA Card_GameState 
03832. JSR DynJump 
03833.  
03834. ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! 
03835. .word Card_SelectCard ; 0: Perform cursor movements 
03836. .word Card_BeginFlip ; 1: Begin card flip 
03837. .word Card_DoFlip ; 2: Perform card flip 
03838. .word Card_TwoCardResponse ; 3: Respond to the two flipped cards 
03839. .word Card_HandleMatch ; 4: Reward the card match 
03840. .word Card_HandleMismatch ; 5: Handle the mismatch 
03841. .word Card_WaitThenExit ; 6: Decrements Card_MoveDelay, then exits to map 
03842. .word Card_BeginFlipBack ; 7: Begin flipping back a card 
03843. .word Card_FlipBackCard ; 8: Flip back a card 
03844.  
03845.  
03846. Card_SelectCard: 
03847. JSR Card_DoSelection ; Handle pressing direction or A button 
03848. JSR Card_DrawCursor ; Draw selection cursor 
03849.  
03850. RTS ; Return 
03851.  
03852.  
03853. Card_BeginFlip: 
03854. LDY Card_Index ; Y = Card_Index 
03855.  
03856. LDA Card_ActiveSet,Y 
03857. AND #$80 
03858. BNE PRG022_D7D8 ; If this card is already flipped, jump to PRG022_D7D8 
03859.  
03860. ; Card_FlipFrame = 4 
03861. LDA #$04 
03862. STA Card_FlipFrame 
03863.  
03864. ; Temp_Var11 = Card_Index 
03865. LDA Card_Index 
03866. STA <Temp_Var11 
03867.  
03868. JSR Card_Blackout ; Blacks out the card that will get flipped 
03869.  
03870. ; Card_AnimTick = 0 
03871. LDA #$00 
03872. STA Card_AnimTick 
03873.  
03874. INC Card_GameState ; Card_GameState = 2 
03875.  
03876. ; Flip card sound 
03877. LDA #SND_MAPINVENTORYFLIP 
03878. STA Sound_QMap 
03879.  
03880. JMP Card_DoFlip ; Jump to Card_DoFlip 
03881.  
03882. PRG022_D7D8: 
03883. ; Card was already flipped, so cancel 
03884. DEC Card_GameState ; Card_GameState = 0 
03885. RTS ; Return 
03886.  
03887. Card_DoFlip: 
03888. LDA Card_AnimTick 
03889. BEQ PRG022_D7E5 ; If Card_AnimTick = 0, jump to PRG022_D7E5 
03890.  
03891. DEC Card_AnimTick ; Card_AnimTick-- 
03892.  
03893. RTS ; Return 
03894.  
03895. PRG022_D7E5: 
03896.  
03897. ; Temp_Var11 = Card_Index 
03898. LDA Card_Index 
03899. STA <Temp_Var11 
03900.  
03901. JSR CardFlip_Draw ; Draw card flip 
03902.  
03903. DEC Card_FlipFrame ; Card_FlipFrame-- 
03904. BPL PRG022_D7FD ; If Card_FlipFrame >= 0 jump to PRG022_D7FD 
03905.  
03906. ; Card flip complete 
03907.  
03908. ; Temp_Var11 = Card_Index 
03909. LDA Card_Index 
03910. STA <Temp_Var11 
03911.  
03912. JSR Card_RenderFace ; Draw card face 
03913.  
03914. INC Card_GameState ; Card_GameState = 3 
03915.  
03916. PRG022_D7FD: 
03917.  
03918. ; Card_AnimTick = 4 
03919. LDA #$04 
03920. STA Card_AnimTick 
03921.  
03922. RTS ; Return 
03923.  
03924. Card_TwoCardResponse: 
03925. INC Card_FlipCount ; Card_FlipCount++ 
03926.  
03927. JSR Card_CheckForMatch ; Determines if cards matched, sets proper state 
03928.  
03929. RTS ; Return 
03930.  
03931. Card_HandleMatch: 
03932. LDY Card_Index ; Y = Card_Index 
03933.  
03934. ; Mark second card as flipped 
03935. LDA Card_ActiveSet,Y 
03936. ORA #$80 
03937. STA Card_ActiveSet,Y 
03938.  
03939. ; Card_GameState = 0 (Return to card selection) 
03940. LDA #$00 
03941. STA Card_GameState 
03942.  
03943. INC Map_NSpadeMatches ; Map_NSpadeMatches++ 
03944. INC Card_Matches ; Card_Matches++ 
03945.  
03946. JSR Card_MatchPairReward ; Give reward 
03947.  
03948. LDA Map_NSpadeMatches 
03949. CMP #$09 
03950. BNE PRG022_D83D ; If Map_NSpadeMatches <> 9, jump to PRG022_D83D (RTS) 
03951.  
03952. ; 9 matches means the game is complete 
03953.  
03954. ; Card_GameState = 6 
03955. LDA #$06 
03956. STA Card_GameState 
03957.  
03958. ; Card_MoveDelay = $40 
03959. LDA #$40 
03960. STA Card_MoveDelay 
03961.  
03962. LDA #$00 
03963. STA Map_NSpadeInProg ; N-Spade game is no longer in prgoress 
03964. STA Map_NSpadeMatches ; Clear the match counter 
03965.  
03966. RTS ; Return 
03967.  
03968. PRG022_D83D: 
03969. RTS ; Return 
03970.  
03971.  
03972. Card_HandleMismatch: 
03973. ; Card_FlipFrame = 0 
03974. LDA #$00  
03975. STA Card_FlipFrame 
03976.  
03977. ; Temp_Var12 = 1 
03978. LDA #$01 
03979. STA <Temp_Var12 
03980.  
03981. INC Card_GameState ; Card_GameState = 6 
03982. INC Card_GameState ; Card_GameState = 7 
03983.  
03984. ; Card_MoveDelay = $40 
03985. LDA #$40 
03986. STA Card_MoveDelay 
03987.  
03988. LDY Card_Index ; Y = Card_Index 
03989.  
03990. ; Clear the card flipped flag on the second card 
03991. LDA Card_ActiveSet,Y 
03992. AND #$7f 
03993. STA Card_ActiveSet,Y 
03994.  
03995. LDY Card_FirstIndex ; Y = Card_FirstIndex 
03996.  
03997. ; Clear the card flipped flag on the first card 
03998. LDA Card_ActiveSet,Y 
03999. AND #$7f 
04000. STA Card_ActiveSet,Y 
04001.  
04002. ; Mismatch sound 
04003. LDA #SND_MAPDENY 
04004. STA Sound_QMap 
04005.  
04006. DEC Card_TurnsRemain ; Card_TurnsRemain-- (one less turn) 
04007. BPL PRG022_D875 ; If turns remain, jump to PRG022_D875 
04008.  
04009. DEC Card_GameState ; Card_GameState = 6 
04010.  
04011. PRG022_D875: 
04012. RTS ; Return 
04013.  
04014. Card_WaitThenExit: 
04015. DEC Card_MoveDelay ; Card_MoveDelay-- 
04016. BPL PRG022_D87D ; If Card_MoveDelay > 0, jump to PRG022_D87D (RTS) 
04017.  
04018. ; Exit to map 
04019. INC <Level_ExitToMap 
04020.  
04021. PRG022_D87D: 
04022. RTS ; Return 
04023.  
04024. Card_BeginFlipBack: 
04025. LDA Card_MoveDelay 
04026. BEQ PRG022_D887 ; If Card_MoveDelay = 0, jump to PRG022_D887 
04027.  
04028. DEC Card_MoveDelay ; Card_MoveDelay-- 
04029.  
04030. RTS ; Return 
04031.  
04032. PRG022_D887: 
04033.  
04034. ; Card_FlipFrame = 0 
04035. LDA #$00 
04036. STA Card_FlipFrame 
04037.  
04038. LDY <Temp_Var12 ; Y = Temp_Var12 
04039.  
04040. LDA Card_Index,Y ; Get first or second card face value 
04041. STA <Temp_Var11 ; Face value -> Temp_Var11 
04042.  
04043. JSR Card_Blackout ; Black out this card 
04044.  
04045. INC Card_GameState ; Card_GameState = 8 
04046.  
04047. ; Card_AnimTick= 0 
04048. LDA #$00 
04049. STA Card_AnimTick 
04050.  
04051. Card_FlipBackCard: 
04052. LDA Card_AnimTick 
04053. BEQ PRG022_D8A7 ; If Card_AnimTick = 0, jump to PRG022_D8A7 
04054.  
04055. DEC Card_AnimTick ; Card_AnimTick-- 
04056.  
04057. RTS ; Return 
04058.  
04059. PRG022_D8A7: 
04060. LDY <Temp_Var12 ; Y = Temp_Var12 (first or second card index) 
04061.  
04062. LDA Card_Index,Y ; Get first or second card face value 
04063. STA <Temp_Var11 ; Face value -> Temp_Var11 
04064.  
04065. JSR CardFlip_Draw ; Draw card flip 
04066.  
04067. INC Card_FlipFrame ; Card_FlipFrame++ 
04068.  
04069. LDA Card_FlipFrame 
04070. CMP #$05 
04071. BLT PRG022_D8D8 ; If Card_FlipFrame < 5, jump to PRG022_D8D8 
04072.  
04073. LDY <Temp_Var12 ; Y = Temp_Var12 (first or second card index) 
04074.  
04075. LDA Card_Index,Y ; Get first or second card face value 
04076. STA <Temp_Var11 ; Face value -> Temp_Var11 
04077.  
04078. JSR Card_RenderBack ; Render the card's back side 
04079.  
04080. DEC <Temp_Var12 ; Temp_Var12-- 
04081. BPL PRG022_D8CF ; If there's another card to do, jump to PRG022_D8CF 
04082.  
04083. ; Both cards are flipped back over 
04084.  
04085. ; Card_GameState = 0 (Return to card selection) 
04086. LDA #$00 
04087. STA Card_GameState 
04088.  
04089. RTS ; Return 
04090.  
04091. PRG022_D8CF: 
04092. ; Card_MoveDelay = 2 
04093. LDA #$02 
04094. STA Card_MoveDelay 
04095.  
04096. DEC Card_GameState 
04097.  
04098. RTS ; Return 
04099.  
04100. PRG022_D8D8: 
04101.  
04102. ; Card_AnimTick = 4 
04103. LDA #$04 
04104. STA Card_AnimTick 
04105.  
04106. RTS ; Return 
04107.  
04108.  
04109. Card_Shuffle: 
04110. ; Temp_Var11 = 2 (3 shuffle operations) 
04111. LDA #$02  
04112. STA <Temp_Var11  
04113. PRG022_D8E2: 
04114. JSR Randomize 
04115. AND #$1f 
04116. TAY ; Y = 0 to 31, random 
04117.  
04118. ; Rotate the first 15 cards 0 to 31 (random) times to shuffle 
04119. PRG022_D8E8: 
04120.  
04121. ; Temp_Var12 = 15th card 
04122. LDA Card_ActiveSet+14 
04123. STA <Temp_Var12  
04124.  
04125. LDX #$0D ; X = $0D 
04126. PRG022_D8EF: 
04127.  
04128. ; Copy card into adjacent slot 
04129. LDA Card_ActiveSet,X 
04130. STA Card_ActiveSet+1,X 
04131.  
04132. DEX ; X-- 
04133. BPL PRG022_D8EF ; While X >= 0, loop! 
04134.  
04135. ; Set the original 15th card as the first card 
04136. LDA <Temp_Var12  
04137. STA Card_ActiveSet 
04138.  
04139. DEY ; Y-- 
04140. BPL PRG022_D8E8 ; While Y >= 0, loop! 
04141.  
04142. LDX #$00 ; X = 0 (this routine will only be run once, even though they structured a loop) 
04143. PRG022_D902: 
04144. ; First card -> Temp_Var12 
04145. LDA Card_ActiveSet,X 
04146. STA <Temp_Var12  
04147.  
04148. ; Sixth card -> first 
04149. LDA Card_ActiveSet+5,X 
04150. STA Card_ActiveSet,X 
04151.  
04152. ; Eleventh card -> sixth 
04153. LDA Card_ActiveSet+10,X 
04154. STA Card_ActiveSet+5,X  
04155.  
04156. ; Former first card -> Eleventh 
04157. LDA <Temp_Var12  
04158. STA Card_ActiveSet+10,X 
04159.  
04160. ; X -= 2 
04161. DEX 
04162. DEX 
04163.  
04164. BPL PRG022_D902 ; While X >= 0, loop! 
04165.  
04166. DEC <Temp_Var11 ; Temp_Var11-- 
04167. BPL PRG022_D8E2 ; While Temp_Var11 >= 0, loop! 
04168.  
04169. RTS ; Return 
04170.  
04171. Card_RenderFace: 
04172. LDY #(CardBase_BufCmds_End - CardBase_BufCmds - 1) 
04173. PRG022_D923: 
04174. LDA CardBase_BufCmds,Y 
04175. STA Graphics_Buffer+$00,Y 
04176.  
04177. DEY ; Y-- 
04178. BPL PRG022_D923 ; While Y >= 0, loop 
04179.  
04180. LDY <Temp_Var11 ; Y = Temp_Var11 (current card) 
04181.  
04182. ; Get VRAM address of this card -> Card_VRAM_H/L 
04183. LDA Card_VRAMHi,Y 
04184. STA Card_VRAM_H  
04185. LDA Card_VRAMLo,Y 
04186. STA Card_VRAM_L  
04187.  
04188. LDY #$00 ; Y = 0 
04189. LDX #$03 ; X = 0 
04190. PRG022_D93E:  
04191.  
04192. ; Patch card VRAM Hi into graphics buffer 
04193. LDA Card_VRAM_H 
04194. STA Graphics_Buffer+$00,Y 
04195.  
04196. INY ; Y++ (next graphics buffer byte) 
04197.  
04198. ; Patch card VRAM Lo into graphics buffer 
04199. LDA Card_VRAM_L  
04200. STA Graphics_Buffer+$00,Y 
04201.  
04202. ; Y += 6 (next card row in buffer commands) 
04203. TYA 
04204. ADD #$06 
04205. TAY 
04206.  
04207. ; +32 to go to next pattern row 
04208. LDA Card_VRAM_L 
04209. ADD #32 
04210. STA Card_VRAM_L 
04211. LDA Card_VRAM_H 
04212. ADC #$00 
04213. STA Card_VRAM_H 
04214.  
04215. DEX ; X-- 
04216. BPL PRG022_D93E ; While X >= 0, loop 
04217.  
04218. LDY <Temp_Var11 ; Y = Temp_Var11 (current card) 
04219.  
04220. ; Get the card face sans "already flipped" bit -> Temp_Var12 
04221. LDA Card_ActiveSet,Y 
04222. AND #$7f 
04223. STA <Temp_Var12 
04224.  
04225. ASL A 
04226. ASL A 
04227. TAY ; Y = face * 4 
04228.  
04229. ; Add the four patterns making up the card face 
04230. LDA Card_FacePatterns,Y  
04231. STA Graphics_Buffer+$0B 
04232. INY ; Y++ (next graphics buffer byte) 
04233. LDA Card_FacePatterns,Y 
04234. STA Graphics_Buffer+$0C 
04235. INY ; Y++ (next graphics buffer byte) 
04236. LDA Card_FacePatterns,Y 
04237. STA Graphics_Buffer+$12 
04238. INY ; Y++ (next graphics buffer byte) 
04239. LDA Card_FacePatterns,Y 
04240. STA Graphics_Buffer+$13 
04241.  
04242. LDY <Temp_Var12 ; Y = Temp_Var12 (current card face) 
04243.  
04244. ; Temp_Var13 = card face attribute 
04245. LDA Card_FaceAttribute,Y 
04246. STA <Temp_Var13  
04247.  
04248. LDA <Temp_Var11 
04249. CMP #6 
04250. BLT PRG022_D99F ; If Temp_Var11 < 6 (card is on first row), jump to PRG022_D99F 
04251.  
04252. CMP #12 
04253. BGE PRG022_D99F ; If Temp_Var11 < 12 (card is on second row), jump to PRG022_D99F 
04254.  
04255. JMP PRG022_D9A9 ; Card is on third row; jump to PRG022_D9A9 
04256.  
04257. PRG022_D99F: 
04258. LDA <Temp_Var13 
04259. ASL A 
04260. ASL A 
04261. ASL A 
04262. ASL A 
04263. ORA #$0f 
04264. STA <Temp_Var13 
04265.  
04266. PRG022_D9A9: 
04267. LDX <Temp_Var11 ; X = Temp_Var11 (current card index) 
04268.  
04269. ; Patch attribute VRAM Hi into graphics buffer 
04270. LDA #$23 
04271. STA Graphics_Buffer+$1C 
04272.  
04273. ; Patch card attribute VRAM Lo into graphics buffer 
04274. LDA Card_VRAMAttrLo,X 
04275. STA Graphics_Buffer+$1D 
04276.  
04277. ; Run length of 1 
04278. LDA #$01 
04279. STA Graphics_Buffer+$1E 
04280.  
04281. ; Attribute byte 
04282. LDA <Temp_Var13 
04283. STA Graphics_Buffer+$1F 
04284.  
04285. ; Terminator 
04286. LDA #$00 
04287. STA Graphics_Buffer+$20 
04288.  
04289. ; Graphics_BufCnt = $20 
04290. LDA #$20 
04291. STA Graphics_BufCnt 
04292.  
04293. LDA <Temp_Var12 
04294. CMP #CARD_1UP 
04295. BLT PRG022_D9E0 ; If Temp_Var12 < CARD_1UP, jump to PRG022_D9E0 
04296.  
04297. SUB #CARD_1UP 
04298. TAY ; Y = relative (0 = 1-up, 1 = 10 coin, 2 = 20 coin) 
04299.  
04300. ; Add the bottom text on 1-up, 10 coin, or 20 coin cards 
04301. LDA Card_BottomLeft,Y 
04302. STA Graphics_Buffer+$19 
04303. LDA Card_BottomRight,Y 
04304. STA Graphics_Buffer+$1A 
04305.  
04306. PRG022_D9E0: 
04307.  
04308. ; Card selector sprites all invisible 
04309. LDA #$f8 
04310. STA Sprite_RAM+$2C 
04311. STA Sprite_RAM+$30 
04312. STA Sprite_RAM+$34 
04313. STA Sprite_RAM+$38 
04314.  
04315. RTS ; Return 
04316.  
04317.  
04318. Card_RenderBack: 
04319. LDY #(CardBack_BufCmds_End - CardBack_BufCmds - 1) 
04320. PRG022_D9F1: 
04321. LDA CardBack_BufCmds,Y ; Get graphics buffer command 
04322. STA Graphics_Buffer+$00,Y ; Store into graphics buffer 
04323.  
04324. DEY ; Y-- 
04325. BPL PRG022_D9F1 ; While Y >= 0, loop 
04326.  
04327. LDY <Temp_Var11 ; Y = Temp_Var11 (current card) 
04328.  
04329. ; Get VRAM address of this card -> Card_VRAM_H/L 
04330. LDA Card_VRAMHi,Y 
04331. STA Card_VRAM_H  
04332. LDA Card_VRAMLo,Y 
04333. STA Card_VRAM_L  
04334.  
04335. LDY #$00 ; Y = 0 
04336. LDX #$03 ; X = 3 (4 rows of patterns per card) 
04337. PRG022_DA0C: 
04338.  
04339. ; Patch card VRAM Hi into graphics buffer 
04340. LDA Card_VRAM_H 
04341. STA Graphics_Buffer+$00,Y 
04342.  
04343. INY ; Y++ (next graphics buffer byte) 
04344.  
04345. ; Patch card VRAM Lo into graphics buffer 
04346. LDA Card_VRAM_L  
04347. STA Graphics_Buffer+$00,Y 
04348.  
04349. ; Y += 6 (next card row in buffer commands) 
04350. TYA 
04351. ADD #$06 
04352. TAY 
04353.  
04354. ; Card_VRAM_L/H += 32 (next row of patterns) 
04355. LDA Card_VRAM_L 
04356. ADD #32 
04357. STA Card_VRAM_L 
04358. LDA Card_VRAM_H 
04359. ADC #$00 
04360. STA Card_VRAM_H 
04361.  
04362. DEX ; X-- 
04363. BPL PRG022_DA0C ; While X >= 0, loop 
04364.  
04365. LDX <Temp_Var11 ; X = Temp_Var11 (current card) 
04366.  
04367. LDA #$23 
04368. STA Graphics_Buffer+$1C 
04369.  
04370. LDA Card_VRAMAttrLo,X 
04371. STA Graphics_Buffer+$1D 
04372.  
04373. ; Run length 1 
04374. LDA #$01 
04375. STA Graphics_Buffer+$1E 
04376.  
04377. ; Set palette 3 
04378. LDA #$FF 
04379. STA Graphics_Buffer+$1F 
04380.  
04381. ; Terminator 
04382. LDA #$00 
04383. STA Graphics_Buffer+$20 
04384.  
04385. ; Graphics_BufCnt = $20 
04386. LDA #$20 
04387. STA Graphics_BufCnt 
04388.  
04389. ; Card selector sprites all invisible 
04390. LDA #$f8 
04391. STA Sprite_RAM+$2C 
04392. STA Sprite_RAM+$30 
04393. STA Sprite_RAM+$34 
04394. STA Sprite_RAM+$38 
04395.  
04396. RTS ; Return 
04397.  
04398. ; FIXME: Anyone want to claim this?? 
04399. ; This seems like it'd have displayed matched pairs perhaps or even just debug data 
04400. ; $DA62  
04401. LDY #$00 ; Y = 0 
04402.  
04403. ; Temp_Var11 = 11 
04404. LDA #$01 
04405. STA <Temp_Var11 
04406.  
04407. LDX Card_Index ; X = Card_Index 
04408.  
04409. ; Card face -> Temp_Var12 
04410. LDA Card_ActiveSet,X 
04411. STA <Temp_Var12  
04412.  
04413. ASL A 
04414. ASL A 
04415. TAX ; X = card face * 4 
04416.  
04417. PRG022_DA73: 
04418. ; Some VRAM Low 
04419. LDA Card_UnusedVL 
04420. STA Graphics_Buffer+$00,Y 
04421.  
04422. INY ; Y++ (next graphics buffer byte) 
04423.  
04424. ; Some VRAM High 
04425. LDA Card_UnusedVH 
04426. STA Graphics_Buffer+$00,Y 
04427.  
04428. INY ; Y++ (next graphics buffer byte) 
04429.  
04430. ; Run length of 2 
04431. LDA #$02 
04432. STA Graphics_Buffer+$00,Y 
04433.  
04434. INY ; Y++ (next graphics buffer byte) 
04435.  
04436.  
04437. LDA Card_FacePatterns,X 
04438. STA Graphics_Buffer+$00,Y 
04439.  
04440. INY ; Y++ (next graphics buffer byte) 
04441.  
04442. INX ; X++ 
04443.  
04444. LDA Card_FacePatterns,X 
04445. STA Graphics_Buffer+$00,Y 
04446.  
04447. INY ; Y++ 
04448. INX ; X++ 
04449.  
04450. ; +32 for next row 
04451. LDA Card_UnusedVH 
04452. ADD #32 
04453. STA Card_UnusedVH 
04454. LDA Card_UnusedVL 
04455. ADC #$00 
04456. STA Card_UnusedVL 
04457.  
04458. DEC <Temp_Var11 ; Temp_Var11-- 
04459. BPL PRG022_DA73 ; While Temp_Var1 >= 0, loop 
04460.  
04461. LDX <Temp_Var12 ; X = Temp_Var12 
04462.  
04463. ; High VRAM in attribute table? 
04464. LDA #$23 
04465. STA Graphics_Buffer+$00,Y 
04466.  
04467. INY ; Y++ (next graphics buffer byte) 
04468.  
04469. LDA Card_UnusedAttr 
04470. STA Graphics_Buffer+$00,Y 
04471.  
04472. INY ; Y++ (next graphics buffer byte) 
04473.  
04474. LDA #$01 
04475. STA Graphics_Buffer+$00,Y 
04476.  
04477. INY ; Y++ (next graphics buffer byte) 
04478.  
04479. LDA Card_Matches 
04480. AND #$01 
04481. BEQ PRG022_DAD6 
04482.  
04483. INC Card_UnusedArrIdx 
04484.  
04485. LDA PRG022_D777,X 
04486. LSR A 
04487. LSR A 
04488. LSR A 
04489. LSR A 
04490. ORA #$f0 
04491. BNE PRG022_DAE2 
04492.  
04493. PRG022_DAD6: 
04494. LDA Card_UnusedAttr 
04495. ADD #$08 
04496. STA Card_UnusedAttr 
04497.  
04498. LDA PRG022_D777,X 
04499.  
04500. PRG022_DAE2: 
04501. LDX Card_UnusedArrIdx 
04502. AND Card_UnusedArray,X 
04503. STA Card_UnusedArray,X 
04504. STA Graphics_Buffer+$00,Y 
04505.  
04506. INY 
04507.  
04508. LDA #$00 
04509. STA Graphics_Buffer+$00,Y 
04510.  
04511. RTS 
04512.  
04513. Card_Blackout: 
04514. LDY #(CardBlackout_BufCmds_End - CardBlackout_BufCmds - 1) 
04515. PRG022_DAF7: 
04516. LDA CardBlackout_BufCmds,Y ; Get buffer command 
04517. STA Graphics_Buffer+$00,Y ; Set in graphics buffer 
04518.  
04519. DEY ; Y-- 
04520. BPL PRG022_DAF7 ; While Y >= 0, loop 
04521.  
04522. LDY <Temp_Var11 ; Y = Temp_Var11 
04523.  
04524. ; Get VRAM address of this card -> Card_VRAM_H/L 
04525. LDA Card_VRAMHi,Y 
04526. STA Card_VRAM_H  
04527. LDA Card_VRAMLo,Y 
04528. STA Card_VRAM_L  
04529.  
04530. LDA #(CardBlackout_BufCmds_End - CardBlackout_BufCmds - 1) 
04531. STA Graphics_BufCnt 
04532.  
04533. LDY #$00 ; Y = 0 
04534. LDX #$03 ; X = 3  
04535. PRG022_DB17: 
04536. ; Patch card VRAM Hi into graphics buffer 
04537. LDA Card_VRAM_H 
04538. STA Graphics_Buffer+$00,Y 
04539.  
04540. INY ; Y++ (next graphics buffer byte) 
04541.  
04542. ; Patch card VRAM Lo into graphics buffer 
04543. LDA Card_VRAM_L  
04544. STA Graphics_Buffer+$00,Y 
04545.  
04546. ; Y += 6 (next card row in buffer commands) 
04547. TYA 
04548. ADD #$06 
04549. TAY 
04550.  
04551. ; +32 to go to next pattern row 
04552. LDA Card_VRAM_L 
04553. ADD #32 
04554. STA Card_VRAM_L 
04555. LDA Card_VRAM_H 
04556. ADC #$00 
04557. STA Card_VRAM_H 
04558.  
04559. DEX ; X-- 
04560. BPL PRG022_DB17 ; While X >= 0, loop 
04561.  
04562. RTS ; Return 
04563.  
04564. Card_CheckForMatch: 
04565. LDA Card_FlipCount 
04566. AND #$01 
04567. BNE PRG022_DB7E ; If this was the first card, jump to PRG022_DB7E 
04568.  
04569. ; Second card flipped 
04570.  
04571. LDY Card_Index ; Y = Card_Index 
04572.  
04573. LDA Card_ActiveSet,Y 
04574. CMP Card_MatchCard 
04575. BEQ PRG022_DB98 ; If you picked the same card, jump to PRG022_DB98 
04576.  
04577. ; Mismatched cards 
04578.  
04579. ; UNUSED Wild card! 
04580. LDA Card_ActiveSet,Y 
04581. CMP #CARD_WILD 
04582. BNE PRG022_DB5D ; If this is not CARD_WILD, jump to PRG022_DB5D 
04583.  
04584. ; Wild card! 
04585.  
04586. LDA Card_MatchCard ; Just pass the match on 
04587. JMP PRG022_DB6C ; Jump to PRG022_DB6C 
04588.  
04589. PRG022_DB5D: 
04590.  
04591. ; UNUSED Wild card! 
04592. LDA Card_MatchCard 
04593. CMP #CARD_WILD 
04594. BNE PRG022_DB72 ; If this is not CARD_WILD, jump to PRG022_DB72 
04595.  
04596. ; Wild card! 
04597.  
04598. LDA Card_ActiveSet,Y ; Get card face 
04599. ORA #$80 ; Mark card as flipped 
04600.  
04601. LDY Card_FirstIndex ; Y = Card_FirstIndex (the first card that was flipped over) 
04602.  
04603. PRG022_DB6C: 
04604. STA Card_ActiveSet,Y ; Mark first card as flipped 
04605. JMP PRG022_DB98 ; Jump to PRG022_DB98 
04606.  
04607. PRG022_DB72: 
04608.  
04609. ; Cards mismatched 
04610.  
04611. INC Card_GameState ; Card_GameState = 4 
04612. INC Card_GameState ; Card_GameState = 5 
04613.  
04614. ; Card_MoveDelay = $30 
04615. LDA #$30 
04616. STA Card_MoveDelay 
04617.  
04618. RTS ; Return 
04619.  
04620. PRG022_DB7E: 
04621.  
04622. ; First card flipped 
04623.  
04624. ; Card_FirstIndex = Card_Index (hold the index of the first card you flipped) 
04625. LDY Card_Index 
04626. STY Card_FirstIndex 
04627.  
04628. ; Record the first card face 
04629. LDA Card_ActiveSet,Y 
04630. STA Card_MatchCard 
04631.  
04632. ; Mark card as flipped 
04633. LDA Card_ActiveSet,Y 
04634. ORA #$80 
04635. STA Card_ActiveSet,Y 
04636.  
04637. ; Card_GameState = 0; Return to selection mode 
04638. LDA #$00 
04639. STA Card_GameState 
04640.  
04641. RTS ; Return 
04642.  
04643. PRG022_DB98: 
04644. ; Cards matched 
04645. INC Card_GameState ; Card_GameState = 4 
04646. RTS ; Return 
04647.  
04648.  
04649. Card_DoSelection: 
04650. LDA Card_MoveDelay 
04651. BEQ PRG022_DBA5 ; If Card_MoveDelay = 0, jump to PRG022_DBA5 
04652.  
04653. DEC Card_MoveDelay ; Card_MoveDelay-- 
04654.  
04655. RTS ; Return 
04656.  
04657. PRG022_DBA5: 
04658. LDA <Pad_Holding 
04659. AND #PAD_A 
04660. BEQ PRG022_DBAF ; If Player is not pressing A, jump to PRG022_DBAF 
04661.  
04662. INC Card_GameState ; Card_GameState = 1 
04663.  
04664. RTS ; Return 
04665.  
04666. PRG022_DBAF: 
04667. LDA <Pad_Holding 
04668. AND #(PAD_LEFT | PAD_RIGHT | PAD_UP | PAD_DOWN) 
04669. BEQ PRG022_DC1D ; If Player is not pressing a direction, jump to PRG022_DC1D (RTS) 
04670.  
04671. ; Card_MoveDelay = 8 
04672. LDA #$08 
04673. STA Card_MoveDelay 
04674.  
04675. ; Play blip sound 
04676. LDA #SND_LEVELBLIP 
04677. STA Sound_QLevel1 
04678.  
04679. LDA <Pad_Holding 
04680. AND #PAD_UP 
04681. BEQ PRG022_DBD9 ; If Player is not pressing UP, jump to PRG022_DBD9 
04682.  
04683. ; Card_Index -= 6 (one row up) 
04684. LDA Card_Index 
04685. SUB #$06 
04686. STA Card_Index 
04687.  
04688. BCS PRG022_DBD9 ; If not below zero, jump to PRG022_DBD9 
04689.  
04690. ; Card_Index += 18 (return to bottom row) 
04691. LDA Card_Index 
04692. ADD #18 
04693. STA Card_Index 
04694.  
04695. PRG022_DBD9: 
04696. LDA <Pad_Holding 
04697. AND #PAD_DOWN 
04698. BEQ PRG022_DBF8 ; If Player is not pressing DOWN, jump to PRG022_DBF8 
04699.  
04700. ; Card_Index += 6 (one row down) 
04701. LDA Card_Index 
04702. ADD #$06 
04703. STA Card_Index 
04704.  
04705. LDA Card_Index 
04706. CMP #18 
04707. BLT PRG022_DBF8 ; If not below the bottom row, jump to PRG022_DBF8 
04708.  
04709. ; Card_Index -= 18 (return to top row) 
04710. LDA Card_Index 
04711. SUB #18 
04712. STA Card_Index 
04713.  
04714. PRG022_DBF8: 
04715. LDA <Pad_Holding 
04716. AND #PAD_RIGHT 
04717. BEQ PRG022_DC0D ; If Player is not pressing RIGHT, jump to PRG022_DC0D 
04718.  
04719. INC Card_Index ; Card_Index++ 
04720.  
04721. LDA Card_Index 
04722. CMP #18 
04723. BLT PRG022_DC0D ; If not passed the last card, jump to PRG022_DC0D 
04724.  
04725. ; Return to first card 
04726. LDA #$00 
04727. STA Card_Index 
04728.  
04729. PRG022_DC0D: 
04730. LDA <Pad_Holding 
04731. AND #PAD_LEFT 
04732. BEQ PRG022_DC1D ; If Player is not pressing LEFT, jump to PRG022_DC1D (RTS) 
04733.  
04734. DEC Card_Index ; Card_Index-- 
04735.  
04736. BPL PRG022_DC1D ; If did not go before first card, jump to PRG022_DC1D (RTS) 
04737.  
04738. ; Card_Index = 17 
04739. LDA #17 
04740. STA Card_Index 
04741.  
04742. PRG022_DC1D: 
04743. RTS ; Return 
04744.  
04745. Card_DrawSelectSprite: 
04746.  
04747. ; Set sprite Y 
04748. LDA Card_SelectY  
04749. STA Sprite_RAM+$04,Y 
04750.  
04751. INY ; Y++ (next Sprite RAM offset) 
04752.  
04753. ; Set sprite pattern 
04754. LDA Card_SelectPattern,X 
04755. STA Sprite_RAM+$04,Y 
04756.  
04757. INY ; Y++ (next Sprite RAM offset) 
04758.  
04759. ; Set sprite attribute 
04760. LDA Card_SelectAttribute,X 
04761. STA Sprite_RAM+$04,Y 
04762.  
04763. INY ; Y++ (next Sprite RAM offset) 
04764.  
04765. ; Set sprite Y 
04766. LDA Card_SelectX 
04767. STA Sprite_RAM+$04,Y 
04768.  
04769. INY ; Y++ (next Sprite RAM offset) 
04770.  
04771. INX ; X++ 
04772.  
04773. RTS ; Return 
04774.  
04775. Card_DrawCursor: 
04776. LDX Card_Index ; X = Card_Index 
04777.  
04778. ; Set Card_SelectX 
04779. LDA Card_CursorXs,X 
04780. STA Card_SelectX 
04781. STA Card_SelectXOrig ; And keep original X 
04782.  
04783. ; Set Card_SelectY 
04784. LDA Card_CursorYs,X 
04785. STA Card_SelectY 
04786.  
04787. LDX #$00 ; X = 0 
04788. LDY #$00 ; Y = 0 
04789. PRG022_DC52: 
04790. JSR Card_DrawSelectSprite ; Draw just a sprite  
04791.  
04792. ; Card_SelectX += 8 
04793. LDA Card_SelectX 
04794. ADD #$08 
04795. STA Card_SelectX 
04796.  
04797. CPX #$04  
04798. BLT PRG022_DC52 ; While X < 4, loop 
04799.  
04800. ; Card_SelectY += 16 
04801. LDA Card_SelectY 
04802. ADD #16 
04803. STA Card_SelectY 
04804.  
04805. ; Card_SelectX = Card_SelectXOrig 
04806. LDA Card_SelectXOrig 
04807. STA Card_SelectX 
04808.  
04809. ; Left edge sprite 
04810. JSR Card_DrawSelectSprite 
04811.  
04812. LDA Card_SelectX 
04813. ADD #24 
04814. STA Card_SelectX 
04815.  
04816. ; Right edge sprite 
04817. JSR Card_DrawSelectSprite 
04818.  
04819. ; Card_SelectY += 16 
04820. LDA Card_SelectY 
04821. ADD #16 
04822. STA Card_SelectY 
04823.  
04824. ; Card_SelectX = Card_SelectXOrig 
04825. LDA Card_SelectXOrig 
04826. STA Card_SelectX 
04827.  
04828. PRG022_DC8F: 
04829. JSR Card_DrawSelectSprite ; Draw just a sprite  
04830.  
04831. ; Card_SelectX += 8 
04832. LDA Card_SelectX 
04833. ADD #$08 
04834. STA Card_SelectX 
04835.  
04836. CPX #$0a 
04837. BLT PRG022_DC8F ; If X < $0A, loop 
04838.  
04839. ; Hold current Sprite RAM offset 
04840. STY Card_SprRAMOff 
04841.  
04842. RTS ; Return 
04843.  
04844. CardFlip_Draw: 
04845. LDX <Temp_Var11 ; X = Temp_Var11 (Card Index) 
04846.  
04847. ; Card starts at selection cursor +8 
04848. LDA Card_CursorXs,X 
04849. ADD #$08 
04850. STA Card_SelectX 
04851. STA Card_SelectXOrig 
04852.  
04853. ; Card is at cursor Y 
04854. LDA Card_CursorYs,X 
04855. ADD #$08 
04856. STA Card_SelectY 
04857.  
04858. LDX #$00 ; X = 0 
04859. LDY Card_SprRAMOff ; Y = Card_SprRAMOff 
04860.  
04861. PRG022_DCBF: 
04862. ; Set sprite Y for card flip 
04863. LDA Card_SelectY 
04864. STA Sprite_RAM+$04,Y 
04865.  
04866. INY ; Y++ (next sprite byte) 
04867.  
04868. JSR CardFlipSprite_GetPattern ; Get pattern for sprite 
04869. STA Sprite_RAM+$04,Y ; Set pattern 
04870.  
04871. INY ; Y++ (next sprite byte) 
04872.  
04873. ; Temp_Var11 = 0 
04874. LDA #$00 
04875. STX <Temp_Var11 
04876.  
04877. LDX Card_FlipFrame ; X = Card_FlipFrame 
04878.  
04879. ; Sprite attribute 
04880. LDA CardFlip_Attributes,X 
04881. STA Sprite_RAM+$04,Y 
04882.  
04883. LDX <Temp_Var11 ; X = Temp_Var11 (current card flip sprite) 
04884.  
04885. INY ; Y++ (next sprite byte) 
04886.  
04887. ; Set flip sprite X 
04888. LDA Card_SelectX 
04889. STA Sprite_RAM+$04,Y 
04890.  
04891. INY ; Y++ (next sprite byte) 
04892.  
04893. INX ; X++ 
04894. CPX #$04 
04895. BGE PRG022_DD09 ; If X >= 4, jump to PRG022_DD09 
04896.  
04897. ; Card_SelectX += 8 
04898. LDA Card_SelectX 
04899. ADD #$08 
04900. STA Card_SelectX 
04901.  
04902. TXA 
04903. AND #$01 
04904. BNE PRG022_DD06 ; Every other flip sprite, jump to PRG022_DD06 
04905.  
04906. ; Card_SelectY += 16 
04907. LDA Card_SelectY 
04908. ADD #16 
04909. STA Card_SelectY 
04910.  
04911. ; Card_SelectX = Card_SelectXOrig 
04912. LDA Card_SelectXOrig 
04913. STA Card_SelectX 
04914.  
04915. PRG022_DD06: 
04916. JMP PRG022_DCBF ; Jump to PRG022_DCBF 
04917.  
04918. PRG022_DD09: 
04919.  
04920. ; Some card flip sprites use HFLIP 
04921. LDA Sprite_RAM+$32 
04922. ORA #SPR_HFLIP 
04923. STA Sprite_RAM+$32 
04924. LDA Sprite_RAM+$3A 
04925. ORA #SPR_HFLIP 
04926. STA Sprite_RAM+$3A 
04927.  
04928. RTS ; Return 
04929.  
04930. CardFlipSprite_GetPattern: 
04931. STX <Temp_Var11 ; Backup 'X' -> Temp_Var11 (current card flip sprite) 
04932.  
04933. LDX Card_FlipFrame ; X = Card_FlipFrame 
04934.  
04935. LDA CardFlip_FrameDefOff,X ; Get initial frame def offset 
04936. ADD <Temp_Var11 ; Offset by current flip sprite 
04937. TAX ; -> 'X' 
04938.  
04939. LDA CardFlip_FrameDefs,X ; Get this sprite pattern 
04940.  
04941. LDX <Temp_Var11 ; Restore 'X' 
04942. RTS ; Return 
04943.  
04944. Card_MFSToInventory: .byte $01, $02, $09 ; Mushroom, Flower, Star card inventory item translation 
04945.  
04946. Card_MatchPairReward: 
04947. LDY Card_Index ; Y = Card_Index 
04948.  
04949. LDA Card_ActiveSet,Y ; Get the second card 
04950. AND #$0f ; Mainly to mask the bit 7 "flipped" marker 
04951. STA <Temp_Var13 ; -> Temp_Var13 
04952.  
04953. CMP #CARD_1UP 
04954. BNE PRG022_DD4A ; If the match was not a 1-up card, jump to PRG022_DD4A 
04955.  
04956. LDX Player_Current ; X = Player_Current 
04957.  
04958. INC Player_Lives,X ; Give Player extra life 
04959.  
04960. ; Play 1-up sound 
04961. LDA #SND_LEVEL1UP 
04962. STA Sound_QLevel1 
04963.  
04964. BNE PRG022_DD77 ; Jump (technically always) to PRG022_DD77 (RTS) 
04965.  
04966. PRG022_DD4A: 
04967. CMP #CARD_10COIN 
04968. BLT PRG022_DD65 ; If this is not one of the coin cards, jump to PRG022_DD65 
04969.  
04970. ; A coin card 
04971.  
04972. LDY #10 ; Y = 10 (10 coins) 
04973.  
04974. CMP #CARD_10COIN 
04975. BEQ PRG022_DD56 ; If this is the 10 coin card, jump to PRG022_DD56 
04976.  
04977. LDY #20 ; Y = 20 (20 coins) 
04978.  
04979. PRG022_DD56: 
04980. TYA 
04981. ADD Card_CoinsToGive 
04982. STA Card_CoinsToGive ; Set coins to give 
04983.  
04984. ; Play coin sound 
04985. LDA #SND_LEVELCOIN 
04986. STA Sound_QLevel1 
04987.  
04988. BNE PRG022_DD77 ; Jump (technically always) to PRG022_DD77 (RTS) 
04989.  
04990. PRG022_DD65: 
04991. LDA <Temp_Var13 
04992. CMP #CARD_1UP 
04993. BGE PRG022_DD77 ; If this is the 1-up, 10, or 20 coin card, jump to PRG022_DD77 (RTS) 
04994.  
04995. TAX ; Mushroom, Flower, Star index -> 'X' 
04996.  
04997. LDA Card_MFSToInventory,X ; Get the appropriate inventory item for this card pair 
04998. JSR Player_GetItem ; Give it to Player 
04999.  
05000. ; Play card match sound 
05001. LDA #SND_MAPBONUSAPPEAR 
05002. STA Sound_QMap 
05003.  
05004. PRG022_DD77: 
05005. RTS ; Return 
05006.  
05007. ; Base card before the face is added 
05008. CardBase_BufCmds: 
05009. vaddr $0000 ; Will be patched 
05010. .byte $04, $64, $FE, $FE, $65 
05011.  
05012. vaddr $0000 ; Will be patched 
05013. .byte $04, $64, $00, $00, $65 
05014.  
05015. vaddr $0000 ; Will be patched 
05016. .byte $04, $64, $00, $00, $65 
05017.  
05018. vaddr $0000 ; Will be patched 
05019. .byte $04, $64, $FE, $FE, $65 
05020. CardBase_BufCmds_End 
05021.  
05022. ; Blacks out a card 
05023. CardBlackout_BufCmds 
05024. vaddr $0000 ; Will be patched 
05025. .byte $04, $FF, $FF, $FF, $FF 
05026.  
05027. vaddr $0000 ; Will be patched 
05028. .byte $04, $FF, $FF, $FF, $FF 
05029.  
05030. vaddr $0000 ; Will be patched 
05031. .byte $04, $FF, $FF, $FF, $FF 
05032.  
05033. vaddr $0000 ; Will be patched 
05034. .byte $04, $FF, $FF, $FF, $FF 
05035.  
05036. ; Terminator 
05037. .byte $00 
05038. CardBlackout_BufCmds_End 
05039.  
05040. ; NSpade Card unflipped backside 
05041. CardBack_BufCmds: 
05042. vaddr $0000 ; Will be patched 
05043. .byte $04, $66, $FD, $FD, $67 
05044.  
05045. vaddr $0000 ; Will be patched 
05046. .byte $04, $66, $2E, $2F, $67 
05047.  
05048. vaddr $0000 ; Will be patched 
05049. .byte $04, $66, $3E, $3F, $67 
05050.  
05051. vaddr $0000 ; Will be patched 
05052. .byte $04, $66, $FD, $FD, $67 
05053. CardBack_BufCmds_End 
05054.  
05055. ; NSpade Game's Candystripe background 
05056. Video_NSpadeBG: 
05057. vaddr $2000 
05058. .byte VU_REPEAT | $22, $98 
05059.  
05060. vaddr $2020 
05061. .byte VU_REPEAT | $22, $98 
05062.  
05063. vaddr $2040 
05064. .byte VU_REPEAT | VU_VERT | $14, $98 
05065.  
05066. vaddr $2041 
05067. .byte VU_REPEAT | VU_VERT | $14, $98 
05068.  
05069. vaddr $205E 
05070. .byte VU_REPEAT | VU_VERT | $14, $98 
05071.  
05072. vaddr $205F 
05073. .byte VU_REPEAT | VU_VERT | $14, $98 
05074.  
05075. vaddr $23C0 
05076. .byte $10, $3F, $0F, $0F, $0F, $0F, $0F, $0F, $CF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF 
05077.  
05078. vaddr $23D0 
05079. .byte $10, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF 
05080.  
05081. vaddr $23E0 
05082. .byte $10, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F 
05083.  
05084. ; Terminator 
05085. .byte $00 
05086.  
05087. ; Rest of ROM bank was empty 
05088.  
05089.