Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNG support and loading of internal resources from pk3 #1688

Closed
wants to merge 2 commits into from

Conversation

rfomin
Copy link
Collaborator

@rfomin rfomin commented May 10, 2024

  • Add support for "sprites" and "colormaps" directories.
  • Move predefined lumps and autoload files to "base".
  • Remove -dumplumps and -dumptables.

Question: Should we add support for "textures" folder and TX_START/TX_END markers? https://zdoom.org/wiki/TX_START

* Add support for "sprites" and "colormaps" directories.

* Move predefined lumps and autoload files to "base".

* Remove -dumplumps and -dumptables.
@fabiangreffrath
Copy link
Owner

This would be a lot easier to review without all these W_CacheLumpName() -> V_CacheLumpName() renames.

@rfomin
Copy link
Collaborator Author

rfomin commented May 11, 2024

This would be a lot easier to review without all these W_CacheLumpName() -> V_CacheLumpName() renames.

But then it won't work - it will crash in menus, etc. We can check for PNG graphics at the w_wad level, but that's irrelevant for most W_CacheLump* calls. I can revert the last commit or split this PR into two.

The code changes that matter are in v_patch.c, d_main.c and w_wad.c. What do you think of this approach in general? (using libspng, function V_CacheLumpNum).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these sounds converted directly from dogs.h? I just want to make sure it still has the fade-in fix applied to prevent clicking: https://github.com/fabiangreffrath/woof/pull/1220/files#diff-e3deb8687f39858b8fc845f21d5d902ba1f941418098989d4bef053ddcd0306aR3567-R3568

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these sounds converted directly from dogs.h?

Yes. I dumped all the internal lumps with -dumplumps and then converted all the graphics and sounds with SLADE.

@liPillON
Copy link

liPillON commented May 11, 2024

ooh shiny new features to comment on, once again! ;)

I tried this out and I was worried at first because I noticed the UMAPDEF lumps are now in woof.pk3 and thought they might have conflicted with the midi/qol/fix pwads I usually load for both NERVE.WAD and MASTERLEVELS.WAD.
Turns out that the pwad-provided UMAPINFO lump overrides what's present in UMAPDEF, regardles of their load order... Today I learned something new after all these years.. (I used to delete the autoload folders I was not interested in)

Anyway.. Looking forward to this!
Go team!

For reference, the following is the verbose log output I get when running
.\woof.exe -iwad DOOM2.WAD -file NERVE.ZIP -config ..\!DOOM2.WAD+NERVE.ZIP\woof.cfg -save ..\!DOOM2.WAD+NERVE.ZIP\

Details
Woof 14.5.0 (built on May 10 2024)

M_LoadDefaults: Load system defaults.
 default file: ..\!DOOM2.WAD+NERVE.ZIP\woof-TMATE.cfg

IWAD found: ..\iwad\DOOM2.WAD
DOOM II version

Savegame directory: ..\!DOOM2.WAD+NERVE.ZIP

W_Init: Init WADfiles.
 adding ..\iwad\DOOM2.WAD
 adding %TEMP%\_woof_woof.pk3\all-all\animated.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crblack.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crblue.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crblue2.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crbrick.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crbrown.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crgold.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crgray.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crgreen.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crorange.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\cross00.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross01.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross02.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross03.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross04.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross05.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross06.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross07.png
 adding %TEMP%\_woof_woof.pk3\all-all\cross08.png
 adding %TEMP%\_woof_woof.pk3\all-all\crpurple.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crred.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crtan.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\crwhite.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\cryellow.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\dig0.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig1.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig2.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig3.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig37.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig4.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig43.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig45.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig46.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig47.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig5.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig58.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig6.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig7.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig8.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig9.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig91.png
 adding %TEMP%\_woof_woof.pk3\all-all\dig93.png
 adding %TEMP%\_woof_woof.pk3\all-all\diga.png
 adding %TEMP%\_woof_woof.pk3\all-all\digb.png
 adding %TEMP%\_woof_woof.pk3\all-all\digc.png
 adding %TEMP%\_woof_woof.pk3\all-all\digd.png
 adding %TEMP%\_woof_woof.pk3\all-all\dige.png
 adding %TEMP%\_woof_woof.pk3\all-all\digf.png
 adding %TEMP%\_woof_woof.pk3\all-all\digg.png
 adding %TEMP%\_woof_woof.pk3\all-all\digh.png
 adding %TEMP%\_woof_woof.pk3\all-all\digi.png
 adding %TEMP%\_woof_woof.pk3\all-all\digj.png
 adding %TEMP%\_woof_woof.pk3\all-all\digk.png
 adding %TEMP%\_woof_woof.pk3\all-all\digl.png
 adding %TEMP%\_woof_woof.pk3\all-all\digm.png
 adding %TEMP%\_woof_woof.pk3\all-all\dign.png
 adding %TEMP%\_woof_woof.pk3\all-all\digo.png
 adding %TEMP%\_woof_woof.pk3\all-all\digp.png
 adding %TEMP%\_woof_woof.pk3\all-all\digq.png
 adding %TEMP%\_woof_woof.pk3\all-all\digr.png
 adding %TEMP%\_woof_woof.pk3\all-all\digs.png
 adding %TEMP%\_woof_woof.pk3\all-all\digt.png
 adding %TEMP%\_woof_woof.pk3\all-all\digu.png
 adding %TEMP%\_woof_woof.pk3\all-all\digv.png
 adding %TEMP%\_woof_woof.pk3\all-all\digw.png
 adding %TEMP%\_woof_woof.pk3\all-all\digx.png
 adding %TEMP%\_woof_woof.pk3\all-all\digy.png
 adding %TEMP%\_woof_woof.pk3\all-all\digz.png
 adding %TEMP%\_woof_woof.pk3\all-all\dsdgact.wav
 adding %TEMP%\_woof_woof.pk3\all-all\dsdgatk.wav
 adding %TEMP%\_woof_woof.pk3\all-all\dsdgdth.wav
 adding %TEMP%\_woof_woof.pk3\all-all\dsdgpain.wav
 adding %TEMP%\_woof_woof.pk3\all-all\dsdgsit.wav
 adding %TEMP%\_woof_woof.pk3\all-all\m_butt1.png
 adding %TEMP%\_woof_woof.pk3\all-all\m_butt2.png
 adding %TEMP%\_woof_woof.pk3\all-all\m_vbox.png
 adding %TEMP%\_woof_woof.pk3\all-all\stbr123.png
 adding %TEMP%\_woof_woof.pk3\all-all\stbr124.png
 adding %TEMP%\_woof_woof.pk3\all-all\stbr125.png
 adding %TEMP%\_woof_woof.pk3\all-all\stbr126.png
 adding %TEMP%\_woof_woof.pk3\all-all\stbr127.png
 adding %TEMP%\_woof_woof.pk3\all-all\stkeys6.png
 adding %TEMP%\_woof_woof.pk3\all-all\stkeys7.png
 adding %TEMP%\_woof_woof.pk3\all-all\stkeys8.png
 adding %TEMP%\_woof_woof.pk3\all-all\switches.lmp
 adding %TEMP%\_woof_woof.pk3\all-all\woofhud.lmp
 adding %TEMP%\_woof_woof.pk3\doom-all\brghtmps.lmp
 adding D:\games\DOOM\BIN\autoload\doom-all\GFX-WideFix-DOOM.wad
 adding D:\games\DOOM\BIN\autoload\doom-all\SFX-SoundBulb.wad
 adding D:\games\DOOM\BIN\autoload\doom-all\WOOFHUD_tweaks.wad
 adding %TEMP%\_0000_woof_GFX-SpriteFixing-DOOM2.zip\D2SPFX20.WAD
 adding %TEMP%\_0000_woof_GFX-SpriteFixing-DOOM2.zip\DEHACKED.LMP
 adding %TEMP%\_0001_woof_NERVE.ZIP\nerve.wad
 adding %TEMP%\_0001_woof_NERVE.ZIP\nerve_midi.wad
 adding %TEMP%\_woof_woof.pk3\nerve.wad\umapdef.lmp
Loading DEH lump from file lump

M_Init: Init miscellaneous info.
R_Init: Init DOOM refresh daemon - [.................................]
P_Init: Init Playloop state.
I_Init: Setting up machine state.
I_InitController: Initialize game controller.
I_InitSound:
 Using 'OpenAL Soft on Speakers (Realtek(R) Audio)' @ 48000 Hz.
 Using 'Linear' resampler.
 Precaching all sound effects... done.
FluidSynth Init: Using 'SoundFonts\RLNDGM.SF2'.
NET_Init: Init network subsystem.
D_CheckNetGame: Checking network game status.
 startskill 2  deathmatch: 0  startmap: 1  startepisode: 1
 player 1 of 1 (1 nodes)
S_Init: Setting up sound.
HU_Init: Setting up heads up display.
ST_Init: Init status bar.
VX_Init: Voxels not found.

SDL render driver: direct3d
ResetResolution: 1152x600
S_ChangeMusic: D_DM2TTL (nerve_midi.wad)
S_ChangeMusInfoMusic: D_NRFTL1 (nerve_midi.wad)
P_SetupLevel: MAP01 (nerve.wad), Skill 3, Doom, Doom 1.9
Exit Sequence[0]: I_QuitFirst (0)
Exit Sequence[1]: I_ShutdownGraphics (0)
Exit Sequence[1]: D_QuitNetGame (0)
Exit Sequence[1]: I_ShutdownMusic (0)
Exit Sequence[1]: I_ShutdownSound (0)
Exit Sequence[1]: I_ShutdownController (0)
Exit Sequence[1]: I_ShutdownTimer (0)
Exit Sequence[1]: I_ShutdownPrintf (0)
Exit Sequence[2]: D_EndDoom (0)
Exit Sequence[2]: I_Quit (0)
Exit Sequence[2]: I_QuitLast (0)
Exit Sequence[3]: I_ErrorMsg (0)

@rfomin
Copy link
Collaborator Author

rfomin commented May 11, 2024

Turns out that the pwad-provided UMAPINFO lump overrides what's present in UMAPDEF, regardles of their load order... Today I learned something new after all these years.. (I used to delete the autoload folders I was not interested in)

Yes, UMAPDEF works like in-engine defaults. Maybe we shouldn't have exposed it to users like that.

Thanks for testing, but this PR is very early, I'm not even sure if this approach is the right one.

@liPillON
Copy link

yeah I was just "kicking the tyres" on what's already there, out of curiosity

@@ -0,0 +1,25 @@
BSD 2-Clause License
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the license to README.md.

V_DrawPatchFullScreen((patch_t *) t);
if (c==2119826587u || c==2391756584u)
// [FG] removed the embedded DOGOVRLY title pic overlay graphic lump
if (W_CheckNumForName("DOGOVRLY") > 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this easter-egg has ever been used, but I'd rather have this checked and be sure than throwing it out altogether.

r += 4

//
// Converts a linear graphic to a patch with transparency. Mostly straight
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code was the reason why we added Simon Judd's copyright when you added DBIGFONT support?


void *buf = W_CacheLumpNum(lump, tag);

if (memcmp(buf, "\211PNG\r\n\032\n", 8))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for lump size here, please.

"../share/" PROJECT_SHORTNAME "/" BASE_FILE_NAME , 0);
if (!result)
{
I_Error("PrepareBasePaths: Failed to open %s", basefile);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using basefile here isn't quite exact.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I'm thinking of making a new PR with new functions and a separate PR with graphics conversion/function renaming etc. I also want to work with .zip/.pk3 archives in memory without temporary files.

I assume you are ok with using libsnpg. What do you think about git submodules? I've read some negative comments about them.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are ok with using libsnpg.

Yes, I like it and the fact that it plays nicely with miniz.

What do you think about git submodules? I've read some negative comments about them.

I'm against them. We are mostly importing "static code", and not some vivid external projects like e.g. ZMusic which just happen to be developed in a separate GIT tree. The very meaning of libs like miniz and spng is that they are developed out and do not change frequently anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.

@@ -215,28 +215,6 @@ void V_InitColorTranslation(void)
}
}

void WriteGeneratedLumpWad(const char *filename)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was quite useful to extract color translation tables after they have been extended and adapted to the current palette in V_InitColorTranslation(), but I 'm not sure if people will miss it.

// Allow writing predefined lumps out as a WAD.
//

if ((p = M_CheckParm("-dumplumps")) && p < myargc-1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please regenerate params.h when removing CLI.

@rfomin
Copy link
Collaborator Author

rfomin commented May 13, 2024

I want to split this PR into smaller parts and reconstruct it.

Thanks again, I will keep this review in mind.

@rfomin rfomin closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants