Commit Graph

34 Commits

Author SHA1 Message Date
Lephenixnoir 1f290006f1
Scrap some memory and somehow avoid heap fragmentation 2021-08-31 19:18:55 +02:00
Lephenixnoir fe82cef7c3
Add a powerful profiler (libprof) 2021-08-25 11:09:35 +02:00
Lephenixnoir 96c7a8bb11
Watch unaligned lumps and per-region free heap 2021-08-24 19:12:30 +02:00
Lephenixnoir d075ba2174
More progress in emulator build
I'd say this is about 70% complete to initial tests, then comes the
debugging. But that's for another day.
2021-08-14 15:11:37 +02:00
Lephenixnoir 2675d6d3aa
Progress in making the emulator build 2021-08-14 11:55:20 +02:00
Lephenixnoir 751d5f186d
Add a PRAM heap and move some of the data there
It's a 32-bit-access-only heap. On the Ultimate Doom WAD the amount of
data moved is about 17 kiB, which is not a lot, but arrays with 4-byte
elements are not easy to find in Doom.
2021-08-12 21:01:35 +02:00
Lephenixnoir 40fe796d85
Add a main screen option to warp to any episode 2021-08-04 18:44:59 +02:00
Lephenixnoir 92c8dcf56e
Restore white frame less agressively
OS does it on its own, so the transition is cleaner like that.
2021-08-04 18:24:37 +02:00
Lephenixnoir db01fa04f2
Set a black frame when not using direct-DD access 2021-08-04 15:11:03 +02:00
Lephenixnoir bb86fd1145
Add an option to start at any map 2021-08-04 11:34:02 +02:00
Lephenixnoir 4c3b0b8fe6
Place WAD fragment map in PRAM0 2021-08-04 09:56:24 +02:00
Lephenixnoir 3e79691ad1
Report CGDMalloc failures 2021-08-04 09:55:36 +02:00
Lephenixnoir b0c1f019e3
Find fragments in file map by binary search
This makes a noticeable difference in Ultimate Doom, which has a lot
more fragments by sheer file size.
2021-08-03 18:43:45 +02:00
Lephenixnoir 9baaeb6d19
Store fragments' file address, not length
Cumulating lengths will allow a binary search for faster lookup. This is
important because performance seems to vary wildly with the number of
fragments, which I suspect is related to the linear search algorithms
(as there are often several hundred fragments).

Performance had dropped to 3.5s from 2.9s since last test, and
surprisingly this change pulls it back up to 2.9s, even though the
number of fragments now (150) is still more than during the first test
(100).

I suspect binary search will improve performance again. This would be
very helpful, as it would prove that WAD access is the primary
bottleneck for the game. Unlike actual game code, WAD access is
something we can look at and even optimize.
2021-08-03 17:50:27 +02:00
Lephenixnoir dce39fcbf5
Offer Bfile vs. mmap dynamically 2021-08-02 21:55:39 +02:00
Lephenixnoir b1f8a97983
UI improvements and sprintf 2021-08-02 21:11:13 +02:00
Lephenixnoir 4e7fa7781e
Add some custom UI for game selection and options 2021-08-02 19:19:42 +02:00
Lephenixnoir e18b08d5e4
Add a file loading progress bar
The bar takes up a little bit of time too, but I think it's a plus.
Currently it's limited to ~20 frames which is normally < 0.3s. A frame
every fragment is disastrous in comparison (loading time x3 lol).
2021-07-29 11:40:09 +02:00
Lephenixnoir 72ab09a35a
Remove performance indications 2021-07-28 23:16:28 +02:00
Lephenixnoir 55f9d43237
Optimize loading speed (x2.7) and game speed (+35%)
Loading is measured by RTC_GetTicks().

* Initial version: 9.8s
  This was a regression due to using 512-byte sectors instead of 4 kiB
  clusters as previously.

* Do BFile reads of 4 kiB: 5.2s (-47%)
  Feels similar to original code, I'll take this as my baseline.

* Test second half of Flash first: 3.6s (-31%)
  By reading from FLASH_FS_HINT to FLASH_END first many OS sectors can
  be skipped (without missing on other sectors just in case).

* Load to XRAM instead or RAM with BFile
  The DMA is 10% slower to XRAM than to RAM, but this benefits memcmp()
  because of faster memory accesses through the operand bus. No effect
  at this point, but ends up saving 8% after memcmp is optimized.

* Optimize memcmp for sectors: 3376 ms (-8%)
  The optimized memcmp uses word accesses for ROM (which is fastest),
  and weaves loop iterations to exploit superscalar parallelism.

* Search sectors most likely to contain data first: 2744 ms (-19%)
  File fragments almost always start on 4-kiB boundaries between
  FLASH_FS_HINT and FLASH_END, so these are tested first.

* Index most likely sectors, improve FLASH_FS_HINT: 2096 ms (-24%)
  Most likely sectors are indexed by first 4 bytes and binary searched,
  and a slightly larger region is considered for hints. The cache hits
  119/129 fragments in my case.

* Use optimized memcmp for consecutive fragments: 1408 ms (-33%)
  I only set it for the search of the first sector in each fragment and
  forgot to use it where it is really needed. x)

Game speed is measured roughly by the time it takes to hit a wall by
walking straight after spawning in Hangar.

* Initial value: 4.4s

* Use cached ROM when loading data from the WAD: 2.9s (-35%)
  Cached accesses are quite detrimental for sector search, I assume
  because everything is aligned like crazy, but it's still a major help
  when reading sequential data in real-time.
2021-07-28 23:06:42 +02:00
Lephenixnoir c04efa5319
Measure file mapping time 2021-07-27 18:43:20 +02:00
Lephenixnoir 75c8730451
Restore fast copies using the fxlibc memcpy() 2021-07-27 15:05:42 +02:00
Lephenixnoir d7ee5a1bbb
Restore video system screens and memcpy bug in V_CopyRect
* Restore screen numbers; BG is 4, at least in the ST module.
* Let ST module allocate BG, which is just 32 pixels high and not a full
  VRAM (huge memory gain!)
* Fix V_CopyRect() not working because memcpy is still broken (this will
  be changed later with a proper memcpy)
2021-07-27 14:20:14 +02:00
Lephenixnoir 271d9d588d
Clean up more warnings 2021-07-27 11:34:35 +02:00
Lephenixnoir 91f8dca1cb
Clean up more very old or unusable code 2021-07-27 11:19:39 +02:00
Lephenixnoir f477b87e50
Clean up file access + allow using BFile as an option
BFile can now be selected in <platform.h> by defining CGDOOM_WAD_BFILE
instead of CGDOOM_WAD_MAPPING. The DMA option is not implemented yet.

BFile works as expected - a lot of stuttering due to reads during
gameplay. But the status bar texture still doesn't load properly!
2021-07-27 11:12:31 +02:00
Lephenixnoir fabdac0b33
Copy manually from flash instead of syscall memcpy
It sure looks like it's broken in certain situations, altough only a
complete disassembly would prove that.
2021-07-26 17:33:00 +02:00
Lephenixnoir f869f45d0d
Split in ROM sectors of 512 bytes instead of clusters of 4 kiB
This makes the search quite a bit slower, I'll look into that later.
2021-07-26 17:25:26 +02:00
Lephenixnoir 7a75e46715
Use memset() in CGDCalloc() again
The bug was libfxcg's sys_calloc() using a memsetZero() function which
simply doesn't work properly.
2021-07-17 16:36:31 +02:00
Lephenixnoir 29b0bffc21
Initialize memory allocator with 422 kB system stack
Instead of ProgrammerNerd's in-user-stack 256 kB stack which works both
quickly hits its size limit when playing.
2021-07-17 10:50:20 +02:00
Lephenixnoir 7db1f33862
Don't use memset() in CGDCalloc
I have no idea why it doesn't work, but it doesn't.
2021-07-17 10:48:38 +02:00
Lephenixnoir 670e3a4b50
Improve I_ErrorI for 32-bit output 2021-07-17 10:47:37 +02:00
Computer Nerd 6bd7e296b4 Possible CG-50 update. 2019-04-04 00:11:35 -05:00
ComputerNerd bd6bb43473 Inital commit 2015-04-14 19:16:51 -05:00