[Maintenance] [th04/th05] Declare scrolling variables and functions in C land

Part of P0089, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2020-04-30 19:24:28 +02:00
parent 708d9fc8ac
commit 5531ed9b8b
8 changed files with 34 additions and 21 deletions

24
th04/main/scroll.hpp Normal file
View File

@ -0,0 +1,24 @@
// [scroll_line] is advanced by 1 for every 16 units.
extern SubpixelLength8 scroll_subpixel_line;
// Amount to add to [scroll_subpixel_line] every frame.
extern SubpixelLength8 scroll_speed;
// Current line at the top of VRAM.
extern int scroll_line;
extern int scroll_line_on_page[2];
// Playfield-space pixels scrolled in the last frame.
extern Subpixel scroll_last_delta;
// If false, the game doesn't draw stage tiles, assuming that someone else
// draws the background.
extern bool scroll_active;
// Transforms [y] to its corresponding VRAM line, adding the current
// [scroll_line] or 0 if scrolling is disabled.
int pascal near scroll_subpixel_y_to_vram_seg1(subpixel_t y);
int pascal near scroll_subpixel_y_to_vram_seg3(subpixel_t y);
// Like the one above, but always adds [scroll_line], even if scrolling is
// disabled.
int pascal near scroll_subpixel_y_to_vram_always(subpixel_t y);

View File

@ -1,12 +1,7 @@
public _scroll_subpixel_line, _scroll_speed, _scroll_line, _scroll_active
; [scroll_line] is advanced by 1 for every 16 units.
_scroll_subpixel_line db ?
; Amount to add to [_scroll_subpixel_line] every frame.
_scroll_speed db ?
; Current line at the top of VRAM.
_scroll_line dw ?
; Amount of 1/16th-pixel units scrolled in the last frame.
_scroll_last_delta dw ?
; If set to 0, the game assumes that the background is drawn by someone else!
_scroll_active db ?
db ?
evendata

View File

@ -1,7 +1,3 @@
; Transforms the 1/16-pixel on-screen Y coordinate [sy] to its corresponding
; VRAM line given the current scrolling offset.
; int pascal near scroll_subpixel_y_to_vram(int sy);
public SCROLL_SUBPIXEL_Y_TO_VRAM_SEG1
scroll_subpixel_y_to_vram_seg1 proc near
@@sy = word ptr 2

View File

@ -1,4 +1,3 @@
; See scroll_subpixel_y_to_vram_seg1().
public SCROLL_SUBPIXEL_Y_TO_VRAM_SEG3
scroll_subpixel_y_to_vram_seg3 proc near
@@sy = word ptr 2
@ -26,7 +25,6 @@ scroll_subpixel_y_to_vram_seg3 proc near
scroll_subpixel_y_to_vram_seg3 endp
; Like the one above, but transforming even if scrolling is disabled.
public SCROLL_SUBPIXEL_Y_TO_VRAM_ALWAYS
scroll_subpixel_y_to_vram_always proc near
@@sy = word ptr 2

View File

@ -53,7 +53,7 @@ tiles_invalidate_around proc near
mov bh, 0
mov bl, _page_back
add bx, bx
add ax, _scroll_line_on_plane[bx]
add ax, _scroll_line_on_page[bx]
jns short @@scroll_wrap?
add ax, RES_Y
jmp short @@invalidate

View File

@ -1,3 +1,3 @@
public _scroll_line_on_plane, _tile_invalidate_box
_scroll_line_on_plane dw 2 dup(?)
public _scroll_line_on_page, _tile_invalidate_box
_scroll_line_on_page dw 2 dup(?)
_tile_invalidate_box Point <?>

View File

@ -920,8 +920,8 @@ sub_B1D0 proc near
mov byte_2D00A, 0
mov _scroll_line, 0
mov word_25100, 0
mov _scroll_line_on_plane[0 * 2], 0
mov _scroll_line_on_plane[1 * 2], 0
mov _scroll_line_on_page[0 * 2], 0
mov _scroll_line_on_page[1 * 2], 0
mov _scroll_subpixel_line, 0
mov byte_25104, 0
mov byte_250FE, 0
@ -2516,7 +2516,7 @@ sub_CCD6 proc near
add ax, ax
mov dx, _scroll_line
mov bx, ax
mov _scroll_line_on_plane[bx], dx
mov _scroll_line_on_page[bx], dx
cmp byte_250FE, 0
jz short loc_CCFE
cmp _scroll_active, 0

View File

@ -1074,8 +1074,8 @@ sub_B55A proc near
mov byte_2C96C, 0
mov _scroll_line, 0
mov word_23F06, 0
mov _scroll_line_on_plane[0 * 2], 0
mov _scroll_line_on_plane[1 * 2], 0
mov _scroll_line_on_page[0 * 2], 0
mov _scroll_line_on_page[1 * 2], 0
mov _scroll_subpixel_line, 0
mov byte_23EFC, 0
mov byte_23F04, 0
@ -7473,7 +7473,7 @@ loc_10223:
add ax, ax
mov dx, _scroll_line
mov bx, ax
mov _scroll_line_on_plane[bx], dx
mov _scroll_line_on_page[bx], dx
cmp byte_23F04, 0
jz short loc_1024F
cmp _scroll_active, 0