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

DynRPG: High Level Emulation of some functionality #1091

Open
1 of 4 tasks
Ghabry opened this issue Jan 27, 2017 · 11 comments
Open
1 of 4 tasks

DynRPG: High Level Emulation of some functionality #1091

Ghabry opened this issue Jan 27, 2017 · 11 comments

Comments

@Ghabry
Copy link
Member

Ghabry commented Jan 27, 2017

List of currently implemented DynRPG plugins (upstream):

  • DynTextPlugin
    • Save/Load support
    • Custom Resolution aware

Under development:

  • DynPEC (some commands broken, lacks Save code)

tl;dr: You can suggest DynRPG plugins here. No QuickPatches and no RPGSS.

Obviously supporting QuickPatches and DLLs is not possible due to how EasyRPG works but what is possible is HLE (High level emulation) which is a common technique used in emulators:
When the emulated/interpreted game calls a function, the function call is intercepted and the emulator executes a reimplementation of the function which returns to the game what it would expect.

So e.g. when a game would call the hyphothetical function "@add V1, V2, 3" instead of running the code from calc.dll (which is not possible without an emulator) EasyRPG calls the HLE-Add function and adds 3 to Variable 2 and writes the result in Variable 1. The game is happy.

The important thing is that the code base is not polluted, so QuickPatches are a no-go. HLEing RPGSS is also not possible because everybody can alter the Lua code. Games with custom DLLs will also break (obviously), only unmodified, documented features of a DynRPG plugin can be supported.

Since many months I have a DynRPG parser in https://github.com/Ghabry/easyrpg-player/tree/dynrpg

@CherryDT
Copy link

Nice! I feel honored ;)
For reference, this is the ugly source code of the actual DynRPG parser (which was more targeted to speed): https://gist.github.com/CherryDT/3b3537940bf7dced05bd0d6a1607c7d5

@carstene1ns carstene1ns added this to the 0.7.0 milestone Apr 17, 2017
@Ghabry
Copy link
Member Author

Ghabry commented Sep 28, 2020

As this finally makes progress in upstreaming I started to update the DynTextPlugin to the latest codebase.

https://github.com/EasyRPG/Player/compare/master...Ghabry:dyntext?expand=1

We have to do some API design discussion but PendingMessage and Game_Message can be nicely used.

For PendingMessage one could replace the hardcoded V and N handling with a callback function:
5836cf5

Game_Message can export ParseParamImpl (under a better name) and add a ParseStringParam function. Then the TextPlugin works nicely and uses all our well tested parsers :). Much simpler than before.

@Ghabry
Copy link
Member Author

Ghabry commented Sep 30, 2020

screenshot_0-fs8

An observation I made years ago when porting the Plugin for Deep8: The text rendering is off by 2 pixel (easily shown by rendering an exfont).

Though not sure why this happens, the plugin just does obj.img->drawText(0, 0, obj.txt, obj.color);
Sourcecode here: https://www.multimediaxis.de/threads/135210-DynRPG-Plugin-Text-Plugin?p=2981120&viewfull=1#post2981120 "Der aktuelle Source"

@Ghabry
Copy link
Member Author

Ghabry commented Oct 2, 2020

There is no sourcecode for DynPEC but this is easy to reverse engineer, here is what the plugin does:

onEventCommand checks for the erase picture command. Not looked into this further, guess it is used to delete the "spritesheet".

The get functions have quite complicated variable realloc code. No idea if you need this in DynRPG. I also hope this was inlined because it is always the same.

set_color: red, green, blue, chroma
set_position: targetx, targety
set_transparency: set top and bottom at once
set_magnification: target_magnification
set_rotation_angle: angle = 256.0 * arg1 / 360.0
set_effect_strength: targetEffectStrength
get_color: like set
get_position: reads x/y, not targetx
get_transparency: gets transparency2
get_magnification: gets magnification
get_rotation_angle: angle  * 360.0 * 0.00390625
get_effect_strength: gets effectStrength

More interesting stuff (this is not saved!)

  • flip_picture/isflipped: This uses custom code for flipping and a custom struct to track the flip-bit.
  • create_spritesheet: This is also custom because 2k3 has no spritesheets. There is a sanity check: "Frame dimnensions (sic!) not evenly dividable by spritesheet dimensions". The frame width/height could be mapped to 2k3e sprite sheet.
  • pec_next_frame: Advances to next frame in x-direction. Looks a bit broken, I can't find a y-adjustment o_O (or I don't understand the code completely)
  • pec_jump_to_frame: adjusts the x/y position behaves as expected
  • destroy_spritesheet: does memory freeing: Needs testing: Does this reset to the original picture?

@Sullien
Copy link

Sullien commented Oct 8, 2020

Does this mean that things such as the Overdrive patch might be compatible with the engine? Dynrpg has patches which uncap stats beyond the editor's limit, not entirely related to DynRPG though since most of them patch the game file itself but adding compatibilty with these plugins does seem encouraging.

@Ghabry
Copy link
Member Author

Ghabry commented Oct 8, 2020

Can you link this overdrive patch?

@Sullien
Copy link

Sullien commented Oct 8, 2020

Sure.
https://rpgmaker.net/engines/rt2k3/utilities/63/
A similar one which only increases values is also here: https://rpgmaker.net/engines/rt2k3/utilities/6/
They mostly increase stats beyond the editor's natural limit, which is done by using reshacker and changing the set limits.

@Ghabry
Copy link
Member Author

Ghabry commented Sep 12, 2021

Everlong :

Warning: Unsupported DynRPG function: quicksave
Warning: Unsupported DynRPG function: is_minimap
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: remove_all
Warning: Unsupported DynRPG function: is_minimap
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: write_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: append_text
Warning: Unsupported DynRPG function: remove_all
Warning: Unsupported DynRPG function: is_minimap
Warning: Unsupported DynRPG function: process_cmd
Warning: Unsupported DynRPG function: autosave

Also tons of plugins and Quick Patches: NOOOOOOOPE

@Ghabry Ghabry modified the milestones: 0.7.1, 0.7.2 May 29, 2022
@Ghabry Ghabry pinned this issue Sep 22, 2023
@Ghabry Ghabry unpinned this issue Sep 22, 2023
@Ghabry
Copy link
Member Author

Ghabry commented Nov 13, 2023

Here the DynRPG stuff used by DQ+ (sorted by usage count)

No quickpatches 🥳

Worst is obviously this Mode7 plugin. PEC is planned anyway and GetMessageInfo is not thaaat hard to do.

    509 @pec_jump_to_frame        <- DynPec
    282 @pec_create_sprite_sheet
     29 @pec_destroy_sprite_sheet
      4 @add_sprite               <- DynMode7
      3 @set_wrapping
      3 @set_boundary_texture
      3 @set_background
      3 @rotate_right_by
      3 @rotate_left_by
      3 @load_map_to_texture
      3 @init_mode7
      1 @GetMessageInfo           <- GetMessageInfo

There is also the opengl plugin but this is only for showing shaders in the settings so not critical for gameplay.

DynMap.dll looks unused and DynBlending.dll is filename based.

Blending has a patch here:

#1068 (comment)

@jetrotal
Copy link
Contributor

jetrotal commented Nov 13, 2023

@DynPec Source Code
@init_mode7 Source Code
@GetMessageInfo Source Code

@Ghabry
Copy link
Member Author

Ghabry commented Nov 13, 2023

Oh there is sourcecode. Problem is that it is from Kazesui who already implemented the dyn particles plugin where I still do not understand why the rendering works 😅

The Mode 7 plugin has glorious code like

srcX += 24*(ev->step&((((ev->step&0x1)^((ev->step&0x2)>>1))<<1)+0x1));
srcY += 32*((ev->facing - ((int)t_angle+135)/90 + 4)&0x3 );

scanline[screen_x] = background->appliedPalette[pixels[(screen_x+(int)(t_angle*deltaBG))%BG_size+BG_size*screen_y]];

Half of it is a custom map renderer to get the map onto a texture. This is something we could skip as we already have full access to the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants