This code is run to display the points won when jumping onto an enemy, hitting a coinblock or grabbing a mushroom, etc.
There is a scetion where it checks if the current enemy falls within a certain range of tests and uses a different OAM offset, but I am uncertian what the purpose is. Otherwise, this is pretty easy to follow.
FloateyNum[ x ]::Control - the score to award (or a 1up)
FloateyNum[ x ]::X_Pos - the screen x pos
FloateyNum[ x ]::Y_Pos - the screen y pos
Note the FloateyNum is not initailized here, just processed, The Spawning code will be posted soon.
001 ; DATA
002 ; Sprite tile pairs:
003
004 FloateyNumTileData:
005
006 .byte $ff, $ff ; dummy
007 .byte $f6, $fb ; "100"
008 .byte $f7, $fb ; "200"
009 .byte $f8, $fb ; "400"
010 .byte $f9, $fb ; "500"
011 .byte $fa, $fb ; "800"
012 .byte $f6, $50 ; "1000"
013 .byte $f7, $50 ; "2000"
014 .byte $f8, $50 ; "4000"
015 .byte $f9, $50 ; "5000"
016 .byte $fa, $50 ; "8000"
017 .byte $fd, $fe ; "1-UP"
018
019 ScoreUpdateData:
020
021 ; high nybble is digit number ( 4 is 100, 3 is 1000), low nybble is number to
022 ; add to the digit of the player's score
023
024 .byte $ff ; dummy
025 .byte $41, $42, $44, $45, $48
026 .byte $31, $32, $34, $35, $38
027 .byte $00 ; 1 up
028
029 .code
030
031 ;----------------------------------------------------------------------------------------------
032
033 .proc FloateyNumbersRoutine
034
035 ; load control for floatey number, if zero, branch to leave
036 if lda FloateyNum[ x ]::Control == zero goto PlayerEndWorld::Exit
037
038 if a >= #$0b
039 mb FloateyNum[ x ]::Control := #$0b ; set to $0b, thus keeping it in range
040 endif
041
042 tay ; use as Y
043
044 if !FloateyNum_Timer[ x ] ; check value here
045 mb FloateyNum[ x ]::Control := a ; #0 ; initialize floatey number control and leave
046 rts
047 endif
048
049 dec FloateyNum_Timer,x ; decrement value here
050
051 ; if FloateyNum_Timer = 2b (before decrement)
052 if a = #$2b
053
054 ; if FloateyNum[ x ]::Control = #$0b
055 if y = #$0b ; check offset for $0b
056 inc NumberofLives ; give player one extra life (1-up)
057 mb Square2SoundQueue := #Sfx_ExtraLife ; and play the 1-up sound
058 endif
059
060 ; use as X offset, essentially the digit to be incremented
061 mb x := ScoreUpdateData[ y ] >> 4
062 ; mask out the high nybble, store as amount to add to the digit
063 mb DigitModifier[ x ] := ScoreUpdateData[ y ] & #%00001111
064
065 jsr AddToScore ; update the score accordingly
066
067 endif
068
069 ldy Enemy_SprDataOffset,x ; get OAM data offset for enemy object
070
071
072 ; This section of codes purpose is uncertain:
073 ; ------------------------------------------------
074 mb a := Enemy_ID[ x ]
075 ; if enemy is not spiny AND not Pplant AND ( is hammerbro OR
076 ; ( Not either cheepcheep AND ( greater or equal to tallenemy OR state less than #2)) )
077
078 if a <> #Spiny && a <> #PiranhaPlant && ( a = #HammerBro || \
079 ( a <> #GreyCheepCheep && a <> #RedCheepCheep && ( a >= #TallEnemy || Enemy_State[x] < #$02 ) ) )
080 ldx SprDataOffset_Ctrl ; load some kind of control bit
081 ldy Alt_SprDataOffset,x ; get alternate OAM data offset
082 ldx ObjectOffset ; get enemy object offset again
083 endif
084 ; ------------------------------------------------
085
086
087 if FloateyNum[ x ]::Y_Pos >= #$18 ; if coordinate is below the status bar:
088 ; carry is clear
089 mb FloateyNum[ x ]::Y_Pos := a -- #1 ; subtract one (move up one pixel) and store as new
090 endif
091
092 mb a := FloateyNum[ x ]::Y_Pos -- #8 ; subtract eight and dump into the
093 jsr DumpTwoSpr ; left and right sprite's Y coordinates
094
095 mb Sprite[ y ]::X_Position := FloateyNum[ x ]::X_Pos ; X coordinate of left sprite
096 mb Sprite[ y + 4 ]::X_Position := a + #8 ; X coordinate of right sprite
097
098 mb a := #$02
099 mb Sprite[ y ]::Attributes := a ; set palette control in attribute bytes
100 mb Sprite[ y + 4 ]::Attributes := a ; of left and right sprites
101
102 mb x := FloateyNum[ x ]::Control * 2 ; and use as offset for look-up table
103 mb Sprite[ y ]::Tilenumber := FloateyNumTileData[ x ] ; display first half of number of points
104 mb Sprite[ y + 4 ]::Tilenumber := FloateyNumTileData[ x + 1 ] ; display the second half
105
106 ldx ObjectOffset ; get enemy object offset and leave
107 rts
108
109 .endproc
No comments:
Post a Comment