Commit Graph
199 Commits
Author SHA1 Message Date
Gleb Mazovetskiy aa2f88e5f6 Remove software cursor state for hardware cursor
Switching between software and hardware cursor could cause a glitch
as described in #5560.

Fixes #5560
2022-12-08 12:09:36 +01:00
Gleb Mazovetskiy 1addfc9e54 dun_render: Deduplicate trapezoid upper half 2022-12-05 05:17:24 +01:00
Gleb Mazovetskiy 63a042d0e3 dun_render: Simplify non-masked primitives
As we recently confirmed, Square and Left/RightTriangle primitives
never use masks other than Transparent and Solid.

Simplify the code to take advantage of that.
2022-12-05 05:17:24 +01:00
Gleb Mazovetskiy 55d25fd079 dun_render: Swap32LE the data offset 2022-12-05 05:05:55 +01:00
Gleb Mazovetskiy 79b330825d dun_render: Avoid Invalid tile type
1. Do not call `RenderTile` with invalid values to begin with.
2. Move mask selection out of `RenderTile`.
2022-12-05 01:32:29 +01:00
Gleb Mazovetskiy 44ed0296d8 dun_render: Overhaul mask handling
We notice that masks can be described by 2 parameters:

1. Whether they have 0 or 1 as their high bits.
2. Whether they shift to the left or to the right on the next line.

Describing masks this way allows us to lift them to template variables and simplify the code.
We also avoid handling the mask in the `RenderLine` loop entirely.

Also fixes a foliage rendering bug: Transparent foliage pixels were previously blended but they should have been simply skipped.
2022-12-04 21:53:52 +01:00
Gleb Mazovetskiy 5024bc0f07 Show FPS up to 1 decimal point
If FPS < 100, print it with 1 decimal point.
Useful for measuring performance impact on low-end devices.
2022-12-03 21:42:18 +01:00
Gleb Mazovetskiy 7a3882722e Text rendering and chat input fixes
1. Fixes the return value (bytes rendered).
2. Fixes line wrapping / end-of-rendering based on the given rectangle:
   1. Accounts for `BaseLineOffset`.
   2. Fixes an off-by-one error for the y coordinate.
   3. Wraps the cursor when needed.
3. Fix chat input box dimensions (height is 3 * line height).
4. Set the hint that indicates that we do not render the current
   IME suggestion (SDL_TEXTEDITING). This indicates to IME
   that it should render the suggestion instead.
2022-11-27 22:40:20 +00:00
Gleb Mazovetskiy aca4aae3c1 dun_render: Remove the use of LightTableIndex
Replaces the global with an argument.
2022-11-25 15:00:04 +01:00
Gleb Mazovetskiy 3afef6299f Level renderer: Remove cel_transparency/foliage_active globals 2022-11-25 15:00:04 +01:00
Gleb Mazovetskiy 1293dfb86d Level renderer: Remove level_piece_id global
`DrawFloor` now passes the piece ID into RenderTile.
Previously, `DrawFloor` did not set `level_piece_id`.
2022-11-25 14:16:30 +01:00
Gleb Mazovetskiy c616e0d6d2 Level renderer: Remove arch_draw_type global 2022-11-25 14:16:30 +01:00
Gleb Mazovetskiy 69c429bb68 Level renderer: Remove level_cel_block global 2022-11-25 14:16:30 +01:00
Gleb Mazovetskiy 5ac54027dc Text rendering: Clip text to the given rect
Previously, we only clipped to the given surface, without clipping to the given rect.
2022-11-22 04:54:21 +01:00
Gleb Mazovetskiy a7324a15c0 Item labels: Clip to viewport
Instead of redrawing the panel to avoid item label clipping, clip the labels themselves.
2022-11-22 03:14:58 +00:00
Gleb Mazovetskiy 9db80ef5d7 Assets: Load files directly for UNPACKED_MPQS
When using `UNPACKED_MPQS`, avoid all the SDL machinery for reading
files.

This is beneficial not only due to reduced indirection but also because
we can test for the file's existence and get the file size without
opening it, which is much faster.
2022-11-22 02:44:25 +01:00
Gleb Mazovetskiy 4c0b43508a DoBlitScreen: Fix update rects
Fixes chat input at 640x480.

Also fixes the other rects, they were slightly off.
2022-11-17 14:25:03 +01:00
obligaron dc3d797269 GetOffsetForWalking: use uint8_t for animation fraction 2022-11-11 13:29:00 +00:00
obligaron eca1a68bec AnimationInfo: Use fixed point math for fractions 2022-11-06 12:31:40 +00:00
Gleb Mazovetskiy 1da4be3839 Fix chat
Accidentally broken by #5453
2022-11-02 11:19:00 +00:00
Gleb Mazovetskiy 680ab5ec40 Overhaul backbuffer state handling
When rendering directly to the output buffer, we need to maintain the
state of what has been drawn and what needs redrawing per-buffer.

We previously tried to do it implicitly by checking `SDL_DOUBLEBUF` and
other flags. The previous implementation was broken in several
ways, resulting in rendering issues on devices that support 8-bit output
directly.

Changes this mechanism to explicitly maintain buffer state per output
buffer. The new mechanism doesn't require knowledge of the number of
buffers, and thus also works correctly with triple-buffering.

Fixes #5447
2022-11-01 02:43:24 +00:00
Gleb Mazovetskiy 0498d7d3a7 Fix compilation warnings 2022-10-29 13:41:23 +01:00
Gleb Mazovetskiy 41f43ea3f5 Support unpacked MPQs from devilutionx-mpq-tools
https://github.com/diasurgical/devilutionx-mpq-tools produces an unpacked MPQ
with all the graphics converted to CLX and the unused files removed.
This is primarily useful on RAM-constrained platforms, such as PS2,
because it eliminates the MPQ overhead.

Adds a build option to load from such unpacked directories instead of the MPQ.

These directories are searched for in the same locations
where the MPQs would be searched for otherwise.

Example directory layout:

* /usr/local/share/diasurgical/devilutionx/diabdat/ -- unpacked and converted diabdat.mpq
* /usr/local/share/diasurgical/devilutionx/hellfire/ -- unpacked and converted hellfire MPQs (all of them merged into 1 directory)
* /usr/local/share/diasurgical/devilutionx/fonts/ -- unpacked fonts.mpq
* /usr/local/share/diasurgical/devilutionx/pl/ -- unpacked pl.mpq

These directory structure is produced by calling `unpack_and_minify_mpq`
2022-10-11 18:00:57 +01:00
staphen 5de080541a Ensure that the last line of text does not exceed the lower bounds of the rectangle in DrawString() 2022-10-02 08:51:24 +02:00
staphen e580c26a1f Ensure that vertically aligned text does not exceed the upper bounds of the rectangle in DrawString() 2022-10-02 08:51:24 +02:00
obligaron a2ec22667f Use AnimationInfo::isLastFrame in more places 2022-09-04 18:00:16 +02:00
obligaron deb0d6d9e1 Use missile helpers in MoveMissile/UpdateMissileRendererData (#5291) 2022-08-26 21:50:42 +02:00
Gleb Mazovetskiy 188dc79f6e Make Players a vector 2022-08-26 13:22:04 +09:00
Gleb Mazovetskiy 6327e713e0 Lowercase all file paths
We want to be able to use unpacked MPQs on low-end platforms
(PS2/rg99/etc).

This is tricky on case-sensitive filesystems. Avoids case issues by
lowercasing all paths in the code (then we'll just need lowercased
listfiles).
2022-08-20 23:49:23 +01:00
obligaron 68891a8df1 Rename MissileMovementDistrubution => MissileMovementDistribution 2022-08-20 23:41:40 +02:00
Gleb Mazovetskiy 4cf0053ece Set underlying type for all the enums
Reduces rg99 binary size by 3 KiB.
2022-08-11 01:43:54 +02:00
Gleb Mazovetskiy 9b65eca49b Remove Art and related functions 2022-08-08 14:29:45 +01:00
Gleb Mazovetskiy 580d3cb6ee touch/renderers: Migrate away from Art 2022-08-08 14:29:45 +01:00
Gleb Mazovetskiy d71a54dba8 Render main panel buttons as CLX
Converted with:

```
pcx2clx --num-sprites 3 data/talkbutton.pcx && rm data/talkbutton.pcx
```

Sizes:

```
Surface(63, 114) -> CLX	7296 -> 5336	-26.9%
Surface(53, 48) -> CLX	2688 -> 2324	-13.5%
```
2022-08-04 15:16:00 +02:00
obligaron 2493f06116 ActorPosition: Remove offset, offset2 and velocity 2022-08-03 21:25:21 +02:00
obligaron a410e989bf Remove ScrollInfo 2022-08-03 21:25:21 +02:00
Gleb Mazovetskiy 8f7dd16ac3 Show an error on outdated devilutionx/font.mpq 2022-08-03 16:37:04 +02:00
Gleb Mazovetskiy 17a97450bc Convert assets to CLX
Converted using the following commands:

```
cd Packaging/resources/assets
pcx2clx --transparent-color 1 --num-sprites 256 fonts/*.pcx && rm fonts/*.pcx
pcx2clx --num-sprites 2 ui_art/dvl_but_sml.pcx && rm ui_art/dvl_but_sml.pcx
pcx2clx --transparent-color 1 data/hintbox.pcx data/hintboxbackground.pcx && rm data/hintbox.pcx data/hintboxbackground.pcx
pcx2clx --transparent-color 1 --num-sprites 6 data/hinticons.pcx && rm data/hinticons.pcx
pcx2clx --num-sprites 2 data/panel8buc.pcx data/dirtybuc.pcx data/dirtybucp.pcx && rm data/panel8buc.pcx data/dirtybuc.pcx data/dirtybucp.pcx
pcx2clx --transparent-color 1 data/healthbox.pcx && rm data/healthbox.pcx
pcx2clx --transparent-color 1 --num-sprites 6 data/resistance.pcx && rm data/resistance.pcx
pcx2clx --transparent-color 1 --num-sprites 5 data/monstertags.pcx && rm data/monstertags.pcx
pcx2clx --transparent-color 1 data/stash.pcx && rm data/stash.pcx
pcx2clx --transparent-color 1 --num-sprites 5 data/stashnavbtns.pcx && rm data/stashnavbtns.pcx
pcx2clx **/*.pcx && rm **/*.pcx
git checkout master -- ui_art/black_diablo.pcx ui_art/black_hellfire.pcx data/charbg.pcx data/talkbutton.pcx data/panel8bucp.pcx
rm ui_art/black_diablo.clx ui_art/black_hellfire.clx data/charbg.clx data/talkbutton.clx data/panel8bucp.clx
```
2022-08-03 16:37:04 +02:00
Gleb Mazovetskiy 0f0f57080c render: Move common_impl.h into clx_render.cpp
We no longer have other renderers.
2022-08-03 02:38:55 +02:00
Gleb Mazovetskiy 961866e1c4 CLX: A new graphics format
The format is almost identical to CL2, except it uses the frame header
to store frame width and height instead of 5 32-line offsets.

This means we always have access to frame dimensions, so we can use it
as an on-disk format for our graphics as well.

Additionally, we may be able to optimize the rendering even more
in the future now that we have guaranteed knowledge of frame dimensions.
2022-08-03 02:38:55 +02:00
Andrew James 480ab945e7 Only draw towners on their base tile (#5171) 2022-08-01 21:02:59 +10:00
obligaron c5ce29106e Fix left sideways walking monsters draw order 2022-07-30 14:11:08 +02:00
ephphatha 0ce76a3f13 Add Object lookup method to mimic map::at() 2022-07-28 12:47:13 +02:00
Gleb Mazovetskiy 1cdd76b617 Remove PCX rendering code
We no longer render PCX
2022-07-20 22:58:15 +01:00
Gleb Mazovetskiy 0cd035ef61 Load PCX as CL2
Similar to #5059, which converted CEL to CL2 at load time,
we now do the same for PCX.

Some size stats: https://gist.github.com/glebm/067bf1ec73f9d14514932cfe237e4e8e

Notably, fonts RAM usage is decreased by ~35%.
2022-07-20 22:58:15 +01:00
ephphatha 9e76cd4ab7 Use object pointer for pcursobj 2022-07-19 13:20:24 +02:00
Gleb Mazovetskiy 43a5d91074 Remove CEL rendering code
We no longer render CEL
2022-07-19 10:59:35 +02:00
Gleb Mazovetskiy 8ca71272b8 Load all CEL as CL2
Convert CEL files to CL2 at load time. CL2 format is more efficient and is about as fast to render.

CEL vs CL2 sizes, on dLvl 5: https://gist.github.com/glebm/9bbdd76962abcd4fd2405ecd3379af97

Memory:

* Peak memory (while loading): -300 KiB
* Memory in-game (dLvl5): -700 KiB
* RG99 binary size: -15 KiB (1333096 -> 1317192)

Performance on rg99:

* On average, -1 FPS in town.
* Same FPS in dungeon (20 FPS on dLvl 1).
2022-07-19 10:59:35 +02:00
Gleb Mazovetskiy f9b9a7de9d CL2 render: Point position argument
Bring the CL2 API closer to CEL and PCX.
2022-07-18 09:25:12 +02:00
Gleb Mazovetskiy 6f01fb6b79 Unify CEL/PCX/CL2 render functions
Except for the outline rendering.
2022-07-17 20:28:29 +02:00