Post by ZTarget on Mar 2, 2023 20:20:52 GMT
This is a mod that makes it so you look upward when you hold up. It also slightly changes the look down behavior. I made the behavior act similar to Sonic 2 where when you look up/down there is a delay and then it goes up/down at 2px per frame and when you let go it returns at 2px per frame (originally there is a delay and then kid looks down at 1px per frame and returns at 8px per frame). Also this mod only works when standing still, so now when kid is crawling he wont look down unless he is not moving.
Step 1
Is always to back up your project, make a complete copy and put it elsewhere. This is always good to do once in a while anyways. If you put a lot of work into it, throw a copy onto another hard drive too.
Step 2
Search to loc_724E: we are going to start by commenting out a chunk of code.
Select from loc_724E through loc_728C (that is to right above loc_72A8:) now in your text/code editor comment out the selection.
(In other words loc_724E, loc_7266, loc_726C, loc_727E, and loc_728C will be completely commented out.)
Now add this code after the commented out chunk of code (right above loc_72A8)
; start of look up and down mod----------------------------------------------
loc_724E:
add.w d2,(Camera_X_pos).w
; end of x camera, start of y camera
move.w $1E(a0),d0 ; kids location y
move.w d0,d7
subi.w #$98,d0 ; (default A0=160)$90=144 98=152 space from kid to top of screen main camera offset y
sub.w (Camera_Y_pos).w,d7 ; get current difference between kid and cam y pos
; not moving on ground checks ; we want lookup/dn to work on h and v platforms
tst.b (Ctrl_Right_Held).w
bne.s return_cam
tst.b (Ctrl_Left_Held).w
bne.s return_cam
cmpi.w #1,(Character_Movement).w
bgt.s return_cam
tst.b (KidGrabbedByHand).w
bne.s limit_cam
; look down
tst.b (Ctrl_Down_Held).w ; is down held?
beq.s + ; if not go to look up
cmpi.w #$28,d7 ; $28=40 about 32 px above bottom of kid
blt.s move_cam
addq.w #2,($FFFFFB58).w ; add 2 to cam timer/offset
bra.s move_cam
+; look up
tst.b (Ctrl_Up_Held).w ; is up held?
beq.s return_cam ; if not skip
cmpi.w #$D0,d7 ; where to stop moving up ;8 under kid D0=208
bgt.s move_cam
subq.w #2,($FFFFFB58).w
bra.s move_cam
return_cam:
tst.w ($FFFFFB58).w ; is cam timer/offset zero?
beq.s limit_cam ; if yes, branch
bgt.s +
addq.w #4,($FFFFFB58).w ; add 2 (4-2) move screen back to default -from up to center
+
subq.w #2,($FFFFFB58).w ; sub 2 move screen back to default -from down to center
move_cam: ; using cam timer/offset to move cam
move.w ($FFFFFB58).w,d7
move.w #$40,d4
tst.w d7
bpl.s +
neg.w d7
neg.w d4
+
cmpi.w #$40,d7 ; $40=64 32 frame delay ;frame to start moving cam at
blt.s limit_cam
add.w ($FFFFFB58).w,d0 ; cam mover
sub.w d4,d0 ; $40=64 ;since subing after 32 frame delay must add/sub 64
limit_cam: ; test for top and bottom of level
tst.w d0 ; is top of camera at zero? (top of map)
bgt.s + ; if greater than branch to bottom check
moveq #0,d0 ; else set cam to 0 if less than or =
addi.w #2,($FFFFFB58).w ; negate cam timer/offset
bra.s loc_72A8 ; skip bottom of level check
+
move.w (Level_height_pixels).w,d1
subi.w #$E0,d1 ; -1screen 224
cmp.w d1,d0 ; compare d1 bottom of map (minus 224 one screen) to d0 camera location
blt.s loc_72A8 ; if less branch
move.w d1,d0 ; if greater or = set to cam y limit down
subi.w #2,($FFFFFB58).w ; negate cam timer/offset
; end of look up and down mod------------------------------------------------
Step 3
The old look down code has some checks in other locations we have to comment out. we can find them by searching for $FFFFFB58
The old look down code has some checks in other locations we have to comment out. we can find them by searching for $FFFFFB58
First location is loc_7650 comment out the contents of the function (leave the loc_7650 line uncommented)
; tst.b (Ctrl_Down_Held).w
; bne.s loc_7664
; subi.w #8,($FFFFFB58).w
; bge.s loc_7664
; move.w #0,($FFFFFB58).w
; bne.s loc_7664
; subi.w #8,($FFFFFB58).w
; bge.s loc_7664
; move.w #0,($FFFFFB58).w
Second location is loc_7772 comment out the one line with $FFFFFB58 in it
;addq.w #1,($FFFFFB58).w
Third location is loc_825C comment out the last three lines only
; subi.w #8,($FFFFFB58).w
; bge.s loc_8270
; move.w #0,($FFFFFB58).w
; bge.s loc_8270
; move.w #0,($FFFFFB58).w
Fourth location is loc_82D8 comment out the first line
;addq.w #1,($FFFFFB58).w
Fifth location is loc_8C12 comment out the contents of the function (leave the loc_8C12 line uncommented)
; tst.b (Ctrl_Down_Held).w
; bne.s loc_8C26
; subi.w #8,($FFFFFB58).w
; bge.s loc_8C26
; move.w #0,($FFFFFB58).w
; bne.s loc_8C26
; subi.w #8,($FFFFFB58).w
; bge.s loc_8C26
; move.w #0,($FFFFFB58).w
Sixth location is loc_8C70 comment out the one line with $FFFFFB58 in it
;addq.w #1,($FFFFFB58).w
That's it, save, build and test it out.
I forgot to mention I also changed the offset of the camera bringing it down 8 pixels now that we can look up. This brings the kid toward the center of the screen and makes it so you can see more of whats below you. Feel free to change it back I noted the default value. its about 5 lines down from the top (subi.w #$98,d0 )
Optional
Its probably best to keep everything commented out encase there is a bug or oversight that pops up after more testing.
But after some testing and if everything works you can go back and delete the large commented block of code.
(A more advance user could also clean up the first and fifth location in Step 3. Delete then search and replace the branches to those location)