The design and the status of the development of the Level-0 endcap muon trigger firmware for the ATLAS experiment at the HL-LHC are presented. The firmware reconstructs muon candidates with an improved momentum resolution by exploiting all hit data from Thin Gap Chambers (TGCs) to be available at XCVU13P FPGA mounted on the trigger and readout boards. The track segment is reconstructed by a pattern matching algorithm, where the TGC hits are compared with predefined hit patterns. Each predefined hit pattern has associated position and angle of the track segment. The algorithm with minimal utilisation of the XCVU13P FPGA resource is a major challenge. We achieved 1 cm position and 4 mrad angular resolutions, which satisfy the requirements, with less than 40% of the UltraRAM resources for full coverage of TGCs. The performance was evaluated with the post-synthesis simulation with the hit inputs from GEANT4 full simulation. The implementation was succeeded with no timing violation by optimised latch circuit locations. The results constitute an important ingredients in the development of the Level-0 endcap muon trigger firmware for HL-LHC.