The forum

[Script] GOG - Heroes of Might and Magic

The first of HOMM series

Author Replies
fujaru Tuesday 29 January 2013 at 17:33
fujaruAnonymous

Hi all,

I just finished writing a script for Heroes of Might and Magic 1 (GOG.com). Since this is my first script, inputs are welcome :)

#!/bin/bash
# Date : (2013-01-29 21-06)
# Last revision : (2013-01-29 21-06)
# Wine version used : 1.4.1
# Distribution used to test : Debian sid
# Author : Fajar Chan
# Script licence : GPLv2
# Program licence : Retail
# Depend :
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

GOGID="heroes_of_might_and_magic"
TITLE="GOG.com - Heroes of Might and Magic"
SHORTCUT_NAME="Heroes of Might and Magic"
PREFIX="HOMM1_gog"
#WINEVERSION="1.4.1" # Any recent version will do

# Installation
POL_SetupWindow_Init

POL_SetupWindow_presentation "$TITLE" "New World Computing, Inc. / Ubisoft" "http://www.gog.com/gamecard/heroes_of_might_and_magic" "Fajar Chan" "$PREFIX"

# Setup file: setup_heroes_of_might_and_magic.exe
POL_Call POL_GoG_setup "$GOGID" "5cc2353c2e73bbb65ed94009df0dd0cc"

POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate #"$WINEVERSION"

INSTALLPATH="$WINEPREFIX/drive_c/Program Files/GOG.com/Heroes Of Might And Magic"

POL_Call POL_GoG_install

# Adjustment on dosbox configuration file
cd "$INSTALLPATH"
cp "dosboxHOMM1.conf" "dosboxHOMM1_POL.conf"
sed -i "s/mount C \\"\\.\\"/mount C \\"..\\"/" "dosboxHOMM1_POL.conf"
sed -i "s/imgmount d \\"homm1\\.gog\\" \\-t iso/imgmount d \\"..\\/homm1.gog\\" -t iso/" "dosboxHOMM1_POL.conf"

# Make shortcuts
POL_Shortcut "dosbox.exe" "$SHORTCUT_NAME" "game.ico" "-conf ../dosboxHOMM1_POL.conf"
POL_Shortcut "EDITOR.EXE" "$SHORTCUT_NAME Map Editor"

# Make documentations shortcuts
POL_Shortcut_Document "$SHORTCUT_NAME" "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Heroes Of Might And Magic/manual.pdf"
# POL_Shortcut_Document "$SHORTCUT_NAME" "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Heroes Of Might And Magic/reference_card.pdf"
# POL_Shortcut_Document "$SHORTCUT_NAME" "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Heroes Of Might And Magic/README.TXT"

POL_SetupWindow_Close
exit


petch Tuesday 29 January 2013 at 18:46
petch

Hi,
PlayOnLinux has a native DOSBox support, this is not very well documented, but the closest thing is some messages I wrote in the forums a while ago:
http://www.playonmac.com/en/topic-8747-Ultima_123_GOGcom_Edition.html

Edited by petch

fujaru Wednesday 30 January 2013 at 4:29
fujaruAnonymous

Hi petch,

Thanks for pointing native DOSBox support and the link to it! I read your Earthworm Jim 1+2 script.

So here's the updated script:
#!/bin/bash
# Date : (2013-01-29 21-06)
# Last revision : (2013-01-30 09-57)
# Wine version used : 1.4-dos_support_0.6
# Distribution used to test : Debian sid
# Author : Fajar Chan
# Script licence : GPLv2
# Program licence : Retail
# Depend :
# 
# Thanks to petch for pointing out how to use POL's native DOSBox support
# 
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="GOG.com - Heroes of Might and Magic"
SHORTCUT_NAME="Heroes of Might and Magic"
SHORTCUT_NAME_EDITOR="Heroes of Might and Magic Map Editor"

GOGID="heroes_of_might_and_magic"
SETUPMD5="5cc2353c2e73bbb65ed94009df0dd0cc"
PREFIX="HOMM1_gog"
WINEVERSION="1.4-dos_support_0.6"

# INSTALLATION #
# Setup file: setup_heroes_of_might_and_magic.exe
POL_SetupWindow_Init

POL_SetupWindow_presentation "$TITLE" "New World Computing, Inc. / Ubisoft" "http://www.gog.com/gamecard/$GOGID" "Fajar Chan" "$PREFIX"

POL_Call POL_GoG_setup "$GOGID" "$SETUPMD5"

POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WINEVERSION"

INSTALLPATH="$WINEPREFIX/drive_c/Program Files/GOG.com/Heroes Of Might And Magic"

POL_Call POL_GoG_install

# DOSBOX SETUP #
cat <<'_EOFCFG_' >> "$WINEPREFIX/playonlinux_dos.cfg"
# These configuration lines are basically copied from $INSTALLPATH/dosboxHOMM1.conf
sdl_fullscreen=true
sdl_fulldouble=false
sdl_fullresolution=original
sdl_windowresolution=original
sdl_output=overlay
sdl_autolock=true
sdl_sensitivity=100
sdl_waitonerror=true
sdl_priority=higher,normal
sdl_mapperfile=mapper.txt
sdl_usescancodes=true
dosbox_language=
dosbox_machine=vga
dosbox_captures=capture
dosbox_memsize=16
render_p=0
render_aspect=false
render_scaler=normal2x
cpu_core=auto
cpu_cycles=max
cpu_cycleup=500
cpu_cycledown=20
mixer_nosound=false
mixer_rate=22050
mixer_blocksize=2048
mixer_prebuffer=10
midi_mpu401=intelligent
midi_device=default
midi_config=
sblaster_sbtype=sb16
sblaster_sbbase=220
sblaster_irq=5
sblaster_dma=1
sblaster_hdma=5
sblaster_mixer=true
sblaster_oplmode=auto
sblaster_oplrate=22050
gus_gus=false
speaker_pcspeaker=true
speaker_pcrate=22050
speaker_tandy=auto
speaker_tandyrate=22050
speaker_disney=true
joystick_joysticktype=auto
joystick_timed=true
joystick_autofire=false
joystick_swap34=false
joystick_buttonwrap=true
serial_serial1=dummy
serial_serial2=dummy
serial_serial3=disabled
serial_serial4=disabled
dos_xms=true
dos_ems=true
dos_umb=true
dos_keyboardlayout=none
IPX_Enable=1
IPX_Connection=1
IPX_ipx=true
_EOFCFG_

cat <<_EOFBAT_ > "$INSTALLPATH/HOMM1.BAT"
@ECHO OFF
mount C "$INSTALLPATH"
imgmount d "$INSTALLPATH/homm1.gog" -t iso
c:
cls
IPXNET STARTSERVER
netbios.exe
cls
loadfix -4 heroes.exe
exit
_EOFBAT_

# SHORTCUTS #
POL_Shortcut "HOMM1.BAT" "$SHORTCUT_NAME" "$SHORTCUT_NAME.png" ""
POL_Shortcut_Document "$SHORTCUT_NAME" "$INSTALLPATH/manual.pdf"
# POL_Shortcut_Document "$SHORTCUT_NAME" "$INSTALLPATH/reference_card.pdf"
# POL_Shortcut_Document "$SHORTCUT_NAME" "$INSTALLPATH/README.TXT"

POL_Shortcut "EDITOR.EXE" "$SHORTCUT_NAME_EDITOR"

POL_SetupWindow_Close
exit

Edited by fujaru

petch Wednesday 30 January 2013 at 9:54
petch

Hi fujaru,
- DOSBox settings have default values (check ~/.PlayOnLinux/wine/linux-x86/1.4-dos_support_0.6/bin/dosbox-wrapper), and some may have different optimal values on Linux than on Windows (sdl_output comes to mind), so you don't need to list all the settings from dosbox.conf files; Strictly speaking,
cat  "$WINEPREFIX/playonlinux_dos.cfg"
dosbox_memsize=16
render_p=0
cpu_cycles=max
midi_config=
sblaster_irq=5
gus_gus=false
IPX_Enable=1
IPX_Connection=1
IPX_ipx=true

would be sufficient (I don't think render_p is handled by 1.4-dos_support_0.6 so it may be disregarded, but that's another story).
Still I personally am a bit incomfortable with mixing explicit and implicit statements among related settings, so I'd still explicitly list all mixer and sblaster settings. I'm sure I'm not 100% consistent with this policy though :p
- DOSBox-mounting C should not work, as even in manual_mount=true mode it's still mounted at the root of the Wine virtual drive ($WINEPREFIX/drive_c) for consistency between Windows and DOS programs. If the game is really looking for files in C: using absolute paths, move files around instead (in practice that's usually not the case)
- Are you sure, say, the editor does not need any files from the mounted image? That's why it's recommended to put mount in imgmount statements in autoexec.bat, it guarantees that all the DOS programs start with the same DOSBox environment, which is usually a good thing
- IPXNET STARTSERVER should default to using port UDP/213, meaning it will usually fail under Linux (http://www.dosbox.com/wiki/Connectivity). I must admit I didn't experiment with IPX at all, but I'm almost sure it won't work without some thinking and adjustments.
- one last thing, GOG systematically use the normal2x scaler, but it's blocky and seldom the best looking one imho. You may experiment with them and see what you like the most for this game (it may vary from game to game). I often picked hq2x in my scripts, but there are exceptions. Until users get an UI to easily tweak those details themselves...

Edited by petch

fujaru Wednesday 30 January 2013 at 13:27
fujaruAnonymous

Hi again petch,

Thanks for the corrections! :)
Yes those settings were copied over 1:1 from GOG's HOMM installation and I didn't experiment with those settings. :p

- Let me rewrite playonlinux_dos.cfg with your codes and change some values if needed.
- About the editor, I am able to run it directly without DOSBox, but I'm also not sure if it needs files from image. The image contains animation and sound files. I agree, perhaps it's better to run the editor inside DOSBox environment.

Edited by fujaru

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com