diff --git a/th02/main/pointnum/pointnum.cpp b/th02/main/pointnum/pointnum.cpp index 1da54a6d..93647825 100644 --- a/th02/main/pointnum/pointnum.cpp +++ b/th02/main/pointnum/pointnum.cpp @@ -5,8 +5,11 @@ #include "th01/rank.h" #include "th02/v_colors.hpp" #include "th02/core/globals.hpp" +#include "th02/hardware/pages.hpp" #include "th02/main/entity.hpp" +#include "th02/main/playfld.hpp" #include "th02/main/pointnum/pointnum.hpp" +#include "th02/main/tile/tile.hpp" #include "th02/sprites/pointnum.h" #pragma option -a2 @@ -77,3 +80,29 @@ void pascal near pointnums_add( } } } + +void near pointnums_invalidate(void) +{ + for(int i = 0; i < POINTNUM_COUNT; i++) { + if(pointnums.flag[i] == F_FREE) { + continue; + } + + tiles_invalidate_rect( + pointnums.left[i], + pointnums.top[i][page_back], + + // Adding the trailing 0, operator, and operand. + // ZUN bloat: And one unnecessary glyph? + (POINTNUM_W * (POINTNUM_DIGITS + 3 + 1)), + + POINTNUM_H + ); + + if(pointnums.flag[i] == F_REMOVE) { + pointnums.flag[i] = F_FREE; + } else { + pointnums.top[i][page_back] = pointnums.top[i][page_front]; + } + } +} diff --git a/th02/main/pointnum/pointnum.hpp b/th02/main/pointnum/pointnum.hpp index f520f05f..76a17feb 100644 --- a/th02/main/pointnum/pointnum.hpp +++ b/th02/main/pointnum/pointnum.hpp @@ -1,4 +1,9 @@ +// Significant, internal digits. An additional 0 is appended to the on-screen +// representation. +static const int POINTNUM_DIGITS = 4; + void near pointnums_init_for_rank_and_reset(void); +void near pointnums_invalidate(void); void pascal near pointnums_add( screen_x_t left, screen_y_t top, uint16_t points ); diff --git a/th02/sprites/pointnum.h b/th02/sprites/pointnum.h index 30a1478f..fd1a782b 100644 --- a/th02/sprites/pointnum.h +++ b/th02/sprites/pointnum.h @@ -1,3 +1,6 @@ +static const pixel_t POINTNUM_W = 8; +static const pixel_t POINTNUM_H = 8; + enum pointnum_cel_t { POINTNUM_0, POINTNUM_1, diff --git a/th02_main.asm b/th02_main.asm index 644e34d5..89af8614 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -2815,71 +2815,11 @@ POINTNUM_TEXT segment byte public 'CODE' use16 @pointnums_init_for_rank_and_rese$qv procdesc near @POINTNUMS_ADD$QIIUI procdesc pascal near \ left:word, top:word, points:word + @pointnums_invalidate$qv procdesc near POINTNUM_TEXT ends main_01__TEXT segment byte public 'CODE' use16 -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C81D proc near - push bp - mov bp, sp - push si - xor si, si - jmp short loc_C885 -; --------------------------------------------------------------------------- - -loc_C825: - cmp _pointnums.PN_flag[si], F_FREE - jz short loc_C884 - mov bx, si - add bx, bx - push _pointnums.PN_left[bx] ; left - mov bx, si - shl bx, 2 - mov al, _page_back - mov ah, 0 - add ax, ax - add bx, ax - push _pointnums.PN_top[bx] ; top - push (64 shl 16) or 8 ; (w shl 16) or h - call @tiles_invalidate_rect$qiiii - cmp _pointnums.PN_flag[si], F_REMOVE - jnz short loc_C85F - mov _pointnums.PN_flag[si], F_FREE - jmp short loc_C884 -; --------------------------------------------------------------------------- - -loc_C85F: - mov bx, si - shl bx, 2 - mov al, _page_front - mov ah, 0 - add ax, ax - add bx, ax - mov ax, _pointnums.PN_top[bx] - mov bx, si - shl bx, 2 - mov dl, _page_back - mov dh, 0 - add dx, dx - add bx, dx - mov _pointnums.PN_top[bx], ax - -loc_C884: - inc si - -loc_C885: - cmp si, POINTNUM_COUNT - jl short loc_C825 - pop si - pop bp - retn -sub_C81D endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -5193,7 +5133,7 @@ loc_D8F9: loc_D8FA: cmp si, 14h jl short loc_D880 - call sub_C81D + call @pointnums_invalidate$qv pop di pop si leave