Bombchu Link's Open source Mods!

Mar 13, 2016 at 1:23 AM
hi hi
"What're YOU lookin' at?"
Join Date: Oct 17, 2011
Location: probably somewhere else
Posts: 1099
Age: 26
WTF do you mean by e_x? Setting npc.inuse to 0 in Doukutsu Assembler converts to MOV DWORD PTR DS:[ECX],0 in ollydbg. Is that for all entities or it just happens to be that?
depending on the last pointer you set, it's going to be either eax, ecx or edx
most likely ecx in your case

and that command basically means the same so it's cool
 
Mar 13, 2016 at 1:33 AM
Senior Member
"Huzzah!"
Join Date: Dec 2, 2015
Location:
Posts: 211
Age: 25
Like how e_x+40 is health and

e_x+54
e_x+58
e_x+5C
e_x+60

Are the display rects.

Npc.inuse is just e_x

(Uh, don't remember if those are the correct ones, i'm typing this on my phone right now.)
 
Mar 13, 2016 at 2:57 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
npc.inuse=[ecx]
npc.collision=[ecx+4]
npc.x=[ecx+8]
npc.y=[ecx+C]
npc.movex=[ecx+10]
npc.movey=[ecx+14]
npc.altvelx=[ecx+18]
npc.altvely=[ecx+1C]
npc.CurlyMacro1=[ecx+20]
npc.CurlyMacro2=[ecx+24]
npc.npcID=[ecx+28]
npc.EntityID=[ecx+2C]
npc.EventNum=[ecx+30]
npc.tileset=[ecx+34]
npc.hurtsound=[ecx+38]
npc.deathsound=[ecx+3C]
npc.health=[ecx+40]
npc.EXP=[ecx+44]
npc.deathgraphic=[ecx+48]
npc.direction=[ecx+4C]
npc.flags=[ecx+50]
npc.DisplayL=[ecx+54]
npc.displayU=[ecx+58]
npc.displayR=[ecx+5C]
npc.displayD=[ecx+60]
npc.frametimer=[ecx+64]
npc.framenum=[ecx+68]
npc.objecttimer=[ecx+6C]
npc.directive=[ecx+70]
npc.scriptstate=[ecx+74]
npc.scripttimer=[ecx+78]
npc.hitrectl=[ecx+7C]
npc.hitrectU=[ecx+80]
npc.hitrectR=[ecx+84]
npc.hitrectD=[ecx+88]
npc.HitTrue=[ecx+9C]
npc.DamageTaken=[ecx+A0]
npc.Damage=[ecx+A4]
npc.parent=[ecx+A8]
 
Mar 13, 2016 at 7:10 AM
hi hi
"What're YOU lookin' at?"
Join Date: Oct 17, 2011
Location: probably somewhere else
Posts: 1099
Age: 26
npc.inuse=[ecx]
npc.collision=[ecx+4]
npc.x=[ecx+8]
npc.y=[ecx+C]
npc.movex=[ecx+10]
npc.movey=[ecx+14]
npc.altvelx=[ecx+18]
npc.altvely=[ecx+1C]
npc.CurlyMacro1=[ecx+20]
npc.CurlyMacro2=[ecx+24]
npc.npcID=[ecx+28]
npc.EntityID=[ecx+2C]
npc.EventNum=[ecx+30]
npc.tileset=[ecx+34]
npc.hurtsound=[ecx+38]
npc.deathsound=[ecx+3C]
npc.health=[ecx+40]
npc.EXP=[ecx+44]
npc.deathgraphic=[ecx+48]
npc.direction=[ecx+4C]
npc.flags=[ecx+50]
npc.DisplayL=[ecx+54]
npc.displayU=[ecx+58]
npc.displayR=[ecx+5C]
npc.displayD=[ecx+60]
npc.frametimer=[ecx+64]
npc.framenum=[ecx+68]
npc.objecttimer=[ecx+6C]
npc.directive=[ecx+70]
npc.scriptstate=[ecx+74]
npc.scripttimer=[ecx+78]
npc.hitrectl=[ecx+7C]
npc.hitrectU=[ecx+80]
npc.hitrectR=[ecx+84]
npc.hitrectD=[ecx+88]
npc.HitTrue=[ecx+9C]
npc.DamageTaken=[ecx+A0]
npc.Damage=[ecx+A4]
npc.parent=[ecx+A8]
it's just the fact you don't need to set the pointer as ECX
you can use EAX or EDX and it still works
so basically just the middle letter changes
hence the E_X
_ is a blank space where you put the correct letter
 
Mar 18, 2016 at 4:16 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
it's just the fact you don't need to set the pointer as ECX
you can use EAX or EDX and it still works
so basically just the middle letter changes
hence the E_X
_ is a blank space where you put the correct letter
So how do you set the pointer to something other than ECX?
 
Mar 18, 2016 at 3:16 PM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
What hina siad was right, but the defines.txt point always to ecx and you'd have to change that manually.
 
Mar 18, 2016 at 9:54 PM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
mov eax, [ebp+8]
mov edx, [ebp+8]
lol
What hina siad was right, but the defines.txt point always to ecx and you'd have to change that manually.
Oh. In that case I'm not going to bother. ECX it is.

EDIT: Blink, I was trying to use one of your asm hacks that you released; the blue save disks from DOR2. But when I was copying it into the executable (My Doukutsu Assembler wasn't working then) something in that code stuffed up the in-game variables and immediately crashed the game at 40C7A6 whenever I picked up EXP or stuff like that in the same map as the save point. Could you maybe check what I did wrong, because I can't really tell. To me it looks exactly like your code, and there was nothing else that could have been crashing the game like that, as the glitch automatically fixes itself when I undo the hack.

EDIT 2: I managed to fix my Doukutsu Assembler and it still does the same thing...
 

Attachments

  • Save Point.PNG
    Save Point.PNG
    28.7 KB · Views: 5
Last edited:
Jun 26, 2016 at 5:40 AM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
I re-wrote the Background rendering code; it's not super optimized because I don't understand all the math exactly but here you go:

Code:
offset 4023D0

#define
BK_type       = [499C88]
X_bitmap_size = [499C78]
Y_bitmap_size = [499C7C]
BK_typeVar = [EBP-1C]
bitmaprender_X = [EBP-18]
bitmaprender_Y = [EBP-14]
Lrect =  [EBP-10]
Urect =  [EBP-C]
Rrect =  [EBP-8]
Drect =  [EBP-4]
#enddefine

PUSH EBP
MOV EBP,ESP
SUB ESP,1C
xor eax, eax
MOV Lrect,eax
MOV Urect,eax
MOV EcX, X_bitmap_size
MOV Rrect,EcX
MOV ECX, Y_bitmap_size
MOV Drect,ECX
MOV EDX, BK_type
MOV BK_typeVar,EDX
CMP BK_typeVar,7  ;is BK type overflowing?
JA :end_of_code
MOV EAX, BK_typeVar
JMP [EAX*4+:StateTable]

:fixed_bk
MOV bitmaprender_Y, 0          ;only runs once 
JMP :enter_fixed_loop

:fixed_loop_full
MOV ECX, Y_bitmap_size
ADD bitmaprender_Y,ECX
CMP bitmaprender_Y,0F0
JGE :end_of_code
:enter_fixed_loop
MOV bitmaprender_X,0
JMP :no_check_fixed_X

:fixed_loop_short
MOV EDX, X_bitmap_size
ADD bitmaprender_X,EDX
:no_check_fixed_X
CMP  bitmaprender_X,140
JGE :fixed_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects              
PUSH EAX                  
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                  
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                  
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :fixed_loop_short

;-----------------------------------------------------------

:follow_slowly
MOV EAX, [EBP+0C]
CDQ
SUB EAX,EDX
SAR EAX,1
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 7C 9C 49 00  ;IDIV  Y_bitmap_size
NEG EDX
MOV  bitmaprender_Y,EDX  ;fuggin math; runs once to set the place to render from
JMP :enter_follow_slowly_loop

:Follow_slowly_loop_full
MOV EAX, bitmaprender_Y
ADD EAX, Y_bitmap_size
MOV  bitmaprender_Y,EAX
:enter_follow_slowly_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [EBP+8]
CDQ
SUB EAX,EDX
SAR EAX,1
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV bitmaprender_X,EDX           ;more fuggin math
JMP :check_follow_slowly_bitmap_area_X

:Follow_slowly_loop_short
MOV ECX, bitmaprender_X
ADD ECX, X_bitmap_size
MOV bitmaprender_X,ECX
:check_follow_slowly_bitmap_area_X
CMP bitmaprender_X,140
JGE :Follow_slowly_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects              
PUSH EAX                  
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                  
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                  
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :Follow_slowly_loop_short

;--------------------------------------------------------------

:follow_foreground
MOV EAX, [EBP+0C]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 7C 9C 49 00  ;IDIV  Y_bitmap_size
NEG EDX
MOV  bitmaprender_Y,EDX
JMP :enter_follow_foreground_loop

:follow_foreground_loop_full
MOV EDX, bitmaprender_Y
ADD EDX, Y_bitmap_size
MOV  bitmaprender_Y,EDX
:enter_follow_foreground_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [EBP+8]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV  bitmaprender_X,EDX
JMP :check_follow_foreground_bitmap_area_X

:follow_foreground_loop_short
MOV EAX, bitmaprender_X
ADD EAX, X_bitmap_size
MOV  bitmaprender_X,EAX
:check_follow_foreground_bitmap_area_X
CMP  bitmaprender_X,140
JGE :follow_foreground_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects              
PUSH EAX                  
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                  
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                  
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :follow_foreground_loop_short

;--------------------------------------------------------------

:scroll_fast_left
MOV ECX, Y_bitmap_size
NEG ECX
MOV  bitmaprender_Y,ECX
JMP :enter_scroll_fast_left_loop

:scroll_fast_left_loop_full
MOV EDX, bitmaprender_Y
ADD EDX, Y_bitmap_size
MOV  bitmaprender_Y,EDX
:enter_scroll_fast_left_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [499C8C]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV  bitmaprender_X,EDX
JMP :check_scroll_fast_left_bitmap_area_X

:scroll_fast_left_loop_short
MOV EAX, bitmaprender_X
ADD EAX, X_bitmap_size
MOV  bitmaprender_X,EAX
:check_scroll_fast_left_bitmap_area_X
CMP  bitmaprender_X,140
JGE :scroll_fast_left_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects              
PUSH EAX                  
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                  
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                  
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :scroll_fast_left_loop_short


:parallax
;402606
MOV   Urect,0
MOV   Drect,58
MOV   Lrect,0
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA ECX, Lrect                         ; |
PUSH ECX                                 ; |Arg4
PUSH 0                                   ; |Arg3 = 0
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,58
MOV   Drect,7B
MOV EAX, [499C8C]
CDQ
SUB EAX,EDX
SAR EAX,1
MOV   Lrect,EAX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 58                                  ; |Arg3 = 58
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 58                                  ; |Arg3 = 58
MOV EAX, [499C8C]            ; |
CDQ                                      ; |
SUB EAX,EDX                              ; |
SAR EAX,1                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,7B
MOV   Drect,92
MOV EAX, [499C8C]
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 7B                                  ; |Arg3 = 7B
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 7B                                  ; |Arg3 = 7B
MOV EAX, [499C8C]            ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,92
MOV   Drect,0B0
MOV EAX, [499C8C]
SHL EAX,1
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 92                                  ; |Arg3 = 92
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 92                                  ; |Arg3 = 92
MOV EAX, [499C8C]            ; |
SHL EAX,1                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,0B0
MOV   Drect,0F0
MOV EAX, [499C8C]
SHL EAX,2
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 0B0                                 ; |Arg3 = 0B0
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 0B0                                 ; |Arg3 = 0B0
MOV EAX, [499C8C]            ; |
SHL EAX,2                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
:end_of_code  
MOV ESP,EBP
POP EBP
RETN

:StateTable

print :fixed_bk                        
print :follow_slowly                  ; follow slowly
print :follow_foreground              ; follow foreground
print :end_of_code                    ; foreground water
print :end_of_code                    ; black
print :scroll_fast_left               ; Scroll fast left
print :parallax                       ; Parallax (items fall left)
print :parallax                       ; Parallax
 
Jun 26, 2016 at 6:21 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
I re-wrote the Background rendering code; it's not super optimized because I don't understand all the math exactly but here you go:

Code:
offset 4023D0

#define
BK_type       = [499C88]
X_bitmap_size = [499C78]
Y_bitmap_size = [499C7C]
BK_typeVar = [EBP-1C]
bitmaprender_X = [EBP-18]
bitmaprender_Y = [EBP-14]
Lrect =  [EBP-10]
Urect =  [EBP-C]
Rrect =  [EBP-8]
Drect =  [EBP-4]
#enddefine

PUSH EBP
MOV EBP,ESP
SUB ESP,1C
xor eax, eax
MOV Lrect,eax
MOV Urect,eax
MOV EcX, X_bitmap_size
MOV Rrect,EcX
MOV ECX, Y_bitmap_size
MOV Drect,ECX
MOV EDX, BK_type
MOV BK_typeVar,EDX
CMP BK_typeVar,7  ;is BK type overflowing?
JA :end_of_code
MOV EAX, BK_typeVar
JMP [EAX*4+:StateTable]

:fixed_bk
MOV bitmaprender_Y, 0          ;only runs once
JMP :enter_fixed_loop

:fixed_loop_full
MOV ECX, Y_bitmap_size
ADD bitmaprender_Y,ECX
CMP bitmaprender_Y,0F0
JGE :end_of_code
:enter_fixed_loop
MOV bitmaprender_X,0
JMP :no_check_fixed_X

:fixed_loop_short
MOV EDX, X_bitmap_size
ADD bitmaprender_X,EDX
:no_check_fixed_X
CMP  bitmaprender_X,140
JGE :fixed_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects            
PUSH EAX                
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :fixed_loop_short

;-----------------------------------------------------------

:follow_slowly
MOV EAX, [EBP+0C]
CDQ
SUB EAX,EDX
SAR EAX,1
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 7C 9C 49 00  ;IDIV  Y_bitmap_size
NEG EDX
MOV  bitmaprender_Y,EDX  ;fuggin math; runs once to set the place to render from
JMP :enter_follow_slowly_loop

:Follow_slowly_loop_full
MOV EAX, bitmaprender_Y
ADD EAX, Y_bitmap_size
MOV  bitmaprender_Y,EAX
:enter_follow_slowly_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [EBP+8]
CDQ
SUB EAX,EDX
SAR EAX,1
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV bitmaprender_X,EDX           ;more fuggin math
JMP :check_follow_slowly_bitmap_area_X

:Follow_slowly_loop_short
MOV ECX, bitmaprender_X
ADD ECX, X_bitmap_size
MOV bitmaprender_X,ECX
:check_follow_slowly_bitmap_area_X
CMP bitmaprender_X,140
JGE :Follow_slowly_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects            
PUSH EAX                
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :Follow_slowly_loop_short

;--------------------------------------------------------------

:follow_foreground
MOV EAX, [EBP+0C]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 7C 9C 49 00  ;IDIV  Y_bitmap_size
NEG EDX
MOV  bitmaprender_Y,EDX
JMP :enter_follow_foreground_loop

:follow_foreground_loop_full
MOV EDX, bitmaprender_Y
ADD EDX, Y_bitmap_size
MOV  bitmaprender_Y,EDX
:enter_follow_foreground_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [EBP+8]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV  bitmaprender_X,EDX
JMP :check_follow_foreground_bitmap_area_X

:follow_foreground_loop_short
MOV EAX, bitmaprender_X
ADD EAX, X_bitmap_size
MOV  bitmaprender_X,EAX
:check_follow_foreground_bitmap_area_X
CMP  bitmaprender_X,140
JGE :follow_foreground_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects            
PUSH EAX                
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :follow_foreground_loop_short

;--------------------------------------------------------------

:scroll_fast_left
MOV ECX, Y_bitmap_size
NEG ECX
MOV  bitmaprender_Y,ECX
JMP :enter_scroll_fast_left_loop

:scroll_fast_left_loop_full
MOV EDX, bitmaprender_Y
ADD EDX, Y_bitmap_size
MOV  bitmaprender_Y,EDX
:enter_scroll_fast_left_loop
CMP  bitmaprender_Y,0F0
JGE :end_of_code
MOV EAX, [499C8C]
CDQ
AND EDX,000001FF
ADD EAX,EDX
SAR EAX,9
CDQ
data F7 3D 78 9C 49 00 ;IDIV  X_bitmap_size
NEG EDX
MOV  bitmaprender_X,EDX
JMP :check_scroll_fast_left_bitmap_area_X

:scroll_fast_left_loop_short
MOV EAX, bitmaprender_X
ADD EAX, X_bitmap_size
MOV  bitmaprender_X,EAX
:check_scroll_fast_left_bitmap_area_X
CMP  bitmaprender_X,140
JGE :scroll_fast_left_loop_full
PUSH 1C                    ; 1C is BK bitmap slot
LEA EAX, Lrect             ;get rects            
PUSH EAX                
MOV ECX, bitmaprender_Y    ; Get Y axis of pixel
PUSH ECX                
MOV EDX, bitmaprender_X    ; Get X axis of pixel
PUSH EDX                
PUSH 0048F91C       ; full-screen clipping rect
CALL 0040C5B0              ; render pixel
ADD ESP,14
JMP :scroll_fast_left_loop_short


:parallax
;402606
MOV   Urect,0
MOV   Drect,58
MOV   Lrect,0
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA ECX, Lrect                         ; |
PUSH ECX                                 ; |Arg4
PUSH 0                                   ; |Arg3 = 0
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,58
MOV   Drect,7B
MOV EAX, [499C8C]
CDQ
SUB EAX,EDX
SAR EAX,1
MOV   Lrect,EAX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 58                                  ; |Arg3 = 58
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 58                                  ; |Arg3 = 58
MOV EAX, [499C8C]            ; |
CDQ                                      ; |
SUB EAX,EDX                              ; |
SAR EAX,1                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,7B
MOV   Drect,92
MOV EAX, [499C8C]
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 7B                                  ; |Arg3 = 7B
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 7B                                  ; |Arg3 = 7B
MOV EAX, [499C8C]            ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,92
MOV   Drect,0B0
MOV EAX, [499C8C]
SHL EAX,1
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 92                                  ; |Arg3 = 92
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 92                                  ; |Arg3 = 92
MOV EAX, [499C8C]            ; |
SHL EAX,1                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV   Urect,0B0
MOV   Drect,0F0
MOV EAX, [499C8C]
SHL EAX,2
CDQ
MOV ECX,140
IDIV ECX
MOV   Lrect,EDX
MOV   Rrect,140
PUSH 1C                                  ; /Arg5 = 1C
LEA EDX, Lrect                         ; |
PUSH EDX                                 ; |Arg4
PUSH 0B0                                 ; |Arg3 = 0B0
PUSH 0                                   ; |Arg2 = 0
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
MOV Lrect,0
PUSH 1C                                  ; /Arg5 = 1C
LEA EAX, Lrect                         ; |
PUSH EAX                                 ; |Arg4
PUSH 0B0                                 ; |Arg3 = 0B0
MOV EAX, [499C8C]            ; |
SHL EAX,2                                ; |
CDQ                                      ; |
MOV ECX,140                              ; |
IDIV ECX                                 ; |
MOV EAX,140                              ; |
SUB EAX,EDX                              ; |
PUSH EAX                                 ; |Arg2
PUSH 0048F91C                     ; |Arg1 = Doukutsu2.48F91C
CALL 0040C5B0                            ; \Doukutsu2.0040C5B0
ADD ESP,14
:end_of_code
MOV ESP,EBP
POP EBP
RETN

:StateTable

print :fixed_bk                      
print :follow_slowly                  ; follow slowly
print :follow_foreground              ; follow foreground
print :end_of_code                    ; foreground water
print :end_of_code                    ; black
print :scroll_fast_left               ; Scroll fast left
print :parallax                       ; Parallax (items fall left)
print :parallax                       ; Parallax
Looks like it works.
There's actually 8 backgrounds BTW. The last one's just unused. I used it for my lava level in Rise of Ballos
 
Jun 26, 2016 at 4:23 PM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
Jul 22, 2016 at 3:47 AM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
Here's ever single hack I've ever made put in a convenient .zip file for you

99% of it is undocumented and poorly explained and named; but It might be of some use to some of you guys maybe??

My hacks - 7-21-16.zip
 
Aug 4, 2016 at 4:28 AM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
Vanilla Physics code: contains players interaction with tiles; spike damage, friction air movement ect and booster stuff

Code:
#define
gravity = 55
spike_damage = A
Boostdir = [49E6E6]

JumpKey=[493610]
ShootKey=[493614]
NextWepKey=[493618]
PrevWepKey=[49361C]
MenuKey=[493620]
MapKey=[493624]
JumpKey=[493628]
ShootKey=[49362C]
LeftKey=[493630]
UpKey=[493634]
RightKey=[493638]
DownKey=[49363C]
#enddefine

offset 4156C0 

push ebp                
mov ebp,esp              
sub esp,2C              
movzx eax,byte PlayerFlags //player flags
and eax,2                
jnz :end_of_code        
mov ecx, PlayerTile 
and ecx,100              
je :WaterPhysics        
mov [ebp-14],196 
mov [ebp-C],2FF  
mov [ebp-1C],28 
mov [ebp-10],10  
mov [ebp-28],280 
mov [ebp-24],2A  
mov [ebp-18],10 
mov [ebp-20],19  
jmp :physics_set    
:WaterPhysics        
mov [ebp-14],32C 
mov [ebp-C],5FF  
mov [ebp-1C],50 
mov [ebp-10],20  
mov [ebp-28],500 
mov [ebp-24],55  
mov [ebp-18],20 
mov [ebp-20],33  
:physics_set


mov byte [49E6E5],0  
cmp [ebp+8],0    
jne :doukutsu41576B          
mov byte  Boostdir,0  //jump state flag???
:doukutsu41576B  
mov edx, 8      
or edx,10
or edx,20
and edx, PlayerTile    //player tile            
jz :in_the_air
mov byte  Boostdir,0  //jump state flag???
mov edx, EquippedItems    //equiped items
and edx,1                
je :No_booster_0.8        
mov  JetpackEnergy,32     //refill booster fuel
jmp :booster_set  

:No_booster_0.8        
mov eax, EquippedItems 
and eax,20          //booster 2.0 check          
jz :No_booster_2.0        
mov  JetpackEnergy,32    //refill booster fuel
jmp :booster_set  

:No_booster_2.0  
mov  JetpackEnergy,0 
:booster_set

cmp [ebp+8],0    //check arg
je :doukutsu4158B3          
mov ecx,  KeyPressed 
cmp ecx, DownKey  //so you look down even of you only hold the key for 1 frame
jne :doukutsu415826          
mov edx, KeyHeld 
cmp edx, DownKey 
jne :doukutsu415826          
movzx eax,byte PlayerFlags 
and eax,1               //inspecting check 
jne :doukutsu415826          
mov ecx, [49E1E8] //gamestate check for gameover.black fade
and ecx,4                
jne :doukutsu415826          
movzx edx,byte PlayerFlags
or edx,1                
mov byte PlayerFlags,dl  
mov byte [49E6E5], 1    
jmp :doukutsu4158B3  

:doukutsu415826  
mov eax, KeyHeld 
cmp eax, DownKey 
je :doukutsu4158B3          
mov ecx, KeyHeld 
and ecx, LeftKey 
je :doukutsu41585D          
mov edx, [ebp-14] 
neg edx                  
cmp  PlayerXVel,edx 
jle :doukutsu41585D          
mov eax, PlayerXVel 
sub eax, [ebp-24]   //friction
mov  PlayerXVel,eax 
:doukutsu41585D 
mov ecx, KeyHeld 
and ecx, RightKey 
je :doukutsu415883          
mov edx, PlayerXVel 
cmp edx, [ebp-14] 
jge :doukutsu415883          
mov eax, PlayerXVel 
add eax,dword [ebp-24] 
mov  PlayerXVel,eax 
:doukutsu415883
mov ecx, KeyHeld 
and ecx, LeftKey 
je :doukutsu41589B          
mov  DirectionFaced,0 
:doukutsu41589B 
mov edx, KeyHeld 
and edx, RightKey 
je :doukutsu4158B3          
mov  DirectionFaced,2 
:doukutsu4158B3  
movzx eax,byte PlayerFlags 
and eax,20              
jne :doukutsu415B5E          
cmp  PlayerXVel,0  
jge :doukutsu4158F0          
mov ecx,dword ptr ss:[ebp-20] 
neg ecx                  
cmp  PlayerXVel,ecx 
jle :doukutsu4158E1  

:doukutsu41585D        
mov  PlayerXVel,0  
jmp :doukutsu4158F0 
:doukutsu4158E1          
mov edx, PlayerXVel 
add edx, [ebp-20] 
mov  PlayerXVel,edx 
:doukutsu4158F0 
cmp  PlayerXVel,0  
jle :doukutsu415B5E        
mov eax, PlayerXVel 
cmp eax, [ebp-20] 
jge :doukutsu41590F          
mov  PlayerXVel,0  
jmp :doukutsu415B5E  
:doukutsu41590F        
mov ecx, PlayerXVel 
sub ecx, [ebp-20] 
mov  PlayerXVel,ecx 
jmp :doukutsu415B5E  
:in_the_air
   
cmp [ebp+8],0  
je :doukutsu415ADC          
mov edx, EquippedItems 
and edx,21           //check for boosters      
je :Booster_done        
mov eax,  KeyPressed 
and eax, JumpKey 
je :Booster_done        
cmp JetpackEnergy,0   //IBF HACK GOES HERE!!!
je :Booster_done        
mov ecx, EquippedItems 
and ecx,1                
jz :booster_2.0_check        
mov byte  Boostdir,1  
cmp  PlayerYVel,100 
jle :booster_2.0_check        
mov eax, PlayerYVel 
cdq                    
sub eax,edx              
sar eax,1                
mov  PlayerYVel,eax 
:booster_2.0_check
mov edx, EquippedItems 
and edx,20              
jz :Booster_done          
mov eax, KeyHeld 
and eax, UpKey 
je :doukutsu4159C3          
mov byte ptr ds: Boostdir,2  
mov  PlayerXVel,0  
mov  PlayerYVel,FFFFFA01  
jmp :Booster_done 
:doukutsu4159C3        
mov ecx, KeyHeld 
and ecx, LeftKey 
je :doukutsu4159EE          
mov byte ptr ds: Boostdir,1  
mov  PlayerYVel,0  
mov  PlayerXVel,FFFFFA01  
jmp :Booster_done  
:doukutsu4159EE        
mov edx, KeyHeld 
and edx, RightKey 
je :doukutsu415A19          
mov byte ptr ds: Boostdir,1  
mov  PlayerYVel,0  
mov  PlayerXVel,5FF 
jmp :Booster_done  
:doukutsu415A19        
mov eax, KeyHeld 
and eax, DownKey 
je :doukutsu415A43          
mov byte ptr ds: Boostdir,3  
mov  PlayerXVel,0  
mov  PlayerYVel,5FF 
jmp :Booster_done 
:doukutsu415A43        
mov byte ptr ds: Boostdir,2  
mov PlayerXVel,0  
mov PlayerYVel,FFFFFA01 



:Booster_done  //at least that part is
mov ecx, KeyHeld 
and ecx, LeftKey 
jz :doukutsu415A86  
mov  DirectionFaced,0      
mov edx, [ebp-14] 
neg edx                  
cmp  PlayerXVel,edx 
jle :doukutsu415A86          
mov eax, PlayerXVel 
sub eax,dword ptr ss:[ebp-18] 
mov  PlayerXVel,eax 
:doukutsu415A86 
mov ecx, KeyHeld 
and ecx, RightKey 
jz :doukutsu415AAC  
mov  DirectionFaced,2        
mov edx, PlayerXVel 
cmp edx,dword ptr ss:[ebp-14] 
jge :doukutsu415AAC          //speed cap
mov eax, PlayerXVel 
add eax,dword ptr ss:[ebp-18] 
mov  PlayerXVel,eax 



:doukutsu415AAC
mov eax, EquippedItems 
and eax,20              
je :doukutsu415B40          
movsx ecx,byte ptr ds: Boostdir
test ecx,ecx              
je :doukutsu415B40 
:doukutsu415ADC        
mov edx, KeyHeld 
and edx, JumpKey 
je :doukutsu415B08          
cmp  JetpackEnergy,0  
jne :doukutsu415B40  
:doukutsu415B08        
movsx eax,byte ptr ds: Boostdir
cmp eax,1                
jne :doukutsu415B25          
mov eax, PlayerXVel 
cdq                    
sub eax,edx              
sar eax,1                
mov  PlayerXVel,eax 
jmp :doukutsu415B40 
:doukutsu415B25        
movsx ecx,byte ptr ds: Boostdir
cmp ecx,2                
jne :doukutsu415B40          
mov eax, PlayerYVel 
cdq                    
sub eax,edx              
sar eax,1                
mov  PlayerYVel,eax 
:doukutsu415B40
cmp  JetpackEnergy,0  
je :doukutsu415B57          
mov edx, KeyHeld 
and edx, JumpKey 
jne :doukutsu415B5E 
:doukutsu415B57          
mov byte ptr ds: Boostdir,0  
:doukutsu415B5E 
cmp [ebp+8],0    
je :doukutsu415C0E          
mov eax, KeyHeld 
and eax, UpKey 
je :doukutsu415B81          
mov IsFacingUp,1  
jmp :doukutsu415B8B 
:doukutsu415B81          
mov IsFacingUp,0  
:doukutsu415B8B
mov ecx, KeyHeld 
and ecx, DownKey 
je :doukutsu415BB0          
mov edx, PlayerTile 
and edx,8                
jne :doukutsu415BB0          
mov IsFacingDown,1  
jmp :doukutsu415BBA  
:doukutsu415BB0      
mov IsFacingDown,0 
:doukutsu415BBA 
mov eax,  KeyPressed 
and eax, JumpKey 
je :doukutsu415C0E      

//collision check 
mov edx, 8      
or edx,10
or edx,20
and edx, PlayerTile    //player tile  
jz :doukutsu415C0E      
mov ecx, PlayerTile 
and ecx,2000             
mov edx,dword ptr ss:[ebp-28]
neg edx
mov dword ptr ds:[49E670],edx
push 1
push F
call Playsound
add esp,8 

:doukutsu415C0E                
cmp [ebp+8],0    
je :doukutsu415C49          
mov eax, LeftKey 
or eax, RightKey  
or eax, UpKey 
or eax, JumpKey  
or eax, ShootKey 
and eax, KeyHeld 
jz :doukutsu415C49          
movzx ecx,byte PlayerFlags
and ecx,FFFFFFFE // -2          
mov byte ptr ds:PlayerFlags,cl 
:doukutsu415C49  
movsx edx,byte ptr ds: Boostdir 
test edx,edx            
je :doukutsu415C6A          
cmp  JetpackEnergy,0  
je :doukutsu415C6A          
dec JetpackEnergy  //IBF HACK GOES HERE
:doukutsu415C6A
mov ecx, PlayerTile 
and ecx,1000             //WindLeft    
jz :WindLDone        
mov edx, PlayerXVel 
sub edx,88                
mov  PlayerXVel,edx 
:WindLDone
mov eax, PlayerTile 
and eax,2000            //windUp 
je :WindUDone        
mov ecx, PlayerYVel 
sub ecx,80                
mov  PlayerYVel,ecx
:WindUDone
mov edx, PlayerTile 
and edx,4000           //WindRight  
je :WindRDone        
mov eax, PlayerXVel 
add eax,88                
mov  PlayerXVel,eax 
:WindRDone  
mov ecx, PlayerTile 
and ecx,8000           //WindDown
je :WindDDone            
mov edx, PlayerYVel 
add edx, gravity              
mov  PlayerYVel,edx 
:WindDDone


mov eax, EquippedItems 
and eax,20              
je :doukutsu415EA3
movsx ecx,byte  Boostdir
test ecx,ecx              
je :doukutsu415EA3          
movsx edx,byte ptr ds: Boostdir
cmp edx,1                
jne :doukutsu415DDF          
mov eax, PlayerTile 
and eax,5                
je :doukutsu415D23          
mov  PlayerYVel,FFFFFF00  //-10
:doukutsu415D23 
cmp  DirectionFaced,0  
jne :doukutsu415D3B          
sub PlayerXVel 20
:doukutsu415D3B
cmp  DirectionFaced,2  
jne :doukutsu415D53          
add PlayerXVel, 20 
:doukutsu415D53    
     


mov eax,  KeyPressed 
and eax, JumpKey 
jne :doukutsu415D72          
mov eax, JetpackEnergy 
cdq                    
mov ecx,3                
idiv ecx                 //shoot exhaust every 3 frames
cmp edx,1                
jne :doukutsu415F87    
:doukutsu415D72      
cmp  DirectionFaced,0  
jne :doukutsu415D9F          
push 2                  
push 7           //ID = puff        
mov edx, PlayerYPos 
add edx,400              
push edx                
mov eax, PlayerXPos 
add eax,400              
push eax                
call 40AC90    //create booster exhaust    
add esp,10    
:doukutsu415D9F            
cmp  DirectionFaced,2  
jne :doukutsu415DCE          
push 0                  
push 7                  
mov ecx, PlayerYPos 
add ecx,400              
push ecx                
mov edx, PlayerXPos 
sub edx,400              
push edx                
call 40AC90        
add esp,10  
:doukutsu415DCE            
push 1                  
push 71                
call Playsound //booster exhaust        
add esp,8                
jmp :doukutsu415F87 

:doukutsu415DDF        
movsx eax,byte ptr ds: Boostdir
cmp eax,2                
jne :doukutsu415E47          
sub PlayerYVel, 20  
mov edx,  KeyPressed 
and edx, JumpKey 
jne :doukutsu415E15        
mov eax, JetpackEnergy 
cdq                    
mov ecx,3                
idiv ecx  
:doukutsu415E15              
cmp edx,1                
jne :doukutsu415F87        
push 3                  
push 7                  
mov edx, PlayerYPos 
add edx,C00              
push edx                
mov eax, PlayerXPos 
push eax                
call 40AC90         //animated effect
add esp,10              
push 1                  
push 71                
call Playsound        
add esp,8                
jmp :doukutsu415F87  

:doukutsu415E47        
movsx ecx,byte ptr ds: Boostdir
cmp ecx,3                
jne :doukutsu415F87          
mov edx,  KeyPressed 
and edx, JumpKey 
jnz :doukutsu415E73          
mov eax, JetpackEnergy 
cdq                    
mov ecx,3                
idiv ecx                
cmp edx,1                
jne :doukutsu415F87  
:doukutsu415E73        
push 1                  
push 7                  
mov edx, PlayerYPos 
sub edx,C00              
push edx                
mov eax, PlayerXPos 
push eax                
call 40AC90         //animated effect        
add esp,10              
push 1                  
push 71                
call Playsound        
add esp,8                
jmp :doukutsu415F87  


:doukutsu415EA3
mov ecx, PlayerTile 
and ecx,2000              //wind up
je :doukutsu415EC5          
mov edx,dword ptr ss:[ebp-1C] 
add PlayerYVel,edx 
jmp :doukutsu415F87 

:doukutsu415EC5        
mov eax, EquippedItems 
and eax,1                
jz :doukutsu415F4C          
movsx ecx,byte ptr ds: Boostdir
test ecx,ecx              
je :doukutsu415F4C          
cmp  PlayerYVel,FFFFFC00  //speedcap check
jle :doukutsu415F4C          
mov edx, PlayerYVel 
sub edx,20                
mov  PlayerYVel,edx 
mov eax, JetpackEnergy 
cdq                    
mov ecx,3                
idiv ecx                
test edx,edx              
jnz :doukutsu415F36          
push 3                  
push 7                  
mov eax, [49E688] 
cdq                    
sub eax,edx              
sar eax,1                
add eax, PlayerYPos 
push eax                
mov edx, PlayerXPos 
push edx                
call 40AC90        
add esp,10              
push 1                  
push 71                
call 420640        
add esp,8    
:doukutsu415F36 
mov eax, PlayerTile 
and eax,2                
jz :doukutsu415F87          
mov  PlayerYVel,200 
jmp :doukutsu415F87    


:doukutsu415F4C      
cmp  PlayerYVel,0  
jge :doukutsu415F7A          
cmp [ebp+8],0  
je :doukutsu415F7A          
mov ecx, KeyHeld 
and ecx, JumpKey 
je :doukutsu415F7A          
mov edx, PlayerYVel 
add edx,dword ptr ss:[ebp-10] 
mov  PlayerYVel,edx 
jmp :doukutsu415F87

:doukutsu415F7A        
mov eax, PlayerYVel 
add eax,dword ptr ss:[ebp-1C] 
mov  PlayerYVel,eax

:doukutsu415F87
cmp [ebp+8],0    
je :doukutsu415F9F          
mov ecx,  KeyPressed 
and ecx, JumpKey 
jne :doukutsu416063 
:doukutsu415F9F        
mov edx, PlayerTile 
and edx,10            //slope up left    
je :doukutsu415FBF          
cmp  PlayerXVel,0  
jge :doukutsu415FBF          
mov eax, PlayerXVel 
neg eax                  
mov  PlayerYVel,eax 
:doukutsu415FBF
mov ecx, PlayerTile 
and ecx,20         //slope up right      
je :doukutsu415FDF          
cmp  PlayerXVel,0  
jle :doukutsu415FDF          
mov edx, PlayerXVel 
mov  PlayerYVel,edx
:doukutsu415FDF 
mov eax, PlayerTile 
and eax,8          //ground      
je :doukutsu41600A          
mov ecx, PlayerTile 
and ecx,80000            
je :doukutsu41600A          
cmp  PlayerXVel,0  
jge :doukutsu41600A          
mov  PlayerYVel,400 
:doukutsu41600A
mov edx, PlayerTile 
and edx,8                
je :doukutsu416034          
mov eax, PlayerTile 
and eax,10000        //unknown tile type    
je :doukutsu416034          
cmp  PlayerXVel,0  
jle :doukutsu416034          
mov  PlayerYVel,400 
:doukutsu416034
mov ecx, PlayerTile 
and ecx,8           //solid ground    
je :doukutsu416063          
mov edx, PlayerTile 
and edx,20000            
je :doukutsu416063          
mov eax, PlayerTile 
and eax,40000            
je :doukutsu416063          
mov  PlayerYVel,400 
:doukutsu416063
mov edx, PlayerTile 
and edx,100         //water    
jz :doukutsu4160D7          
mov eax, PlayerTile 
and eax,F000              
jnz :doukutsu4160D7          
cmp  PlayerXVel,FFFFFD01  //speed caps underwater
jge :doukutsu416093          
mov  PlayerXVel,FFFFFD01  
:doukutsu416093 
cmp  PlayerXVel,2FF 
jle :doukutsu4160A9          
mov  PlayerXVel,2FF 
:doukutsu4160A9
cmp  PlayerYVel,FFFFFD01  
jge :doukutsu4160BF          
mov  PlayerYVel,FFFFFD01 
:doukutsu4160BF  
cmp  PlayerYVel,2FF 
jle :doukutsu41612F          
mov  PlayerYVel,2FF 
jmp :doukutsu41612F  

:doukutsu4160D7   //speed caps
cmp  PlayerXVel,FFFFFA01  
jge :doukutsu4160ED          
mov  PlayerXVel,FFFFFA01  
:doukutsu4160ED 
cmp  PlayerXVel,5FF 
jle :doukutsu416103          
mov  PlayerXVel,5FF 
:doukutsu416103 
cmp  PlayerYVel,FFFFFA01  
jge :doukutsu416119          
mov  PlayerYVel,FFFFFA01 
:doukutsu416119 
cmp  PlayerYVel,5FF 
jle :doukutsu41612F          
mov  PlayerYVel,5FF 

:doukutsu41612F 
movsx ecx,byte ptr ds:[49E6E4] 
test ecx,ecx            
jnz :doukutsu4162CE          
mov edx, PlayerTile 
and edx,100              
jz :doukutsu4162CE          
mov eax, PlayerTile 
and eax,800              
jz :doukutsu416165          
mov [ebp-2C],2  
jmp :doukutsu41616C 
:doukutsu416165        
mov [ebp-2C],0 
:doukutsu41616C  
mov ecx, PlayerTile 
and ecx,8            //ground    
jne :doukutsu416225          
cmp  PlayerYVel,200 
jle :doukutsu416225          
mov [ebp-8],0  
jmp :doukutsu41619D  

:doukutsu416194  //water splash loop        
inc [ebp-8] 
:doukutsu41619D 
cmp [ebp-8],8    
jge :doukutsu416214          
push 8                  
push FFFFFFF8            
call RANDOM        
add esp,8                
shl eax,9                
add eax, PlayerXPos 
mov [ebp-4],eax  
push 0                  
push 0                  
mov eax,dword ptr ss:[ebp-2C] 
push eax 
               
push 80                
push FFFFFE00            
call RANDOM        
add esp,8                
mov ecx,eax              
mov eax, PlayerYVel 
cdq                    
sub eax,edx              
sar eax,1                
sub ecx,eax              
push ecx    
             
push 200                
push FFFFFE00            
call RANDOM        
add esp,8 
               
add eax, PlayerXVel 
push eax                
mov edx, PlayerYPos 
push edx                
mov eax,dword ptr ss:[ebp-4]  
push eax                
push 49                  
call 46EFD0      //create water drop on entry into water  
add esp,20              
jmp :doukutsu416194 

:doukutsu416214        
push 1                  
push 38                  
call 420640  //splash sound        
add esp,8                
jmp :doukutsu4162C7 


:doukutsu416225
cmp  PlayerXVel,200 
jg :doukutsu416241          
cmp  PlayerXVel,FFFFFE00  //exit water 
jge :doukutsu4162C7  
:doukutsu416241        
mov [ebp-8],0  
jmp :doukutsu416253  
:doukutsu41624A        
inc [ebp-8] 
:doukutsu416253
cmp [ebp-8],8    
jge :doukutsu4162BB          
push 8                  
push FFFFFFF8            
call Random        
add esp,8                
shl eax,9                
add eax, PlayerXPos 
mov [ebp-4],eax  
push 0                  
push 0                  
mov edx,dword ptr ss:[ebp-2C] 
push edx                
push 80                
push FFFFFE00            
call Random        
add esp,8                
push eax                
push 200                
push FFFFFE00            
call random        
add esp,8                
add eax, PlayerXVel 
push eax                
mov eax, PlayerYPos 
push eax                
mov ecx,dword ptr ss:[ebp-4]  
push ecx                
push 49                  
call 46EFD0      //npc create water drops  
add esp,20              
jmp :doukutsu41624A 
:doukutsu4162BB      
push 1                  
push 38                //exit water sfx 
call Playsound        
add esp,8  


:doukutsu4162C7            
mov byte ptr ds:[49E6E4],1  
:doukutsu4162CE 


mov edx, PlayerTile 
and edx,100   //water check            
jnz :doukutsu4162E3          
mov byte ptr ds:[49E6E4],0  
:doukutsu4162E3
mov eax, PlayerTile 
and eax,400             //spike tile 
je :doukutsu4162F9          
push spike_damage                  
call 419910         //damage
add esp,4      

     
:doukutsu4162F9    
cmp  DirectionFaced,0  
jne :doukutsu41632C          
mov ecx, [49E664] 
sub ecx,200              
mov  [49E664],ecx 
cmp  [49E664],FFFF8000  
jge :doukutsu416354 
mov  [49E664],FFFF8000  
jmp :doukutsu416354  
:doukutsu41632C        
mov edx, [49E664] 
add edx,200              
mov  [49E664],edx 
cmp  [49E664],8000 
jle :doukutsu416354          
mov  [49E664],8000
:doukutsu416354 


mov eax, KeyHeld 
and eax, UpKey 
je :doukutsu416391          
cmp [ebp+8],0  
je :doukutsu416391          
mov ecx, [49E668] 
sub ecx,200              
mov  [49E668],ecx 
cmp  [49E668],FFFF8000  
jge :doukutsu416408          
mov  [49E668],FFFF8000  
jmp :doukutsu416408 

:doukutsu416391        
mov edx, KeyHeld 
and edx, DownKey 
je :doukutsu4163CC          
cmp [ebp+8],0  
je :doukutsu4163CC          
mov eax, [49E668] 
add eax,200              
mov  [49E668],eax 
cmp  [49E668],8000 
jle :doukutsu416408          
mov  [49E668],8000
jmp :doukutsu416408  

:doukutsu4163CC        
cmp  [49E668],200 
jle :doukutsu4163EA          
mov ecx, [49E668] 
sub ecx,200              
mov  [49E668],ecx 
:doukutsu4163EA
cmp  [49E668],FFFFFE00  
jge :doukutsu416408          
mov edx, [49E668] 
add edx,200              
mov  [49E668],edx
:doukutsu416408 
mov eax, PlayerXPos 
add eax, [49E664] 
mov  [49E65C],eax 
mov ecx, PlayerYPos 
add ecx, [49E668] 
mov  [49E660],ecx 
mov edx, PlayerXVel 
cmp edx,dword ptr ss:[ebp-20] 
jg :doukutsu416444          
mov eax,dword ptr ss:[ebp-20] 
neg eax                  
cmp  PlayerXVel,eax 
jg :doukutsu416456 
:doukutsu416444          
mov ecx, PlayerXPos 
add ecx, PlayerXVel 
mov  PlayerXPos,ecx 
:doukutsu416456
mov edx, PlayerYPos 
add edx, PlayerYVel 
mov  PlayerYPos,edx 
:end_of_code
mov esp,ebp              
pop ebp                  
retn

I didn't bother to change the unsigned number to signed, or mention that [49E664] and [49E668] are the damage boost vel vars.
 
Apr 8, 2017 at 7:22 PM
The TideWalker
Modding Community Discord Founder
"That dog!"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1640
Age: 26
Code:
offset NPC191

#define

globalWaterlvl = [499c90]

#enddefine


push ebp                          ;This starts the code
mov ebp, esp  
setpointer

;----------------------------------------

:stateIdle
cmp npc.directive, 0
jg :set
mov eax, npc.Y
add eax, 2000
mov globalwaterlvl, eax  //move water level to npc location on frame one
inc npc.directive
:set

mov eax, npc.Y
;drift up
cmp globalwaterlvl, eax
jg :add_to_reach
add npc.moveY, 3
jmp :add_vels
:add_to_reach
sub npc.moveY, 3

:add_vels
cmp npc.scriptstate, 0
je :set_for_vanilla
mov eax, npc.scriptstate
imul eax, eax, 10       //scriptstate X 10 is water rising speed cap
jmp :set_speed_water

:set_for_vanilla
mov eax, 1000

:set_speed_water
cmp npc.moveY, eax     //positive 
jl :speed_cap_pos_set
mov npc.moveY, eax
:speed_cap_pos_set
neg eax
cmp npc.moveY, eax   //negative
jg :speed_cap_neg_set
mov npc.moveY, eax
:speed_cap_neg_set



mov eax, npc.moveY
add globalwaterlvl, eax
jmp :end_of_code
;----------------------------------------

cmp npc.moveY, eax    //scriptstate X 10 is water rising speed cap
jl :speed_cap_1_set
mov npc.moveY, eax
:speed_cap_1_set
mov eax, npc.moveY
add globalwaterlvl, eax
jmp :end_of_code

;----------------------------------------

:end_of_code
mov esp, ebp
pop ebp
retn

I recoded the Water level npc.

<ANP0000 makes water rise to wherever the npc is at a vanilla rate (0x1000)

<ANPXXXX does the same but the speedcap is X multiplied by 10 (so <ANP0004 would make the speed 0x40)

Do with this what you will, maybe throw in a damage function when you get below the global water level and make rising lava in your mod.
 
Apr 10, 2017 at 2:29 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
Code:
offset NPC191

#define

globalWaterlvl = [499c90]

#enddefine


push ebp                          ;This starts the code
mov ebp, esp 
setpointer

;----------------------------------------

:stateIdle
cmp npc.directive, 0
jg :set
mov eax, npc.Y
add eax, 2000
mov globalwaterlvl, eax  //move water level to npc location on frame one
inc npc.directive
:set

mov eax, npc.Y
;drift up
cmp globalwaterlvl, eax
jg :add_to_reach
add npc.moveY, 3
jmp :add_vels
:add_to_reach
sub npc.moveY, 3

:add_vels
cmp npc.scriptstate, 0
je :set_for_vanilla
mov eax, npc.scriptstate
imul eax, eax, 10       //scriptstate X 10 is water rising speed cap
jmp :set_speed_water

:set_for_vanilla
mov eax, 1000

:set_speed_water
cmp npc.moveY, eax     //positive
jl :speed_cap_pos_set
mov npc.moveY, eax
:speed_cap_pos_set
neg eax
cmp npc.moveY, eax   //negative
jg :speed_cap_neg_set
mov npc.moveY, eax
:speed_cap_neg_set



mov eax, npc.moveY
add globalwaterlvl, eax
jmp :end_of_code
;----------------------------------------

cmp npc.moveY, eax    //scriptstate X 10 is water rising speed cap
jl :speed_cap_1_set
mov npc.moveY, eax
:speed_cap_1_set
mov eax, npc.moveY
add globalwaterlvl, eax
jmp :end_of_code

;----------------------------------------

:end_of_code
mov esp, ebp
pop ebp
retn

I recoded the Water level npc.

<ANP0000 makes water rise to wherever the npc is at a vanilla rate (0x1000)

<ANPXXXX does the same but the speedcap is X multiplied by 10 (so <ANP0004 would make the speed 0x40)

Do with this what you will, maybe throw in a damage function when you get below the global water level and make rising lava in your mod.
Nice to see you making ASM for the community again!
There are still quite a few more places where you could optimize, but you're getting a lot better now.
 
Apr 10, 2017 at 3:20 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Nice to see you making ASM for the community again!
There are still quite a few more places where you could optimize, but you're getting a lot better now.
premature optimization is bad
 
Apr 10, 2017 at 4:47 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
Apr 10, 2017 at 4:48 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
is it making the application unusably slow? no? then it's premature.
 
Apr 10, 2017 at 4:50 AM
Catz R cool
Modding Community Discord Moderator
"..."
Join Date: Nov 23, 2015
Location: Somewhere within a world far away from reality...
Posts: 381
Age: 23
Top