ThomasSpeedrunner

Untitled

Aug 16th, 2013
776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; Subroutine to change what you're selecting in the level select
  3. ; ---------------------------------------------------------------------------
  4.  
  5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  6.  
  7.  
  8. LevSelControls:                 ; XREF: LevelSelect
  9.         move.b  (v_jpadpress1).w,d1
  10.         andi.b  #btnUp+btnDn,d1     ; is up/down pressed and held?
  11.         bne.s   LevSel_UpDown       ; if yes, branch
  12.         subq.w  #1,(v_levseldelay).w    ; subtract 1 from time to next move
  13.         bpl.w   LevSel_ChkSndTest   ; if time remains, branch
  14.  
  15. LevSel_UpDown:
  16.         move.w  #$B,(v_levseldelay).w   ; reset time delay
  17.         move.b  (v_jpadhold1).w,d1
  18.         andi.b  #btnUp+btnDn,d1     ; is up/down pressed?
  19.         beq.w   LevSel_ChkSndTest   ; if not, branch
  20.         move.w  (v_levselitem).w,d0
  21.         btst    #bitUp,d1       ; is up pressed?
  22.         beq.s   LevSel_Down     ; if not, branch
  23.         subq.w  #1,d0           ; move up 1 selection
  24.         bhs.s   LevSel_Down
  25.         moveq   #$15,d0         ; if selection moves below 0, jump to selection $15
  26.  
  27. LevSel_Down:
  28.         btst    #bitDn,d1       ; is down pressed?
  29.         beq.s   LevSel_Refresh      ; if not, branch
  30.         addq.w  #1,d0           ; move down 1 selection
  31.         cmpi.w  #$16,d0
  32.         blo.s   LevSel_Refresh
  33.         moveq   #0,d0           ; if selection moves above $15, jump to selection 0
  34.  
  35. LevSel_Refresh:
  36.         move.w  d0,(v_levselitem).w ; set new selection
  37.         bsr.w   LevSelTextLoad  ; refresh text
  38.         rts
  39. ; ===========================================================================
  40.  
  41. LevSel_ChkSndTest:              ; XREF: LevSelControls
  42.         cmpi.w  #$14,(v_levselitem).w   ; is item $14 selected?
  43.         bne.s   LevSel_ChkGimmickChoice ; if not, branch
  44.         move.b  (v_jpadpress1).w,d1
  45.         andi.b  #btnR+btnL,d1       ; is left/right pressed?
  46.         beq.s   LevSel_NoMove       ; if not, branch
  47.         move.w  (v_levselsound).w,d0
  48.         btst    #bitL,d1        ; is left pressed?
  49.         beq.s   LevSel_Right        ; if not, branch
  50.         subq.w  #1,d0           ; subtract 1 from sound test
  51.         bhs.s   LevSel_Right
  52.         moveq   #$4F,d0         ; if sound test moves below 0, set to $4F
  53.  
  54. LevSel_Right:
  55.         btst    #bitR,d1        ; is right pressed?
  56.         beq.s   LevSel_Refresh2     ; if not, branch
  57.         addq.w  #1,d0           ; add 1 to sound test
  58.         cmpi.w  #$4F,d0
  59.         blo.s   LevSel_Refresh2
  60.         moveq   #0,d0           ; if sound test moves above $4F, set to 0
  61.  
  62. LevSel_Refresh2:
  63.         move.w  d0,(v_levselsound).w    ; set sound test number
  64.         bsr.w   LevSelTextLoad      ; refresh text
  65.  
  66. LevSel_NoMove:
  67.         rts
  68. ; ===========================================================================
  69.  
  70. LevSel_ChkGimmickChoice:            ; XREF: LevSelControls
  71.         cmpi.w  #$15,(v_levselitem).w   ; is item $15 selected?
  72.         bne.s   LevSel_NoMove_Gim   ; if not, branch
  73.         move.b  (v_jpadpress1).w,d1
  74.         andi.b  #btnR+btnL,d1       ; is left/right pressed?
  75.         beq.s   LevSel_NoMove_Gim   ; if not, branch
  76.         move.w  (v_gimmickchoice).w,d0
  77.         btst    #bitL,d1        ; is left pressed?
  78.         beq.s   LevSel_Right_Gim    ; if not, branch
  79.         subq.w  #1,d0           ; subtract 1 from gimmick choice
  80.         bhs.s   LevSel_Right_Gim
  81.         moveq   #$10,d0         ; if gimmick choice moves below 0, set to $4F
  82.  
  83. LevSel_Right_Gim:
  84.         btst    #bitR,d1        ; is right pressed?
  85.         beq.s   LevSel_Refresh2_Gim ; if not, branch
  86.         addq.w  #1,d0           ; add 1 to gimmick choice
  87.         cmpi.w  #$10,d0
  88.         blo.s   LevSel_Refresh2_Gim
  89.         moveq   #0,d0           ; if gimmick choice moves above $10, set to 0
  90.  
  91. LevSel_Refresh2_Gim:
  92.         move.w  d0,(v_gimmickchoice).w  ; set gimmick choice number
  93.         bsr.w   LevSelTextLoad      ; refresh text
  94.  
  95. LevSel_NoMove_Gim:
  96.         rts
  97. ; End of function LevSelControls
  98.  
  99. ; ---------------------------------------------------------------------------
  100. ; Subroutine to load level select text
  101. ; ---------------------------------------------------------------------------
  102.  
  103. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  104.  
  105.  
  106. LevSelTextLoad:             ; XREF: GM_Title
  107.  
  108.     textpos:    = ($40000000+(($E210&$3FFF)<<16)+(($E210&$C000)>>14))
  109.                     ; $E210 is a VRAM address
  110.  
  111.         lea (LevelMenuText).l,a1
  112.         lea (vdp_data_port).l,a6
  113.         move.l  #textpos,d4 ; text position on screen
  114.         move.w  #$E680,d3   ; VRAM setting (4th palette, $680th tile)
  115.         moveq   #$15,d1     ; number of lines of text
  116.  
  117.     LevSel_DrawAll:
  118.         move.l  d4,4(a6)
  119.         bsr.w   LevSel_ChgLine  ; draw line of text
  120.         addi.l  #$800000,d4 ; jump to next line
  121.         dbf d1,LevSel_DrawAll
  122.  
  123.         moveq   #0,d0
  124.         move.w  (v_levselitem).w,d0
  125.         move.w  d0,d1
  126.         move.l  #textpos,d4
  127.         lsl.w   #7,d0
  128.         swap    d0
  129.         add.l   d0,d4
  130.         lea (LevelMenuText).l,a1
  131.         lsl.w   #3,d1
  132.         move.w  d1,d0
  133.         add.w   d1,d1
  134.         add.w   d0,d1
  135.         adda.w  d1,a1
  136.         move.w  #$C680,d3   ; VRAM setting (3rd palette, $680th tile)
  137.         move.l  d4,4(a6)
  138.         bsr.w   LevSel_ChgLine  ; recolour selected line
  139.         move.w  #$E680,d3
  140.         cmpi.w  #$15,(v_levselitem).w
  141.         beq.w   LevSel_ChkSndTest2
  142.         bsr.w   LevSel_DrawGim
  143.  
  144. LevSel_ChkSndTest2:
  145.         cmpi.w  #$14,(v_levselitem).w
  146.         bne.s   LevSel_DrawSnd
  147.         move.w  #$C680,d3
  148.  
  149. LevSel_DrawSnd:
  150.         locVRAM $EC30       ; sound test position on screen
  151.         move.w  (v_levselsound).w,d0
  152.         addi.w  #$80,d0
  153.         move.b  d0,d2
  154.         lsr.b   #4,d0
  155.         bsr.w   LevSel_ChgSnd   ; draw 1st digit
  156.         move.b  d2,d0
  157.         bsr.w   LevSel_ChgSnd   ; draw 2nd digit
  158.         rts
  159.  
  160. LevSel_DrawGim:
  161.         locVRAM $ECB0       ; gimmick option position on screen
  162.         move.w  (v_gimmickchoice).w,d0
  163.         move.b  d0,d2
  164.         lsr.b   #4,d0
  165.         bsr.w   LevSel_ChgSnd   ; draw 1st digit
  166.         move.b  d2,d0
  167.         bsr.w   LevSel_ChgSnd   ; draw 2nd digit
  168.         rts
  169. ; End of function LevSelTextLoad
  170.  
  171.  
  172. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  173.  
  174.  
  175. LevSel_ChgSnd:              ; XREF: LevSelTextLoad
  176.         andi.w  #$F,d0
  177.         cmpi.b  #$A,d0      ; is digit $A-$F?
  178.         blo.s   LevSel_Numb_Snd ; if not, branch
  179.         addi.b  #4,d0       ; use alpha characters
  180.  
  181.     LevSel_Numb_Snd:
  182.         add.w   d3,d0
  183.         move.w  d0,(a6)
  184.         rts
  185. ; End of function LevSel_ChgSnd
  186.  
  187.  
  188. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
  189.  
  190.  
  191. LevSel_ChgLine:             ; XREF: LevSelTextLoad
  192.         moveq   #$17,d2     ; number of characters per line
  193.  
  194.     LevSel_LineLoop:
  195.         moveq   #0,d0
  196.         move.b  (a1)+,d0    ; get character
  197.         bpl.s   LevSel_CharOk   ; branch if valid
  198.         move.w  #0,(a6)     ; use blank character
  199.         dbf d2,LevSel_LineLoop
  200.         rts
  201.  
  202.  
  203.     LevSel_CharOk:
  204.         cmp.w   #$40,d0     ; Check for $40 (End of ASCII number area)
  205.         blt.s   @notText    ; If this is not an ASCII text character, branch
  206.         sub.w   #$3,d0      ; Subtract an extra 3 (Compensate for missing characters in the font)
  207.     @notText:
  208.         sub.w   #$30,d0     ; Subtract #$33 (Convert to S2 font from ASCII)
  209.         add.w   d3,d0       ; combine char with VRAM setting
  210.         move.w  d0,(a6)     ; send to VRAM
  211.         dbf d2,LevSel_LineLoop
  212.         rts
  213. ; End of function LevSel_ChgLine
  214.  
  215. ; ===========================================================================
  216. ; ---------------------------------------------------------------------------
  217. ; Level select menu text
  218. ; ---------------------------------------------------------------------------
  219. LevelMenuText:   if Revision=0
  220.         dc.b    "GREEN HILL ZONE  STAGE 1"
  221.         dc.b    "                 STAGE 2"
  222.         dc.b    "                 STAGE 3"
  223.         dc.b    "LABYRINTH        STAGE 1"
  224.         dc.b    "                 STAGE 2"
  225.         dc.b    "                 STAGE 3"
  226.         dc.b    "MARBLE ZONE      STAGE 1"
  227.         dc.b    "                 STAGE 2"
  228.         dc.b    "                 STAGE 3"
  229.         dc.b    "STAR LIGHT ZONE  STAGE 1"
  230.         dc.b    "                 STAGE 2"
  231.         dc.b    "                 STAGE 3"
  232.         dc.b    "SPRING YARD ZONE STAGE 1"
  233.         dc.b    "                 STAGE 2"
  234.         dc.b    "                 STAGE 3"
  235.         dc.b    "SCRAP BRAIN ZONE STAGE 1"
  236.         dc.b    "                 STAGE 2"
  237.         dc.b    "                 STAGE 3"
  238.         dc.b    "FINAL ZONE              "
  239.         dc.b    "SPECIAL STAGE           "
  240.         dc.b    "SOUND TEST              "
  241.         dc.b    "GIM CHOICE              "
  242.         even
  243.         else
  244.         dc.b    "GREEN HILL ZONE  STAGE 1"
  245.         dc.b    "                 STAGE 2"
  246.         dc.b    "                 STAGE 3"
  247.         dc.b    "MARBLE ZONE      STAGE 1"
  248.         dc.b    "                 STAGE 2"
  249.         dc.b    "                 STAGE 3"
  250.         dc.b    "SPRING YARD ZONE STAGE 1"
  251.         dc.b    "                 STAGE 2"
  252.         dc.b    "                 STAGE 3"
  253.         dc.b    "LABYRINTH        STAGE 1"
  254.         dc.b    "                 STAGE 2"
  255.         dc.b    "                 STAGE 3"
  256.         dc.b    "STAR LIGHT ZONE  STAGE 1"
  257.         dc.b    "                 STAGE 2"
  258.         dc.b    "                 STAGE 3"
  259.         dc.b    "SCRAP BRAIN ZONE STAGE 1"
  260.         dc.b    "                 STAGE 2"
  261.         dc.b    "                 STAGE 3"
  262.         dc.b    "FINAL ZONE              "
  263.         dc.b    "SPECIAL STAGE           "
  264.         dc.b    "SOUND TEST              "
  265.         dc.b    "CHOSEN GIMMICK          "
  266.         endc
Advertisement