2019-02-27 17:05:22 +00:00
|
|
|
; Draws the hardcoded spark sprite with the given ID, with ([x], [vram_y])
|
|
|
|
; pointing to the top-left point. Assumptions:
|
|
|
|
; • The GRCG is active, and set to the intended color
|
|
|
|
; • [sprite_id] ≤ SPARK_SPRITES
|
|
|
|
|
|
|
|
; void pascal near spark_render(int x, int vram_y, int sprite_id);
|
|
|
|
spark_render proc near
|
|
|
|
@@sprite_id = word ptr 4
|
|
|
|
@@vram_y = word ptr 6
|
|
|
|
@@x = word ptr 8
|
|
|
|
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
mov ax, GRAM_400
|
|
|
|
mov es, ax
|
|
|
|
mov bx, [bp+@@x]
|
|
|
|
mov ax, bx
|
|
|
|
sar ax, 3 ; x /= 8
|
|
|
|
mov dx, [bp+@@vram_y]
|
|
|
|
shl dx, 6 ; [vram_y] * 64
|
|
|
|
add ax, dx
|
|
|
|
shr dx, 2 ; (([vram_y] * 64) / 4) = [vram_y] * 16
|
|
|
|
add ax, dx
|
|
|
|
mov di, ax ; ([vram_y] * 64) + ([vram_y] * 16) = [vram_y * ROW_SIZE]
|
|
|
|
mov ax, bx
|
|
|
|
and ax, 7 ; [x] & 7
|
|
|
|
shl ax, 7 ; *= SPARK_SIZE * SPARK_SPRITES (offset of X-shifted sprite)
|
|
|
|
mov dx, [bp+@@sprite_id]
|
|
|
|
shl dx, 4 ; sprite_ptr = [sprite_id] * SPARK_SIZE
|
|
|
|
add ax, dx
|
[Maintenance] Decide how to handle pre-shifted sprites in C land
Ideally, the future sprite compiler should automatically pre-shift such
sprites, and correctly place the shifted variants in memory, by merely
parsing the C header. On disk, you'd then only have a .BMP with each
individual cel at x=0.
And that's why we need macros and consistent naming: To express these
semantics, without having to duplicate the sprite declaration in some
other format. sSPARKS[8][8][8] wouldn't help anyone 😛
Now, we could go even further there by defining a separate type
(`preshifted_dots8_t`), and maybe get rid of the _W macro by replacing
it with a method on that type. However,
• that would be inconsistent, since we'll need the _H macro anyway, for
both the actual rendering code and the sprite compiler
• we couldn't directly call such a method on a 2D or 3D array, and have
to go down to a single element to do so (`sSPARKS[0][0][0].w()`)
• making it a static method instead duplicates the type all over the
code
• and any variables of that type would no longer be scalar-type values
that can be stored in registers, requiring weird workarounds in those
places. As we've already seen with subpixels.
Part of P0085, funded by -Tom-.
2020-03-25 14:22:51 +00:00
|
|
|
add ax, offset _sSPARKS
|
2019-02-27 17:05:22 +00:00
|
|
|
mov si, ax
|
|
|
|
mov cx, SPARK_H
|
|
|
|
|
|
|
|
@@blit_loop:
|
|
|
|
movsw
|
|
|
|
add di, (ROW_SIZE - SPARK_VRAM_W)
|
2020-02-05 21:45:59 +00:00
|
|
|
cmp di, PLANE_SIZE
|
2019-02-27 17:05:22 +00:00
|
|
|
jl short @@next_row
|
2020-02-05 21:45:59 +00:00
|
|
|
sub di, PLANE_SIZE
|
2019-02-27 17:05:22 +00:00
|
|
|
|
|
|
|
@@next_row:
|
|
|
|
loop @@blit_loop
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
|
|
|
retn 6
|
|
|
|
spark_render endp
|
|
|
|
even
|