diff --git a/th04/main/scroll.hpp b/th04/main/scroll.hpp new file mode 100644 index 000000000..673447145 --- /dev/null +++ b/th04/main/scroll.hpp @@ -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); diff --git a/th04/main/scroll[bss].asm b/th04/main/scroll[bss].asm index 49bb0ee7e..bd77697d7 100644 --- a/th04/main/scroll[bss].asm +++ b/th04/main/scroll[bss].asm @@ -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 diff --git a/th04/main/scroll_y_1.asm b/th04/main/scroll_y_1.asm index 67c5c42b6..b8e06f314 100644 --- a/th04/main/scroll_y_1.asm +++ b/th04/main/scroll_y_1.asm @@ -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 diff --git a/th04/main/scroll_y_3.asm b/th04/main/scroll_y_3.asm index 859e4b2e7..63dbdd396 100644 --- a/th04/main/scroll_y_3.asm +++ b/th04/main/scroll_y_3.asm @@ -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 diff --git a/th04/main/tiles_invalidate.asm b/th04/main/tiles_invalidate.asm index 21dd8372c..2574c3c2a 100644 --- a/th04/main/tiles_invalidate.asm +++ b/th04/main/tiles_invalidate.asm @@ -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 diff --git a/th04/main/tiles_invalidate[bss].asm b/th04/main/tiles_invalidate[bss].asm index c74ad2fd6..792e2f7b3 100644 --- a/th04/main/tiles_invalidate[bss].asm +++ b/th04/main/tiles_invalidate[bss].asm @@ -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 diff --git a/th04_main.asm b/th04_main.asm index 52f5a4a52..609924338 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -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 diff --git a/th05_main.asm b/th05_main.asm index f26d773cd..0b853fecc 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -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