Dandaman955

Example Code

Nov 3rd, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.76 KB | None | 0 0
  1. ; ---------------------------------------------------------------------------
  2. ; Sega screen
  3. ; ---------------------------------------------------------------------------
  4.  
  5. SegaScreen: ; XREF: GameModeArray
  6. move.b #$E4,d0 ; Load stop music ID into d0.
  7. bsr.w PlaySound_Special ; Stop music.
  8. bsr.w ClearPLC ; Clear PLC address queue.
  9. bsr.w Pal_FadeFrom ; Fade the palettes.
  10. lea ($C00004).l,a6 ; Load VDP data port into a6.
  11. move.w #$8004,(a6) ; Disable HBlank.
  12. move.w #$8230,(a6) ; Set Plane A nametable location - $C000.
  13. move.w #$8407,(a6) ; Set Plane B nametable location - $E000.
  14. move.w #$8700,(a6) ; Set background colour - Palette line 0, entry 0.
  15. move.w #$8B00,(a6) ; Set scrolling data to scroll by screen.
  16. clr.b ($FFFFF64E).w ; Clear water level.
  17. move #$2700,sr ; Disable interrupts.
  18. move.w ($FFFFF60C).w,d0 ; Move VDP register 1 value into d0.
  19. andi.b #$BF,d0 ; Disable display bit.
  20. move.w d0,($C00004).l ; Turn off the display.
  21. bsr.w ClearScreen ; Clear plane mappings.
  22. move.l #$40000000,($C00004).l ; Set VDP to VRAM write, $0000.
  23. lea SegaStarsArt(pc),a0 ; Load Sega screen BG stars.
  24. move.w #(SegaStarsArt_End-SegaStarsArt)/4-1,d0 ; Load data length to repeat by.
  25. @loop:
  26. move.l (a0)+,-4(a6) ; Load first 8 pixels into VRAM.
  27. dbf d0,@loop ; Repeat until fully loaded.
  28. move.l #$60000000,($C00004).l ; Set the VDP to VRAM write, $2000.
  29. lea SegaLetterArt(pc),a0 ; Load the Sega screen flying letters.
  30. move.w #(SegaLetterArt_End-SegaLetterArt)/4-1,d0 ; Load data length to repeat by.
  31. @hoop:
  32. move.l (a0)+,-4(a6) ; Load first 8 pixels into VRAM.
  33. dbf d0,@hoop ; Repeat until fully loaded.
  34. lea SegaScreenMaps(pc),a1 ; Load plane mappings source into a0.
  35. moveq #0,d5 ; Load plane mappings art tile increment value into d5.
  36. move.l #$60000003,d0 ; Set to write to Plane B.
  37. moveq #$3F,d1 ; Draw 512 pixels horizontally...
  38. moveq #$1F,d2 ; ...And draw 256 pixels vertically.
  39. bsr.w ShowVDPGraphics ; Draw onto the screen.
  40. moveq #0,d0 ; Load Sega screen palette ID.
  41. bsr.w PalLoad1 ; Load Sega screen palette into the palette buffer.
  42. move.b #2,($FFFFD000).w ; Set to load the flying 'SEGA' letters.
  43. move.w ($FFFFF60C).w,d0 ; Load VDP register 1 value into d0.
  44. ori.b #$40,d0 ; Enable display bit.
  45. move.w d0,($C00004).l ; Turn on the display.
  46. ; move.b #$E1,d0
  47. ; bsr.w PlaySound_Special ; play "SEGA" sound
  48. bsr.w Pal_FadeTo ; Fade in the palettes.
  49. moveq #0,d0 ; Clear any garbage data.
  50. moveq #0,d1 ; ''
  51. moveq #0,d3 ; ''
  52. SetSpeed:
  53. move.l #$60,d2 ; Set timer for the speed increase.
  54. lea HScrollSpeeds(pc,d1.w),a0; Get correct HScroll speed.
  55. RepeatScroll:
  56. move.w (a0),d5 ; Copy value to d5.
  57. cmpi.b #4,d5 ; Is the scroll value any lower than 4?
  58. bcs.s SkipObjLoad ; If it is, don't load the object.
  59. move.w SEGAAnimTable(pc,d1.w),d5; Get the animation value to run.
  60. move.b d5,($FFFFD01C).w ; Copy it to d5.
  61. movem.l d0-a6,-(sp) ; Store register values to the stack.
  62. jsr ObjectsLoad ; Run object's code for one frame.
  63. jsr BuildSprites ; Convert the mappings into sprites.
  64. movem.l (sp)+,d0-a6 ; Restore register values.
  65. SkipObjLoad:
  66. move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
  67. andi.w #$80,d4 ; Is start being pressed?
  68. bne.w SkipGameMode ; If it is, skip to the title screen.
  69. move.l #$7C000003,($C00004).l ; Set to write to the HScroll VRAM nametable.
  70. add.w (a0),d0 ; Add the speed to d0.
  71. move.l d0,($C00000).l ; Write to plane B.
  72. move.w (a0),d3 ; If the scroll value is set to 0...
  73. beq.s StopScrolling ; ...Stop Scrolling.
  74. move.b #2,($FFFFF62A).w ; Set to load VBlank routine 2.
  75. bsr.w DelayProgram ; Set to scroll every frame.
  76. subq.b #1,d2 ; Subtract from the timer (frames).
  77. bne.s RepeatScroll ; If it isn't equal, continue scrolling the plane.
  78. addq.b #2,d1 ; Load next speed.
  79. bra.s SetSpeed ; Load a new speed, refresh the counter.
  80.  
  81.  
  82. ; ----------------------------------------------------------------------
  83. HScrollSpeeds:
  84. dc.w $01 ; $00
  85. dc.w $02 ; $01
  86. dc.w $04 ; $02
  87. dc.w $08 ; $03
  88. dc.w $10 ; $04
  89. dc.w $00 ; $05
  90.  
  91. ; ----------------------------------------------------------------------
  92. SEGAAnimTable:
  93. dc.w $00 ; Invalid.
  94. dc.w $00 ; Invalid.
  95. dc.w $00 ; HScroll - $04
  96. dc.w $01 ; HScroll - $08
  97. dc.w $02 ; HScroll - $10
  98. dc.w $03 ; HScroll - $00
  99. ; ----------------------------------------------------------------------
  100.  
  101.  
  102. StopScrolling:
  103. move.w #$80,($FFFFF614).w ; Set timer to count down on this screen.
  104. bsr.w Pal_MakeFlash ; Make a white flash.
  105. moveq #0,d0 ; Load Sega screen palette ID.
  106. bsr.w PalLoad1 ; Load Sega screen palette into the palette buffer.
  107. bsr.w Pal_FadeTo ; Fade in the palettes.
  108. WaitforTimer:
  109. move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
  110. andi.w #$80,d4 ; Is start being pressed?
  111. bne.w SkipGameMode ; If it is, skip to the title screen.
  112. move.b #2,($FFFFF62A).w ; Load the VBlank routine to run.
  113. bsr.w DelayProgram ; Wait for $100 frames.
  114. tst.w ($FFFFF614).w ; Is there any time left on the frame timer?
  115. beq.s FadePalLine1 ; If there is, fade the first palette line and then the rest.
  116. bra.s WaitforTimer ; Otherwise, wait for the timer.
  117.  
  118. FadePalLine1:
  119. bsr.w Pal_FadeLine1 ; Fade the first palette line.
  120. move.w #$80,($FFFFF614).w ; Set timer to count down on this screen.
  121. WaitforTimer2:
  122. move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
  123. andi.w #$80,d4 ; Is start being pressed?
  124. bne.w SkipGameMode ; If it is, skip to the title screen.
  125. move.b #2,($FFFFF62A).w ; Load the VBlank routine to run.
  126. bsr.w DelayProgram ; Wait for $100 frames.
  127. tst.w ($FFFFF614).w ; Is there any time left on the frame timer?
  128. beq.s SkipGameMode ; If there is, fade the first palette line and then the rest.
  129. bra.s WaitforTimer2 ; Otherwise, wait for the timer.
  130.  
  131.  
  132. SkipGameMode:
  133. move.b #4,($FFFFF600).w ; Set the gamemode to load the title screen.
  134. rts
  135.  
  136. ; ======================================================================
  137.  
  138. Pal_FadeLine1:
  139. moveq #6,d5 ; Repeat for the possible combinations of colours available, -1.
  140. Pal_FadeLineRepeat:
  141. lea ($FFFFFB00).w,a0 ; Load the palette buffer into a0
  142. bsr.w Pal_FadeoutColours ; Fade out red.
  143. move.b #2,($FFFFF62A).w ; Set to update CRAM.
  144. bsr.w DelayProgram ; Update it.
  145. dbf d5,Pal_FadeLineRepeat ; Repeat until everything is faded.
  146. rts ; Return.
  147. ; ----------------------------------------------------------------------
  148. Pal_FadeoutColours:
  149. moveq #$F,d0 ; Fade the whole palette line by one unit.
  150. RepeatFade:
  151. move.w (a0),d1 ; Load palette into register for fading (Red).
  152. move.w (a0),d2 ; Load palette into register for fading (Green).
  153. move.w (a0)+,d3 ; Load palette into register for fading (Blue).
  154. andi.w #$000E,d1 ; Get red first.
  155. beq.s FadeGreen ; If there's nothing to fade, move onto green.
  156. subi.w #2,d1 ; Fade out a unit of intensity from it.
  157. FadeGreen:
  158. andi.w #$00E0,d2 ; Get green next.
  159. beq.s FadeBlue ; If there's nothing to fade, move onto blue.
  160. subi.w #$0020,d2 ; Fade out a unit of intensity from it.
  161. FadeBlue:
  162. andi.w #$0E00,d3 ; Get blue.
  163. beq.s SetFading ; If there's nothing to fade, update the palette buffer.
  164. subi.w #$0200,d3 ; Fade out a unit of intensity from it.
  165. SetFading:
  166. or.w d3,d2 ; Combine bits for blue and green.
  167. or.w d2,d1 ; Combine bits for blue, green and red; get the faded palette.
  168. move.w d1,-2(a0) ; Update faded palette.
  169. dbf d0,RepeatFade ; Repeat for the rest of the palette line.
  170. rts ; Return.
  171. ; ======================================================================
  172.  
  173.  
  174. SegaStarsArt:
  175. incbin "SegaStarsArt.bin"
  176. SegaStarsArt_End:
  177.  
  178. SegaScreenMaps:
  179. incbin "SegaScreenMaps.bin"
  180.  
  181. SegaLetterArt:
  182. incbin "SegaLetterArt.bin"
  183. SegaLetterArt_End:
Advertisement
Add Comment
Please, Sign In to add comment