Source Structure Asm

From Seven Kingdoms
Jump to: navigation, search

AssemblyCodeRemoval

This page documents the original assembly code. The goal is to rewrite the code in portable C/C++ for a direct replacement that can be used on all architectures.

Options in currently handling the ASM code before the switch:

  • Compile the individial ASM files with JWasm
  • Compile the inlined ASM with GAS by adding the ".intel_syntax" directive, and switching to gcc "__asm__" syntax

Status (the3dfxdude):
Currently the individual ASM files will build on JWasm without errors, but will not link into a winelib executable that I am trying to build on my side. I was able to build the inline ASM using GAS, after solving several quirks.


The steps in the switch will likely be as follows:

  1. Build the ASM code with JWasm (multiplatform replacement for MASM) or GAS with changes if Jwasm does not work
  2. Write test cases for each function used in the game
  3. Write C/C++ code and use the same test cases for verification
  4. Commit new code to SVN

Do we want to allow the Intel 32-bit ASM while building for x86?

Original Assembly Files

The following are each specialized graphics routines that could be used by the game. The encoding used in the naming of the files is shown first, then the lists of files. Unless specified, the encoding of the filename designates what it does. Even though this scheme is presented, each file still needs to be checked very closely as there are inconsistencies, especially some in the code commenting.

First two characters:

  • I_ - drawing routines
  • IB - blit routines
  • IC - copy routines
  • IR - remapping routines

Character representations for the more specialized files:

  • A - specify area
  • T - transparency handling
  • R - color table remapping
  • D - decompression
  • M - horizontal mirroring

The assembly files (files marked with * appear to be unused in the game):

  • ALL.INC - macros to handle function calls and returns
  • COLCODE.INC - macros for handling transparency graphics
  • CRC.ASM - 8-bit CRC calculation
  • IB.ASM
  • *IB2.ASM - specify width and height
  • *IB_32.ASM - 32x32 bitmap
  • IB_A.ASM
  • *IB_AR.ASM
  • *IB_AT.ASM
  • *IB_ATD.ASM
  • *IB_ATDM.ASM
  • *IB_ATM.ASM
  • *IB_ATR.ASM
  • *IB_ATRD.ASM
  • *IB_ATRDM.ASM
  • *IB_DW.ASM - dword align blitting
  • IB_R.ASM
  • IB_RD.ASM
  • IB_T.ASM
  • *IB_TD.ASM
  • *IB_TDM.ASM
  • *IB_TM1.ASM - horizontal mirroring
  • *IB_TM2.ASM - vertical mirroring
  • *IB_TM3.ASM - diagonal mirroring
  • *IB_TR.ASM
  • *IB_TRD.ASM
  • *IB_TRDM.ASM
  • IC.ASM - copy a rectangle
  • IC_R.ASM - copy a rectange with color table remapping
  • IJ_T.ASM - blit and copy across display surfaces with transparency handling
  • IMGFUN.INC - address calculation macros
  • *IR.ASM - remap the display buffer's color table
  • *IR_AM.ASM - remap an area of the display buffer's color table, with mirroring
  • *IR_BAR.ASM - remap a rectangular bar
  • *IR_M.ASM - remap the display buffer with mirroring
  • I_BAR.ASM - draw a rectangular bar
  • *I_BLACK.ASM - 32x32 black fill
  • *I_CTRL.ASM - initializes an image buffer
  • *I_EMASK.ASM - 32x32 exploration masking
  • *I_EREMAP.ASM - 32x32 exploration remap
  • *I_FONT.AS1 - font drawing
  • *I_FONT.ASM - font drawing, specify geometry
  • *I_FREMAP.ASM - 32x32 fog remap
  • I_LINE.ASM - draw a line
  • *I_PIXEL.ASM - 32x32 color fill?
  • *I_READ.ASM - read from display surface
  • *I_SNOW.ASM - 32x32 fill with random snow
  • *I_XOR.ASM - 32x32 xor

Inline ASM is found in the following files:

  • OFLAME.CPP
  • OVGABUF2.CPP
  • OWORLD.CPP