Skip to content

Commit 751481b

Browse files
committed
[Maintenance] Assign segment-specific names to the motion_update() variants
Well, we *could* pointlessly decompile this function into an unreadable mess, but only if we throw away the semantics of the return value, and replace its type with `void` or `uint32_t`. (Turbo C++ can't cast registers to a struct value, and adding a constructor to SPPoint would break everything else, if it even works.) ZUN's original usage code doesn't care either way, because it only ever accesses the returned value directly through DX:AX. Part of P0148, funded by [Anonymous].
1 parent f3d59bc commit 751481b

File tree

8 files changed

+78
-74
lines changed

8 files changed

+78
-74
lines changed

th04/main/player/pos_update_and_clamp.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ public PLAYER_POS_UPDATE_AND_CLAMP
22
player_pos_update_and_clamp proc near
33
push bp
44
mov bp, sp
5-
call _motion_update_1 pascal, offset _player_pos
5+
call motion_update_seg1 pascal, offset _player_pos
66
cmp ax, ((0 + PLAYER_MOVE_MARGIN_LEFT) shl 4)
77
jge short @@clamp_right?
88
mov ax, ((0 + PLAYER_MOVE_MARGIN_LEFT) shl 4)

th04/main/sparks.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sparks_update proc near
1717
@@update:
1818
lea ax, [si+spark_t.pos]
1919
push ax
20-
call _motion_update_1
20+
call motion_update_seg1
2121
add ax, ((SPARK_W / 2) shl 4)
2222
cmp ax, ((PLAYFIELD_W + SPARK_W) shl 4)
2323
jnb short @@remove

th04/math/motion.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ typedef struct {
1010
prev.y.set(screen_y);
1111
}
1212
} motion_t;
13+
14+
// Moves the given [motion] instance by one step, and returns its new position.
15+
// The _seg1() and _seg3() variants are provided for near calls within code
16+
// segment #1 (rendering) and code segment #3 (update), respectively.
17+
// Note that some calls to these functions directly access the returned value
18+
// through the AX (X) and DX (Y) registers.
19+
SPPoint pascal near motion_update_seg1(motion_t near &motion);
20+
SPPoint pascal near motion_update_seg3(motion_t near &motion);

th04/math/motion.inc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
; For increased precision, all values are stored in units of 1/16th of a pixel.
21
motion_t struc
32
cur Point ?
43
prev Point ?
54
velocity Point ?
65
motion_t ends
76

87
MOTION_UPDATE_DEF macro instance
9-
; Returns the new current position in AX (X) and DX (Y).
10-
;
11-
; Point pascal near motion_update(motion_t near *motion);
12-
public _MOTION_UPDATE_&instance
13-
_motion_update_&instance proc near
8+
public MOTION_UPDATE_SEG&instance
9+
motion_update_seg&instance proc near
1410
arg_bx near, @motion:word
1511

1612
mov bx, @motion
@@ -24,5 +20,5 @@ MOTION_UPDATE_DEF macro instance
2420
add dx, word ptr [bx+motion_t.velocity]
2521
mov word ptr [bx+motion_t.cur], dx
2622
ret_bx
27-
_motion_update_&instance endp
23+
motion_update_seg&instance endp
2824
endm

0 commit comments

Comments
 (0)