diff --git a/th04/main/spark_render.asm b/th04/main/spark_render.asm index 6293fa34..18eea38a 100644 --- a/th04/main/spark_render.asm +++ b/th04/main/spark_render.asm @@ -23,38 +23,8 @@ public @spark_render and cx, 7 ; & (SPARK_SPRITES - 1) shl cx, 4 ; * SPARK_SIZE add si, cx - cmp bx, RES_Y - SPARK_H - ja short @@ywrap_needed - mov cx, SPARK_H ; CX = # of rows copied *before* Y wrap - xor bx, bx ; BX = # of rows copied *after* Y wrap - jmp short @@blit_loop -@@ywrap_needed: - mov cx, RES_Y - sub cx, bx - mov bx, SPARK_H - sub bx, cx - -@@blit_loop: - lodsw - or ah, ah - jz short @@8px - mov es:[di], ax - jmp short @@next_row - -@@8px: - or al, al - jz short @@next_row - mov es:[di], al - -@@next_row: - add di, ROW_SIZE - loop @@blit_loop - or bx, bx - jz short @@ret - sub di, PLANE_SIZE - xchg cx, bx - jmp short @@blit_loop + blit_dots16_empty2opt_emptyopt_roll , SPARK_H @@ret: pop di diff --git a/th04/sprites/blit.inc b/th04/sprites/blit.inc new file mode 100644 index 00000000..15c70c76 --- /dev/null +++ b/th04/sprites/blit.inc @@ -0,0 +1,53 @@ +; Shared sprite blitting macros +; ----------------------------- +; All of these assume that: +; • the GRCG to be active, and set to the intended color and tile +; • DS:SI being set to the source sprite data, and ES:DI to the intended +; destination byte within a VRAM plane. + +; Modes: +; • roll: Y-wrapped +; • empty2opt: Not writing the right 8 dots to VRAM if they are 0 +; • emptyopt: Writing nothing to VRAM if all 16 dots are 0 + +; Blitting [h] rows, with [top] being the first one. +blit_dots16_empty2opt_emptyopt_roll macro @@top:req, @@h:req + +@@rows_after_roll equ + + cmp @@top, (RES_Y - @@h) + ja short @@roll_needed + mov cx, @@h ; CX = # of rows copied *before* Y wrap + xor @@rows_after_roll, @@rows_after_roll + jmp short @@blit_loop + +@@roll_needed: + mov cx, RES_Y + sub cx, @@top + mov @@rows_after_roll, @@h + sub @@rows_after_roll, cx + even + +@@blit_loop: + lodsw + or ah, ah + jz short @@blit_al? + mov es:[di], ax + jmp short @@next_row + +@@blit_al?: + or al, al + jz short @@next_row + mov es:[di], al + +@@next_row: + add di, ROW_SIZE + loop @@blit_loop + or @@rows_after_roll, @@rows_after_roll + jz short @@blit_done + sub di, PLANE_SIZE + xchg cx, @@rows_after_roll + jmp short @@blit_loop + +@@blit_done: +endm diff --git a/th04_main.asm b/th04_main.asm index b623d8a9..d3f6dd40 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -23,6 +23,7 @@ BINARY = 'M' include ReC98.inc include th04/th04.inc include th04/sprites/main_pat.inc +include th04/sprites/blit.inc include th04/main/phase.inc include th04/main/bullet/pattypes.inc diff --git a/th05_main.asm b/th05_main.asm index 254236df..5e6ee7b6 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -23,6 +23,7 @@ BINARY = 'M' include ReC98.inc include th05/th05.inc include th05/sprites/main_pat.inc +include th04/sprites/blit.inc include th04/main/phase.inc include th05/main/bullet/pattypes.inc include th05/main/player/shot_types.inc