Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------------------------------------------------------
- ; Sega screen
- ; ---------------------------------------------------------------------------
- SegaScreen: ; XREF: GameModeArray
- move.b #$E4,d0 ; Load stop music ID into d0.
- bsr.w PlaySound_Special ; Stop music.
- bsr.w ClearPLC ; Clear PLC address queue.
- bsr.w Pal_FadeFrom ; Fade the palettes.
- lea ($C00004).l,a6 ; Load VDP data port into a6.
- move.w #$8004,(a6) ; Disable HBlank.
- move.w #$8230,(a6) ; Set Plane A nametable location - $C000.
- move.w #$8407,(a6) ; Set Plane B nametable location - $E000.
- move.w #$8700,(a6) ; Set background colour - Palette line 0, entry 0.
- move.w #$8B00,(a6) ; Set scrolling data to scroll by screen.
- clr.b ($FFFFF64E).w ; Clear water level.
- move #$2700,sr ; Disable interrupts.
- move.w ($FFFFF60C).w,d0 ; Move VDP register 1 value into d0.
- andi.b #$BF,d0 ; Disable display bit.
- move.w d0,($C00004).l ; Turn off the display.
- bsr.w ClearScreen ; Clear plane mappings.
- move.l #$40000000,($C00004).l ; Set VDP to VRAM write, $0000.
- lea SegaStarsArt(pc),a0 ; Load Sega screen BG stars.
- move.w #(SegaStarsArt_End-SegaStarsArt)/4-1,d0 ; Load data length to repeat by.
- @loop:
- move.l (a0)+,-4(a6) ; Load first 8 pixels into VRAM.
- dbf d0,@loop ; Repeat until fully loaded.
- move.l #$60000000,($C00004).l ; Set the VDP to VRAM write, $2000.
- lea SegaLetterArt(pc),a0 ; Load the Sega screen flying letters.
- move.w #(SegaLetterArt_End-SegaLetterArt)/4-1,d0 ; Load data length to repeat by.
- @hoop:
- move.l (a0)+,-4(a6) ; Load first 8 pixels into VRAM.
- dbf d0,@hoop ; Repeat until fully loaded.
- lea SegaScreenMaps(pc),a1 ; Load plane mappings source into a0.
- moveq #0,d5 ; Load plane mappings art tile increment value into d5.
- move.l #$60000003,d0 ; Set to write to Plane B.
- moveq #$3F,d1 ; Draw 512 pixels horizontally...
- moveq #$1F,d2 ; ...And draw 256 pixels vertically.
- bsr.w ShowVDPGraphics ; Draw onto the screen.
- moveq #0,d0 ; Load Sega screen palette ID.
- bsr.w PalLoad1 ; Load Sega screen palette into the palette buffer.
- move.b #2,($FFFFD000).w ; Set to load the flying 'SEGA' letters.
- move.w ($FFFFF60C).w,d0 ; Load VDP register 1 value into d0.
- ori.b #$40,d0 ; Enable display bit.
- move.w d0,($C00004).l ; Turn on the display.
- ; move.b #$E1,d0
- ; bsr.w PlaySound_Special ; play "SEGA" sound
- bsr.w Pal_FadeTo ; Fade in the palettes.
- moveq #0,d0 ; Clear any garbage data.
- moveq #0,d1 ; ''
- moveq #0,d3 ; ''
- SetSpeed:
- move.l #$60,d2 ; Set timer for the speed increase.
- lea HScrollSpeeds(pc,d1.w),a0; Get correct HScroll speed.
- RepeatScroll:
- move.w (a0),d5 ; Copy value to d5.
- cmpi.b #4,d5 ; Is the scroll value any lower than 4?
- bcs.s SkipObjLoad ; If it is, don't load the object.
- move.w SEGAAnimTable(pc,d1.w),d5; Get the animation value to run.
- move.b d5,($FFFFD01C).w ; Copy it to d5.
- movem.l d0-a6,-(sp) ; Store register values to the stack.
- jsr ObjectsLoad ; Run object's code for one frame.
- jsr BuildSprites ; Convert the mappings into sprites.
- movem.l (sp)+,d0-a6 ; Restore register values.
- SkipObjLoad:
- move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
- andi.w #$80,d4 ; Is start being pressed?
- bne.w SkipGameMode ; If it is, skip to the title screen.
- move.l #$7C000003,($C00004).l ; Set to write to the HScroll VRAM nametable.
- add.w (a0),d0 ; Add the speed to d0.
- move.l d0,($C00000).l ; Write to plane B.
- move.w (a0),d3 ; If the scroll value is set to 0...
- beq.s StopScrolling ; ...Stop Scrolling.
- move.b #2,($FFFFF62A).w ; Set to load VBlank routine 2.
- bsr.w DelayProgram ; Set to scroll every frame.
- subq.b #1,d2 ; Subtract from the timer (frames).
- bne.s RepeatScroll ; If it isn't equal, continue scrolling the plane.
- addq.b #2,d1 ; Load next speed.
- bra.s SetSpeed ; Load a new speed, refresh the counter.
- ; ----------------------------------------------------------------------
- HScrollSpeeds:
- dc.w $01 ; $00
- dc.w $02 ; $01
- dc.w $04 ; $02
- dc.w $08 ; $03
- dc.w $10 ; $04
- dc.w $00 ; $05
- ; ----------------------------------------------------------------------
- SEGAAnimTable:
- dc.w $00 ; Invalid.
- dc.w $00 ; Invalid.
- dc.w $00 ; HScroll - $04
- dc.w $01 ; HScroll - $08
- dc.w $02 ; HScroll - $10
- dc.w $03 ; HScroll - $00
- ; ----------------------------------------------------------------------
- StopScrolling:
- move.w #$80,($FFFFF614).w ; Set timer to count down on this screen.
- bsr.w Pal_MakeFlash ; Make a white flash.
- moveq #0,d0 ; Load Sega screen palette ID.
- bsr.w PalLoad1 ; Load Sega screen palette into the palette buffer.
- bsr.w Pal_FadeTo ; Fade in the palettes.
- WaitforTimer:
- move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
- andi.w #$80,d4 ; Is start being pressed?
- bne.w SkipGameMode ; If it is, skip to the title screen.
- move.b #2,($FFFFF62A).w ; Load the VBlank routine to run.
- bsr.w DelayProgram ; Wait for $100 frames.
- tst.w ($FFFFF614).w ; Is there any time left on the frame timer?
- beq.s FadePalLine1 ; If there is, fade the first palette line and then the rest.
- bra.s WaitforTimer ; Otherwise, wait for the timer.
- FadePalLine1:
- bsr.w Pal_FadeLine1 ; Fade the first palette line.
- move.w #$80,($FFFFF614).w ; Set timer to count down on this screen.
- WaitforTimer2:
- move.b ($FFFFF604).w,d4 ; Load the button press values into d0.
- andi.w #$80,d4 ; Is start being pressed?
- bne.w SkipGameMode ; If it is, skip to the title screen.
- move.b #2,($FFFFF62A).w ; Load the VBlank routine to run.
- bsr.w DelayProgram ; Wait for $100 frames.
- tst.w ($FFFFF614).w ; Is there any time left on the frame timer?
- beq.s SkipGameMode ; If there is, fade the first palette line and then the rest.
- bra.s WaitforTimer2 ; Otherwise, wait for the timer.
- SkipGameMode:
- move.b #4,($FFFFF600).w ; Set the gamemode to load the title screen.
- rts
- ; ======================================================================
- Pal_FadeLine1:
- moveq #6,d5 ; Repeat for the possible combinations of colours available, -1.
- Pal_FadeLineRepeat:
- lea ($FFFFFB00).w,a0 ; Load the palette buffer into a0
- bsr.w Pal_FadeoutColours ; Fade out red.
- move.b #2,($FFFFF62A).w ; Set to update CRAM.
- bsr.w DelayProgram ; Update it.
- dbf d5,Pal_FadeLineRepeat ; Repeat until everything is faded.
- rts ; Return.
- ; ----------------------------------------------------------------------
- Pal_FadeoutColours:
- moveq #$F,d0 ; Fade the whole palette line by one unit.
- RepeatFade:
- move.w (a0),d1 ; Load palette into register for fading (Red).
- move.w (a0),d2 ; Load palette into register for fading (Green).
- move.w (a0)+,d3 ; Load palette into register for fading (Blue).
- andi.w #$000E,d1 ; Get red first.
- beq.s FadeGreen ; If there's nothing to fade, move onto green.
- subi.w #2,d1 ; Fade out a unit of intensity from it.
- FadeGreen:
- andi.w #$00E0,d2 ; Get green next.
- beq.s FadeBlue ; If there's nothing to fade, move onto blue.
- subi.w #$0020,d2 ; Fade out a unit of intensity from it.
- FadeBlue:
- andi.w #$0E00,d3 ; Get blue.
- beq.s SetFading ; If there's nothing to fade, update the palette buffer.
- subi.w #$0200,d3 ; Fade out a unit of intensity from it.
- SetFading:
- or.w d3,d2 ; Combine bits for blue and green.
- or.w d2,d1 ; Combine bits for blue, green and red; get the faded palette.
- move.w d1,-2(a0) ; Update faded palette.
- dbf d0,RepeatFade ; Repeat for the rest of the palette line.
- rts ; Return.
- ; ======================================================================
- SegaStarsArt:
- incbin "SegaStarsArt.bin"
- SegaStarsArt_End:
- SegaScreenMaps:
- incbin "SegaScreenMaps.bin"
- SegaLetterArt:
- incbin "SegaLetterArt.bin"
- SegaLetterArt_End:
Advertisement
Add Comment
Please, Sign In to add comment