From 0f3359e1b3d3d1b65065bacbcfb3d85b8d999815 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 5 Feb 2020 22:45:59 +0100 Subject: [PATCH] [Maintenance] Use @@locals for self-modifying code in bfnt_entry_pat() Which finally allows us to use the PLANE_SIZE macro in ASM land. Yeah, (ROW_SIZE * RES_Y) has finally got old. Part of P0073, funded by [Anonymous] and -Tom-. --- libs/master.lib/bfnt_entry_pat.asm | 16 ++++++++-------- pc98.inc | 3 +-- th02/music/music.asm | 6 +++--- th02/spark_render.asm | 4 ++-- th03/music/draw_cmt.asm | 2 +- th04/bgimage.asm | 12 ++++++------ th04/formats/cdg_put_plane_roll.asm | 6 +++--- th04/hardware/egccopyr.asm | 2 +- th04/spark_render.asm | 2 +- th04_main.asm | 4 ++-- th05/formats/pi_slot_put_mask.asm | 4 ++-- th05_main.asm | 4 ++-- 12 files changed, 32 insertions(+), 33 deletions(-) diff --git a/libs/master.lib/bfnt_entry_pat.asm b/libs/master.lib/bfnt_entry_pat.asm index bff60743..2ba46b7e 100644 --- a/libs/master.lib/bfnt_entry_pat.asm +++ b/libs/master.lib/bfnt_entry_pat.asm @@ -79,10 +79,10 @@ func BFNT_ENTRY_PAT ; bfnt_entry_pat() { @@clear_color = (RETSIZE+1)*2 mov AX,[BP+@@clear_color] - mov CS:bftentry_color,AX + mov CS:@@color,AX mov CS:_DS_,DS mov AX,[BP+@@handle] - mov CS:bftentry_file_handle,AX + mov CS:@@file_handle,AX _push DS _lds BX,[BP+@@header] mov AX,(bfnt_header PTR [BX]).Xdots @@ -98,9 +98,9 @@ func BFNT_ENTRY_PAT ; bfnt_entry_pat() { mov CS:@@patsize,DX mov BYTE PTR CS:[@@ysize],CL mul CX - mov CS:plane_size,AX + mov CS:@@plane_size,AX shl AX,2 ;pattern size (BRGI) - mov CS:read_byte,AX + mov CS:@@read_byte,AX xchg BX,AX push BX _call SMEM_WGET @@ -115,9 +115,9 @@ func BFNT_ENTRY_PAT ; bfnt_entry_pat() { mov DS,CX @@NEXT_PATTERN: - JMOV CX,read_byte + JMOV CX,@@read_byte xor DX,DX - JMOV BX,bftentry_file_handle + JMOV BX,@@file_handle mov AH,3fh int 21h ;read handle @@ -133,7 +133,7 @@ endif jmp BFTENTRY_INVAL @@NEXT_PATTERN_2: xor SI,SI - JMOV DX,plane_size + JMOV DX,@@plane_size xor BX,BX @@ -211,7 +211,7 @@ B2V_LOOP: push ES ; seg addr xor AX,AX push AX ;offset address - JMOV AX,bftentry_color ;clear_color + JMOV AX,@@color ;clear_color push AX _call SUPER_ENTRY_PAT ; (patsize, far addr, clear_color) diff --git a/pc98.inc b/pc98.inc index cffe80ae..9197d303 100644 --- a/pc98.inc +++ b/pc98.inc @@ -16,7 +16,6 @@ GLYPH_H = 16 RES_X = 640 RES_Y = 400 ROW_SIZE = (RES_X / 8) -; Collides with master.lib's bfnt_entry_pat.asm -; PLANE_SIZE = (ROW_SIZE * RES_Y) +PLANE_SIZE = (ROW_SIZE * RES_Y) COLOR_COUNT = 16 ; ======== diff --git a/th02/music/music.asm b/th02/music/music.asm index 329ec16f..b08bb5af 100644 --- a/th02/music/music.asm +++ b/th02/music/music.asm @@ -15,7 +15,7 @@ screen_back_B_snap proc near push bp mov bp, sp push si - call hmem_allocbyte pascal, (ROW_SIZE * RES_Y) + call hmem_allocbyte pascal, PLANE_SIZE mov _screen_back_B, ax xor si, si jmp short loc_A5DF @@ -30,7 +30,7 @@ loc_A5CA: add si, 4 loc_A5DF: - cmp si, (ROW_SIZE * RES_Y) + cmp si, PLANE_SIZE jl short loc_A5CA pop si pop bp @@ -62,7 +62,7 @@ screen_back_B_put proc near mov ds, ax xor di, di xor si, si - mov cx, (ROW_SIZE * RES_Y) / 2 + mov cx, (PLANE_SIZE / 2) rep movsw pop ds pop di diff --git a/th02/spark_render.asm b/th02/spark_render.asm index 82307a21..273ee79d 100644 --- a/th02/spark_render.asm +++ b/th02/spark_render.asm @@ -37,9 +37,9 @@ spark_render proc near @@blit_loop: movsw add di, (ROW_SIZE - SPARK_VRAM_W) - cmp di, (ROW_SIZE * RES_Y) + cmp di, PLANE_SIZE jl short @@next_row - sub di, (ROW_SIZE * RES_Y) + sub di, PLANE_SIZE @@next_row: loop @@blit_loop diff --git a/th03/music/draw_cmt.asm b/th03/music/draw_cmt.asm index 58af3b52..9e7e230a 100644 --- a/th03/music/draw_cmt.asm +++ b/th03/music/draw_cmt.asm @@ -52,7 +52,7 @@ loc_ABE5: add si, 4 loc_ABFA: - cmp si, (ROW_SIZE * RES_Y) + cmp si, PLANE_SIZE jl short loc_ABE5 pop di pop si diff --git a/th04/bgimage.asm b/th04/bgimage.asm index e860cb4e..c2d96730 100644 --- a/th04/bgimage.asm +++ b/th04/bgimage.asm @@ -4,13 +4,13 @@ bgimage_snap proc far push di cmp bgimage_PL_B, 0 jnz short @@already_allocated - call hmem_allocbyte pascal, (ROW_SIZE * RES_Y) + call hmem_allocbyte pascal, PLANE_SIZE mov bgimage_PL_B, ax - call hmem_allocbyte pascal, (ROW_SIZE * RES_Y) + call hmem_allocbyte pascal, PLANE_SIZE mov bgimage_PL_R, ax - call hmem_allocbyte pascal, (ROW_SIZE * RES_Y) + call hmem_allocbyte pascal, PLANE_SIZE mov bgimage_PL_G, ax - call hmem_allocbyte pascal, (ROW_SIZE * RES_Y) + call hmem_allocbyte pascal, PLANE_SIZE mov bgimage_PL_E, ax @@already_allocated: @@ -30,7 +30,7 @@ bgimage_snap proc far pop ds xor si, si xor di, di - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) rep movsd dec dl jnz short @@next_plane @@ -61,7 +61,7 @@ bgimage_put proc far pop es xor si, si xor di, di - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) rep movsd dec dl jnz short @@next_plane diff --git a/th04/formats/cdg_put_plane_roll.asm b/th04/formats/cdg_put_plane_roll.asm index 2d2686cf..01ba84e5 100644 --- a/th04/formats/cdg_put_plane_roll.asm +++ b/th04/formats/cdg_put_plane_roll.asm @@ -47,9 +47,9 @@ cdg_put_plane_roll proc far @@plane_src_num_to_offset: add si, ax loop @@plane_src_num_to_offset - cmp di, (ROW_SIZE * RES_Y) + cmp di, PLANE_SIZE jb short @@start_blitting - sub di, (ROW_SIZE * RES_Y) + sub di, PLANE_SIZE @@start_blitting: cld @@ -67,7 +67,7 @@ cdg_put_plane_roll proc far loop @@blit_dword sub di, @@stride_backwards jge short @@more_rows? - add di, (ROW_SIZE * RES_Y) + add di, PLANE_SIZE @@more_rows?: dec @@h diff --git a/th04/hardware/egccopyr.asm b/th04/hardware/egccopyr.asm index 00e18672..77093a53 100644 --- a/th04/hardware/egccopyr.asm +++ b/th04/hardware/egccopyr.asm @@ -53,7 +53,7 @@ endif if GAME eq 5 or di, di js short @@skip - cmp di, (ROW_SIZE * RES_Y) + cmp di, PLANE_SIZE jnb short @@skip endif mov al, 1 diff --git a/th04/spark_render.asm b/th04/spark_render.asm index 7dcf8f6b..2a3eba84 100644 --- a/th04/spark_render.asm +++ b/th04/spark_render.asm @@ -52,7 +52,7 @@ public @spark_render loop @@blit_loop or bx, bx jz short @@ret - sub di, (ROW_SIZE * RES_Y) + sub di, PLANE_SIZE xchg cx, bx jmp short @@blit_loop diff --git a/th04_main.asm b/th04_main.asm index ed62f46a..6c59942a 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -12663,11 +12663,11 @@ sub_12024 proc near mov ax, 1 out 0A6h, ax xor di, di - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) rep stosd xor ax, ax out 0A6h, ax - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) xor di, di rep stosd pop di diff --git a/th05/formats/pi_slot_put_mask.asm b/th05/formats/pi_slot_put_mask.asm index 84a80f3c..35105956 100644 --- a/th05/formats/pi_slot_put_mask.asm +++ b/th05/formats/pi_slot_put_mask.asm @@ -120,9 +120,9 @@ TEMP_ROW = RES_Y push si mov di, _pi_put_mask_vram_offset add _pi_put_mask_vram_offset, ROW_SIZE - cmp _pi_put_mask_vram_offset, (ROW_SIZE * RES_Y) + cmp _pi_put_mask_vram_offset, PLANE_SIZE jb short @@next_row - sub _pi_put_mask_vram_offset, (ROW_SIZE * RES_Y) + sub _pi_put_mask_vram_offset, PLANE_SIZE @@next_row: call pi_egc_mask diff --git a/th05_main.asm b/th05_main.asm index 446a69ae..95123751 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -3838,11 +3838,11 @@ sub_CFEE proc near mov ax, 1 out 0A6h, ax xor di, di - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) rep stosd xor ax, ax out 0A6h, ax - mov cx, (ROW_SIZE * RES_Y) / 4 + mov cx, (PLANE_SIZE / 4) xor di, di rep stosd pop di