Player icon indicating copy to clipboard operation
Player copied to clipboard

DynRPG: High Level Emulation of some functionality

Open Ghabry opened this issue 8 years ago • 11 comments

List of currently implemented DynRPG plugins (upstream):

  • [X] 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

Ghabry avatar Jan 27 '17 10:01 Ghabry

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

CherryDT avatar Apr 10 '17 15:04 CherryDT

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: https://github.com/EasyRPG/Player/commit/5836cf5b7c8e304a75d2414c68b5e5a7c37ae838

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 avatar Sep 28 '20 16:09 Ghabry

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 avatar Sep 30 '20 15:09 Ghabry

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?

Ghabry avatar Oct 02 '20 11:10 Ghabry

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.

Sullien avatar Oct 08 '20 00:10 Sullien

Can you link this overdrive patch?

Ghabry avatar Oct 08 '20 06:10 Ghabry

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.

Sullien avatar Oct 08 '20 14:10 Sullien

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 avatar Sep 12 '21 20:09 Ghabry

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:

https://github.com/EasyRPG/Player/issues/1068#issuecomment-916342474

Ghabry avatar Nov 13 '23 11:11 Ghabry

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

jetrotal avatar Nov 13 '23 20:11 jetrotal

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.

Ghabry avatar Nov 13 '23 23:11 Ghabry