User:Toaster

From Seven Kingdoms

Jump to: navigation, search

Contents

Git repo

https://github.com/7k2/7k2

Compiling 7K2 with MSVC in Wine

  • Wine 1.5.2
  • Windows SDK 7.0 (installed via winetricks)
  • DirectX SDK (April 2006)
  • libjpeg 8c
  • USE_FLIP isn’t supported in Wine (see http://wine.1045685.n5.nabble.com/DX6-more-compatibility-td1823921.html for a more technical discussion)
  • Screen doesn’t redraw properly
  • Need to define DEBUG and have a debug.sys file for game to work properly
  • “SpyArray[] is deleted” occurs after a while when playing new games. It seems to be caused by an abnormally large value in inn_unit_count (14000+ to 24000+). The maximum value expected by the game is 12 (MAX_INN_UNIT).
    • Cause: Accessing uninitialized variables (inn_unit_count in FirmInn and spy_count in UnitWagon) before init_derived() is called.
    • Fix/Workaround: Initialize them in the constructors.
  • Need to add GetInputState() to Sys::yield() for mouse to work in menus (see http://bugs.winehq.org/show_bug.cgi?id=8854#c48 )
  • Need to compile with structure packing (/Zp) for tutorials to work
  • JPEG decompression error when starting new campaign or viewing hall of fame
    • Workaround: Specify default packing when including jpeglib.h
  • Tutorial instructions don’t display
  • Music and sound effects work
  • When using ddr=opengl in Wine, there's a delay when clicking on buildings and units. Mouse movement is smooth, except when click-dragging. When ddr=gdi, mouse movement seems ok.
  • No apparent issues with keyboard input (repeat rate seems ok)
  • Multiplayer untested; needs native dplay dlls
  • Cannot build non-English exe because of missing functions
  • Screenshot: http://imgur.com/mrYza
  • Download: sk2-wine-wip-toaster-20120320.exe

Compiling 7K2 with g++

  • Debian wheezy/sid
  • g++ 4.6.1-4
  • Wine 1.5.2
  • JWasm 2.04c
  • binutils-2.21-5 (more recent versions of ld like 2.21.52.20110606 cause 7K2 to segfault at startup): 7k2.exe.so[3528]: segfault at 0 ip (null) sp bfb22e2c error 4
  • Need to comment out functions that have inline asm in omagic.cpp, otherwise the game will hang when it tries to draw the lightning bolt
  • Campaign works if calls to jpeg functions are commented out

7K2 tasks

  • Convert inline asm to C++
  • Convert external asm to C++
  • Pack structures for binary compatibility
  • Factor out code shared by 7kaa and 7k2
  • Prepare for SDL+OpenAL backends
    • Add OpenAL backend
    • Add SDL backend
    • Add SDL_net backend
  • Fix 64-bit portability
  • Add autoconf build system
  • Add i18n support

7K2 SDL Port (WIP)

7K2 codebase notes

  • MapMatrix::draw_map(): asm simply colors the minimap black. See it in action by enabling “world map unexplored” option.
  • MapMatrix::disp(): Redraws minimap
  • LocationCorners::render_special(Blob2DW *...): Draws a valid/invalid box on the map when placing a building
  • LocationCorners::render_special(BitmapW *...): Called when “unexplored world map” option is on
  • LocationCorners::render(BitmapW *...): Renders terrain
  • draw_cubic_plane(): unused function

7kaa notes

  • segfault when compiled with “-march=native”
bt:
in Town::update_resistance at OTOWN.cpp:1516
race_resistance_array[i][j] = (float) 0;
disas:
movaps %xmm0,(%edi)
info reg:
edi: 0x9c489b2
  • Probable cause: unaligned access
    • Workaround: Don’t pack Town class (breaks binary compatibility)
  • SDL port: Black screenshot when debug enabled and debug.sys exists
    • Cause: Wrong vga buffer used to save screenshot
    • Fix/workaround: Use vga_front instead of vga_true_front
  • 7kaa_glsdl.patch
    • no eol: resave in Vim
    • last hunk rejected (vga_sdl.cpp): can be ignored
    • no support for out-of-tree builds: Duplicate CXXFLAGS and rename CXXFLAGS to CFLAGS in configure.ac
  • SDL 1.3 port
    • SDL_NO_COMPAT
    • not using 2D accelerated rendering
    • unhandled events? 0x200, 0x1, 0x2, 0x4
    • colors messed up (hall of fame, encyclopedia and credits)
    • black screen when in fullscreen mode