2019-09-20 18:36:19 +00:00
|
|
|
.186 ; The 8086 couldn't into PUSH imm8?!
|
|
|
|
locals
|
|
|
|
|
|
|
|
include libs/master.lib/master.inc
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
include th03/arg_bx.inc
|
2020-04-05 14:17:33 +00:00
|
|
|
include th02/main/hud/hud.inc
|
2019-12-25 14:36:11 +00:00
|
|
|
include th04/gaiji/gaiji.inc
|
2019-09-20 18:36:19 +00:00
|
|
|
|
2020-08-27 20:26:02 +00:00
|
|
|
extrn _hud_gaiji_row:byte:HUD_KANJI_W
|
2019-09-20 18:36:19 +00:00
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
|
2020-04-28 16:10:07 +00:00
|
|
|
MAIN_01_TEXT segment word public 'CODE' use16
|
|
|
|
assume cs:MAIN_01_TEXT
|
2019-09-20 18:36:19 +00:00
|
|
|
|
|
|
|
; void pascal near hud_bar_put(
|
2023-11-27 09:32:04 +00:00
|
|
|
; utram_y_t y, unsigned char value, tram_atrb2 atrb
|
2019-09-20 18:36:19 +00:00
|
|
|
; );
|
|
|
|
public HUD_BAR_PUT
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
HUD_BAR_PUT proc near
|
|
|
|
arg_bx near, @atrb:word, @value:byte, @y:word
|
2019-09-20 18:36:19 +00:00
|
|
|
|
|
|
|
push di
|
|
|
|
push ds
|
|
|
|
pop es
|
|
|
|
mov di, offset _hud_gaiji_row
|
2020-08-25 18:29:24 +00:00
|
|
|
push HUD_LEFT
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
push @y
|
2019-09-20 18:36:19 +00:00
|
|
|
push ds
|
|
|
|
push di
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
push @atrb
|
2019-09-20 18:36:19 +00:00
|
|
|
mov al, g_BAR_MAX
|
2020-08-27 20:26:02 +00:00
|
|
|
mov cx, HUD_KANJI_W
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
mov bl, @value
|
2019-09-20 18:36:19 +00:00
|
|
|
cmp bl, BAR_MAX
|
|
|
|
jb short @@below_max
|
|
|
|
|
|
|
|
@@at_max:
|
|
|
|
stosb
|
|
|
|
inc al
|
|
|
|
loop @@at_max
|
|
|
|
jmp short @@put
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
@@below_max:
|
|
|
|
mov dl, bl
|
|
|
|
dec al
|
|
|
|
jmp short @@cell_still_fully_filled?
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
@@cell_is_fully_filled:
|
|
|
|
stosb
|
|
|
|
|
|
|
|
@@cell_still_fully_filled?:
|
|
|
|
dec cx
|
|
|
|
sub dl, BAR_GAIJI_MAX
|
|
|
|
jg short @@cell_is_fully_filled
|
|
|
|
mov al, bl
|
|
|
|
dec al
|
|
|
|
and al, BAR_GAIJI_MAX - 1
|
|
|
|
add al, G_BAR
|
|
|
|
stosb
|
|
|
|
mov al, g_EMPTY
|
|
|
|
rep stosb
|
|
|
|
|
|
|
|
@@put:
|
2020-04-28 16:10:07 +00:00
|
|
|
call GAIJI_PUTSA
|
2019-09-20 18:36:19 +00:00
|
|
|
pop di
|
[Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.
So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.
Part of P0134, funded by [Anonymous].
2021-02-10 11:51:14 +00:00
|
|
|
ret_bx
|
|
|
|
HUD_BAR_PUT endp
|
2020-04-28 16:10:07 +00:00
|
|
|
MAIN_01_TEXT ends
|
2019-09-20 18:36:19 +00:00
|
|
|
|
|
|
|
end
|