diff --git a/acmlib/CMakeLists.txt b/acmlib/CMakeLists.txt
deleted file mode 100644
index 590033a9..00000000
--- a/acmlib/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set(HEADERS)
-set(CPPS
- acmlib.cpp)
-
-add_library(acmlib STATIC ${HEADERS} ${CPPS})
diff --git a/acmlib/acmlib.cpp b/acmlib/acmlib.cpp
deleted file mode 100644
index b585a29b..00000000
--- a/acmlib/acmlib.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-
-
-#include "Adecode.h"
-#include "mem.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-AudioDecoder *Create_AudioDecoder(ReadFunction *reader, void *data, unsigned *pChannels, unsigned *pSampleRate,
- int32_t *pSampleCount) {
- return (AudioDecoder *)mem_malloc(sizeof(AudioDecoder));
-}
-
-// Read from audio decoder at most the specified qty of bytes
-// (each sample takes two bytes).
-// Returns zero when the end of file is reached.
-unsigned __cdecl AudioDecoder_Read(AudioDecoder *ad, void *buf, unsigned qty) { return 0; }
-
-// Close audio decoder
-void __cdecl AudioDecoder_Close(AudioDecoder *ad) {
- if (ad)
- mem_free(ad);
-}
-
-// Optional interface for supplying your own malloc and free functions
-// Default is to use standard malloc and free.
-
-void __cdecl AudioDecoder_MallocFree(ad_malloc *fn_malloc, ad_free *fn_free) {}
-
-#ifdef __cplusplus
-};
-#endif
diff --git a/lib/mvelibw.h b/lib/mvelibw.h
deleted file mode 100644
index 4832a43c..00000000
--- a/lib/mvelibw.h
+++ /dev/null
@@ -1,349 +0,0 @@
-#if 0
-/*
-** mvelibw.h
-**
-** Interplay Movie File (MVE) Player
-** Library Definitions (32-Bit Win95 Version)
-** Written by Paul Allen Edelstein, Interplay Productions.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-*/
-
-#ifndef _MVELIB_H_INCLUDED
-
-#include
-#include "ddraw.h"
-#include "dsound.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Call this function to provide hooks into your memory management.
-*/
-typedef void *(__cdecl mve_cb_alloc)(unsigned size);
-typedef void (__cdecl mve_cb_free)(void *p);
-void __cdecl MVE_memCallbacks(mve_cb_alloc *fn_alloc,
- mve_cb_free *fn_free);
-
-/* This function remains from the DOS version of mvelib.
-** It allows you to provide a preallocated buffer for file I/O,
-** but under Windows there's no real point to doing this.
-*/
-void __cdecl MVE_memIO(void *p, unsigned size);
-
-/* Call this function to provide hook into your file io.
-*/
-typedef unsigned __cdecl mve_cb_read(int handle, void *buf, unsigned count);
-void __cdecl MVE_ioCallbacks(mve_cb_read *fn_read);
-
-/* Call this function to provide hook into your digital sound driver.
-** Call with NULL if no sound support is available (default).
-*/
-void __cdecl MVE_sndInit(LPDIRECTSOUND lpDS);
-
-/* Volume controls.
-** These functions are equivalent to the IDirectSoundBuffer
-** SetVolume and SetPan functions. They take effect immediately
-** and do NOT reset when a new movie starts.
-** Volume ranges from 0 (0 db, no volume change) to -10,000 (-100db, essentially silent).
-** Pan ranges from -10,000 (left full volume, right -100db), thru 0 (both full),
-** thru 10,000 (left -100db, right full volume).
-** The default value for volume and pan is zero.
-*/
-void __cdecl MVE_dsbSetVolume(int32_t lVolume);
-void __cdecl MVE_dsbSetPan(int32_t lPan);
-
-
-/* Only call this function to configure software to work with a Super VGA
-** mode if you do not have VESA support.
-**
-** Restrictions/Assumptions:
-** 64K >= WinSize >= WinGran
-** WinSize % WinGran == 0
-** WinGran of 64K is represented by 0
-** SetBank is address of function with following protocol:
-** bh: 0=Set window, 1=Get Window
-** bl: Window number (0 or 1)
-** dx: Window position in video memory in units of WinGran.
-** on return, registers AX and DX are destroyed.
-**
-** Hicolor is 0 for 8-bit color, 1 for 15-bit rgb color, 2
-** for byte swapped 15-bit rgb color.
-*/
-
-/* Note: 16-bit WriteWinSeg replaced with 32-bit WriteWinPtr */
-
-/* The functionality of the following function is reduced in the Windows
-** version of the player. Call it as follows:
-** MVE_sfSVGA(w,h,w,0,NULL,0,0,NULL,hicolor)
-** where w and h are the width and height of your window,
-** and hicolor is a boolean which indicates if the screen
-** is operating in hi color, rather than 8-bit paletted color.
-** Under windows, the information provided by this function
-** is just used for window centering and for determining
-** how and when to do palette callbacks.
-*/
-void __cdecl
-MVE_sfSVGA(unsigned w, unsigned h, unsigned LineWidth,
- unsigned WriteWin, uint8_t *WriteWinPtr,
- uint32_t WinSize, unsigned WinGran,
- void *SetBank, unsigned hicolor);
-
-/* This function alters the display from 640x480 or 640x400 to 640x350 resolution.
-*/
-void __cdecl
-MVE_ForceVres350(void);
-
-/* This function alters the display from 640x480/400/350 to
-** 640x240/200/175.
-*/
-void __cdecl
-MVE_ForceVresHalf(void);
-
-/* **NOTE** There still need to be calls to restore original screen resolution
-** after using MVE_ForceVres350() or MVE_ForceVresHalf()!
-*/
-
-/* Only call this function to either
-** 1. Replace method of copying frame to screen (perhaps for a nonstandard
-** screen format).
-** 2. Wrap your own code around the transfer of frame to screen
-** or modify which portions of the screen are updated.
-** This function replaces calls to the default MVE_ShowFrame function
-** with calls to your function, which can itself call MVE_ShowFrame.
-*/
-typedef void __cdecl mve_cb_ShowFrame
- (LPDIRECTDRAWSURFACE buf, unsigned bufw, unsigned bufh,
- unsigned sx, unsigned sy, unsigned w, unsigned h,
- unsigned dstx, unsigned dsty, unsigned hicolor);
-void __cdecl MVE_sfCallbacks(mve_cb_ShowFrame *fn_ShowFrame);
-
-typedef void __cdecl mve_cb_SetPalette
- (uint8_t *p, unsigned start, unsigned count);
-void __cdecl
-MVE_palCallbacks(mve_cb_SetPalette *fn_SetPalette);
-
-void __cdecl
-MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-
-/* Configure the software for a graphics mode, optionally setting the
-** display to that mode (see the MVE_GFX_xxx constants defined below).
-*/
-unsigned __cdecl MVE_gfxMode(int16_t mode);
-
-/* Reset the screen to text mode (usually done before exiting a program).
-*/
-void __cdecl MVE_gfxReset(void);
-
-/* Set line for split screen graphics */
-/* {Use vbe_SetDisplayStart(x,y) to set vid buf for upper screen} */
-void __cdecl MVE_gfxSetSplit(unsigned line);
-
-/* Setup double buffering */
-void __cdecl MVE_gfxSetDoubleBuffer(unsigned y1, unsigned y2, unsigned vis);
-
-/* Get double buffering state */
-void __cdecl MVE_gfxGetDoubleBuffer(unsigned *vis_y, unsigned *hid_y);
-
-/* Enable double buffering for auto screen modes */
-void __cdecl MVE_sfAutoDoubleBuffer(unsigned on);
-
-/* Wait for video retrace off (0) or on (1) */
-void __cdecl MVE_gfxWaitRetrace(unsigned state);
-
-/* Establish link to DirectDraw
-*/
-void __cdecl MVE_rmDirectDraw(LPDIRECTDRAW lpDD);
-
-/* Establish primary to DirectDraw Surface
-** This is only necessary for playing back hi-color movies.
-** Its establishes the rgb format for decompression.
-*/
-void __cdecl MVE_rmPrimarySurface(LPDIRECTDRAWSURFACE lpDD);
-
-/* Establish callback for user control of movie playback.
-*/
-typedef int __cdecl mve_cb_ctl(void);
-void __cdecl MVE_rmCallbacks(mve_cb_ctl *fn_ctl);
-
-/* Specify playback fastmode option (default is MVE_RM_NORMAL).
-*/
-#define MVE_RM_NORMAL 0 /* Normal playback */
-#define MVE_RM_HALF 1 /* Half height (even lines only) */
-#define MVE_RM_DITHERED 2 /* Half height (dither between lines) */
-#define MVE_RM_HALF_2 5 /* Full height, even lines only */
-#define MVE_RM_DITHERED_2 6 /* Full height, dither, even lines only */
-
-void __cdecl MVE_rmFastMode(int mode);
-
-/* Specifying horizontal magnification:
-** 3: 4/3 horizontal magnification
-** 4: normal
-*/
-void __cdecl MVE_rmHScale(int hscale);
-
-/* Get frame count and number of dropped frames from last movie played.
-*/
-void __cdecl MVE_rmFrameCounts(unsigned *FrameCount, unsigned *FrameDropCount);
-
-/* Dump timing statistics (if enabled).
-*/
-void __cdecl MVE_logDumpStats(void);
-
-/* Run a compressed movie by reading data starting at the current
-** position in the file specified by handle hFile.
-** The movie window is displaced by dx,dy from the upper left hand corner
-** or is centered if dx,dy is -1,-1.
-** track specifies which audio track to play (usually 0 for a single
-** audio track).
-**
-** Returns an error/result code.
-**
-** Memory may be dynamically allocated while movie runs.
-*/
-int __cdecl MVE_RunMovie(int hFile, int dx, int dy, unsigned track);
-
-/* MVE_RunMovieContinue is the same as MVE_RunMovie except that it does not
-** automatically call MVE_rmEndMovie(). This may improve the smoothness
-** of immediately playing another movie afterwards.
-*/
-int __cdecl MVE_RunMovieContinue(int hFile, int dx, int dy, unsigned track);
-
-/*
-** Alternative to using MVE_RunMovie() and MVE_rmCallbacks().
-** Call MVE_rmPrepMovie() to prepare movie for playing.
-** Call MVE_rmStepMovie() to display next frame of movie until nonzero
-** result is returned (MVE_ERR_EOF for no next frame or some other error).
-** Call MVE_rmHoldMovie() to hold on current frame (and pause audio).
-** Call MVE_rmEndMovie() to abort movie.
-** All functions except MVE_rmEndMovie() return an error code.
-*/
-int __cdecl MVE_rmPrepMovie(int hFile, int dx, int dy, unsigned track);
-int __cdecl MVE_rmStepMovie(void);
-int __cdecl MVE_rmHoldMovie(void);
-void __cdecl MVE_rmEndMovie(void);
-
-/* Frame Reader Streams
-** This is a special interface to the movie system which
-** allows a movie file to be opened as a stream from which
-** its frames may be retrieved. Audio and timing information
-** are ignored. For 256-color screen applications, palette
-** information is also typically ignored, and movies with a common
-** predefined palette are used. However, for hi-color screen
-** applications, an interface to obtain palette information has
-** been provided. This system is intended for use by video sprites
-** played off of the hard drive or out of memory.
-*/
-typedef struct _MVE_frstream *MVE_frStream;
-
-/* MVE_frOpen
-** Before calling this function, be sure to call MVE_memCallbacks()
-** and MVE_rmDirectDraw().
-**
-** fn_read specifies a file reader similar to the one
-** used by MVE_ioCallbacks().
-** handle specifies a file handle for an already opened
-** movie file. It is used by the file reader and is similar
-** to hFile argument used by MVE_RunMovie() and MVE_rmPrepMovie().
-** fr_callback is normally NULL, but can be used to supply
-** a handler for user data which has been interleaved into
-** the movie stream.
-**
-** If the movie file is invalid or the call otherwise fails,
-** NULL is returned.
-*/
-MVE_frStream __cdecl MVE_frOpen(unsigned (__cdecl *fn_read)(int handle, void *buf,
- unsigned count),
- int handle,
- int (__cdecl *fr_callback)(unsigned op, unsigned subop,
- void *buf));
-
-/* MVE_frGet
-** Returns the next frame from the specified frame reader stream
-** a nonzero error code {the same codes as returned by MVE_RunMovie()
-** and MVE_rmStepMovie()}.
-** If successful, MVE_frGet(frs, &buf, &w, &h) returns a pointer
-** to a direct draw surface containing the frame in buf,
-** and its width and height in w and h.
-*/
-int __cdecl MVE_frGet(MVE_frStream frs,
- LPDIRECTDRAWSURFACE *pBuf,
- unsigned *width, unsigned *height);
-
-/* MVE_frPal
-** After each successful call to MVE_frGet(), this call may be used to
-** obtain corresponding palette information. It returns a pointer to the
-** entire current palette for the frame, and the subportion of the palette
-** which has changed this frame is identified by start and count (they will
-** both be zero on frames for which the palette has not changed).
-**
-** Paltbl points to 256*3 bytes of 6-bit r,g,b triples.
-** Start ranges from 0 to 255. Count from 0 to 256.
-**
-** These conventions are similar to those used by the palette callback arguments
-** with the standard player interface, except that this interface requires
-** polling each frame instead, and must be passed pointers to the variables where
-** the values will be returned.
-**
-*/
-void __cdecl MVE_frPal(MVE_frStream frs,
- uint8_t **pPaltbl, unsigned *pStart, unsigned *pCount);
-
-/* MVE_frClose
-** Closes the specified Frame Reader Stream frs.
-** Frees all storage associated with the stream.
-** The specified frs must not be used after this call.
-** Note that the open file handle specified in MVE_frOpen() is
-** not closed by this call...that is the caller's responsibility.
-*/
-void __cdecl MVE_frClose(MVE_frStream frs);
-
-
-/* Release any memory dynamically allocated by MVE_RunMovie.
-*/
-void __cdecl MVE_ReleaseMem(void);
-
-/* Return string corresponding to MVE_RunMovie result code.
-*/
-const char* __cdecl MVE_strerror(int code);
-
-/* RunMovie callback control code and result codes.
-** Codes > 1 are user defined.
-*/
-
-#define MVE_CTL_HOLD -1 /* Returned by rmCtl() to hold current frame */
-#define MVE_CTL_EXIT 1 /* Returned by rmCtl() to end movie */
-
-#define MVE_ERR_EOF -1 /* Returned by StepMovie() for end of movie */
-#define MVE_ERR_IO -2 /* File I/O error or unable to alloc memory. */
-#define MVE_ERR_SYNC -3 /* Timer error. */
-#define MVE_ERR_SND -4 /* Unable to allocate memory for sound */
-#define MVE_ERR_NF -5 /* Unable to allocate memory for video */
-#define MVE_ERR_GFX_FIT -6 /* Screen size too small for movie */
-#define MVE_ERR_GFX_FAIL -7 /* Failed to set desired graphics mode */
-#define MVE_ERR_BADFMT -8 /* Not a MVE file or unacceptable version */
-#define MVE_ERR_GFX_CLR -9 /* Incorrect screen color mode */
-#define MVE_ERR_PREP -10 /* StepMovie() without PrepMovie() */
-#define MVE_ERR_DD -11 /* Unable to initialize DirectDraw */
-#define MVE_ERR_LOST -12 /* Direct Draw Surface Lost */
-
-#define MVE_ERR_LAST -12
-
-#define _MVELIB_H_INCLUDED
-#ifdef __cplusplus
-};
-#endif
-#endif
-
-#else
-#include "../libmve/mvelibl.h"
-#endif
diff --git a/lib/win/Mvelibw.lib b/lib/win/Mvelibw.lib
deleted file mode 100644
index b8432b1c..00000000
Binary files a/lib/win/Mvelibw.lib and /dev/null differ
diff --git a/libmve/SystemInterfaces.h b/libmve/SystemInterfaces.h
deleted file mode 100644
index 41b01de4..00000000
--- a/libmve/SystemInterfaces.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifndef MVE_SYSTEM_INTERFACES_H__
-#define MVE_SYSTEM_INTERFACES_H__
-
-#include
-
-// Max&Min values for settings
-#define LNXSND_VOLUME_MAX 0
-#define LNXSND_VOLUME_MIN (-10000)
-#define LNXSND_PAN_LEFT (-10000)
-#define LNXSND_PAN_RIGHT 10000
-
-// Status/Buffer flags
-#define LNXSND_PLAYING 0x0001
-#define LNXSND_LOOPING 0x0002
-
-// Buffer lock flags
-#define LNXSND_LOCK_FROMWRITECURSOR 0x0001
-#define LNXSND_LOCK_ENTIREBUFFER 0x0002
-
-// Capability flags
-#define LNXSND_CAPS_PRIMARYBUFFER 0x0001
-#define LNXSND_CAPS_CTRLVOLUME 0x0080
-#define LNXSND_CAPS_CTRLPAN 0x0040
-#define LNXSND_CAPS_CTRLFREQUENCY 0x0020
-#define LNXSND_CAPS_CTRLDEFAULT 0x00E0
-#define LNXSND_CAPS_LOCSOFTWARE 0x0008
-#define LNXSND_CAPS_LOCHARDWARE 0x0004
-
-struct SoundWAVEFormatEx {
- uint16_t wFormatTag;
- uint16_t nChannels;
- uint32_t nSamplesPerSec;
- uint32_t nAvgBytesPerSec;
- uint16_t nBlockAlign;
- uint16_t wBitsPerSample;
- uint16_t cbSize;
-};
-#define SOUND_WAVE_FORMAT_PCM 0x01
-
-struct SysSoundCaps {
- uint32_t dwFlags;
- uint32_t dwBufferBytes;
-};
-
-class SysSoundBufferDesc {
-public:
- SoundWAVEFormatEx *lpwfxFormat;
- uint32_t dwBufferBytes;
- uint32_t dwFlags;
-};
-
-class ISysSoundBuffer {
-public:
- ////////////////////////////
- // Release
- ////////////////////////////
- // Releases the memory associated with a sound buffer. This pointer is
- // no longer valid after return.
- //
- // Returns:
- // -1 : Invalid Parameter
- // 0 : Ok!
- virtual int Release() = 0;
-
- //////////////////////////////
- // SetVolume
- //////////////////////////////
- // Sets the volume of a buffer.
- //
- // Returns:
- // 0 : no error
- // -1 : Cannot set volume
- // -2 : Invalid parameters
- virtual int SetVolume(int32_t vol) = 0;
-
- ///////////////////////////
- // SetPan
- ///////////////////////////
- // Sets the pan of a buffer.
- //
- // Returns:
- // 0 : no error
- // -1 : Cannot set pan
- // -2 : Invalid parameters
- virtual int SetPan(int32_t pan) = 0;
-
- /////////////////////////
- // Stop
- /////////////////////////
- // Stops a buffer from playing
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int Stop() = 0;
-
- /////////////////////////
- // Play
- /////////////////////////
- // Starts a buffer playing (or changes the flags for a buffer currently
- // playing).
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int Play(uint32_t flags) = 0;
-
- ////////////////////////////
- // GetCaps
- ////////////////////////////
- // Get the capabilities of a sound buffer
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int GetCaps(SysSoundCaps *caps) = 0;
-
- //////////////////////////////
- // GetStatus
- //////////////////////////////
- // Returns the status of a buffer
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int GetStatus(uint32_t *status) = 0;
-
- ///////////////////////////////////////
- // GetCurrentPosition
- ///////////////////////////////////////
- // Returns the current play and write positions of the buffer
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int GetCurrentPosition(uint32_t *ppos, uint32_t *wpos) = 0;
-
- ///////////////////////////////////////
- // SetCurrentPosition
- ///////////////////////////////////////
- // Sets the current play position of the buffer
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int SetCurrentPosition(uint32_t pos) = 0;
-
- /////////////////////////
- // Lock
- /////////////////////////
- // Locks the given buffer, returning pointer(s) to the buffer(s) along with
- // available the size of the buffer(s) for writing.
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int Lock(uint32_t pos, uint32_t numbytes, void **ptr1, uint32_t *numbytes1, void **ptr2,
- uint32_t *numbytes2, uint32_t flags) = 0;
-
- ///////////////////////////
- // Unlock
- ///////////////////////////
- // Unlocks a buffer.
- //
- // Returns:
- // 0 : no error
- // -1 : invalid parameters
- virtual int Unlock(void *ptr1, uint32_t num1, void *ptr2, uint32_t num2) = 0;
-};
-
-class ISoundDevice {
-public:
- ///////////////////////////////
- // CreateSoundBuffer
- ///////////////////////////////
- // Creates a sound buffer to be used with mixing and output.
- //
- // Returns:
- // -1 : Invalid Parameter
- // -2 : Out of memory
- // 0 : Ok!
- virtual int CreateSoundBuffer(SysSoundBufferDesc *lbdesc, ISysSoundBuffer **lsndb) = 0;
-};
-
-#endif
diff --git a/libmve/lnxdsound.cpp b/libmve/lnxdsound.cpp
deleted file mode 100644
index f820926d..00000000
--- a/libmve/lnxdsound.cpp
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-#ifdef __LINUX__
-#include
-#include
-#include
-#endif
-
-#include
-
-#include "args.h"
-#include "lnxdsound.h"
-
-#define FRAGMENT_LENGTH (LnxBuffers[0]->bps >> 4)
-#define FREQUENCY_SHIFT (14)
-
-/*
- * TODO:
- * * Might be wise to use mutex's for the enter/exit critical functions
- */
-static int LnxNumBuffers = 0;
-static LnxSoundBuffer **LnxBuffers = NULL;
-static LnxSoundDevice LinuxSoundDevice;
-
-static bool StartupSoundSystem(LnxSoundDevice *dev);
-static void ShutdownSoundSystem(void);
-static void LinuxSoundMixWithVolume(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len);
-static uint32_t LinuxSoundMixNormalize(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len);
-static uint32_t LinuxSoundMixInMainBuffer(LnxSoundBuffer *dsb, int len);
-static void LinuxSoundMixBuffersIntoMain(int len);
-static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len);
-
-static inline void enter_critical() { SDL_LockAudio(); }
-
-static inline void exit_critical() { SDL_UnlockAudio(); }
-
-///////////////////////////////
-// LnxSound_CreateSoundBuffer
-///////////////////////////////
-// Creates a sound buffer to be used with mixing and output.
-//
-// Returns:
-// -1 : Invalid Parameter
-// -2 : Out of memory
-// 0 : Ok!
-int LnxSound_CreateSoundBuffer(LnxSoundDevice *dev, LnxBufferDesc *lbdesc, LnxSoundBuffer **lsndb) {
- WAVEFORMATEX *wfex;
-
- if (!lbdesc || !lsndb || !dev)
- return -1;
-
- wfex = lbdesc->lpwfxFormat;
- if (!wfex)
- return -1;
-
- // Check to see if we have a primary buffer yet, if not, create it
- // now
- if (lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- if (LnxNumBuffers != 0)
- return -1;
- } else {
- if (LnxNumBuffers == 0) {
- // we need to create a primary buffer
- LnxSoundBuffer *primary;
- LnxBufferDesc primdesc;
- WAVEFORMATEX wf;
-
- memset(&primdesc, 0, sizeof(LnxBufferDesc));
- memset(&wf, 0, sizeof(wf));
-
- primdesc.dwBufferBytes = 0;
- primdesc.dwFlags = LNXSND_CAPS_PRIMARYBUFFER;
- primdesc.lpwfxFormat = &wf;
-
- int ret = LnxSound_CreateSoundBuffer(dev, &primdesc, &primary);
- if (ret != 0)
- return ret;
- }
- }
-
- *lsndb = (LnxSoundBuffer *)malloc(sizeof(LnxSoundBuffer));
- if (!(*lsndb))
- return -2;
- memset(*lsndb, 0, sizeof(LnxSoundBuffer));
-
- if (lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- (*lsndb)->buffer_len = dev->bps;
- (*lsndb)->freq = dev->freq;
- (*lsndb)->bps = dev->bps;
- (*lsndb)->buffer = nullptr;
- } else {
- (*lsndb)->buffer_len = lbdesc->dwBufferBytes;
- (*lsndb)->freq = lbdesc->lpwfxFormat->nSamplesPerSec;
-
- (*lsndb)->buffer = (uint8_t *)malloc((*lsndb)->buffer_len);
- if (!(*lsndb)->buffer) {
- free(*lsndb);
- *lsndb = nullptr;
- return -2;
- }
- memset((*lsndb)->buffer, 0, (*lsndb)->buffer_len);
- }
-
- (*lsndb)->play_cursor = 0;
- (*lsndb)->write_cursor = 0;
- (*lsndb)->playing = 0;
- (*lsndb)->left_vol = (1 << 15);
- (*lsndb)->right_vol = (1 << 15);
-
- if (!(lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- (*lsndb)->freq_adjustment = ((*lsndb)->freq << FREQUENCY_SHIFT) / LnxBuffers[0]->freq;
- (*lsndb)->bps = (*lsndb)->freq * lbdesc->lpwfxFormat->nBlockAlign;
- }
-
- memcpy(&((*lsndb)->lbdesc), lbdesc, sizeof(LnxBufferDesc));
-
- if (!(lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- memcpy(&((*lsndb)->wfx), lbdesc->lpwfxFormat, sizeof(WAVEFORMATEX));
- } else {
- // set up the wave format based on the device settings (primary)
- (*lsndb)->wfx.wFormatTag = WAVE_FORMAT_PCM;
- (*lsndb)->wfx.nChannels = dev->channels;
- (*lsndb)->wfx.nSamplesPerSec = dev->freq;
- (*lsndb)->wfx.nBlockAlign = dev->channels * (dev->bit_depth / 8);
- (*lsndb)->wfx.nAvgBytesPerSec = dev->freq * (*lsndb)->wfx.nBlockAlign;
- (*lsndb)->wfx.wBitsPerSample = dev->bit_depth;
- (*lsndb)->wfx.cbSize = 0;
- }
-
- if (LnxBuffers) {
- enter_critical();
- LnxBuffers = (LnxSoundBuffer **)realloc(LnxBuffers, sizeof(LnxSoundBuffer *) * (LnxNumBuffers + 1));
- LnxBuffers[LnxNumBuffers] = *lsndb;
- LnxNumBuffers++;
- exit_critical();
- } else {
- LnxBuffers = (LnxSoundBuffer **)malloc(sizeof(LnxSoundBuffer *));
- LnxBuffers[0] = *lsndb;
- LnxNumBuffers++;
-
- // Initialize the Sound system and thread
- StartupSoundSystem(dev);
- }
-
- return 0;
-}
-
-////////////////////////////
-// LnxSoundBuffer_Release
-////////////////////////////
-// Releases the memory associated with a sound buffer. This pointer is
-// no longer valid after return.
-//
-// Returns:
-// -1 : Invalid Parameter
-// 0 : Ok!
-int LnxSoundBuffer_Release(LnxSoundBuffer *buff) {
- int i;
-
- if (!buff)
- return -1;
-
- for (i = 0; i < LnxNumBuffers; i++) {
- if (LnxBuffers[i] == buff)
- break;
- }
-
- if (i < LnxNumBuffers) {
- if (LnxNumBuffers == 1) {
- // stop the thread! primary going down
- ShutdownSoundSystem();
-
- LnxNumBuffers = 0;
- LnxBuffers = nullptr;
- } else {
- // wait until it is ok (our thread is in a good position)
- enter_critical();
-
- if (i == 0) {
- // can't delete the primary! whats going on here?
- return -1;
- }
-
- LnxBuffers[i] = LnxBuffers[LnxNumBuffers - 1];
- LnxBuffers = (LnxSoundBuffer **)realloc(LnxBuffers, sizeof(LnxSoundBuffer *) * (LnxNumBuffers - 1));
- LnxNumBuffers--;
-
- exit_critical();
- }
-
- if (buff->buffer)
- free(buff->buffer);
- free(buff);
- } else
- return -1;
-
- if (LnxNumBuffers == 1) {
- // we freed the last non-primary buffer
- // so remove the primary buffer that is remaining
- return LnxSoundBuffer_Release(LnxBuffers[0]);
- }
-
- return 0;
-}
-
-//////////////////////////////
-// LnxSoundBuffer_SetVolume
-//////////////////////////////
-// Sets the volume of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set volume
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetVolume(LnxSoundBuffer *buff, int32_t vol) {
- if (!buff)
- return -1;
-
- if (!(buff->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME))
- return -1;
-
- if ((vol > LNXSND_VOLUME_MAX) || (vol < LNXSND_VOLUME_MIN))
- return -2;
-
- if (buff->lbdesc.dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- // not supported
- enter_critical();
- buff->volume = vol;
- exit_critical();
- return 0;
- }
-
- enter_critical();
-
- buff->volume = vol;
-
- double vt;
- vt = (double)(buff->volume - (buff->pan > 0 ? buff->pan : 0));
- buff->left_vol = (uint32_t)(pow(2.0, vt / 600.0) * 32768.0);
- vt = (double)(buff->volume + (buff->pan < 0 ? buff->pan : 0));
- buff->right_vol = (uint32_t)(pow(2.0, vt / 600.0) * 32768.0);
-
- exit_critical();
-
- return 0;
-}
-
-///////////////////////////
-// LnxSoundBuffer_SetPan
-///////////////////////////
-// Sets the pan of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set pan
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetPan(LnxSoundBuffer *buff, int32_t pan) {
- if (!buff)
- return -1;
-
- if ((pan > LNXSND_PAN_RIGHT) || (pan < LNXSND_PAN_LEFT))
- return -2;
-
- if (!(buff->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (buff->lbdesc.dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- return -1;
- }
-
- enter_critical();
-
- buff->pan = pan;
-
- double pt;
- pt = (double)(buff->volume - (buff->pan > 0 ? buff->pan : 0));
- buff->left_vol = (uint32_t)(pow(2.0, pt / 600.0) * 32768.0);
- pt = (double)(buff->volume + (buff->pan < 0 ? buff->pan : 0));
- buff->right_vol = (uint32_t)(pow(2.0, pt / 600.0) * 32768.0);
-
- exit_critical();
-
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Stop
-/////////////////////////
-// Stops a buffer from playing
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Stop(LnxSoundBuffer *buff) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->playing = 0;
- exit_critical();
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Play
-/////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Play(LnxSoundBuffer *buff, uint32_t flags) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->flags = flags;
- buff->playing = 1;
- exit_critical();
- return 0;
-}
-
-////////////////////////////
-// LnxSoundBuffer_GetCaps
-////////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCaps(LnxSoundBuffer *buff, LinuxSoundCaps *caps) {
- if (!caps || !buff)
- return -1;
-
- caps->dwFlags = buff->lbdesc.dwFlags | LNXSND_CAPS_LOCSOFTWARE;
- caps->dwBufferBytes = buff->lbdesc.dwBufferBytes;
-
- return 0;
-}
-
-//////////////////////////////
-// LnxSoundBuffer_GetStatus
-//////////////////////////////
-// Returns the status of a buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetStatus(LnxSoundBuffer *buff, uint32_t *status) {
- if (!status || !buff)
- return -1;
-
- *status = 0;
- if (buff->playing)
- *status |= LNXSND_PLAYING;
- if (buff->flags & LNXSND_LOOPING)
- *status |= LNXSND_LOOPING;
-
- return 0;
-}
-
-///////////////////////////////////////
-// LnxSoundBuffer_GetCurrentPosition
-///////////////////////////////////////
-// Returns the current play and write positions of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCurrentPosition(LnxSoundBuffer *buff, uint32_t *ppos, uint32_t *wpos) {
- if (!buff)
- return -1;
-
- if (ppos)
- *ppos = buff->play_cursor;
- if (wpos)
- *wpos = buff->write_cursor;
-
- return 0;
-}
-
-///////////////////////////////////////
-// LnxSoundBuffer_SetCurrentPosition
-///////////////////////////////////////
-// Sets the current play position of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_SetCurrentPosition(LnxSoundBuffer *buff, uint32_t pos) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->play_cursor = pos;
- exit_critical();
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Lock
-/////////////////////////
-// Locks the given buffer, returning pointer(s) to the buffer(s) along with
-// available the size of the buffer(s) for writing.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Lock(LnxSoundBuffer *buff, uint32_t pos, uint32_t numbytes, void **ptr1,
- uint32_t *numbytes1, void **ptr2, uint32_t *numbytes2, uint32_t flags) {
- if (!buff)
- return -1;
-
- if (flags & LNXSND_LOCK_FROMWRITECURSOR)
- pos += buff->write_cursor;
- if (flags & LNXSND_LOCK_ENTIREBUFFER)
- numbytes = buff->buffer_len;
- if (numbytes > buff->buffer_len)
- numbytes = buff->buffer_len;
-
- assert(numbytes1 != numbytes2);
- assert(ptr1 != ptr2);
-
- if (pos + numbytes <= buff->buffer_len) {
- *(uint8_t **)ptr1 = buff->buffer + pos;
- *numbytes1 = numbytes;
- if (ptr2)
- *(uint8_t **)ptr2 = nullptr;
- if (numbytes2)
- *numbytes2 = 0;
- } else {
- *(uint8_t **)ptr1 = buff->buffer + pos;
- *numbytes1 = buff->buffer_len - pos;
- if (ptr2)
- *(uint8_t **)ptr2 = buff->buffer;
- if (numbytes2)
- *numbytes2 = numbytes - (buff->buffer_len - pos);
- }
- return 0;
-}
-
-///////////////////////////
-// LnxSoundBuffer_Unlock
-///////////////////////////
-// Unlocks a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Unlock(LnxSoundBuffer *buff, void *ptr1, uint32_t num1, void *ptr2, uint32_t num2) {
- if (!buff)
- return -1;
-
- return 0;
-}
-
-///////////////////////////////////////////
-// Internal Sound System routines
-//////////////////////////////////////////////////////////////
-
-// Starts up the sound processing thread
-static bool StartupSoundSystem(LnxSoundDevice *dev) {
- SDL_AudioSpec spec;
-
- if (LnxNumBuffers < 1)
- return false;
-
- const int kDefaultSampleCount = 1024;
- int sampleCount = kDefaultSampleCount;
- int sampleArgIndex = FindArg("-sdlSndSizeMovie");
- if (sampleArgIndex == 0) {
- sampleArgIndex = FindArg("-sdlSndSize");
- }
- if (sampleArgIndex != 0) {
- const char *sampleCountStr = GetArg(sampleArgIndex + 1);
- if (sampleCountStr) {
- sampleCount = atoi(sampleCountStr);
- if (sampleCount <= 0) {
- sampleCount = kDefaultSampleCount;
- }
- }
- }
-
- memcpy(&LinuxSoundDevice, dev, sizeof(LnxSoundDevice));
- spec.freq = dev->freq;
- spec.format = dev->bit_depth == 8 ? AUDIO_U8 : AUDIO_S16SYS;
- spec.channels = dev->channels;
- spec.samples = sampleCount;
- spec.callback = LinuxSoundThreadHandler;
-
- if (SDL_OpenAudio(&spec, nullptr) < 0) {
- return false;
- }
- SDL_PauseAudio(0);
- return true;
-}
-
-// Shutsdown the sound processing thread
-static void ShutdownSoundSystem() { SDL_CloseAudio(); }
-
-static inline void GetValues(const LnxSoundBuffer *dsb, uint8_t *buf, uint32_t *fl, uint32_t *fr) {
- int16_t *bufs = (int16_t *)buf;
-
- // 8 bit stereo
- if ((dsb->wfx.wBitsPerSample == 8) && dsb->wfx.nChannels == 2) {
- *fl = (*buf - 128) << 8;
- *fr = (*(buf + 1) - 128) << 8;
- return;
- }
-
- // 16 bit stereo
- if ((dsb->wfx.wBitsPerSample == 16) && dsb->wfx.nChannels == 2) {
- *fl = *bufs;
- *fr = *(bufs + 1);
- return;
- }
-
- // 8 bit mono
- if ((dsb->wfx.wBitsPerSample == 8) && dsb->wfx.nChannels == 1) {
- *fl = (*buf - 128) << 8;
- *fr = *fl;
- return;
- }
-
- // 16 bit mono
- if ((dsb->wfx.wBitsPerSample == 16) && dsb->wfx.nChannels == 1) {
- *fl = *bufs;
- *fr = *bufs;
- return;
- }
-}
-
-static inline void SetValues(uint8_t *buf, uint32_t fl, uint32_t fr) {
- int16_t *bufs = (int16_t *)buf;
-
- // 8 bit stereo
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 8) && (LnxBuffers[0]->wfx.nChannels == 2)) {
- *buf = (fl + 32768) >> 8;
- *(buf + 1) = (fr + 32768) >> 8;
- return;
- }
-
- // 16 bit stereo
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 16) && (LnxBuffers[0]->wfx.nChannels == 2)) {
- *bufs = fl;
- *(bufs + 1) = fr;
- return;
- }
-
- // 8 bit mono
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 8) && (LnxBuffers[0]->wfx.nChannels == 1)) {
- *buf = (((fl + fr) >> 1) + 32768) >> 8;
- return;
- }
-
- // 16 bit mono
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 16) && (LnxBuffers[0]->wfx.nChannels == 1)) {
- *bufs = (fl + fr) >> 1;
- return;
- }
-}
-
-static void LinuxSoundMixWithVolume(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len) {
- uint32_t i, inc = (LnxBuffers[0]->wfx.wBitsPerSample >> 3);
- uint8_t *bpc = buf;
- int16_t *bps = (int16_t *)buf;
-
- if ((!(dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (dsb->pan == 0)) &&
- (!(dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME) || (dsb->volume == 0)))
- return;
-
- for (i = 0; i < len; i += inc) {
- uint32_t val;
- switch (inc) {
- case 1: {
- val = *bpc - 128;
- val = ((val * (i & inc ? dsb->right_vol : dsb->left_vol)) >> 15);
- *bpc = val + 128;
- bpc++;
- } break;
- case 2: {
- val = *bps;
- val = ((val * ((i & inc) ? dsb->right_vol : dsb->left_vol)) >> 15);
- *bps = val;
- bps++;
- } break;
- }
- }
-}
-
-static uint32_t LinuxSoundMixNormalize(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len) {
- uint32_t i, size, ipos, ilen, fieldL = 0, fieldR = 0;
- uint8_t *ibp, *obp;
- uint32_t iAdvance = dsb->wfx.nBlockAlign;
- uint32_t oAdvance = LnxBuffers[0]->wfx.nBlockAlign;
-
- ibp = dsb->buffer + dsb->play_cursor;
- obp = buf;
-
- if ((dsb->freq == LnxBuffers[0]->wfx.nSamplesPerSec) &&
- (dsb->wfx.wBitsPerSample == LnxBuffers[0]->wfx.wBitsPerSample) &&
- (dsb->wfx.nChannels == LnxBuffers[0]->wfx.nChannels)) {
- if ((ibp + len) < (uint8_t *)(dsb->buffer + dsb->buffer_len))
- memcpy(obp, ibp, len);
- else {
- memcpy(obp, ibp, dsb->buffer_len - dsb->play_cursor);
- memcpy(obp + (dsb->buffer_len - dsb->play_cursor), dsb->buffer, len - (dsb->buffer_len - dsb->play_cursor));
- }
- return len;
- }
-
- if (dsb->freq == LnxBuffers[0]->wfx.nSamplesPerSec) {
- ilen = 0;
- for (i = 0; i < len; i += oAdvance) {
- GetValues(dsb, ibp, &fieldL, &fieldR);
- ibp += iAdvance;
- ilen += iAdvance;
- SetValues(obp, fieldL, fieldR);
- obp += oAdvance;
- if (ibp >= (uint8_t *)(dsb->buffer + dsb->buffer_len))
- ibp = dsb->buffer;
- }
- return (ilen);
- }
-
- size = len / oAdvance;
- ilen = ((size * dsb->freq_adjustment) >> FREQUENCY_SHIFT) * iAdvance;
- for (i = 0; i < size; i++) {
- ipos = (((i * dsb->freq_adjustment) >> FREQUENCY_SHIFT) * iAdvance) + dsb->play_cursor;
-
- if (ipos >= dsb->buffer_len)
- ipos %= dsb->buffer_len;
-
- GetValues(dsb, (dsb->buffer + ipos), &fieldL, &fieldR);
- SetValues(obp, fieldL, fieldR);
- obp += oAdvance;
- }
- return ilen;
-}
-
-int DoMulDiv(int nNumber, int nNumerator, int nDenominator) {
- if (!nDenominator)
- return -1;
- int64_t ret;
- ret = (((int64_t)nNumber * nNumerator) + (nDenominator / 2)) / nDenominator;
-
- if ((ret > 0x7FFFFFFF) || (ret < 0xFFFFFFFF))
- return -1;
- return ret;
-}
-
-static void *TempSoundBuffer = nullptr;
-static int TempSoundBufferLen = 0;
-static uint32_t LinuxSoundMixInMainBuffer(LnxSoundBuffer *dsb, int len) {
- uint32_t i, ilen, advance = (LnxBuffers[0]->wfx.wBitsPerSample >> 3);
- uint8_t *buf, *ibuf, *obuf;
- int32_t temp, field;
- int16_t *ibufs, *obufs;
-
- if (!(dsb->flags & LNXSND_LOOPING)) {
- temp = DoMulDiv(LnxBuffers[0]->wfx.nAvgBytesPerSec, dsb->buffer_len, dsb->bps) -
- DoMulDiv(LnxBuffers[0]->wfx.nAvgBytesPerSec, dsb->play_cursor, dsb->bps);
- len = (len > temp) ? temp : len;
- }
- len &= ~3; // align to 4 byte boundary
-
- if (!len) {
- dsb->playing = 0;
- dsb->write_cursor = 0;
- dsb->play_cursor = 0;
- return 0;
- }
-
- if (len > TempSoundBufferLen) {
- void *nb = realloc(TempSoundBuffer, len);
- if (nb) {
- TempSoundBuffer = nb;
- TempSoundBufferLen = len;
- buf = ibuf = (uint8_t *)nb;
- } else {
- return 0;
- }
- } else {
- buf = ibuf = (uint8_t *)TempSoundBuffer;
- }
-
- ilen = LinuxSoundMixNormalize(dsb, ibuf, len);
- if ((dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME)) {
- LinuxSoundMixWithVolume(dsb, ibuf, len);
- }
-
- obuf = LnxBuffers[0]->buffer + LnxBuffers[0]->play_cursor;
- for (i = 0; i < len; i += advance) {
- obufs = (int16_t *)obuf;
- ibufs = (int16_t *)ibuf;
- if (LnxBuffers[0]->wfx.wBitsPerSample == 16) {
- field = *ibufs;
- field += *obufs;
- field = (field > 32767) ? (32767) : field;
- field = (field < -32768) ? (-32768) : field;
- *obufs = field;
- } else {
- field = (*ibuf - 128);
- field += (*obuf - 128);
- field = (field > 127) ? (127) : field;
- field = (field < -128) ? (-128) : field;
- *obuf = field + 128;
- }
- ibuf += advance;
- obuf += advance;
- if (obuf >= (uint8_t *)(LnxBuffers[0]->buffer + LnxBuffers[0]->buffer_len))
- obuf = LnxBuffers[0]->buffer;
- }
-
- // adjust positions of the cursors in the buffer
- dsb->play_cursor += ilen;
- dsb->write_cursor = dsb->play_cursor + ilen;
-
- if (dsb->play_cursor >= dsb->buffer_len) {
- if (!(dsb->flags & LNXSND_LOOPING)) {
- // we're not looping, this buffer is done, reset it
- dsb->playing = 0;
- dsb->write_cursor = 0;
- dsb->play_cursor = 0;
- } else {
- // loop back around
- dsb->play_cursor = dsb->play_cursor % dsb->buffer_len;
- }
- }
-
- if (dsb->write_cursor >= dsb->buffer_len) {
- dsb->write_cursor = dsb->write_cursor % dsb->buffer_len;
- }
-
- return len;
-}
-
-static void LinuxSoundMixBuffersIntoMain(int len) {
- LnxSoundBuffer *dsb;
-
- // only go to 1 since 0 is the main buffer
- for (int i = LnxNumBuffers - 1; i > 0; i--) {
- if (!(dsb = LnxBuffers[i]))
- continue;
-
- if (dsb->buffer_len && dsb->playing) {
- LinuxSoundMixInMainBuffer(dsb, len);
- }
- }
-}
-
-static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len) {
- SDL_memset(stream, '\0', len);
-
- LnxBuffers[0]->buffer = stream;
- LnxBuffers[0]->buffer_len = len;
- LnxBuffers[0]->play_cursor = 0;
- LnxBuffers[0]->write_cursor = 0;
-
- LinuxSoundMixBuffersIntoMain(len);
-
- LnxBuffers[0]->buffer = nullptr;
-}
diff --git a/libmve/lnxdsound.h b/libmve/lnxdsound.h
deleted file mode 100644
index a0fe3155..00000000
--- a/libmve/lnxdsound.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifndef __LNX_DSOUND_H_
-#define __LNX_DSOUND_H_
-
-#include "SystemInterfaces.h"
-struct LnxSoundDevice {
- int sound_device; // file device handle for sound
- uint32_t bps; // (bytes per second) channels*freq*bit_depth/8
- uint32_t freq; // frequency (22050, etc.)
- uint32_t bit_depth; // 8 or 16
- uint32_t channels; // 1 or 2 (mono or stereo)
-};
-
-#define WAVEFORMATEX SoundWAVEFormatEx
-
-#define WAVE_FORMAT_PCM 0x01
-
-#define LinuxSoundCaps SysSoundCaps
-
-#define LnxBufferDesc SysSoundBufferDesc
-
-struct LnxSoundBuffer {
- int freq_adjustment;
- int bps;
- uint32_t buffer_len;
- uint32_t play_cursor;
- uint32_t write_cursor;
- uint32_t flags;
- uint32_t left_vol, right_vol;
-
- uint8_t *buffer;
-
- int32_t volume;
- int32_t pan;
-
- WAVEFORMATEX wfx;
-
- LnxBufferDesc lbdesc;
-
- uint16_t freq;
- char playing;
- char __pad;
-};
-
-///////////////////////////////
-// LnxSound_CreateSoundBuffer
-///////////////////////////////
-// Creates a sound buffer to be used with mixing and output.
-//
-// Returns:
-// -1 : Invalid Parameter
-// -2 : Out of memory
-// 0 : Ok!
-int LnxSound_CreateSoundBuffer(LnxSoundDevice *dev, LnxBufferDesc *lbdesc, LnxSoundBuffer **lsndb);
-
-////////////////////////////
-// LnxSoundBuffer_Release
-////////////////////////////
-// Releases the memory associated with a sound buffer. This pointer is
-// no longer valid after return.
-//
-// Returns:
-// -1 : Invalid Parameter
-// 0 : Ok!
-int LnxSoundBuffer_Release(LnxSoundBuffer *buff);
-
-//////////////////////////////
-// LnxSoundBuffer_SetVolume
-//////////////////////////////
-// Sets the volume of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set volume
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetVolume(LnxSoundBuffer *buff, int32_t vol);
-
-///////////////////////////
-// LnxSoundBuffer_SetPan
-///////////////////////////
-// Sets the pan of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set pan
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetPan(LnxSoundBuffer *buff, int32_t pan);
-
-/////////////////////////
-// LnxSoundBuffer_Stop
-/////////////////////////
-// Stops a buffer from playing
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Stop(LnxSoundBuffer *buff);
-
-/////////////////////////
-// LnxSoundBuffer_Play
-/////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Play(LnxSoundBuffer *buff, uint32_t flags);
-
-////////////////////////////
-// LnxSoundBuffer_GetCaps
-////////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCaps(LnxSoundBuffer *buff, LinuxSoundCaps *caps);
-
-//////////////////////////////
-// LnxSoundBuffer_GetStatus
-//////////////////////////////
-// Returns the status of a buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetStatus(LnxSoundBuffer *buff, uint32_t *status);
-
-///////////////////////////////////////
-// LnxSoundBuffer_GetCurrentPosition
-///////////////////////////////////////
-// Returns the current play and write positions of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCurrentPosition(LnxSoundBuffer *buff, uint32_t *ppos, uint32_t *wpos);
-
-///////////////////////////////////////
-// LnxSoundBuffer_SetCurrentPosition
-///////////////////////////////////////
-// Sets the current play position of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_SetCurrentPosition(LnxSoundBuffer *buff, uint32_t pos);
-
-/////////////////////////
-// LnxSoundBuffer_Lock
-/////////////////////////
-// Locks the given buffer, returning pointer(s) to the buffer(s) along with
-// available the size of the buffer(s) for writing.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Lock(LnxSoundBuffer *buff, uint32_t pos, uint32_t numbytes, void **ptr1,
- uint32_t *numbytes1, void **ptr2, uint32_t *numbytes2, uint32_t flags);
-
-///////////////////////////
-// LnxSoundBuffer_Unlock
-///////////////////////////
-// Unlocks a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Unlock(LnxSoundBuffer *buff, void *ptr1, uint32_t num1, void *ptr2, uint32_t num2);
-
-#endif
diff --git a/libmve/mve.asm b/libmve/mve.asm
deleted file mode 100644
index faf2d5e5..00000000
--- a/libmve/mve.asm
+++ /dev/null
@@ -1,9635 +0,0 @@
-; .386
- .486 ; I only need .386, but I wanted the 486 cycle timings
- .MODEL FLAT, C
-
-;;--- Types ---
-
-PTRBYTE TYPEDEF PTR BYTE
-PTRWORD TYPEDEF PTR WORD
-PTRDWORD TYPEDEF PTR DWORD
-PTRPROC TYPEDEF PTR PROC
-
-;;--- Constants ---
-
-; Width and height of sections in pixels.
-SWIDTH equ 8
-SHEIGHT equ 8
-
-LOG2_SWIDTH equ 3
-LOG2_SHEIGHT equ 3
-
-;;---
-
-EXTERN pal_tbl:BYTE ;unsigned char pal_tbl[3*256];
-EXTERN pal15_tbl:WORD ;unsigned short pal15_tbl[256];
-;; NextFrame working storage
- ; MemRec nf_mem_buf1;
- ; MemRec nf_mem_buf2;
-EXTERN nf_buf_cur: PTRBYTE ; unsigned char* nf_buf_cur;
-EXTERN nf_buf_prv: PTRBYTE ; unsigned char* nf_buf_prv;
-
-;; NextFrame parameters
-EXTERN nf_wqty: BYTE ;unsigned char nf_wqty; // (width/SWIDTH)
-EXTERN nf_hqty: BYTE ;unsigned char nf_hqty; // (height/SHEIGHT)
-EXTERN nf_fqty: BYTE ;unsigned char nf_fqty; // Number of fields
-EXTERN nf_hicolor: DWORD ;unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
-;;
-EXTERN nf_width: DWORD ;unsigned nf_width; // wqty * SWIDTH
-EXTERN nf_height: DWORD ;unsigned nf_height; // hqty * SHEIGHT;
-EXTERN nf_new_line: DWORD ;unsigned nf_new_line; // width - SWIDTH
-EXTERN nf_new_row0: DWORD ;unsigned nf_new_row0; // SHEIGHT*width*2-width
-EXTERN nf_back_right: DWORD ;unsigned nf_back_right; // (SHEIGHT-1)*width
-
-;; Frame parameters
-;; Portion of current frame which has been updated
-;; and needs to be sent to screen.
-;;
-EXTERN nf_new_x: DWORD ;unsigned nf_new_x;
-EXTERN nf_new_y: DWORD ;unsigned nf_new_y;
-EXTERN nf_new_w: DWORD ;unsigned nf_new_w;
-EXTERN nf_new_h: DWORD ;unsigned nf_new_h;
-
- .data
-
- BYTE "(c) 1997 Interplay Productions. All Rights Reserved.\n"
- BYTE "This file is confidential and consists of proprietary information\n"
- BYTE "of Interplay Productions. This file and associated libraries\n"
- BYTE "may not, in whole or in part, be disclosed to third parties,\n"
- BYTE "incorporated into any software product which is not being created\n"
- BYTE "for Interplay Productions, copied or duplicated in any form,\n"
- BYTE "without the prior written permission of Interplay Productions.\n"
- BYTE "Further, you may not reverse engineer, decompile or otherwise\n"
- BYTE "attempt to derive source code of this material.\n",0
-
- .code
-
-
-NF_DECOMP_INIT MACRO HI_COLOR_FLAG: REQ
-
- mov ax, ds ; Insure es==ds for symantec flat mode
- mov es, ax
-
- mov eax, nf_buf_prv ; DiffBufPtrs = nf_buf_prv - nf_buf_cur
- sub eax, nf_buf_cur
- mov DiffBufPtrs, eax
-
- xor ebx, ebx ; ebx = nf_fqty (convert to 32-bits)
- mov bl, nf_fqty
-
- mov eax, x ; nf_new_x = x*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- mov nf_new_x, eax
-
- mov eax, w ; nf_new_w = w*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- mov nf_new_w, eax
-
- mov eax, y ; nf_new_y = y*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov nf_new_y, eax
-
- mov eax, h ; nf_new_h = h*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov nf_new_h, eax
-
- mov eax, nf_new_row0 ; new_row = nf_new_row0 - nf_new_w;
- sub eax, nf_new_w
- mov new_row, eax
-
- ;; Move to correct place in current buffer
- mov eax, nf_buf_cur ; tbuf = nf_buf_cur
- mov tbuf, eax
- .if x || y ; if (x||y)
- mov eax, nf_new_y ; tbuf += nf_new_y*nf_width + nf_new_x;
- mul nf_width
- add eax, nf_new_x
- add tbuf, eax
- .endif
-
- ENDM ; DECOMP_INIT
-
-DECOMP_BODY MACRO HI_COLOR_FLAG:REQ
-
- LOCAL HI_COLOR_SCALE
- HI_COLOR_SCALE equ HI_COLOR_FLAG+1
- NF_DECOMP_INIT HI_COLOR_FLAG
-
- mov eax, w ; parms_sz = (w*h*nf_fqty)<<1
- mul h
- mul ebx ;nf_fqty
- shl eax, 1
- mov parms_sz, eax
-
- ; esi indexes comp (to get new section data)
- ; edi indexes current screen buffer
- ; edx is a frequently used constant
- ; ebx indexes section params
- mov edi, tbuf
- mov edx, nf_new_line ; width - SWIDTH
- mov ebx, comp ; Parms index
- mov esi, ebx
- add esi, parms_sz ; Skip over flags (w*h*2)
-
- ; Iterate over params and copy new hires data to appropriate sections.
- mov cl, nf_fqty
-ns_0f: push ecx
- push edi
- mov ch, byte ptr h
-ns_0: mov cl, byte ptr w
-ns_1: cmp word ptr [ebx],0
- je ns_10
- add edi, SWIDTH*HI_COLOR_SCALE
-ns_2: add ebx, 2
- dec cl
- jnz ns_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ns_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ns_0f
- jmp ns_99
-
- ; Copy new data to one section
- ; Enter with esi pointing to source data, edi to screen section.
-
- ; Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
-ns_10:
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- jmp ns_2
-
-ns_99:
-
- ; Iterate over flags and motion source addresses from params
- ; to determine which sections to move.
- ; ebx indexes params.
- ; esi indexes source from buffer
- ; esi will be computed as +- 16K relative to edi.
-
- sub ebx, parms_sz ; Move back to start of section parms
- mov edi, tbuf
- mov cl, nf_fqty
- xor esi, esi
-ms_0f: push ecx
- push edi
- mov ch, byte ptr h
-ms_0: mov cl, byte ptr w
-ms_1: or si, [ebx]
- jg ms_10
- jl ms_j30
- add edi, SWIDTH*HI_COLOR_SCALE
-ms_2: add ebx, 2
- dec cl
- jnz ms_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_0f
- jmp ms_99
-
-ms_j30: jmp ms_30
-
- ; Move one section from current screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_10: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-04000h*HI_COLOR_SCALE+edi]
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- jmp ms_2
-
-
-ms_20f: push ecx
- push edi
- mov ch, byte ptr h
-ms_20: mov cl, byte ptr w
-ms_21: or si, [ebx]
- jl ms_30
- jg ms_j10
- add edi, SWIDTH*HI_COLOR_SCALE
-ms_22: add ebx, 2
- dec cl
- jnz ms_21
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_20
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_20f
- jmp ms_99
-
-ms_j10: jmp ms_10
-
- ; Move one section from previous screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_30: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-0C000h*HI_COLOR_SCALE+edi]
- add esi, DiffBufPtrs ; and point to other buffer
-
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- jmp ms_22
-
-ms_99:
- ENDM ; DECOMP_BODY
-
-; Non-HiColor versions
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-;
-;void nfDecomp(unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfDecomp PROC USES ESI EDI EBX, comp:PTRBYTE, x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
- LOCAL parms_sz: DWORD
-
- .if nf_hicolor
- INVOKE nfHiColorDecomp, comp,x,y,w,h
- ret
- .endif
-
- DECOMP_BODY 0 ; Not HiColor
-
- ret
-nfDecomp ENDP
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-;
-
-;void
-;nfHiColorDecomp(unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfHiColorDecomp PROC USES ESI EDI EBX,comp:PTRBYTE,x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
- LOCAL parms_sz: DWORD
-
- DECOMP_BODY 1 ; HiColor
-
- ret
-nfHiColorDecomp ENDP
-
-DECOMP_CHG_BODY MACRO HI_COLOR_FLAG:REQ
-
- LOCAL HI_COLOR_SCALE
- HI_COLOR_SCALE equ HI_COLOR_FLAG+1
- NF_DECOMP_INIT HI_COLOR_FLAG
-
- ; esi indexes comp (to get new section data)
- ; edi indexes current screen buffer
- ; edx is a frequently used constant
- ; ebx indexes section params
- mov edi, tbuf
- mov edx, nf_new_line ; width - SWIDTH
- mov esi, comp
- mov ebx, parms
-
- ; Iterate over params and copy new hires data to appropriate sections.
-
- mov eax, chgs
- mov pChgs, eax
- mov eax, 0
- mov cl, nf_fqty
-ns_0f: push ecx
- push edi
- mov ch, byte ptr h
-ns_0: mov cl, byte ptr w
-ns_1: add ax, ax
- ja ns_1b
- jz ns_5
- cmp word ptr [ebx],0
- je ns_10
- add ebx, 2
-ns_1b: add edi, SWIDTH*HI_COLOR_SCALE
-ns_2: dec cl
- jnz ns_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ns_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ns_0f
- jmp ns_99
-
-ns_5: mov eax, pChgs
- add pChgs, 2
- mov ax, [eax]
- jmp ns_1
-
- ; Copy new data to one section
- ; Enter with ds:si pointing to source data, es:di to screen section.
-
- ; Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
-ns_10:
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- add ebx, 2
- jmp ns_2
-
-ns_99:
-
- ; Iterate over flags and motion source addresses from params
- ; to determine which sections to move.
- ; ebx indexes params.
- ; esi indexes source from buffer
- ; esi will be computed as +- 16K relative to edi.
-
- mov edi, tbuf
- mov ebx, parms
-
- mov eax, chgs
- mov pChgs, eax
- mov eax, 0
- mov cl, byte ptr nf_fqty
- xor esi, esi
-ms_0f: push ecx
- push edi
- mov ch, byte ptr h
-ms_0: mov cl, byte ptr w
-ms_1: add ax, ax
- ja ms_1b
- jz ms_5
- or si, [ebx]
- jg ms_10
- jl ms_j30
- add ebx, 2
-ms_1b: add edi, SWIDTH*HI_COLOR_SCALE
-ms_2: dec cl
- jnz ms_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_0f
- jmp ms_99
-
-ms_5: mov eax, pChgs
- add pChgs, 2
- mov ax, word ptr [eax]
- jmp ms_1
-
-
-ms_j30: jmp ms_30
-
- ; Move one section from current screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_10: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-04000h*HI_COLOR_SCALE+edi]
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- add ebx, 2
- jmp ms_2
-
-
-ms_20f: push ecx
- push edi
- mov ch, byte ptr h
-ms_20: mov cl, byte ptr w
-ms_21: add ax, ax
- ja ms_21b
- jz ms_25
- or si, [ebx]
- jl ms_30
- jg ms_j10
- add ebx, 2
-ms_21b: add edi, SWIDTH*HI_COLOR_SCALE
-ms_22: dec cl
- jnz ms_21
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_20
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_20f
- jmp ms_99
-
-ms_25: mov eax, pChgs
- add pChgs, 2
- mov ax, [eax]
- jmp ms_21
-
-ms_j10: jmp ms_10
-
- ; Move one section from previous screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_30: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-0C000h*HI_COLOR_SCALE+edi]
- add esi, DiffBufPtrs ; and point to other buffer
-
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- add ebx, 2
- xor esi, esi ; Reset esi to zero
- jmp ms_22
-
-ms_99:
- ENDM ; DECOMP_CHG_BODY
-
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-; Chgs specifies which squares to update.
-; Parms are motion parms for squares to update.
-;
-;void
-;nfDecompChg(unsigned short *chgs,
-; unsigned short *parms,
-; unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfDecompChg PROC USES ESI EDI EBX,chgs:PTRWORD, parms:PTRWORD,comp:PTRBYTE,x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
- LOCAL pChgs: PTRBYTE
-
- .if nf_hicolor
- INVOKE nfHiColorDecompChg, chgs,parms,comp,x,y,w,h
- ret
- .endif
-
- DECOMP_CHG_BODY 0 ; Not HiColor
-
- ret
-nfDecompChg ENDP
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-; Chgs specifies which squares to update.
-; Parms are motion parms for squares to update.
-;
-;void
-;nfHiColorDecompChg(unsigned short *chgs,
-; unsigned short *parms,
-; unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfHiColorDecompChg PROC USES ESI EDI EBX,chgs:PTRWORD,parms:PTRWORD,comp:PTRBYTE,x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
- LOCAL pChgs: PTRBYTE
-
- DECOMP_CHG_BODY 1 ; HiColor
- ret
-nfHiColorDecompChg ENDP
-
-
-.data
-
-; luminace table for palette entries
-lum_tbl DWORD 256 DUP (0)
-
-; signed 8-bit y * nf_width
-nfpk_ShiftY DWORD 256 DUP (0)
-
-; Constant tables
-
-; 8-bit -8:7 x nf_width + -8:7
-nfpk_ShiftP1 LABEL WORD
-FOR y, <-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7>
- FOR x, <-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7>
- BYTE x,y
- ENDM
-ENDM
-
-; 8-bit to right and below in roughly 0:14*nf_width + -14:14 (-3 cases)
-; negative is
-; 8-bit to left and above in roughly -14:0*nf_width + -14:14 (-3 cases)
-nfpk_ShiftP2 LABEL WORD
-FOR y, <0,1,2,3,4,5,6,7>
- FOR x, <8,9,10,11,12,13,14>
- BYTE x,y
- ENDM
-ENDM
-FOR y, <8,9,10,11,12,13>
- FOR x, <-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1>
- BYTE x,y
- ENDM
- FOR x, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14>
- BYTE x,y
- ENDM
-ENDM
-FOR x, <-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1>
- BYTE x,14
-ENDM
-FOR x, <0,1,2,3,4,5,6,7,8,9,10,11>
- BYTE x,14
-ENDM
-
-nfpk_mov4l LABEL DWORD
-; mov ax, bx,cx
-MOV4L_REGS TEXTEQU >
-%FOR m4, MOV4L_REGS
-% FOR m3, MOV4L_REGS
-% FOR m2, MOV4L_REGS
-% FOR m1, MOV4L_REGS
- BYTE m2,m1,m4,m3
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfpk_mov8 LABEL DWORD
-; mov ax, bx/dx/cx/bp
-MOV8_REGS TEXTEQU >
-%FOR m4, MOV8_REGS
-% FOR m3, MOV8_REGS
-% FOR m2, MOV8_REGS
-% FOR m1, MOV8_REGS
- BYTE m2,m1,m4,m3
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfpk_mov4 LABEL DWORD
-; mov al, bl/bh/cl/ch
-MOV4_REGS0 TEXTEQU >
-; mov ah, bl/bh/cl/ch
-MOV4_REGS1 TEXTEQU >
-%FOR m4, MOV4_REGS1
-% FOR m3, MOV4_REGS0
-% FOR m2, MOV4_REGS1
-% FOR m1, MOV4_REGS0
- BYTE m3,m4,m1,m2
- ENDM
- ENDM
- ENDM
- ENDM
-
-.code
-
-; nfPkConfig initializes tables used by nfPkDecomp
-; which are dependent on screen size.
-nfPkConfig PROC USES ESI EDI EBX
-
- ; Build ShiftY table
- ;
- lea edi, nfpk_ShiftY
- mov ebx, nf_width
-
- mov eax, 0
- mov ecx, 128
-lp1: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp1
-
- mov eax, ebx
- shl eax, 7
- neg eax
- mov ecx, 128
-lp2: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp2
-
- ret
-nfPkConfig ENDP
-
-
-
-EXTERN sf_LineWidth: DWORD ;unsigned sf_LineWidth; // Distance between lines in memory
-
-; Banked screen parameters
-EXTERN sf_SetBank: PTRPROC ;unsigned long sf_SetBank;
-EXTERN sf_WinGran: DWORD ;unsigned sf_WinGran;
-EXTERN sf_WinSize: DWORD ;unsigned long sf_WinSize;
-EXTERN sf_WinGranPerSize: DWORD ;unsigned sf_WinGranPerSize;
-;{sf_WriteWinPtr and sf_WriteWinLimit replace sf_WriteWinSeg, see mveliba.asm}
-EXTERN sf_WriteWinPtr: PTRBYTE ;unsigned char *sf_WriteWinPtr;
-EXTERN sf_WriteWinLimit: PTRBYTE ;unsigned char *WriteWinLimit;
-EXTERN sf_WriteWin: DWORD ;unsigned sf_WriteWin;
-
-EXTERN opt_hscale_step: DWORD
-EXTERN opt_hscale_adj: DWORD
-
-
-;void mve_ShowFrameField(
-; unsigned char *buf, unsigned bufw, unsigned bufh,
-; unsigned sx, unsigned sy, unsigned w, unsigned h,
-; unsigned dstx, unsigned dsty, unsigned field)
-
-mve_ShowFrameField PROC USES ESI EDI EBX, buf:PTRBYTE, bufw:DWORD, bufh:DWORD, sx:DWORD, sy:DWORD, w:DWORD, h:DWORD, dstx:DWORD, dsty:DWORD, field:DWORD
- LOCAL bank:DWORD
- LOCAL w4:DWORD
- LOCAL new_src_line:DWORD
- LOCAL linestep:DWORD
- LOCAL new_dst_line:DWORD
-
- mov ax, ds ; Insure es==ds for symantec flat mode
- mov es, ax
-
- mov eax, w ; w4 = w>>2
- shr eax, 2
- mov w4, eax
-
-;;;
-;;; In stretched width mode, we either keep 4/5 (a) of the source pixels,
-;;; or duplicate every fourth pixel to magnify by 5/4 (b).
-;;; In these cases, new_src_line is either bufw-w*5/4 (a) or bufw-w*4/5 (b).
-;;; Let ScaleStep be 5 (a) or 3 (b) instead of 4. This is the amount to advance
-;;; the source after copying 32-bits from source to destination.
-;;; The coordinate system used for the source will be a simulated scaled system.
-;;; Rather than scale height, I plan to use alternate vertical resolutions. However,
-;;; it might be a good idea to also provide for scaled height in case we want a
-;;; higher resolution border.
-;;; Question: Do we still need to support transferring subrectangles?
-
- .if opt_hscale_step==4
- mov eax, bufw ; new_src_line = bufw - w
- sub eax, w
- mov new_src_line, eax
- .else
- mov eax, opt_hscale_adj
- mov new_src_line, eax
- .endif
-
- mov eax, sf_LineWidth ; linestep = sf_LineWidth<<1;
- .if field ; if (field)
- add eax, eax ; linestep <<= 1;
- .endif
- mov linestep, eax
-
- sub eax, w ; new_dst_line = linestep - w;
- mov new_dst_line, eax
-
- mov eax, sy ; buf += sy*bufw + sx
- mul bufw
- add eax, sx
- add buf, eax
-
- mov eax, sx ; dstx += sx
- add dstx, eax
-
- ; This is a hack. We should pass in src x,y of origin
- ; or make dstx/dsty absolute.
- ;
- mov eax, bufw ; if (field && sx >= (bufw>>1)
- shr eax, 1
- .if field && sx >= eax
- sub dstx, eax ; dstx -= bufw>>1
- .endif
-
- mov eax, sy ; dsty += sy
- add dsty, eax
-
- .if sf_SetBank==0 ;------------------
-
-
- ; dst = WriteWinPtr + (dsty*linestep+dstx)
- mov edi, sf_WriteWinPtr
- mov eax, dsty
- mul linestep
- add eax, dstx
- add edi, eax
-
- .if field & 1
- add edi, sf_LineWidth;
- .endif
-
- mov eax, new_src_line
- mov edx, new_dst_line
- mov esi, buf
- mov ebx, h
-
- .if opt_hscale_step==3
- sub edi, 8
-sf_lp2a:mov ecx, w4
- shr ecx, 2
- ALIGN 4
-sf_lp2b:mov eax, [esi]
- mov [edi+8], eax
- mov eax, [esi+3]
- mov [edi+12], eax
- add edi, 16
- mov eax, [esi+6]
- mov [edi], eax
- mov eax, [esi+9]
- mov [edi+4], eax
- add esi, 12
- dec ecx
- jnz sf_lp2b
- ; To avoid problem of last pixel coming from next line
- ; with arrange for w%16==12, so here is where we copy
- ; last 12 pixels.
- mov eax, [esi]
- mov [edi+8], eax
- mov eax, [esi+3]
- mov [edi+12], eax
- add edi, 12
- mov eax, [esi+6]
- mov [edi+4], eax
- add esi, 9
- add esi, new_src_line
- add edi, edx
- dec ebx
- jnz sf_lp2a
- add edi, 8
- .else
-sf_lp: mov ecx, w4 ;width/4
- rep movsd
- add esi, eax
- add edi, edx
- dec ebx
- jnz sf_lp
- .endif
-
- .else ; sf_SetBank ;------------------
-
-
- mov esi, buf
-
- ; start = dsty * linestep + dstx
-
- mov eax, linestep
- mul dsty
- .if field & 1
- add eax, sf_LineWidth
- .endif
- add eax, dstx
- ; bank = start / WinGran
- ; dst = (start % WinGran) + sf_WriteWinPtr
- mov edx, 0
- div sf_WinGran
- mov bank, eax
- mov edi, edx
- add edi, sf_WriteWinPtr
-
- ; Select new bank
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by sf_SetBank
-
-sf_0: ; rem = sf_WriteWinLimit - dst
- mov eax, sf_WriteWinLimit
- sub eax, edi
- ; h2 = (rem+(LineWidth-w))/LineWidth
- add eax, linestep
- sub eax, w
- mov edx, 0
- div linestep
- ; if (h
-
-extern uint8_t *nf_buf_cur;
-extern uint8_t *nf_buf_prv;
-extern unsigned nf_new_x;
-extern unsigned nf_new_y;
-extern unsigned nf_new_w;
-extern unsigned nf_new_h;
-extern uint8_t nf_fqty; // Number of fields
-extern unsigned nf_new_row0; // SHEIGHT*width*2-width
-extern unsigned nf_width; // wqty * SWIDTH
-extern unsigned nf_new_line; // width - SWIDTH
-extern unsigned nf_back_right; // (SHEIGHT-1)*width
-extern unsigned nf_hicolor;
-
-extern uint16_t nf_trans16_lo[256];
-extern uint16_t nf_trans16_hi[256];
-
-extern int16_t snd_8to16[256];
-void PkDecompWorker(const bool hiColor, const uint8_t *ops, const uint8_t *comp, const unsigned x,
- const unsigned y, const unsigned w, const unsigned h);
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, int x, int y, int w, int h);
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkConfig(void);
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev);
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev);
-
-void Trans16Blk(uint8_t *edi, const uint8_t *idx);
-void DOnf_xycshift(const bool hiColor, const uint32_t eax, uint8_t *&edi, const int nfpk_back_right);
-void DOnf_xypshift(const bool hiColor, const uint32_t eax, uint8_t *&edi, const int nfpk_back_right,
- const int DiffBufPtrs);
-void DOnf_shift(const bool hiColor, int eax, uint8_t *&edi, const int nfpk_back_right);
-
-//--------------------------------------------------------------------
-// Sound Management
-//--------------------
-
-// Decompresses a mono stream containing len samples
-// (src is len bytes, dst is len*2 bytes)
-// prev is the previous decompression state or zero.
-// Returns new decompression state.
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- uint32_t i, eax, ebx;
- if (len == 0)
- return prev;
- eax = prev;
- ebx = 0;
-
- for (i = 0; i < len; i++) {
- ebx = *src;
- src++;
-
- eax += snd_8to16[ebx];
- *dst = eax & 0xFFFF;
- dst++;
- }
-
- return eax;
-}
-
-// Decompresses a stereo stream containing len samples
-// (src is len*2 bytes, dst is len*4 bytes)
-// prev is the previous decompression state or zero
-// (It encodes the 16-bit states of the two stereo channels
-// in its low and high order 16-bit halves.)
-// Returns new decompression state.
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- unsigned re = 0;
- uint32_t eax, edx, ebx, i;
-
- if (len == 0) {
- return prev;
- }
-
- eax = (prev & 0xFFFF);
- edx = ((prev & 0xFFFF0000) >> 16);
- ebx = 0;
-
- for (i = 0; i < len; i++) {
- ebx = *src;
- src++;
-
- eax += snd_8to16[ebx];
- *dst = (eax & 0xFFFF);
- dst++;
-
- ebx = *src;
- src++;
-
- edx += snd_8to16[ebx];
- *dst = (edx & 0xFFFF);
- dst++;
- }
-
- return (eax & 0xFFFF) | ((edx & 0xFFFF) << 16);
-}
-
-struct tNextFrame {
- uint8_t *tbuf;
- int new_row, DiffBufPtrs;
- unsigned x, y, w, h;
-};
-
-// NOTE: On exit ebx is nf_fqty
-void NF_DECOMP_INIT(bool HI_COLOR_FLAG, tNextFrame *nf) {
- nf->DiffBufPtrs = nf_buf_prv - nf_buf_cur;
-
- if (HI_COLOR_FLAG) {
- nf_new_x = nf->x << (LOG2_SWIDTH + 1);
- nf_new_w = nf->w << (LOG2_SWIDTH + 1);
- } else {
- nf_new_x = nf->x << LOG2_SWIDTH;
- nf_new_w = nf->w << LOG2_SWIDTH;
- }
- nf_new_y = (nf->y << LOG2_SHEIGHT) * nf_fqty;
- nf_new_h = (nf->h << LOG2_SHEIGHT) * nf_fqty;
-
- nf->new_row = nf_new_row0 - nf_new_w;
-
- // Move to correct place in current buffer
- nf->tbuf = nf_buf_cur;
- if (nf->x || nf->y) {
- nf->tbuf += nf_new_y * nf_width + nf_new_x;
- }
-}
-
-//----------------------------------------------------------------------
-
-// signed 8-bit y * nf_width
-int32_t nfpk_ShiftY[256];
-
-// Constant tables
-
-// 8-bit -8:7 x nf_width + -8:7
-int16_t nfpk_ShiftP1[256];
-int16_t nfpk_ShiftP2[256];
-
-// Constant tables
-// mov eax, ebx/ecx
-// EBX = 0
-// ECX = 1
-uint8_t nfhpk_mov4l[64];
-
-// mov ax, bx,cx
-// EBX = 0
-// ECX = 1
-uint8_t nfpk_mov4l[64];
-
-// mov ds:[edi+0/4/8/12], ebx/edx/ecx/ebp
-// EBX = 0
-// EDX = 1
-// ECX = 2
-// EBP = 3
-uint8_t nfhpk_mov8[1024];
-
-// mov ax, bx/dx/cx/bp
-// BX = 0
-// DX = 1
-// CX = 2
-// BP = 3
-uint8_t nfpk_mov8[1024];
-
-// mov eax, ebx/edx/ecx/ebp
-// EBX = 0
-// EDX = 1
-// ECX = 2
-// EBP = 3
-uint8_t nfhpk_mov4[1024];
-
-// mov al, bl/bh/cl/ch
-// BL = 0
-// BH = 1
-// CL = 2
-// CH = 3
-uint8_t nfpk_mov4[1024];
-
-class initme {
-public:
- initme() {
- int x, y;
- int m4, m3, m2, m1;
- int8_t *ptr;
- uint8_t *uptr;
-
- // Do nfhpk_mov4l
- uptr = nfhpk_mov4l;
- for (m4 = 0; m4 < 2; ++m4)
- for (m3 = 0; m3 < 2; ++m3)
- for (m2 = 0; m2 < 2; ++m2)
- for (m1 = 0; m1 < 2; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // Do nfpk_mov4l
- uptr = nfpk_mov4l;
- for (m4 = 0; m4 < 2; ++m4)
- for (m3 = 0; m3 < 2; ++m3)
- for (m2 = 0; m2 < 2; ++m2)
- for (m1 = 0; m1 < 2; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // Do nfhpk_mov8
- uptr = nfhpk_mov8;
- for (m4 = 0; m4 < 4; ++m4)
- for (m3 = 0; m3 < 4; ++m3)
- for (m2 = 0; m2 < 4; ++m2)
- for (m1 = 0; m1 < 4; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // Do nfpk_mov8
- uptr = nfpk_mov8;
- for (m4 = 0; m4 < 4; ++m4)
- for (m3 = 0; m3 < 4; ++m3)
- for (m2 = 0; m2 < 4; ++m2)
- for (m1 = 0; m1 < 4; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // Do nfhpk_mov4
- uptr = nfhpk_mov4;
- for (m4 = 0; m4 < 4; ++m4)
- for (m3 = 0; m3 < 4; ++m3)
- for (m2 = 0; m2 < 4; ++m2)
- for (m1 = 0; m1 < 4; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // Do nfpk_mov4
- uptr = nfpk_mov4;
- for (m4 = 0; m4 < 4; ++m4)
- for (m3 = 0; m3 < 4; ++m3)
- for (m2 = 0; m2 < 4; ++m2)
- for (m1 = 0; m1 < 4; ++m1) {
- *uptr++ = m1;
- *uptr++ = m2;
- *uptr++ = m3;
- *uptr++ = m4;
- }
-
- // do nfpk_ShiftP1
- ptr = (int8_t *)nfpk_ShiftP1;
- for (y = -8; y != 8; y++) {
- for (x = -8; x != 8; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = y;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = y;
-#endif
- ptr += 2;
- }
- }
-
- // do nfpk_ShiftP2[]
- ptr = (int8_t *)nfpk_ShiftP2;
- for (y = 0; y != 8; y++) {
- for (x = 8; x != 15; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = y;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = y;
-#endif
- ptr += 2;
- }
- }
-
- for (y = 8; y != 14; y++) {
- for (x = -14; x != 0; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = y;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = y;
-#endif
- ptr += 2;
- }
-
- for (x = 0; x != 15; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = y;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = y;
-#endif
- ptr += 2;
- }
- }
- for (x = -14; x != 0; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = 14;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = 14;
-#endif
- ptr += 2;
- }
- for (x = 0; x != 12; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- ptr[0] = 14;
- ptr[1] = x;
-#else
- ptr[0] = x;
- ptr[1] = 14;
-#endif
- ptr += 2;
- }
- }
-};
-
-initme _initme;
-
-// nfPkConfig initializes tables used by nfPkDecomp
-// which are dependent on screen size.
-void nfPkConfig(void) {
- // Build ShiftY table
- int index = 0;
- int val;
-
- val = 0;
- for (int i = 0; i < 128; ++i) {
- nfpk_ShiftY[index++] = val;
- val += nf_width;
- }
-
- val = -int(nf_width << 7);
- for (int i = 0; i < 128; ++i) {
- nfpk_ShiftY[index++] = val;
- val += nf_width;
- }
-}
-
-uint16_t Trans16(const uint8_t *idx) { return nf_trans16_lo[idx[0]] | nf_trans16_hi[idx[1]]; }
-
-int SkipOpcode(int opcode_to_use, bool hiColor, const uint8_t *&esi, const uint8_t *&bcomp,
- uint8_t *&edi) {
- switch (opcode_to_use) {
- case 0:
- case 1:
- case 2:
- // no esi change
- break;
- case 3:
- case 4:
- if (hiColor) {
- ++bcomp;
- } else {
- ++esi;
- }
- break;
- case 5:
- esi += 2;
- break;
- case 6:
- if (hiColor) {
- esi += 2;
- } else {
- // we can't skip this -- though I've never came across this
- return opcode_to_use;
- }
- break;
- case 7: {
- bool donf23 = false;
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- donf23 = true;
- }
- } else {
- if (esi[0] > esi[1]) {
- donf23 = true;
- }
- }
-
- if (donf23) {
- esi += (hiColor) ? 6 : 4;
- } else {
- esi += (hiColor) ? 12 : 10;
- }
- } break;
-
- case 8: {
- bool mode2 = false;
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- mode2 = true;
- }
- } else {
- if (esi[0] > esi[1]) {
- mode2 = true;
- }
- }
-
- if (!mode2) {
- esi += (hiColor) ? 24 : 16;
- } else {
- esi += (hiColor) ? 16 : 12;
- }
- } break;
-
- case 9: {
- bool mode2 = false;
- bool mode3 = false;
-
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- mode2 = true;
- } else {
- val = IntelSwapper(*(uint16_t *)(esi + 4));
- if (val & 0x8000) {
- mode3 = true;
- }
- }
- } else {
- if (esi[0] > esi[1]) {
- mode2 = true;
- } else if (esi[2] > esi[3]) {
- mode3 = true;
- }
- }
-
- if (mode2)
- esi += (hiColor) ? 16 : 12;
- else if (mode3)
- esi += (hiColor) ? 12 : 8;
- else
- esi += (hiColor) ? 24 : 20;
- } break;
- case 10: {
- // 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- bool mode2 = false;
-
- if (hiColor) {
- int val1 = IntelSwapper(*(uint16_t *)esi);
- if (val1 & 0x8000) {
- mode2 = true;
- }
- } else {
- if (esi[0] > esi[1]) {
- mode2 = true;
- }
- }
-
- if (!mode2) {
- esi += (hiColor) ? 48 : 32;
- } else {
- esi += (hiColor) ? 32 : 24;
- }
- } break;
-
- case 11: {
- esi += (hiColor) ? 128 : 64;
- } break;
-
- case 12: {
- esi += (hiColor) ? 32 : 16;
- } break;
-
- case 13: {
- esi += (hiColor) ? 8 : 4;
- } break;
-
- case 14: {
- esi += (hiColor) ? 2 : 1;
- } break;
-
- case 15: {
- esi += (hiColor) ? 0 : 2;
- } break;
- }
- return -1;
-}
-
-// HiColor version
-//
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) {
- PkDecompWorker(true, ops, comp, x, y, w, h);
-}
-
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) {
- PkDecompWorker(false, ops, comp, x, y, w, h);
-}
-
-void PkDecompWorker(const bool hiColor, const uint8_t *ops, const uint8_t *comp, const unsigned x,
- const unsigned y, unsigned w, unsigned h) {
-#ifdef OUTRAGE_BIG_ENDIAN
- struct reg_word {
- uint16_t hax, ax;
- };
- struct reg_byte {
- int8_t hah, hal, ah, al;
- };
-#else
- struct reg_word {
- uint16_t ax, hax;
- };
- struct reg_byte {
- int8_t al, ah, hal, hah;
- };
-#endif
-
- tNextFrame nf;
- nf.w = w;
- nf.h = h;
- nf.x = x;
- nf.y = y;
-
- NF_DECOMP_INIT((hiColor) ? 1 : 0, &nf);
- const uint32_t kSWidthScaled = (hiColor) ? SWIDTH * 2 : SWIDTH;
-
- int nfpk_back_right = nf_back_right - kSWidthScaled;
-
- const uint8_t *esi = comp;
- uint8_t *edi = nf.tbuf;
-
- const uint8_t *bcomp = NULL;
- if (hiColor) {
- uint32_t bcompOffset = IntelSwapper(*((const uint16_t *)esi));
- bcomp = esi + bcompOffset;
- esi += 2;
- }
-
- int wcnt = w >> 1;
- do {
- if (--wcnt < 0) {
- edi += nf.new_row;
- --h;
- wcnt = w >> 1;
- continue;
- }
-
- bool first_opcode = true;
- bool skipNextOpCode = false;
-
- uint8_t opcode = *ops++;
- int opcode_to_use = opcode & 0xF;
-
- do_next_opcode:
-
- /////////////////////////////////////////////////////////////////////////////
- // Note: this is all you should have to tweak
- bool opcodesToProcess[16] = {true, true, true, true, // 0 - 3
- true, true, true, true, // 4 - 7
- true, true, true, true, // 8 - 11
- true, true, true, true}; // 12 - 15
- if (!opcodesToProcess[opcode_to_use]) {
- opcode_to_use = SkipOpcode(opcode_to_use, hiColor, esi, bcomp, edi);
- }
- /////////////////////////////////////////////////////////////////////////////
-
- switch (opcode_to_use) {
- case -1: {
- // DEBUG: skip processing
- // Note: esi will have been adjusted above in SkipOpcode
-
- if (hiColor) {
- // Here we can set the color to exactly what we want
- const uint16_t kColor = 0;
- uint16_t *pDst = reinterpret_cast(edi);
- for (int r = 0; r < 8; ++r) {
- pDst[0] = kColor;
- pDst[1] = kColor;
- pDst[2] = kColor;
- pDst[3] = kColor;
- pDst[4] = kColor;
- pDst[5] = kColor;
- pDst[6] = kColor;
- pDst[7] = kColor;
- pDst += nf_width >> 1;
- }
- } else {
- // Here we paint with the palette index we want
- const uint32_t kPaletteIndex = 0;
-
- uint32_t *pDst = reinterpret_cast(edi);
- const uint32_t kPalIndexDWord =
- (kPaletteIndex << 24) | (kPaletteIndex << 16) | (kPaletteIndex << 8) | kPaletteIndex;
- for (int r = 0; r < 8; ++r) {
- pDst[0] = kPalIndexDWord;
- pDst[1] = kPalIndexDWord;
- pDst += nf_width >> 2;
- }
- }
-
- // Adjust edi
- edi += kSWidthScaled;
- } break;
-
- case 0: {
- // No change from previous buffer
- DOnf_shift(hiColor, nf.DiffBufPtrs, edi, nfpk_back_right);
- } break;
- case 1: {
- // No change (and copied to screen)
- edi += kSWidthScaled;
- } break;
- case 2: {
- // Near shift from older part of current buffer
- uint32_t offset;
- if (hiColor) {
- offset = *bcomp++;
- } else {
- offset = *esi++;
- }
- DOnf_xycshift(hiColor, nfpk_ShiftP2[offset], edi, nfpk_back_right);
- } break;
- case 3: {
- // Near shift from newer part of current buffer
- union {
- uint32_t eax;
- reg_word word;
- reg_byte byte;
- } myeax;
-
- if (hiColor) {
- myeax.eax = *bcomp++;
- } else {
- myeax.eax = *esi++;
- }
-
- myeax.word.ax = nfpk_ShiftP2[myeax.eax];
- myeax.byte.al = -myeax.byte.al;
- myeax.byte.ah = -myeax.byte.ah;
-
- DOnf_xycshift(hiColor, myeax.eax, edi, nfpk_back_right);
- } break;
- case 4: {
- // Near shift from previous buffer
- union {
- uint32_t eax;
- reg_word word;
- reg_byte byte;
- } myeax;
-
- if (hiColor) {
- myeax.eax = *bcomp++;
- } else {
- myeax.eax = *esi++;
- }
-
- myeax.word.ax = nfpk_ShiftP1[myeax.eax];
- DOnf_xypshift(hiColor, myeax.eax, edi, nfpk_back_right, nf.DiffBufPtrs);
- } break;
- case 5: {
- // Far shift from previous buffer
- uint32_t eax = IntelSwapper(*(uint16_t *)(esi));
- esi += 2;
- DOnf_xypshift(hiColor, eax, edi, nfpk_back_right, nf.DiffBufPtrs);
- } break;
- case 6: {
- if (hiColor) {
- // Far shift from current buffer
- uint32_t val1 = IntelSwapper(*(uint16_t *)esi);
- esi += 2;
- DOnf_xycshift(hiColor, val1, edi, nfpk_back_right);
- } else {
- // Run of no changes (must only appear in first nibble opcodes)
- // Next nibble k specifies 2k+4 squares with no changes
- skipNextOpCode = true; // Next nibble is not an opcode
- uint32_t cnt = ((opcode >> 4) & 0xF) + 2; // (minimum of 4 squares)
-
- while (true) {
- edi += SWIDTH * 2; // Advance over two squares
- if (--cnt == 0)
- break; // Last pair of squares
-
- if (--wcnt >= 0) // Same row?
- continue; // Yes
-
- edi += nf.new_row; // Advance to next row
- --h; // Decrement row count (should never become zero here)
- wcnt = (w >> 1) - 1; // Reset wcnt
- }
- }
- } break;
- case 7: {
- bool donf23 = false;
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- donf23 = true;
- }
- } else {
- if (esi[0] > esi[1]) {
- donf23 = true;
- }
- }
-
- if (!donf23) {
- // 8x8x1 (12/10 bytes)
- uint32_t colors[4];
- if (hiColor) {
- uint32_t ecx = (Trans16(esi + 2) << 16) | Trans16(esi);
- uint32_t edx = (ecx >> 16) | (ecx << 16);
- uint32_t ebx = (edx & 0xFFFF0000) | (ecx & 0xFFFF);
- uint32_t ebp = (ecx & 0xFFFF0000) | (edx & 0xFFFF);
- colors[0] = ebx;
- colors[1] = edx;
- colors[2] = ecx;
- colors[3] = ebp;
- } else {
- uint32_t tcLo = esi[0];
- uint32_t tcHi = esi[1];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
-
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov8 : nfpk_mov8;
- const int kOffset = (hiColor) ? 4 : 2;
- const int max_repcount = 8;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- const uint8_t *color_idx = lookupTable + (esi[rep_count + kOffset] * 4);
-#ifdef OUTRAGE_BIG_ENDIAN
- uint32_t w1 = colors[color_idx[3]];
- uint32_t w2 = colors[color_idx[2]];
- uint32_t w3 = colors[color_idx[1]];
- uint32_t w4 = colors[color_idx[0]];
-#else
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-#endif
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- } else {
- *(uint16_t *)(edi + 0) = w1;
- *(uint16_t *)(edi + 2) = w2;
- *(uint16_t *)(edi + 4) = w3;
- *(uint16_t *)(edi + 6) = w4;
- }
-
- edi += nf_width;
- }
- esi += hiColor ? 12 : 10;
- edi -= nf_width;
- edi -= nfpk_back_right;
- } else {
- // low 4x4x1 (6/4 bytes)
- uint32_t colors[2];
- if (hiColor) {
- uint32_t temp = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = (temp << 16) | temp;
- temp = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = (temp << 16) | temp;
- } else {
- uint32_t tcLo = esi[0];
- uint32_t tcHi = esi[1];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcHi << 8);
- }
-
- const uint8_t *esiOffset = (hiColor) ? (esi + 4) : (esi + 2);
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov4l : nfpk_mov4l;
- const int max_repcount = 4;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx;
- switch (rep_count) {
- case 0:
- idx = esiOffset[0] & 0xF;
- break;
- case 1:
- idx = esiOffset[0] >> 4;
- break;
- case 2:
- idx = esiOffset[1] & 0xF;
- break;
- case 3:
- idx = esiOffset[1] >> 4;
- break;
- }
-
- const uint8_t *color_idx = lookupTable + (idx * 4);
-#ifdef OUTRAGE_BIG_ENDIAN
- uint32_t w1 = colors[color_idx[3]];
- uint32_t w2 = colors[color_idx[2]];
- uint32_t w3 = colors[color_idx[1]];
- uint32_t w4 = colors[color_idx[0]];
-#else
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-#endif
-
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- *(uint32_t *)(edi + nf_width + 0) = w1;
- *(uint32_t *)(edi + nf_width + 4) = w2;
- *(uint32_t *)(edi + nf_width + 8) = w3;
- *(uint32_t *)(edi + nf_width + 12) = w4;
- } else {
- *(uint16_t *)(edi + 0) = w1;
- *(uint16_t *)(edi + 2) = w2;
- *(uint16_t *)(edi + 4) = w3;
- *(uint16_t *)(edi + 6) = w4;
- *(uint16_t *)(edi + 0 + nf_width) = w1;
- *(uint16_t *)(edi + 2 + nf_width) = w2;
- *(uint16_t *)(edi + 4 + nf_width) = w3;
- *(uint16_t *)(edi + 6 + nf_width) = w4;
- }
-
- edi += nf_width * 2;
- }
- edi -= nf_width * 2;
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += (hiColor) ? 6 : 4;
- }
- } break;
- case 8: {
- bool donf24 = false;
- bool donf40 = false;
-
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- val = IntelSwapper(*(uint16_t *)(esi + 8));
- if (val & 0x8000) {
- donf40 = true;
- } else {
- donf24 = true;
- }
- }
- } else {
- if (esi[0] > esi[1]) {
- if (esi[6] > esi[7]) {
- donf40 = true;
- } else {
- donf24 = true;
- }
- }
- }
-
- if (!donf24 && !donf40) {
- uint32_t colors[4];
- int max_repcount = 8;
-
- if (hiColor) {
- uint32_t tempcolor;
- tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[0];
- uint32_t tcHi = esi[1];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
-
- int repLookup[8] = {4, 5, 10, 11, 16, 17, 22, 23};
- if (!hiColor) {
- repLookup[0] -= 2;
- repLookup[1] -= 2;
- repLookup[2] -= 4;
- repLookup[3] -= 4;
- repLookup[4] -= 6;
- repLookup[5] -= 6;
- repLookup[6] -= 8;
- repLookup[7] -= 8;
- }
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov8 : nfpk_mov8;
-
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = repLookup[rep_count];
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
-#ifdef OUTRAGE_BIG_ENDIAN
- uint32_t w1 = colors[color_idx[3]];
- uint32_t w2 = colors[color_idx[2]];
- uint32_t w3 = colors[color_idx[1]];
- uint32_t w4 = colors[color_idx[0]];
-#else
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-#endif
-
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- edi += nf_width;
- *(uint32_t *)(edi + 0) = w3;
- *(uint32_t *)(edi + 4) = w4;
- edi += nf_width;
- } else {
- *(uint16_t *)(edi + 0) = w1;
- *(uint16_t *)(edi + 2) = w2;
- edi += nf_width;
- *(uint16_t *)(edi + 0) = w3;
- *(uint16_t *)(edi + 2) = w4;
- edi += nf_width;
- }
-
- if (rep_count == 1) {
- if (hiColor) {
- uint32_t tempcolor = nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[4];
- uint32_t tcHi = esi[5];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
- } else if (rep_count == 3) {
- if (hiColor) {
- edi -= nf_width * 8 - 8;
- uint32_t tempcolor = nf_trans16_lo[*(esi + 14)] | nf_trans16_hi[*(esi + 15)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 12)] | nf_trans16_hi[*(esi + 13)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- edi -= nf_width * 8 - 4;
- uint32_t tcLo = esi[8];
- uint32_t tcHi = esi[9];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
- } else if (rep_count == 5) {
- if (hiColor) {
- uint32_t tempcolor = nf_trans16_lo[*(esi + 20)] | nf_trans16_hi[*(esi + 21)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[12];
- uint32_t tcHi = esi[13];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
- }
- }
-
- edi -= nf_width;
- esi += (hiColor) ? 24 : 16;
- edi -= ((hiColor) ? 8 : 4) + nfpk_back_right;
- }
-
- if (donf24) {
- uint32_t colors[4];
-
- if (hiColor) {
- uint32_t tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[0];
- uint32_t tcHi = esi[1];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
-
- int repLookupTable[8] = {4, 5, 6, 7, 12, 13, 14, 15};
- if (!hiColor) {
- repLookupTable[0] -= 2;
- repLookupTable[1] -= 2;
- repLookupTable[2] -= 2;
- repLookupTable[3] -= 2;
- repLookupTable[4] -= 4;
- repLookupTable[5] -= 4;
- repLookupTable[6] -= 4;
- repLookupTable[7] -= 4;
- }
-
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov8 : nfpk_mov8;
-
- int max_repcount = 8;
- for (int rep_count = 0; rep_count < max_repcount; rep_count++) {
- int idx = repLookupTable[rep_count];
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- edi += nf_width;
- *(uint32_t *)(edi + 0) = w3;
- *(uint32_t *)(edi + 4) = w4;
- edi += nf_width;
- } else {
- *(uint16_t *)(edi + 0) = w1;
- *(uint16_t *)(edi + 2) = w2;
- edi += nf_width;
- *(uint16_t *)(edi + 0) = w3;
- *(uint16_t *)(edi + 2) = w4;
- edi += nf_width;
- }
-
- if (rep_count == 3) {
- if (hiColor) {
- edi -= nf_width * 8 - 8;
-
- uint32_t tempcolor = nf_trans16_lo[*(esi + 10)] | nf_trans16_hi[*(esi + 11)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- edi -= nf_width * 8 - 4;
-
- uint32_t tcLo = esi[6];
- uint32_t tcHi = esi[7];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
- }
- }
-
- esi += (hiColor) ? 16 : 12;
- edi -= nf_width + ((hiColor) ? 8 : 4) + nfpk_back_right;
- }
-
- if (donf40) {
- uint32_t colors[4];
-
- if (hiColor) {
- uint32_t tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[0];
- uint32_t tcHi = esi[1];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
-
- int repLookupTable[8] = {4, 5, 6, 7, 12, 13, 14, 15};
- if (!hiColor) {
- repLookupTable[0] -= 2;
- repLookupTable[1] -= 2;
- repLookupTable[2] -= 2;
- repLookupTable[3] -= 2;
- repLookupTable[4] -= 4;
- repLookupTable[5] -= 4;
- repLookupTable[6] -= 4;
- repLookupTable[7] -= 4;
- }
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov8 : nfpk_mov8;
-
- int max_repcount = 8;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = repLookupTable[rep_count];
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
-#ifdef OUTRAGE_BIG_ENDIAN
- uint32_t w1 = colors[color_idx[3]];
- uint32_t w2 = colors[color_idx[2]];
- uint32_t w3 = colors[color_idx[1]];
- uint32_t w4 = colors[color_idx[0]];
-#else
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-#endif
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- } else {
- *(uint16_t *)(edi + 0) = w1;
- *(uint16_t *)(edi + 2) = w2;
- *(uint16_t *)(edi + 4) = w3;
- *(uint16_t *)(edi + 6) = w4;
- }
- edi += nf_width;
-
- if (rep_count == 3) {
- if (hiColor) {
- uint32_t tempcolor = nf_trans16_lo[*(esi + 10)] | nf_trans16_hi[*(esi + 11)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- } else {
- uint32_t tcLo = esi[6];
- uint32_t tcHi = esi[7];
- colors[0] = tcLo | (tcLo << 8);
- colors[1] = tcHi | (tcLo << 8);
- colors[2] = tcLo | (tcHi << 8);
- colors[3] = tcHi | (tcHi << 8);
- }
- }
- }
-
- esi += (hiColor) ? 16 : 12;
- edi -= nf_width + nfpk_back_right;
- }
- } break;
- case 9: {
- bool donf41 = false;
- bool donf25 = false;
- bool donf57 = false;
-
- if (hiColor) {
- uint16_t val = IntelSwapper(*(uint16_t *)esi);
- if (val & 0x8000) {
- val = IntelSwapper(*(uint16_t *)(esi + 4));
- if (val & 0x8000) {
- donf57 = true;
- } else {
- donf41 = true;
- }
-
- } else {
- val = IntelSwapper(*(uint16_t *)(esi + 4));
- if (val & 0x8000) {
- donf25 = true;
- }
- }
- } else {
- if (esi[0] > esi[1]) {
- if (esi[2] > esi[3]) {
- donf57 = true;
- } else {
- donf41 = true;
- }
- } else if (esi[2] > esi[3]) {
- donf25 = true;
- }
- }
-
- if (donf57) {
- uint16_t colors[4];
- if (hiColor) {
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- } else {
- colors[0] = esi[0];
- colors[1] = esi[1];
- colors[2] = esi[2];
- colors[3] = esi[3];
- }
-
- const int max_repcount = 8;
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov4 : nfpk_mov4;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = rep_count + ((hiColor) ? 8 : 4);
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
-
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-
- if (rep_count & 1) {
-#ifdef OUTRAGE_BIG_ENDIAN
- if (hiColor) {
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- } else {
- *(uint8_t *)(edi + 4) = w4;
- *(uint8_t *)(edi + 5) = w3;
- *(uint8_t *)(edi + 6) = w2;
- *(uint8_t *)(edi + 7) = w1;
-
- *(uint8_t *)(edi + nf_width + 4) = w4;
- *(uint8_t *)(edi + nf_width + 5) = w3;
- *(uint8_t *)(edi + nf_width + 6) = w2;
- *(uint8_t *)(edi + nf_width + 7) = w1;
- }
-#else
- if (hiColor) {
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- } else {
- *(uint8_t *)(edi + 4) = w1;
- *(uint8_t *)(edi + 5) = w2;
- *(uint8_t *)(edi + 6) = w3;
- *(uint8_t *)(edi + 7) = w4;
-
- *(uint8_t *)(edi + nf_width + 4) = w1;
- *(uint8_t *)(edi + nf_width + 5) = w2;
- *(uint8_t *)(edi + nf_width + 6) = w3;
- *(uint8_t *)(edi + nf_width + 7) = w4;
- }
-#endif
- edi += nf_width * 2;
- } else {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 0) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16);
-#else
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-#endif
- } else {
- const uint32_t value = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- *(uint32_t *)(edi) = value;
- *(uint32_t *)(edi + nf_width) = value;
- }
- }
- }
-
- esi += (hiColor) ? 16 : 12;
- edi -= nf_width * 2;
- edi += nf_width;
- edi -= nfpk_back_right;
- } else if (donf41) {
- uint32_t colors[4];
- if (hiColor) {
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = ((colors[0]) << 16) | colors[0];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = ((colors[1]) << 16) | colors[1];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[2] = ((colors[2]) << 16) | colors[2];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- colors[3] = ((colors[3]) << 16) | colors[3];
- } else {
- colors[0] = esi[0];
- colors[1] = esi[1];
- colors[2] = esi[2];
- colors[3] = esi[3];
- }
-
- const int max_repcount = 8;
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov8 : nfpk_mov4;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = rep_count + ((hiColor) ? 8 : 4);
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-#ifdef OUTRAGE_BIG_ENDIAN
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w4;
- *(uint32_t *)(edi + 4) = w3;
- *(uint32_t *)(edi + 8) = w2;
- *(uint32_t *)(edi + 12) = w1;
- } else {
- *(uint8_t *)(edi + 0) = w4;
- *(uint8_t *)(edi + 1) = w4;
- *(uint8_t *)(edi + 2) = w3;
- *(uint8_t *)(edi + 3) = w3;
- *(uint8_t *)(edi + 4) = w2;
- *(uint8_t *)(edi + 5) = w2;
- *(uint8_t *)(edi + 6) = w1;
- *(uint8_t *)(edi + 7) = w1;
- }
-#else
- if (hiColor) {
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- } else {
- *(uint8_t *)(edi + 0) = w1;
- *(uint8_t *)(edi + 1) = w1;
- *(uint8_t *)(edi + 2) = w2;
- *(uint8_t *)(edi + 3) = w2;
- *(uint8_t *)(edi + 4) = w3;
- *(uint8_t *)(edi + 5) = w3;
- *(uint8_t *)(edi + 6) = w4;
- *(uint8_t *)(edi + 7) = w4;
- }
-
-#endif
- edi += nf_width;
- }
-
- esi += (hiColor) ? 16 : 12;
- edi -= nf_width;
- edi -= nfpk_back_right;
- } else if (donf25) {
- uint32_t colors[4];
- if (hiColor) {
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = ((colors[0]) << 16) | colors[0];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = ((colors[1]) << 16) | colors[1];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[2] = ((colors[2]) << 16) | colors[2];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- colors[3] = ((colors[3]) << 16) | colors[3];
- } else {
- colors[0] = esi[0];
- colors[1] = esi[1];
- colors[2] = esi[2];
- colors[3] = esi[3];
- }
-
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov4 : nfpk_mov4;
- const int max_repcount = 4;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = rep_count + (hiColor ? 8 : 4);
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 0) = w4;
- *(uint32_t *)(edi + nf_width) = w4;
- *(uint32_t *)(edi + 4) = w3;
- *(uint32_t *)(edi + nf_width + 4) = w3;
- *(uint32_t *)(edi + 8) = w2;
- *(uint32_t *)(edi + nf_width + 8) = w2;
- *(uint32_t *)(edi + 12) = w1;
- *(uint32_t *)(edi + nf_width + 12) = w1;
-#else
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + nf_width) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + nf_width + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + nf_width + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- *(uint32_t *)(edi + nf_width + 12) = w4;
-#endif
- } else {
- uint32_t c0 = IntelSwapper((uint32_t)(w2 << 24) | (w2 << 16) | (w1 << 8) | w1);
- uint32_t c1 = IntelSwapper((uint32_t)(w4 << 24) | (w4 << 16) | (w3 << 8) | w3);
- *(uint32_t *)(edi + 0) = c0;
- *(uint32_t *)(edi + nf_width) = c0;
- *(uint32_t *)(edi + 4) = c1;
- *(uint32_t *)(edi + nf_width + 4) = c1;
- }
-
- edi += nf_width * 2;
- }
-
- edi -= nf_width * 2;
- edi += nf_width;
- esi += (hiColor) ? 12 : 8;
- edi -= nfpk_back_right;
- } else {
- uint16_t colors[4];
- if (hiColor) {
- colors[0] = Trans16(esi + 0);
- colors[1] = Trans16(esi + 2);
- colors[2] = Trans16(esi + 4);
- colors[3] = Trans16(esi + 6);
- } else {
- colors[0] = esi[0];
- colors[1] = esi[1];
- colors[2] = esi[2];
- colors[3] = esi[3];
- }
-
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov4 : nfpk_mov4;
- const int max_repcount = 16;
- for (int rep_count = 0; rep_count < max_repcount; ++rep_count) {
- int idx = rep_count + ((hiColor) ? 8 : 4);
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
-
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-
- if (rep_count & 1) {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 8) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 12) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16);
-#else
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-#endif
- } else {
- *(uint32_t *)(edi + 4) = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- }
-
- edi += nf_width;
- } else {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 0) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16);
-#else
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-#endif
- } else {
- *(uint32_t *)(edi + 0) = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- }
- }
- }
-
- edi -= nf_width;
- esi += (hiColor) ? 24 : 20;
- edi -= nfpk_back_right;
- }
- } break;
- case 10: {
- // 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- bool do26 = false;
- bool do42 = false;
-
- if (hiColor) {
- int val1 = IntelSwapper(*(uint16_t *)esi);
- if (val1 & 0x8000) {
- val1 = IntelSwapper(*(uint16_t *)(esi + 16));
- if (val1 & 0x8000) {
- do42 = true;
- } else {
- do26 = true;
- }
- }
- } else {
- if (esi[0] > esi[1]) {
- if (esi[12] > esi[13]) {
- do42 = true;
- } else {
- do26 = true;
- }
- }
- }
-
- // Load bx,dx,cx,bp with four colors
- uint16_t colors[4];
- if (hiColor) {
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- } else {
- colors[0] = esi[0];
- colors[1] = esi[1];
- colors[2] = esi[2];
- colors[3] = esi[3];
- }
-
- // build our iteration lookup table
- int repLookup[16];
- if (do26 || do42) {
- int baseCnt1 = (hiColor) ? 8 : 4;
- int baseCnt2 = (hiColor) ? 24 : 16;
- for (int i = 0; i < 8; ++i) {
- repLookup[i + 0] = baseCnt1 + i;
- repLookup[i + 8] = baseCnt2 + i;
- }
- } else {
- int baseCnt1 = (hiColor) ? 8 : 4;
- int baseCnt2 = (hiColor) ? 20 : 12;
- int baseCnt3 = (hiColor) ? 32 : 20;
- int baseCnt4 = (hiColor) ? 44 : 28;
- for (int i = 0; i < 4; ++i) {
- repLookup[i + 0] = baseCnt1 + i;
- repLookup[i + 4] = baseCnt2 + i;
- repLookup[i + 8] = baseCnt3 + i;
- repLookup[i + 12] = baseCnt4 + i;
- }
- }
-
- const uint8_t *lookupTable = (hiColor) ? nfhpk_mov4 : nfpk_mov4;
- for (int rep_count = 0; rep_count < 16; ++rep_count) {
- int idx = repLookup[rep_count];
- const uint8_t *color_idx = lookupTable + (esi[idx] * 4);
- uint32_t w1 = colors[color_idx[0]];
- uint32_t w2 = colors[color_idx[1]];
- uint32_t w3 = colors[color_idx[2]];
- uint32_t w4 = colors[color_idx[3]];
-
- if (!do42) {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 0) = ((uint32_t)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 4) = ((uint32_t)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16));
-#else
- *(uint32_t *)(edi + 0) = ((uint32_t)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 4) = ((uint32_t)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16));
-#endif
- } else {
- *(uint32_t *)(edi + 0) = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- }
- edi += nf_width;
- } else {
- // 42
- if (rep_count & 1) {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 8) = ((uint32_t)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 12) = ((uint32_t)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16));
-#else
-
- *(uint32_t *)(edi + 8) = ((uint32_t)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 12) = ((uint32_t)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16));
-#endif
- } else {
- *(uint32_t *)(edi + 4) = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- }
- edi += nf_width;
- } else {
- if (hiColor) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(uint32_t *)(edi + 0) = ((uint32_t)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 4) = ((uint32_t)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16));
-#else
- *(uint32_t *)(edi + 0) = ((uint32_t)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16));
- *(uint32_t *)(edi + 4) = ((uint32_t)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16));
-#endif
- } else {
- *(uint32_t *)(edi + 0) = IntelSwapper((uint32_t)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1);
- }
- }
- }
-
- if (rep_count == 3 && !do42 && !do26) {
- if (hiColor) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 12)] | nf_trans16_hi[*(esi + 13)];
- colors[1] = nf_trans16_lo[*(esi + 14)] | nf_trans16_hi[*(esi + 15)];
- colors[2] = nf_trans16_lo[*(esi + 16)] | nf_trans16_hi[*(esi + 17)];
- colors[3] = nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)];
- } else {
- colors[0] = esi[8];
- colors[1] = esi[9];
- colors[2] = esi[10];
- colors[3] = esi[11];
- }
- }
-
- if (rep_count == 7) {
- if (!do42 && !do26) {
- edi -= nf_width * 8 - ((hiColor) ? 8 : 4);
-
- if (hiColor) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 24)] | nf_trans16_hi[*(esi + 25)];
- colors[1] = nf_trans16_lo[*(esi + 26)] | nf_trans16_hi[*(esi + 27)];
- colors[2] = nf_trans16_lo[*(esi + 28)] | nf_trans16_hi[*(esi + 29)];
- colors[3] = nf_trans16_lo[*(esi + 30)] | nf_trans16_hi[*(esi + 31)];
- } else {
- colors[0] = esi[16];
- colors[1] = esi[17];
- colors[2] = esi[18];
- colors[3] = esi[19];
- }
- }
-
- if (do26 || do42) {
- if (do26) {
- edi -= nf_width * 8 - ((hiColor) ? 8 : 4);
- }
-
- if (hiColor) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 16)] | nf_trans16_hi[*(esi + 17)];
- colors[1] = nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)];
- colors[2] = nf_trans16_lo[*(esi + 20)] | nf_trans16_hi[*(esi + 21)];
- colors[3] = nf_trans16_lo[*(esi + 22)] | nf_trans16_hi[*(esi + 23)];
- } else {
- colors[0] = esi[12];
- colors[1] = esi[13];
- colors[2] = esi[14];
- colors[3] = esi[15];
- }
- }
- }
-
- if (rep_count == 11 && !do42 && !do26) {
- if (hiColor) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 36)] | nf_trans16_hi[*(esi + 37)];
- colors[1] = nf_trans16_lo[*(esi + 38)] | nf_trans16_hi[*(esi + 39)];
- colors[2] = nf_trans16_lo[*(esi + 40)] | nf_trans16_hi[*(esi + 41)];
- colors[3] = nf_trans16_lo[*(esi + 42)] | nf_trans16_hi[*(esi + 43)];
- } else {
- colors[0] = esi[24];
- colors[1] = esi[25];
- colors[2] = esi[26];
- colors[3] = esi[27];
- }
- }
- }
-
- if (!do42 && !do26) {
- esi += (hiColor) ? 48 : 32;
- } else {
- esi += (hiColor) ? 32 : 24;
- }
-
- edi -= nf_width;
- if (!do42) {
- edi -= ((hiColor) ? 8 : 4) + nfpk_back_right;
- } else {
- edi -= nfpk_back_right;
- }
- } break;
-
- case 11: {
- // 8x8x16 (128 bytes)
- if (hiColor) {
- Trans16Blk(edi, esi);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 16);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 32);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 48);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 64);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 80);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 96);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 112);
-
- esi += 128;
- } else {
- // 8x8x8 (64 bytes)
- uint32_t *ediW = (uint32_t *)edi;
- uint32_t *esiW = (uint32_t *)esi;
- const uint32_t width = nf_width >> 2;
- ediW[0] = (esiW[0]);
- ediW[1] = (esiW[1]);
- ediW += width;
- ediW[0] = (esiW[2]);
- ediW[1] = (esiW[3]);
- ediW += width;
- ediW[0] = (esiW[4]);
- ediW[1] = (esiW[5]);
- ediW += width;
- ediW[0] = (esiW[6]);
- ediW[1] = (esiW[7]);
- ediW += width;
- ediW[0] = (esiW[8]);
- ediW[1] = (esiW[9]);
- ediW += width;
- ediW[0] = (esiW[10]);
- ediW[1] = (esiW[11]);
- ediW += width;
- ediW[0] = (esiW[12]);
- ediW[1] = (esiW[13]);
- ediW += width;
- ediW[0] = (esiW[14]);
- ediW[1] = (esiW[15]);
- esi += 64;
- edi = ((uint8_t *)ediW);
- }
- edi -= nfpk_back_right;
- } break;
- case 12: {
- for (int i = 0; i < 4; ++i) {
- if (hiColor) {
- // low 4x4x16 (32 bytes)
- uint32_t eax, ebx;
-
- eax = *(uint8_t *)(esi + i * 8 + 0);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 1);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 0) = eax;
- *(uint32_t *)(edi + nf_width) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 2);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 3);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 4) = eax;
- *(uint32_t *)(edi + nf_width + 4) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 4);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 5);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 8) = eax;
- *(uint32_t *)(edi + nf_width + 8) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 6);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 7);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 12) = eax;
- *(uint32_t *)(edi + nf_width + 12) = eax;
- } else {
- // low 4x4x8 (16 bytes)
- uint32_t eax, ebx;
-
- eax = IntelSwapper(((uint32_t *)esi)[i]);
- ebx = ((eax & 0xFF00) << 16) | ((eax & 0xFF00) << 8) | ((eax & 0xFF) << 8) | (eax & 0xFF);
- ((uint32_t *)edi)[0] = ebx;
- ((uint32_t *)(edi + nf_width))[0] = ebx;
-
- eax = eax >> 16;
- ebx = ((eax & 0xFF00) << 16) | ((eax & 0xFF00) << 8) | ((eax & 0xFF) << 8) | (eax & 0xFF);
- ((uint32_t *)edi)[1] = ebx;
- ((uint32_t *)(edi + nf_width))[1] = ebx;
- }
-
- edi += nf_width * 2;
- }
-
- edi -= nf_width * 2;
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += (hiColor) ? 32 : 16;
- } break;
- case 13: {
- if (hiColor) {
- // 2x2 4x4x0 (8 bytes)
- for (int i = 0; i < 2; ++i) {
- const uint8_t *loopEsi = esi + (i * 4);
-
- uint32_t temp = nf_trans16_lo[loopEsi[0]] | nf_trans16_hi[loopEsi[1]];
- uint32_t ebx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- temp = nf_trans16_lo[loopEsi[2]] | nf_trans16_hi[loopEsi[3]];
- uint32_t ecx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi += nf_width * 2;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi += nf_width * 2;
- }
- } else {
- // 2x2 4x4x0 (4 bytes)
- for (int i = 0; i < 2; ++i) {
- uint32_t c1 = esi[(i << 1) + 0];
- uint32_t eax = (c1 << 24) | (c1 << 16) | (c1 << 8) | c1;
-
- uint32_t c2 = esi[(i << 1) + 1];
- uint32_t ebx = (c2 << 24) | (c2 << 16) | (c2 << 8) | c2;
-
- *(uint32_t *)(edi + 0) = eax;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 0 + nf_width) = eax;
- *(uint32_t *)(edi + 4 + nf_width) = ebx;
- edi += nf_width * 2;
-
- *(uint32_t *)(edi + 0) = eax;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 0 + nf_width) = eax;
- *(uint32_t *)(edi + 4 + nf_width) = ebx;
- edi += nf_width * 2;
- }
- }
-
- edi -= nf_width * 2;
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += (hiColor) ? 8 : 4;
- } break;
- case 14: {
- if (hiColor) {
- // 8x8x0 (2 bytes)
- uint32_t ecx = nf_trans16_lo[esi[0]] | nf_trans16_hi[esi[1]];
- uint32_t ebx = ((ecx & 0xFFFF) << 16) | (ecx & 0xFFFF);
- esi += 2;
-
- for (int i = 0; i < 8; ++i) {
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
- }
-
- edi -= nf_width;
- edi -= nfpk_back_right;
- } else {
- // 8x8x0 (1 byte)
- uint32_t c = *esi++; // Copy color into 8 positions
- uint32_t col = (c << 24) | (c << 16) | (c << 8) | c;
-
- for (int i = 0; i < 8; ++i) {
- *(uint32_t *)(edi + 0) = col;
- *(uint32_t *)(edi + 4) = col;
- edi += nf_width;
- }
- edi -= nf_width;
- edi -= nfpk_back_right;
- }
- } break;
- case 15: {
- if (!hiColor) {
- // mix 8x8x0 (2 bytes)
- uint32_t ebx = IntelSwapper(*(uint16_t *)(esi)); // Copy 2 colors into 8 positions
- esi += 2; // in a checkerboard
- uint32_t eax = (ebx << 16) | ebx;
- ebx = (eax << 8) | ((eax >> 24) & 0xFF);
-
- for (int i = 0; i < 4; ++i) {
- *(uint32_t *)(edi + 0) = eax;
- *(uint32_t *)(edi + 4) = eax;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- edi += nf_width;
- }
- edi -= nf_width;
- edi -= nfpk_back_right;
- }
- } break;
- }
-
- if (first_opcode && !skipNextOpCode) {
- first_opcode = false;
- opcode_to_use = (opcode >> 4);
- goto do_next_opcode;
- }
- } while (h != 0);
-}
-
-void Trans16Blk(uint8_t *edi, const uint8_t *idx) {
- *((uint16_t *)(edi + 0)) = nf_trans16_lo[*(idx + 0)] | nf_trans16_hi[*(idx + 1)];
- *((uint16_t *)(edi + 2)) = nf_trans16_lo[*(idx + 2)] | nf_trans16_hi[*(idx + 3)];
- *((uint16_t *)(edi + 4)) = nf_trans16_lo[*(idx + 4)] | nf_trans16_hi[*(idx + 5)];
- *((uint16_t *)(edi + 6)) = nf_trans16_lo[*(idx + 6)] | nf_trans16_hi[*(idx + 7)];
- *((uint16_t *)(edi + 8)) = nf_trans16_lo[*(idx + 8)] | nf_trans16_hi[*(idx + 9)];
- *((uint16_t *)(edi + 10)) = nf_trans16_lo[*(idx + 10)] | nf_trans16_hi[*(idx + 11)];
- *((uint16_t *)(edi + 12)) = nf_trans16_lo[*(idx + 12)] | nf_trans16_hi[*(idx + 13)];
- *((uint16_t *)(edi + 14)) = nf_trans16_lo[*(idx + 14)] | nf_trans16_hi[*(idx + 15)];
-}
-
-void DOnf_xycshift(const bool hiColor, const uint32_t eax, uint8_t *&edi, const int nfpk_back_right) {
- uint32_t ebx = (eax >> 8) & 0xFF;
-
- // get the lower byte of the offset, but sign extend it
- int offset = eax & 0xFF;
- if (eax & 0x80) {
- // extend...
- offset |= 0xFFFFFF00;
- }
-
- // hiColor is multiplied by two
- if (hiColor) {
- offset <<= 1;
- }
-
- // factor in the table
- offset += nfpk_ShiftY[ebx];
- DOnf_shift(hiColor, offset, edi, nfpk_back_right);
-}
-
-void DOnf_xypshift(const bool hiColor, const uint32_t eax, uint8_t *&edi, const int nfpk_back_right,
- const int DiffBufPtrs) {
- uint32_t ebx = (eax >> 8) & 0xFF;
-
- // get the lower byte of the offset, but sign extend it
- int offset = eax & 0xFF;
- if (eax & 0x80) {
- // extend...
- offset |= 0xFFFFFF00;
- }
-
- // hiColor is multiplied by two
- if (hiColor) {
- offset <<= 1;
- }
-
- // factor in the table
- offset += nfpk_ShiftY[ebx] + DiffBufPtrs;
- DOnf_shift(hiColor, offset, edi, nfpk_back_right);
-}
-
-// Copy the 128/64 bytes from an offset of edi to edi is.
-void DOnf_shift(const bool hiColor, const int offset, uint8_t *&edi, const int nfpk_back_right) {
- union ptr {
- uint32_t *pAsInt;
- uint8_t *pAsChar;
- };
- ptr dstBuffer;
- dstBuffer.pAsChar = edi;
- ptr srcBuffer;
- srcBuffer.pAsChar = edi + offset;
-
- for (int i = 0; i < 8; ++i) {
- dstBuffer.pAsInt[0] = (srcBuffer.pAsInt[0]);
- dstBuffer.pAsInt[1] = (srcBuffer.pAsInt[1]);
-
- if (hiColor) {
- dstBuffer.pAsInt[2] = (srcBuffer.pAsInt[2]);
- dstBuffer.pAsInt[3] = (srcBuffer.pAsInt[3]);
- }
-
- dstBuffer.pAsChar += nf_width;
- srcBuffer.pAsChar += nf_width;
- }
-
- // restore edi
- dstBuffer.pAsChar -= nf_width;
- dstBuffer.pAsChar -= nfpk_back_right;
- edi = dstBuffer.pAsChar;
-}
-
-////////////////////////////////////////////////
-// Non-Implemented Functions
-////////////////////////////////////////////////
-void nfHiColorDecomp(const uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfHiColorDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h);
-void nfDecomp(const uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h);
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-void palLoadCompPalette(uint8_t *buf);
-void gfxMode(unsigned mode);
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res);
-void gfxGetCrtc(uint8_t *crtc);
-void gfxVres(uint8_t misc, uint8_t *crtc);
-void MVE_gfxWaitRetrace(int state);
-void MVE_gfxSetSplit(unsigned line);
-
-
-void DECOMP_BODY(bool HI_COLOR_FLAG, const uint8_t *&comp, uint32_t _x, uint32_t _y, uint32_t _w,
- uint32_t _h) {
- uint32_t HI_COLOR_SCALE = (HI_COLOR_FLAG) ? 2 : 1;
-
- tNextFrame nf;
- nf.w = _w;
- nf.h = _h;
- nf.x = _x;
- nf.y = _y;
- NF_DECOMP_INIT(HI_COLOR_FLAG ? 1 : 0, &nf);
-
- uint32_t parms_sz = (nf.w * nf.h * nf_fqty) << 1;
- const uint8_t *compData = comp + parms_sz;
-
- // New Data
- //=====================
-
- // Iterate over params and copy new hires data to appropriate sections.
- uint8_t *curr_tbuf = nf.tbuf;
- const uint16_t *compAsWord = (const uint16_t *)comp;
- for (uint8_t fqIt = nf_fqty; fqIt != 0; --fqIt, curr_tbuf += nf_width) {
- uint8_t *this_tbuf = curr_tbuf;
- for (uint32_t ch = nf.h; ch != 0; --ch, this_tbuf += nf.new_row) {
- for (uint32_t cl = nf.w; cl != 0; --cl) {
- int flags = (int)IntelSwapper(*compAsWord++);
- if (flags != 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- // Copy new data to one section
- // Enter with esi(compData) pointing to source data, edi(this_tbuf) to screen section.
- // Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
- for (int currH = 0; currH < 8; ++currH) {
- size_t amt = sizeof(uint32_t) * 2 * HI_COLOR_SCALE;
- // memcpy( this_tbuf, compData, amt );
- for (uint32_t ii = 0; ii < (amt / 2); ii++) {
- uint16_t *destword = (uint16_t *)this_tbuf[ii];
- uint16_t *srcword = (uint16_t *)compData[ii];
- *destword = IntelSwapper(*srcword);
- }
- compData += amt;
- this_tbuf += amt + nf_new_line;
- }
- this_tbuf -= nf_new_line;
- this_tbuf -= nf_back_right;
- }
- }
- }
-
- // Motion Compensation
- //=====================
-
- // Iterate over flags and motion source addresses from params
- // to determine which sections to move.
- // ebx indexes params.
- // esi indexes source from buffer
- // esi will be computed as +- 16K relative to edi.
- compAsWord = (const uint16_t *)comp;
- curr_tbuf = nf.tbuf;
- for (uint8_t fqIt = nf_fqty; fqIt != 0; --fqIt, curr_tbuf += nf_width) {
- uint8_t *this_tbuf = curr_tbuf;
- for (uint32_t ch = nf.h; ch != 0; --ch, this_tbuf += nf.new_row) {
- for (uint32_t cl = nf.w; cl != 0; --cl) {
- int flags = (int)IntelSwapper(*compAsWord++);
- if (flags == 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- // Make esi absolute
- uint8_t *src = this_tbuf;
- if (flags > 0) {
- // jg
- src += (flags - 0x4000) * HI_COLOR_SCALE;
- } else {
- // jl
- src += (flags - 0xC000) * HI_COLOR_SCALE + nf.DiffBufPtrs;
- }
-
- for (int i = 0; i < 8; ++i) {
- size_t amt = sizeof(uint32_t) * 2 * HI_COLOR_SCALE;
- // memcpy( this_tbuf, src, amt );
- for (uint32_t ii = 0; ii < (amt / 2); ii++) {
- uint16_t *destword = (uint16_t *)this_tbuf[ii];
- uint16_t *srcword = (uint16_t *)src[ii];
- *destword = IntelSwapper(*srcword);
- }
- src += amt + nf_new_line;
- this_tbuf += amt + nf_new_line;
- }
-
- this_tbuf -= nf_new_line;
- this_tbuf -= nf_back_right;
- }
- }
- }
-}
-
-void DECOMP_CHG_BODY(bool HI_COLOR_FLAG, const uint16_t *&chgs, const uint16_t *&parms,
- const uint8_t *&comp, uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h) {
- uint32_t HI_COLOR_SCALE = (HI_COLOR_FLAG) ? 2 : 1;
-
- tNextFrame nf;
- nf.w = _w;
- nf.h = _h;
- nf.x = _x;
- nf.y = _y;
- NF_DECOMP_INIT(HI_COLOR_FLAG ? 1 : 0, &nf);
-
- // Iterate over params and copy new hires data to appropriate sections.
- const uint16_t *pChgs = chgs;
- uint32_t eax = 0;
- const uint8_t *compData = comp;
- uint8_t *curr_tbuf = nf.tbuf;
- const uint16_t *curr_parms = parms;
- for (uint8_t fqIt = nf_fqty; fqIt != 0; --fqIt, curr_tbuf += nf_width) {
- uint8_t *this_tbuf = curr_tbuf;
- for (uint32_t ch = nf.h; ch != 0; --ch, this_tbuf += nf.new_row) {
- for (uint32_t cl = nf.w; cl != 0; --cl) {
- eax *= 2;
- while (eax == 0) {
- eax = IntelSwapper(*pChgs++);
- eax *= 2;
- }
-
- if (((int)eax) > 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- uint16_t flags = IntelSwapper(*curr_parms++);
- if (flags != 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- // Copy new data to one section
- // Enter with ds:si pointing to source data, es:di to screen section.
- // Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
- for (int i = 0; i < 8; ++i) {
- size_t amt = sizeof(uint32_t) * 2 * HI_COLOR_SCALE;
- // TODO: Do these bytes need swapping? Is this data shorts?
- // memcpy( this_tbuf, compData, amt );
- for (uint32_t ii = 0; ii < (amt / 2); ii++) {
- uint16_t *dest = (uint16_t *)this_tbuf[ii];
- uint16_t *src = (uint16_t *)compData[ii];
- *dest = IntelSwapper(*src);
- }
- compData += amt;
- this_tbuf += amt + nf_new_line;
- }
- this_tbuf -= nf_new_line;
- this_tbuf -= nf_back_right;
- }
- }
- }
-
- // Iterate over flags and motion source addresses from params
- // to determine which sections to move.
- // ebx indexes params.
- // esi indexes source from buffer
- // esi will be computed as +- 16K relative to edi.
- curr_tbuf = nf.tbuf;
- curr_parms = parms;
- pChgs = chgs;
- eax = 0;
-
- for (uint8_t fqIt = nf_fqty; fqIt != 0; --fqIt, curr_tbuf += nf_width) {
- uint8_t *this_tbuf = curr_tbuf;
- for (uint32_t ch = nf.h; ch != 0; --ch, this_tbuf += nf.new_row) {
- for (uint32_t cl = nf.w; cl != 0; --cl) {
- eax *= 2;
- while (eax == 0) {
- eax = IntelSwapper(*pChgs++);
- eax *= 2;
- }
-
- if (((int)eax) > 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- int flags = (int)IntelSwapper((*curr_parms++));
- if (flags == 0) {
- this_tbuf += SWIDTH * HI_COLOR_SCALE;
- continue;
- }
-
- // Make esi absolute
- uint8_t *src = this_tbuf;
- if (flags > 0) {
- src += (flags - 0x4000) * HI_COLOR_SCALE;
- } else {
- src += (flags - 0xC000) * HI_COLOR_SCALE;
- src += nf.DiffBufPtrs; // and point to other buffer
- }
-
- for (int i = 0; i < 8; ++i) {
- size_t amt = sizeof(uint32_t) * 2 * HI_COLOR_SCALE;
- // memcpy( this_tbuf, src, amt );
- for (uint32_t ii = 0; ii < (amt / 2); ii++) {
- uint16_t *destword = (uint16_t *)this_tbuf[ii];
- uint16_t *srcword = (uint16_t *)src[ii];
- *destword = IntelSwapper(*srcword);
- }
- src += amt + nf_new_line;
- this_tbuf += amt + nf_new_line;
- }
- this_tbuf -= nf_new_line;
- this_tbuf -= nf_back_right; // (SHEIGHT-1)*width
- }
- }
- }
-}
-
-// Decompress into subsection of current buffer specified by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-void nfHiColorDecomp(const uint8_t *comp, uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
- DECOMP_BODY(true, comp, x, y, w, h);
-}
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-void nfHiColorDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h) {
- DECOMP_CHG_BODY(true, chgs, parms, comp, x, y, w, h);
-}
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-void nfDecomp(const uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) {
- if (nf_hicolor) {
- nfHiColorDecomp(comp, x, y, w, h);
- return;
- }
-
- DECOMP_BODY(false, comp, x, y, w, h);
-}
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-void nfDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h) {
- if (nf_hicolor) {
- nfHiColorDecompChg(chgs, parms, comp, x, y, w, h);
- return;
- }
-
- DECOMP_CHG_BODY(false, chgs, parms, comp, x, y, w, h);
-}
-
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { debug_break(); }
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { debug_break(); }
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- debug_break();
-}
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- debug_break();
-}
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- debug_break();
-}
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- debug_break();
-}
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- debug_break();
-}
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- debug_break();
-}
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count) { debug_break(); }
-void palLoadCompPalette(uint8_t *buf) { debug_break(); }
-void gfxMode(unsigned mode) { debug_break(); }
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res) { debug_break(); }
-void gfxGetCrtc(uint8_t *crtc) { debug_break(); }
-void gfxVres(uint8_t misc, uint8_t *crtc) { debug_break(); }
-void MVE_gfxWaitRetrace(int state) { debug_break(); }
-void MVE_gfxSetSplit(unsigned line) { debug_break(); }
diff --git a/libmve/mvegfx.h b/libmve/mvegfx.h
deleted file mode 100644
index 3d1e21e3..00000000
--- a/libmve/mvegfx.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#define MVE_GFX_VESA_640_400 0x100
-#define MVE_GFX_VESA_640_200 0x8100
-#define MVE_GFX_VESA_640_480 0x101
-#define MVE_GFX_VESA_640_240 0x8101
-#define MVE_GFX_VESA_800_600 0x103
-#define MVE_GFX_VESA_800_300 0x8103
-#define MVE_GFX_VESA_1024_768 0x105
-#define MVE_GFX_VESA_1024_384 0x8105
-#define MVE_GFX_VESA_1280_1024 0x107
-#define MVE_GFX_VESA_1280_512 0x8107
-
-#define MVE_GFX_VESA_320_200_HI 0x10d /* 1:5:5:5 Hi Color modes */
-#define MVE_GFX_VESA_640_480_HI 0x110
-#define MVE_GFX_VESA_800_600_HI 0x113
-#define MVE_GFX_VESA_1024_768_HI 0x116
-#define MVE_GFX_VESA_1280_1024_HI 0x119
-
-/* Some hacked vesa modes */
-#define MVE_GFX_VESA_640_350 0x0F00 /* 640x350 */
-#define MVE_GFX_VESA_640_175 0x8F00 /* 640x175 */
-#define MVE_GFX_VESA_640_160 0x0F01 /* 640x160 */
-
-#define MVE_GFX_VESA_CURRENT 0 /* Use current VESA mode */
-
-#define MVE_GFX_AUTO (-1) /* Choose mode based on movie's preference */
-#define MVE_GFX_VGA 0x13 /* 320x200 */
-#define MVE_GFX_VGA_CURRENT (-2) /* 320x200 (mode already set) */
-#define MVE_GFX_VGA_MEDRES (-3) /* 248x264 out of 320x350 */
-#define MVE_GFX_VGA_HIRES (-4) /* 224x288 out of 360x480 */
-#define MVE_GFX_VGA_LORES (-5) /* 288x224 out of 320x240 */
-#define MVE_GFX_VESA_320_480 (-6) /* 320x480 */
diff --git a/libmve/mvelib.h b/libmve/mvelib.h
index 257bf776..c5d40907 100644
--- a/libmve/mvelib.h
+++ b/libmve/mvelib.h
@@ -21,8 +21,6 @@
#include
#include
-#include "SystemInterfaces.h"
-
/* callback for reading stream */
typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
/* callback for memore allocating */
@@ -77,8 +75,6 @@ void MVE_rmEndMovie(MVESTREAM *mve);
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
-void MVE_sndInit(ISoundDevice *lpDS);
-
void MVE_sndInit(int x);
void MVE_ioCallbacks(mve_cb_Read io_read);
diff --git a/libmve/mvelibi.h b/libmve/mvelibi.h
deleted file mode 100644
index 03f0506a..00000000
--- a/libmve/mvelibi.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifndef MVELIBI_H__
-#define MVELIBI_H__
-
-#if __SC__
-#pragma SC align 1
-#elif __WATCOMC__
-#pragma pack(1);
-#elif _MSC_VER
-#pragma pack(1)
-#elif __LINUX__
-#pragma pack(1)
-#else
-#error No platform defined
-#endif
-
-#include "byteswap.h"
-//--------------------------------
-// Compressed Video Constants
-//--------------------------------
-
-// Width and height of sections in pixels.
-#define SWIDTH 8
-#define SHEIGHT 8
-
-#define LOG2_SWIDTH 3
-#define LOG2_SHEIGHT 3
-
-//------------------------------
-// Movie File Header
-//------------------------------
-
-#define MVE_FILE_TYPE "Interplay MVE File\x1A\0"
-#define MVE_FILE_VERSION 0x0100
-
-// some inlines to prevent macro craziness when using incrementers and dereferencing, and so I can use operator
-// overloading
-inline uint16_t IntelSwapper(uint16_t a) { return INTEL_SHORT(a); }
-
-inline int16_t IntelSwapper(int16_t a) { return INTEL_SHORT(a); }
-
-inline uint32_t IntelSwapper(uint32_t a) { return INTEL_INT(a); }
-
-inline int IntelSwapper(int a) { return INTEL_INT(a); }
-
-struct mve_hdr {
- char FileType[20]; // MVE_FILE_TYPE
- uint16_t HdrSize; // sizeof(mve_hdr)
- uint16_t version; // MVE_FILE_VERSION
- uint16_t id; // ~MVE_FILE_VERSION+0x1234
- void SwapBytes() {
- HdrSize = IntelSwapper(HdrSize);
- version = IntelSwapper(version);
- id = IntelSwapper(id);
- }
-};
-
-//------------------------------
-// Movie File Records
-//------------------------------
-
-struct ioHdrRec {
- uint16_t len; // Length of record data (pad to even)
- uint16_t kind; // See IO_REC_xxx
- // uint8_t data[0]; // Record data
- void SwapBytes() {
- len = IntelSwapper(len);
- kind = IntelSwapper(kind);
- }
-};
-
-// This record classifications simplify utilities which must operate on
-// records. They are not used by this library when running a movie.
-//
-#define IO_REC_SND_INIT 0 // Sound setup
-#define IO_REC_SND_PRELOAD 1 // Sound preload
-#define IO_REC_FRAME_INIT 2 // Frame (video) setup
-#define IO_REC_FRAME 3 // Movie frames
-#define IO_REC_END 4 // Last Record (End of Movie)
-#define IO_REC_EOF 5 // Empty eof record at end of file.
-
-//------------------------------
-// Movie File Major Opcodes
-//------------------------------
-//
-
-#define MCMD_DATA(arg) ((uint8_t *)((arg) + 1))
-
-struct mcmd_hdr {
- uint16_t len; // Length of data (pad to even)
- uint8_t major; // Major opcode
- uint8_t minor; // Minor opcode
- // uint8_t data[0]; // Opcode data
- void SwapBytes() { len = IntelSwapper(len); }
-};
-
-#define mcmd_end 0 // End processing of movie
-
-#define mcmd_next 1 // Advance to next movie record
-
-#define mcmd_syncInit 2
-struct marg_syncInit {
- uint32_t period; // period of quanta
- uint16_t wait_quanta; // # of quanta per frame
- void SwapBytes() {
- period = IntelSwapper(period);
- wait_quanta = IntelSwapper(wait_quanta);
- }
-};
-
-#define mcmd_sndConfigure 3
-struct marg_sndConfigure {
- uint16_t rate; // 65536-(256E6/(frequency*(stereo+1)))
- // comp16 is a minor opcode 1 field
- // It indicates that 16-bit data has been compressed to 8-bits.
- // When it is set, bits16 will also be set.
- // Each record will contain initial 16-bit sample followed
- // by remaining compressed 8-bit samples.
- // For stereo, there will be two initial 16-bit samples.
- // and compressed streams will be interleaved.
-#ifdef OUTRAGE_BIG_ENDIAN
- uint8_t pad : 5;
- uint8_t stereo : 1, bits16 : 1, comp16 : 1;
- uint8_t pad2;
-#else
- uint8_t stereo : 1, bits16 : 1, comp16 : 1;
- uint8_t pad;
-#endif
- uint16_t frequency;
- // Minor opcode 1 extends buflen to be a long
- uint32_t buflen;
- void SwapBytes() {
- rate = IntelSwapper(rate);
- frequency = IntelSwapper(frequency);
- buflen = IntelSwapper(buflen);
- }
-};
-
-#define mcmd_sndSync 4
-
-#define mcmd_nfConfig 5
-struct marg_nfConfig {
- uint16_t wqty;
- uint16_t hqty;
- // Minor opcode 1 fields:
- uint16_t fqty;
- // Minor opcode 2 fields:
- uint16_t hicolor; /*0=256-color, 1=HiColor, 2=HiColorSwapped*/
- void SwapBytes() {
- wqty = IntelSwapper(wqty);
- hqty = IntelSwapper(hqty);
- fqty = IntelSwapper(fqty);
- hicolor = IntelSwapper(hicolor);
- }
-};
-
-#define mcmd_nfDecomp 6
-#define mcmd_nfDecompChg 16
-#define mcmd_nfPkDecomp 17
-struct marg_nfDecomp {
- uint16_t prev; // info:Prev frames+1 needed for full picture
- uint16_t iframe; // info:Current internal frame #
- uint16_t x;
- uint16_t y;
- uint16_t w;
- uint16_t h;
-#ifdef OUTRAGE_BIG_ENDIAN
- uint8_t bitpadder : 7;
- uint8_t advance : 1;
- uint8_t dummy1;
-#else
- uint16_t advance : 1;
- uint16_t pad : 15;
-#endif
-
- void SwapBytes() {
- prev = IntelSwapper(prev);
- iframe = IntelSwapper(iframe);
- x = IntelSwapper(x);
- y = IntelSwapper(y);
- w = IntelSwapper(w);
- h = IntelSwapper(h);
- }
-};
-
-#define mcmd_sfShowFrame 7
-#if 0 // Not supported
-#define mcmd_sfPkShowFrameChg 18
-#endif
-struct marg_sfShowFrame {
- uint16_t pal_start;
- uint16_t pal_count;
- // Minor opcode 1 fields:
- uint16_t field; // 0:none, 2:send to even, 3:send to odd
- void SwapBytes() {
- pal_start = IntelSwapper(pal_start);
- pal_count = IntelSwapper(pal_count);
- field = IntelSwapper(field);
- }
-};
-
-#define mcmd_sndAdd 8
-#define mcmd_sndSilence 9
-struct marg_sndAdd {
- uint16_t iframe; // info: iframe # of sound
- uint16_t TrackMask;
- uint16_t qty; // Uncompressed audio size in bytes
- // uint8_t data[0];
- void SwapBytes() {
- iframe = IntelSwapper(iframe);
- TrackMask = IntelSwapper(TrackMask);
- qty = IntelSwapper(qty);
- }
-};
-
-#define mcmd_gfxMode 10
-struct marg_gfxMode {
- uint16_t minw;
- uint16_t minh;
- uint16_t mode;
- void SwapBytes() {
- minw = IntelSwapper(minw);
- minh = IntelSwapper(minh);
- mode = IntelSwapper(mode);
- }
-};
-
-#define mcmd_palMakeSynthPalette 11
-struct marg_palMakeSynthPalette {
- uint8_t base_r;
- uint8_t range_r;
- uint8_t range_rb;
- uint8_t base_g;
- uint8_t range_g;
- uint8_t range_gb;
- void SwapBytes() {}
-};
-
-#define mcmd_palLoadPalette 12
-struct marg_palLoadPalette {
- uint16_t start;
- uint16_t count;
- // uint8_t data[0];
- void SwapBytes() {
- start = IntelSwapper(start);
- count = IntelSwapper(count);
- }
-};
-
-#define mcmd_palLoadCompPalette 13
-
-#define mcmd_nfChanges 14
-#define mcmd_nfParms 15
-// 16 is used for mcmd_nfDecompChg, see above.
-// 17 is used for mcmd_nfPkDecomp, see above.
-// 18 is used for mcmd_nfPkShowFrameChg, see above
-
-#define mcmd_nfPkInfo 19
-#define mcmd_nfHPkInfo 20
-struct marg_nfPkInfo {
- uint32_t error; // scaled by 10000
- uint16_t usage[64];
-};
-
-#define mcmd_idcode 21
-struct marg_idcode {
- uint32_t idcode; // Code identifying version mcomp used to create
-};
-
-#if __SC__
-#pragma SC align
-#elif __WATCOMC__
-#pragma pack();
-#elif _MSC_VER
-#pragma pack()
-#elif __LINUX__
-#pragma pack()
-#else
-#error No platform defined
-#endif
-
-#endif
diff --git a/libmve/mvelibl.cpp b/libmve/mvelibl.cpp
deleted file mode 100644
index 849d2358..00000000
--- a/libmve/mvelibl.cpp
+++ /dev/null
@@ -1,1762 +0,0 @@
-/*
-** mvelibl.cpp
-**
-** Interplay Movie File (MVE) Player Library (32-Bit Linux Version)
-** Written by Paul Allen Edelstein. Partial Linux port by Jeff Slutter.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-**
-
---- HISTORICAL COMMENTS FOLLOW ---
-
-** Linux Specific Notes:
-** Only HiColor mode movies are supported. Others could
-** be supported, but the nf*, etc. functions need to be
-** implemented to do so. See mveasm.cpp.
-**
-** No gfx or resolution changing functions are implemented in
-** here.
-*/
-static char notice1[] = "(c) 1997 Interplay Productions. All Rights Reserved.\n"
- "This file is confidential and consists of proprietary information\n"
- "of Interplay Productions. This file and associated libraries\n"
- "may not, in whole or in part, be disclosed to third parties,\n"
- "incorporated into any software product which is not being created\n"
- "for Interplay Productions, copied or duplicated in any form,\n"
- "without the prior written permission of Interplay Productions.\n"
- "Further, you may not reverse engineer, decompile or otherwise\n"
- "attempt to derive source code of this material.\n";
-
-#include
-#include
-#include
-
-#include "platform.h"
-#include "mvelibi.h"
-#include "mvegfx.h"
-#include "mvelibl.h"
-
-static unsigned opt_fastmode = 0; // 0:normal, 1:even lines only, 2:dither between even/odd lines |4 to spread lines
-
-unsigned opt_hscale_step = 4; // 3: 4/3, 4:4/4, 5:4/5 (not fully implemented)
-unsigned opt_hscale_adj;
-extern unsigned sf_ScreenHeight;
-extern unsigned sf_ScreenWidth;
-
-#define logLabel(x)
-
-#include "snd8to16.h"
-// len always specifies length of destination in bytes.
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned state);
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned state);
-
-//----------------------------------------------------------------------
-// Memory Management
-//--------------------
-
-static void *(*mem_alloc)(unsigned size);
-static void (*mem_free)(void *p);
-
-struct MemRec {
- void *ptr;
- unsigned size;
- bool dynamic;
-};
-
-static void MemInit(MemRec* m, unsigned size, void *p);
-static void *MemAlloc(MemRec* m, unsigned size);
-static void MemFree(MemRec* m);
-
-void MVE_memCallbacks(void *(*fn_alloc)(unsigned size), void (*fn_free)(void *p)) {
- mem_alloc = fn_alloc;
- mem_free = fn_free;
-}
-
-static void MemFree(MemRec* m) {
- if (m->dynamic && mem_free) {
- (*mem_free)(m->ptr);
- m->dynamic = false; // prevent from being freed again!
- }
- m->size = 0;
-}
-
-static void MemInit(MemRec* m, unsigned size, void *p) {
- if (!p)
- return;
-
- MemFree(m);
- m->ptr = p;
- m->size = size;
- m->dynamic = false;
-}
-
-static void *MemAlloc(MemRec* m, unsigned size) {
- if (size <= m->size)
- return m->ptr;
-
- if (mem_alloc) {
- void *p;
- MemFree(m);
- size += 100; // Add some pad to reduce chance of another realloc.
- p = (*mem_alloc)(size);
- if (!p)
- return (void *)NULL;
- MemInit(m, size, p);
- m->dynamic = true;
- return m->ptr;
- }
-
- return (void *)NULL;
-}
-
-//----------------------------------------------------------------------
-// Synchronization Management
-//-----------------------------
-
-static bool sync_active = false;
-static int sync_time = 0;
-static int sync_wait_quanta = 0;
-
-static bool sync_late = false;
-static bool sync_FrameDropped = false;
-
-static void syncReset(uint32_t wait_quanta);
-static void syncRelease(void);
-static bool syncInit(uint32_t period, unsigned wait_quanta);
-static bool syncWait(void);
-static void syncSync(void);
-
-static void syncReset(uint32_t wait_quanta) {
- sync_time = wait_quanta - platform_timeGetTime() * 1000;
- sync_active = true;
-}
-
-static void syncRelease(void) { sync_active = false; }
-
-static bool syncInit(uint32_t period, unsigned wait_quanta) {
- int new_wait_quanta = -(int32_t)(period * wait_quanta + (wait_quanta >> 1));
-
- // If timer is still running and has same timing
- // characteristics, assume we are trying to continue smoothly
- // with another movie and ignore new syncInit() call.
- if (sync_active && sync_wait_quanta == new_wait_quanta)
- return true;
-
- syncWait();
- sync_wait_quanta = new_wait_quanta;
- syncReset(sync_wait_quanta);
- return true;
-}
-
-// Returns true if actually waited, false if called too late to wait.
-static bool syncWait(void) {
- bool waited = false;
- if (!sync_active)
- return false;
-
- while ((int)(sync_time + platform_timeGetTime() * 1000) < 0) {
- waited = true;
- }
-
- sync_time += sync_wait_quanta;
- return waited;
-}
-
-// Returns true if actually waited, false if called too late to wait.
-static int syncWaitLevel(int level) {
- int waited;
- if (!sync_active)
- return 0;
-
- level += sync_time;
-
- for (;;) {
- waited = level + platform_timeGetTime() * 1000;
- if (waited >= 0)
- break;
- }
-
- sync_time += sync_wait_quanta;
- return waited;
-}
-
-static void syncSync(void) {
- if (sync_active) {
- while ((int)(sync_time + platform_timeGetTime() * 1000) < 0)
- ;
- }
-}
-
-int MVE_syncTime(void) {
- if (sync_active)
- return sync_time + platform_timeGetTime() * 1000;
- return 0;
-}
-
-void MVE_logDumpStats(void) {}
-
-//----------------------------------------------------------------------
-// I/O Management
-//-----------------
-
-static unsigned (*io_read)(int handle, void *buf, unsigned count);
-
-static MemRec io_mem_buf;
-
-static int io_handle;
-static ioHdrRec io_next_hdr;
-
-static bool ioReset(int h);
-static uint8_t *ioRead(unsigned qty);
-static uint8_t *ioNextRecord(void);
-static void ioRelease(void);
-
-void MVE_ioCallbacks(unsigned (*fn_read)(int handle, void *buf, unsigned count)) { io_read = fn_read; }
-
-static bool ioReset(int h) {
- mve_hdr *hdr;
-
- io_handle = h;
- hdr = (mve_hdr *)ioRead(sizeof(mve_hdr) + sizeof(ioHdrRec));
- if (!hdr)
- return false;
- hdr->SwapBytes();
- if (strcmp(hdr->FileType, MVE_FILE_TYPE) != 0 || hdr->id != ~hdr->version + 0x1234 ||
- // The following two checks may eventually be weakened.
- hdr->version != MVE_FILE_VERSION || hdr->HdrSize != sizeof(mve_hdr))
- return false;
-
- io_next_hdr = *(ioHdrRec *)(hdr + 1);
- io_next_hdr.SwapBytes();
- return true;
-}
-
-void MVE_memIO(void *p, unsigned size) { MemInit(&io_mem_buf, size, p); }
-
-static uint8_t *ioRead(unsigned len) {
- uint8_t *buf;
-
- buf = (uint8_t *)MemAlloc(&io_mem_buf, len);
- if (!buf)
- return (uint8_t *)NULL;
-
- if (!(*io_read)(io_handle, buf, len))
- return (uint8_t *)NULL;
-
- return buf;
-}
-
-static uint8_t *ioNextRecord(void) {
- uint8_t *buf;
- logLabel("StartRead");
- buf = ioRead(io_next_hdr.len + sizeof(ioHdrRec));
- logLabel("EndRead");
- if (!buf)
- return (uint8_t *)NULL;
- io_next_hdr = *(ioHdrRec *)(buf + io_next_hdr.len);
- io_next_hdr.SwapBytes();
- return buf;
-}
-
-static void ioRelease(void) { MemFree(&io_mem_buf); }
-
-//----------------------------------------------------------------------
-// Sound Management
-//-----------------------
-
-#define SOUND_SUPPORT 1
-
-#if SOUND_SUPPORT
-
-static ISoundDevice *snd_ds = NULL;
-static ISysSoundBuffer *snd_buffer = NULL;
-static SysSoundCaps snd_buffer_caps;
-static uint32_t snd_write_cursor = 0;
-
-enum { snd_queue_max = 60 };
-
-static struct _snd_queue {
- unsigned ptr;
-} snd_queue[snd_queue_max];
-static unsigned snd_fill = 0;
-static unsigned snd_empty = 0;
-static int snd_pad = 0;
-static unsigned snd_stereo = 0;
-static unsigned snd_comp16 = 0;
-static unsigned snd_bits16 = 0;
-static int32_t snd_volume = 0;
-static int32_t snd_pan = 0;
-
-#endif
-
-void MVE_sndInit(ISoundDevice *lpDS) {
-#if SOUND_SUPPORT
- snd_ds = lpDS;
-#endif
-}
-
-void MVE_dsbSetVolume(int32_t lVolume) {
-#if SOUND_SUPPORT
- snd_volume = lVolume;
- if (snd_buffer) {
- snd_buffer->SetVolume(snd_volume);
- }
-#endif
-}
-
-void MVE_dsbSetPan(int32_t lPan) {
-#if SOUND_SUPPORT
- snd_pan = lPan;
- if (snd_buffer) {
- snd_buffer->SetPan(snd_pan);
- }
-#endif
-}
-
-static void sndReset(void) {
-#if SOUND_SUPPORT
- if (snd_buffer) {
- snd_buffer->Stop();
- snd_buffer->Release();
- snd_buffer = NULL;
- }
-#endif
-}
-
-static bool sndConfigure(unsigned rate, unsigned buflen, unsigned stereo, unsigned frequency, unsigned bits16,
- unsigned comp16) {
-#if SOUND_SUPPORT
- if (!snd_ds)
- return true;
-
- syncSync();
- sndReset();
-
- snd_stereo = stereo;
- snd_bits16 = bits16;
- snd_comp16 = comp16;
- snd_fill = 0;
- snd_empty = 0;
-
- SoundWAVEFormatEx snd_wfx;
- snd_wfx.wFormatTag = SOUND_WAVE_FORMAT_PCM;
- snd_wfx.nChannels = stereo ? 2 : 1;
- snd_wfx.nSamplesPerSec = frequency;
- snd_wfx.nBlockAlign = (stereo ? 2 : 1) * (bits16 ? 2 : 1);
- snd_wfx.nAvgBytesPerSec = frequency * snd_wfx.nBlockAlign;
- snd_wfx.wBitsPerSample = bits16 ? 16 : 8;
-
- SysSoundBufferDesc snd_bufferdesc;
- snd_bufferdesc.dwFlags = LNXSND_CAPS_CTRLDEFAULT;
- snd_bufferdesc.dwBufferBytes = (buflen + (buflen >> 1)) & ~3;
- snd_bufferdesc.lpwfxFormat = &snd_wfx;
-
- int dsrval = snd_ds->CreateSoundBuffer(&snd_bufferdesc, &snd_buffer);
- if (dsrval != 0)
- return false;
-
- snd_buffer->SetVolume(snd_volume);
- snd_buffer->SetPan(snd_pan);
-
- snd_write_cursor = 0;
-
- dsrval = snd_buffer->GetCaps(&snd_buffer_caps);
- if (dsrval != 0)
- return false;
-#endif
-
- return true;
-}
-
-static void sndSync(void) {
- // Better frame dropping using more flexible synchronization
- sync_late = syncWaitLevel(sync_wait_quanta >> 2) > (-sync_wait_quanta >> 1) && !sync_FrameDropped;
- sync_FrameDropped = false;
-
-#if SOUND_SUPPORT
- if (!snd_ds || !snd_buffer)
- return;
-
- uint32_t dsbstatus;
- uint32_t target;
- uint32_t play_cursor, write_cursor;
-#define set_target(t) \
- (target = (snd_queue[snd_empty].ptr + (t) + snd_buffer_caps.dwBufferBytes) % snd_buffer_caps.dwBufferBytes)
-#define target_pending() \
- ((play_cursor <= write_cursor) ? (play_cursor <= target && target < write_cursor) \
- : (play_cursor <= target || target < write_cursor))
-
- bool need_resync = false;
- for (;;) {
- int dsrval = snd_buffer->GetStatus(&dsbstatus);
- if (dsrval != 0)
- return;
-
- dsrval = snd_buffer->GetCurrentPosition(&play_cursor, &write_cursor);
- if (dsrval != 0)
- return;
- write_cursor = snd_write_cursor;
-
- // Don't get too far ahead of sound (target-pad not yet played)
- set_target(-snd_pad);
- if (target_pending() && (dsbstatus & LNXSND_PLAYING)) {
- need_resync = true;
- } else {
- break;
- }
- }
-
- if (need_resync) {
- syncReset(sync_wait_quanta + (sync_wait_quanta >> 2));
- }
-
- if (!(dsbstatus & LNXSND_PLAYING)) // If currently not playing
- {
- // Don't restart too soon (restart when target hasn't been played)
- set_target(0);
- if (target_pending()) {
- int dsrval = snd_buffer->SetCurrentPosition(target);
- if (dsrval != 0)
- return;
-
- dsrval = snd_buffer->Play(LNXSND_LOOPING);
- if (dsrval != 0)
- return;
-
- syncReset(sync_wait_quanta);
- }
- }
- // Because DirectSound can consume an unpredictable amount into primary, this won't always be invoked when it should
- else {
- // Don't get too far behind sound (has target+pad already been played?)
- set_target(snd_pad);
- {
- int amt = write_cursor - play_cursor;
- if (amt < 0)
- amt += snd_buffer_caps.dwBufferBytes;
- amt = snd_buffer_caps.dwBufferBytes - amt - 1;
- if (amt > (int)snd_buffer_caps.dwBufferBytes / 2) {
- amt = snd_buffer_caps.dwBufferBytes / 2;
- }
- play_cursor = (play_cursor - amt + snd_buffer_caps.dwBufferBytes) % snd_buffer_caps.dwBufferBytes;
- }
-
- if (!target_pending()) {
- snd_buffer->Stop();
- // dsrval = snd_buffer->GetCurrentPosition( &snd_write_cursor, &write_cursor );
- }
- }
-
- if (snd_empty != snd_fill) {
- if (snd_empty == snd_queue_max - 1) {
- snd_empty = 0;
- } else {
- ++snd_empty;
- }
- }
-#endif
-}
-
-// For compressed streams, assumes len (which is in bytes) will be in multiples
-// of 2 for mono and 4 for stereo.
-static unsigned sndAddHelper(uint8_t *dst, const uint8_t **pSrc, unsigned len, unsigned state, bool init) {
-#if SOUND_SUPPORT
- const uint8_t *src;
- src = *pSrc;
- if (!src) {
- memset(dst, (snd_bits16 ? 0 : 0x80), len);
- } else {
- if (snd_comp16) {
- if (!snd_stereo) {
- if (init) {
- state = IntelSwapper(*(uint16_t *)src);
- *(uint16_t *)dst = state;
- src += 2;
- dst += 2;
- len -= 2;
- }
-
- state = sndDecompM16((uint16_t *)dst, src, len >> 1, state);
-
- src += len >> 1;
- } else {
- if (init) {
- state = IntelSwapper(*(uint32_t *)src);
- *(uint32_t *)dst = state;
- src += 4;
- dst += 4;
- len -= 4;
- }
- state = sndDecompS16((uint16_t *)dst, src, len >> 2, state);
- src += len >> 1;
- }
- } else {
- memcpy(dst, src, len);
- src += len;
- }
- }
-
- *pSrc = src;
- return state;
-#else
- return 0;
-#endif
-}
-
-static void sndAdd(const uint8_t *buf, unsigned len) {
-#if SOUND_SUPPORT
- int dsrval;
- uint32_t play_cursor, write_cursor;
- uint32_t len1, len2;
-
- unsigned state = 0;
- bool init = true;
- uint8_t *ptr1, *ptr2;
-
- snd_pad = len;
-
- if (!snd_buffer || snd_fill + 1 == (snd_empty ? snd_empty : snd_queue_max))
- return;
-
- dsrval = snd_buffer->GetCurrentPosition(&play_cursor, &write_cursor);
- if (dsrval != 0)
- return;
- write_cursor = snd_write_cursor;
-
- dsrval = snd_buffer->Lock(write_cursor, len, (void **)&ptr1, &len1, (void **)&ptr2, &len2,
- 0 /*LNXSND_LOCK_FROMWRITECURSOR*/ /*flags*/);
- if (dsrval != 0)
- return;
-
- if (len1) {
- state = sndAddHelper(ptr1, &buf, len1, state, init);
- init = false;
- snd_write_cursor += len1;
- }
-
- if (len2) {
- sndAddHelper(ptr2, &buf, len2, state, init);
- snd_write_cursor = len2;
- }
-
- if (snd_write_cursor == snd_buffer_caps.dwBufferBytes) {
- snd_write_cursor = 0;
- }
-
- snd_buffer->Unlock(ptr1, len1, ptr2, len2);
-
- snd_queue[snd_fill].ptr = write_cursor;
- if (snd_fill == snd_queue_max - 1) {
- snd_fill = 0;
- } else {
- ++snd_fill;
- }
-#endif
-}
-
-static void sndRelease(void) {
-#if SOUND_SUPPORT
- // Nothing to free
-#endif
-}
-
-static void sndPause(void) {
-#if SOUND_SUPPORT
- if (snd_buffer) {
- snd_buffer->Stop();
- }
-#endif
-}
-
-static void sndResume(void) {
- // Nothing need be done here to resume sound
- // The next call to sndSync will automatically resume the sound.
-}
-
-//--------------------------------------------------------------------
-// NextFrame (Video Decompression)
-//----------------------------------
-
-// static removed from most nf_ vars to support mveliba.asm
-
-static bool nf_memory_mode = false;
-
-// NextFrame working storage
-uint8_t *nf_buf_cur = NULL;
-uint8_t *nf_buf_prv = NULL;
-static MemRec nf_mem_buf1;
-static MemRec nf_mem_buf2;
-
-// NextFrame parameters
-uint8_t nf_wqty = 0; // (width/SWIDTH)
-uint8_t nf_hqty = 0; // (height/SHEIGHT)
-uint8_t nf_fqty = 0; // Number of fields
-unsigned nf_hicolor = 0; // HiColor (0:none,1:normal,2:swapped)
-//
-unsigned nf_width = 0; // wqty * SWIDTH
-unsigned nf_height = 0; // hqty * SHEIGHT;
-unsigned nf_new_line = 0; // width - SWIDTH
-unsigned nf_new_row0 = 0; // SHEIGHT*width*2-width
-unsigned nf_back_right = 0; // (SHEIGHT-1)*width
-
-// Frame parameters
-// Portion of current frame which has been updated
-// and needs to be sent to screen.
-//
-unsigned nf_new_x = 0;
-unsigned nf_new_y = 0;
-unsigned nf_new_w = 0;
-unsigned nf_new_h = 0;
-
-// Hicolor format translation tables
-uint16_t nf_trans16_lo[256];
-uint16_t nf_trans16_hi[256];
-
-void MVE_memVID(void *p1, void *p2, unsigned size) {
- MemInit(&nf_mem_buf1, size, p1);
- MemInit(&nf_mem_buf2, size, p2);
-}
-
-void nfPkConfig(void);
-
-// ffs()
-// Returns position of most significant bit set (0 to 31).
-// Assumes bits is nonzero.
-static int ffs(unsigned bits) {
- int pos;
- unsigned t;
- t = bits & 0xFFFF0000;
- if (t)
- bits = t, pos = 16;
- else
- pos = 0;
- t = bits & 0xFF00FF00;
- if (t)
- bits = t, pos |= 8;
- t = bits & 0xF0F0F0F0;
- if (t)
- bits = t, pos |= 4;
- t = bits & 0xCCCCCCCC;
- if (t)
- bits = t, pos |= 2;
- if (bits & 0xAAAAAAAA)
- pos |= 1;
- return pos;
-}
-
-static bool nfConfig(int wqty, int hqty, int fqty, int hicolor) {
- unsigned size;
-
- if (!nf_memory_mode) {
- if (nf_buf_cur) {
- free(nf_buf_cur);
- nf_buf_cur = NULL;
- }
- if (nf_buf_prv) {
- free(nf_buf_prv);
- nf_buf_prv = NULL;
- }
- }
-
- nf_wqty = (uint8_t)wqty;
- nf_hqty = (uint8_t)hqty;
- nf_fqty = (uint8_t)fqty;
- nf_width = wqty * SWIDTH;
- nf_height = hqty * fqty * SHEIGHT;
- if (opt_fastmode) {
- nf_height >>= 1;
- }
-
- {
- if (hicolor) {
- const uint32_t pal_rmask = 0x001F;
- const uint32_t pal_bmask = 0xF800;
- const uint32_t pal_gmask = 0x07E0;
-
- const int pal_rshift = ffs(pal_rmask) - 4;
- const int pal_gshift = ffs(pal_gmask) - 4;
- const int pal_bshift = ffs(pal_bmask) - 4;
- unsigned i, r, g, b;
- for (i = 0, r = 0, g = 0; g < 8; ++g) {
- for (b = 0; b < 32; ++b, ++i) {
- nf_trans16_lo[i] = (((pal_rshift > 0 ? r << pal_rshift : r >> -pal_rshift) & pal_rmask) |
- ((pal_gshift > 0 ? g << pal_gshift : g >> -pal_gshift) & pal_gmask) |
- ((pal_bshift > 0 ? b << pal_bshift : b >> -pal_bshift) & pal_bmask));
- }
- }
-
- for (i = 0, r = 0, b = 0; r < 32; ++r) {
- for (g = 0; g < 32; g += 8, ++i) {
- nf_trans16_hi[i + 128] = nf_trans16_hi[i] =
- (((pal_rshift > 0 ? r << pal_rshift : r >> -pal_rshift) & pal_rmask) |
- ((pal_gshift > 0 ? g << pal_gshift : g >> -pal_gshift) & pal_gmask) |
- ((pal_bshift > 0 ? b << pal_bshift : b >> -pal_bshift) & pal_bmask));
- }
- }
- }
- int size = nf_width * nf_height << 1;
-
- nf_buf_cur = (uint8_t *)malloc(size);
- nf_buf_prv = (uint8_t *)malloc(size);
- }
-
- nf_new_line = nf_width * fqty - SWIDTH;
- nf_hicolor = hicolor;
- if (hicolor) {
- nf_width <<= 1;
- nf_new_line <<= 1;
- }
-
- nf_new_row0 = fqty * SHEIGHT * nf_width;
- nf_back_right = fqty * (SHEIGHT - 1) * nf_width;
- size = nf_width * nf_height;
-
- nfPkConfig();
-
- return true;
-}
-
-static void nfRelease(void) {
- free(nf_buf_cur);
- free(nf_buf_prv);
- nf_buf_cur = NULL;
- nf_buf_prv = NULL;
-}
-
-static void nfAdvance(void) {
- uint8_t *tmp = nf_buf_prv;
- nf_buf_prv = nf_buf_cur;
- nf_buf_cur = tmp;
-}
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-//
-void nfHiColorDecomp(const uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-//
-void nfHiColorDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h);
-
-// Non-HiColor versions
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-//
-void nfDecomp(const uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-//
-void nfDecompChg(const uint16_t *chgs, const uint16_t *parms, const uint8_t *comp, unsigned x,
- unsigned y, unsigned w, unsigned h);
-
-//---------------------------------------------------------------------
-// ShowFrame
-//------------
-
-// TODO:
-// Support for software cursor.
-// Issues & Considerations:
-// 1. Current code only deals with writing to screen, not reading it.
-// 2. To prevent flicker, cursor should be drawn into current buffer
-// before it is sent to screen, first saving area overwritten.
-// After current before is sent to screen, the area modified
-// by the cursor in the current buffer should be restored.
-// 3. Screen must also be updated in outside areas if cursor
-// appears there. This requires read/modify/write to screen,
-// because current buffer may not exist or be valid for area
-// of screen. Also, contents of screen must be saved so that
-// if next frame doesn't modify that area of screen, it can be
-// restored when mouse moves away.
-// In other words:
-// (a):
-// Save area on screen where mouse will go.
-// Draw mouse onto screen.
-// When mouse moves, restore previous contents of screen and
-// loop back to (a).
-// When screen is to be redrawn with video, draw mouse clipped
-// into buffer, saving previous contents. Draw video, then restore
-// buffer. Note that saving previous contents saves into same
-// area that was used when area under mouse was originally saved,
-// but it may only be a subrectangle.
-// Question: Should I implement VESA read from screen code?
-// Or work with caller to implement?
-// With caller:
-// Caller provides pointer to mouse image and save area buffers,
-// and screen location. Caller informs us when mouse changes
-// (position or contents). We deal with drawing mouse into internal
-// buffer and updating save area. Caller deals with drawing
-// mouse on screen and saving areas from screen. Color zero will
-// be assumed transparent. If old and new locations are within
-// area we are about to draw, caller need do nothing other than
-// call us (we can return a bool to let him know that). We can
-// call him to draw cursor just before showframe (whereas
-// call back from pausing would be just after showframe).
-// Without special support?
-// Everytime frame is shown, redraw mouse on screen, saving previous
-// contents. If mouse moves, restore previous contents and redraw.
-// Result will be a flickering mouse (mostly on, briefly off).
-
-static mve_cb_ShowFrame sf_ShowFrame = NULL;
-
-static unsigned sf_ResolutionHeight = 0; // Height of screen
-static unsigned sf_ResolutionWidth = 0; // Width of screen
-unsigned sf_ScreenHeight = 0; // Height of modifiable screen
-unsigned sf_ScreenWidth = 0; // Width of modifiable screen
-// Private, see mveliba.asm :
-unsigned sf_LineWidth = 0; // Distance between lines in memory
-static unsigned sf_hicolor = 0; // Hicolor mode (0:none,1:normal,2:swapped)
-
-// Banked screen parameters, Private, see mveliba.asm
-void *sf_SetBank = NULL;
-unsigned sf_WinGran = 0;
-uint32_t sf_WinSize = 0;
-unsigned sf_WinGranPerSize = 0;
-//{sf_WriteWinPtr and sf_WriteWinLimit replace sf_WriteWinSeg, see mveliba.asm}
-uint8_t *sf_WriteWinPtr = NULL;
-uint8_t *sf_WriteWinLimit = NULL;
-unsigned sf_WriteWin = 0;
-
-//
-static bool sf_auto = true; // True if mode can be set from movie
- // (mode not specified by caller).
-static int sf_auto_mode = 0; // Current sf_auto mode.
-
-static void sfVGA(unsigned w, unsigned h, unsigned resw, unsigned resh);
-static void sfShowFrame(int dx, int dy, unsigned field);
-
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-
-// Restrictions/Assumptions:
-// 64K >= WinSize >= WinGran
-// WinSize % WinGran == 0
-// WinGran of 64K is represented by 0
-// SetBank is address of function with following protocol:
-// bh: 0=Set window, 1=Get Window
-// bl: Window number (0 or 1)
-// dx: Window position in video memory in units of WinGran.
-// on return, registers AX and DX are destroyed.
-void MVE_sfSVGA(unsigned w, unsigned h, unsigned LineWidth, unsigned WriteWin, uint8_t *WriteWinPtr,
- uint32_t WinSize, unsigned WinGran, void *SetBank, unsigned hicolor) {
- sf_ScreenWidth = w;
- sf_ScreenHeight = h;
- sf_ResolutionWidth = w;
- sf_ResolutionHeight = h;
- sf_LineWidth = LineWidth;
- if (opt_fastmode & 4) {
- sf_LineWidth <<= 1;
- }
- sf_WriteWin = WriteWin;
- sf_WinSize = WinSize;
- sf_WriteWinPtr = WriteWinPtr;
- sf_WriteWinLimit = sf_WriteWinPtr + sf_WinSize;
- sf_WinGran = WinGran;
- sf_SetBank = SetBank;
- if (WinGran) {
- // Assumes WinGran divides evenly into WinSize.
- sf_WinGranPerSize = (unsigned)WinSize / WinGran;
- } else {
- // Assumes WinSize is also 64K.
- sf_WinGranPerSize = 1;
- }
- sf_auto = false;
- sf_hicolor = hicolor;
-}
-
-// QUESTION: Should sfShowFrame also take x,y,w,h as command args?
-// The issue is, will it always be true that area to update on
-// screen matches area updated in memory, since previous contents
-// of memory will be from two frames back, not one!
-// Answer: By having compressor compare previous screen to desired screen,
-// areas that are identical can be located. Only areas that change
-// need to be built in memory. Remaining areas will not be correct,
-// but can still be used for source data for next screen.
-// Therefore, additional x,y,w,h args are not needed.
-// However, should this prove to be wrong, a minor opcode variant
-// can always be added which supplies the additional arguments.
-static void sfShowFrame(int dx, int dy, unsigned field) {
- unsigned scaled_width = nf_width * 4 / opt_hscale_step;
- scaled_width = ((scaled_width - 12) & ~0xf) + 12; // Round down to a multiple of 16 + 12.
- opt_hscale_adj = nf_width - (scaled_width / 4 * opt_hscale_step);
-
- logLabel("StartShow");
- if (dx < 0) {
- if (nf_hicolor) {
- dx = (sf_ScreenWidth - (scaled_width >> 1)) >> 1;
- } else {
- dx = (sf_ScreenWidth - scaled_width) >> 1;
- }
- }
-
- if (nf_hicolor) {
- dx <<= 1;
- }
-
- if (dy < 0) {
- if (opt_fastmode & 4) // HACK
- {
- dy = (sf_ScreenHeight - nf_height * 2) >> 1;
- } else {
- dy = (sf_ScreenHeight - nf_height) >> 1;
- }
- }
-
- dx &= ~3; // Force to a multiple of 4 boundary for performance!
-
- if (opt_fastmode & 4) // HACK
- {
- dy >>= 1;
- }
-
- if (field) {
- mve_ShowFrameField(nf_buf_cur, nf_width, nf_height, nf_new_x, nf_new_y, nf_new_w, nf_new_h, dx, dy, field);
- } else {
- if (opt_hscale_step != 4) {
- sf_ShowFrame(nf_buf_cur, nf_width, nf_height, 0, nf_new_y, scaled_width, nf_new_h, dx, dy, nf_hicolor);
- } else {
- sf_ShowFrame(nf_buf_cur, nf_width, nf_height, nf_new_x, nf_new_y, nf_new_w, nf_new_h, dx, dy, nf_hicolor);
- }
- }
-
- logLabel("EndShow");
-}
-
-void MVE_sfCallbacks(mve_cb_ShowFrame fn_ShowFrame) { sf_ShowFrame = fn_ShowFrame; }
-
-// Restriction: w must be a multiple of 4.
-// Strong Recommendation: sx and dstx should be multiples of 4.
-// dstx & dsty are deltas relative to sx & sy.
-// Field is a hack and should be removed. Instead, nfConfig
-// should specify interlace mode and cause linestep to be twice
-// sf_LineWidth. dstx/dsty should be made absolute to allow interlace
-// field to be determined by dst.
-// ON THE OTHER HAND -- All this makes user clipping quite complex...
-// A caller would probably like to deal in ordinary coordinates,
-// but then we still need 'field'.
-// Also note that when field is on, the actual height of the image
-// on the screen is 2*h alternate lines.
-//
-
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-
-static void sfShowFrameChg(int dx, int dy, uint16_t *chgs) { logLabel("StartShowChg"); }
-
-//---------------------------------------------------------------------
-// Palette Management
-//---------------------
-
-static void (*pal_SetPalette)(uint8_t *p, unsigned start, unsigned count) = MVE_SetPalette;
-
-uint8_t pal_tbl[3 * 256]; // Private, see mveliba.asm
-#if DBL_DBG
-uint8_t pal_tbl_old[3 * 256];
-#endif
-uint16_t pal15_tbl[256]; // Private, see mveliba.asm
-
-void MVE_palCallbacks(void (*fn_SetPalette)(uint8_t *p, unsigned start, unsigned count)) {
- pal_SetPalette = fn_SetPalette;
-}
-
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-
-static void palSetPalette(unsigned start, unsigned count) {
- if (!nf_hicolor) {
- (*pal_SetPalette)((uint8_t *)pal_tbl, start, count);
- }
-}
-
-static void palClrPalette(unsigned start, unsigned count) {
- static uint8_t clr_pal_tbl[256 * 3];
- if (!nf_hicolor) {
- (*pal_SetPalette)((uint8_t *)clr_pal_tbl, start, count);
- }
-}
-
-// Old Synth: 0,21,6
-// 128,32,4
-//
-// New Synth: 129,21,6
-// 17,28,4
-//
-static void palMakeSynthPalette(int base_r, int range_r, int range_rb, int base_g, int range_g, int range_gb) {
- uint8_t(*SynthPal)[3] = (uint8_t(*)[3])pal_tbl;
- int i, j;
-
- for (i = 0; i < range_r; ++i) {
- for (j = 0; j < range_rb; ++j) {
- int idx = base_r + i * range_rb + j;
- SynthPal[idx][0] = (char)(i * 63 / (range_r - 1));
- SynthPal[idx][1] = 0;
- SynthPal[idx][2] = (char)((j * 63 / (range_rb - 1)) * 5 / 8);
- }
- }
-
- for (i = 0; i < range_g; ++i) {
- for (j = 0; j < range_gb; ++j) {
- int idx = base_g + i * range_gb + j;
- SynthPal[idx][0] = 0;
- SynthPal[idx][1] = (char)(i * 63 / (range_g - 1));
- SynthPal[idx][2] = (char)((j * 63 / (range_gb - 1)) * 5 / 8);
- }
- }
-}
-
-static void palLoadPalette(uint8_t *buf, unsigned start, unsigned count) {
-#if DBL_DBG
- memcpy(pal_tbl_old, pal_tbl, 256 * 3);
-#endif
- memcpy(&pal_tbl[start * 3], buf, count * 3);
-}
-
-// If at least 11 palette entries aren't changed, this is more compact
-// than uncompressed 256 entry palette.
-//
-void palLoadCompPalette(uint8_t *buf);
-
-//-----------------------------------------------------------------------
-// Graphics
-//----------
-
-void gfxVres(uint8_t misc, uint8_t *crtc);
-
-static void ForceVres2(uint8_t misc, unsigned vt, unsigned height, unsigned vrs /*vpos*/, unsigned _2t4,
- unsigned msl, unsigned bdr_b, unsigned bdr_t) {}
-
-void MVE_ForceVres350(void) {}
-
-void MVE_ForceVresHalf(void) {}
-
-// If auto is set, and this function is being called to change mode
-// for movie, be sure to turn auto back on after call!
-//
-bool MVE_gfxMode(int16_t mode) { return false; }
-
-// Restore a text mode
-void MVE_gfxReset(void) {
- sf_auto = true;
- sf_auto_mode = 0;
-}
-
-//----------------------------------------------------------------------
-// Movie Interpreter
-//--------------------
-
-static int (*rm_ctl)(void);
-
-static int rm_dx = 0;
-static int rm_dy = 0;
-static unsigned rm_track_bit = 0;
-static uint8_t *rm_p = NULL;
-static unsigned rm_len = 0;
-static bool rm_hold = false;
-static bool rm_active = false;
-static unsigned rm_FrameCount = 0;
-static unsigned rm_FrameDropCount = 0;
-
-void MVE_rmCallbacks(int (*fn_ctl)(void)) { rm_ctl = fn_ctl; }
-
-void MVE_rmFastMode(int mode) { opt_fastmode = mode; }
-
-void MVE_rmHScale(int hscale) {
- if (hscale == 3)
- opt_hscale_step = 3;
- else
- opt_hscale_step = 4;
-}
-
-void MVE_rmFrameCounts(unsigned *FrameCount, unsigned *FrameDropCount) {
- *FrameCount = rm_FrameCount;
- *FrameDropCount = rm_FrameDropCount;
-}
-
-int MVE_rmPrepMovie(int hFile, int dx, int dy, unsigned track) {
- rm_dx = dx;
- rm_dy = dy;
-
- rm_track_bit = 1 << track;
- if (!rm_track_bit)
- rm_track_bit = 1;
-
- if (!ioReset(hFile)) {
- MVE_rmEndMovie();
- return MVE_ERR_BADFMT;
- }
-
- rm_p = ioNextRecord();
- rm_len = 0;
- if (!rm_p) {
- MVE_rmEndMovie();
- return MVE_ERR_IO;
- }
-
- rm_active = true;
- rm_hold = false;
- rm_FrameCount = 0;
- rm_FrameDropCount = 0;
- return 0;
-}
-
-int MVE_rmHoldMovie(void) {
- if (!rm_hold) {
- sndPause();
- rm_hold = true;
- }
- syncWait();
- return 0;
-}
-
-int dbgcount = 0;
-int MVE_rmStepMovie(void) {
- unsigned len = rm_len;
- uint8_t *p = rm_p;
-
- int result;
-
- if (!rm_active)
- return MVE_ERR_PREP;
-
- if (rm_hold) {
- sndResume();
- rm_hold = false;
- }
-
- for (;; p = ioNextRecord(), len = 0) {
- uint16_t *DecompChg_chgs = (uint16_t *)NULL;
- uint16_t *DecompChg_parms = (uint16_t *)NULL;
-
- if (!p) {
- result = MVE_ERR_IO;
- goto done;
- }
-
- for (;;) {
- mcmd_hdr hdr;
- p += len; // Advance past data of previous command
- hdr = *(mcmd_hdr *)p;
- hdr.SwapBytes();
- p += sizeof(hdr);
- len = hdr.len;
- /*
- FILE *logf = fopen("mve.log","a");
- if(logf)
- {
- fprintf(logf,"hdr len=%d,major=%d,minor=%d\n",hdr.len,hdr.major,hdr.minor);
- fclose(logf);
- }
-
- if(hdr.len==14896 &&
- hdr.major==17 &&
- hdr.minor==3)
- {
- dbgcount++;
- if(dbgcount >= 3)
- {
- printf("***");
- }
-
- }
- */
- switch (hdr.major) {
- default:
- continue;
-
- case mcmd_end:
- result = MVE_ERR_EOF;
- goto movie_eof;
- case mcmd_next:
- break;
- case mcmd_syncInit: {
- marg_syncInit *arg = (marg_syncInit *)p;
- arg->SwapBytes();
- if (!syncInit(arg->period, arg->wait_quanta)) {
- result = MVE_ERR_SYNC;
- goto done;
- }
- continue;
- }
-
- case mcmd_sndConfigure: {
- marg_sndConfigure *arg = (marg_sndConfigure *)p;
- arg->SwapBytes();
- unsigned comp16 = hdr.minor >= 1 ? arg->comp16 : 0;
- unsigned buflen = arg->buflen;
- if (hdr.minor == 0)
- buflen &= 0xFFFF;
- if (!sndConfigure(arg->rate, buflen, arg->stereo, arg->frequency, arg->bits16, comp16)) {
- result = MVE_ERR_SND;
- goto done;
- }
- continue;
- }
-
- case mcmd_sndSync: {
- sndSync();
- continue;
- }
-
- case mcmd_nfConfig: {
- marg_nfConfig *arg = (marg_nfConfig *)p;
- arg->SwapBytes();
- unsigned hicolor = hdr.minor >= 2 ? arg->hicolor : 0;
- if (!nfConfig(arg->wqty, arg->hqty, (hdr.minor >= 1 ? arg->fqty : 1), hicolor)) {
- result = MVE_ERR_NF;
- goto done;
- }
- // To handle interlace mode, we need the following:
- // A window width/height in addition to nf_width/height.
- // Window width/height should be used here and in centering
- // code in sfShowFrame.
- {
- unsigned scaled_width = nf_width * 4 / opt_hscale_step;
- scaled_width &= ~0xf; // Round down to a multiple of 16.
- if (nf_hicolor)
- scaled_width >>= 1; /*HACK*/
- if (scaled_width + (rm_dx < 0 ? 0 : rm_dx) > sf_ScreenWidth ||
- nf_height + (rm_dy < 0 ? 0 : rm_dy) > sf_ScreenHeight) {
- result = MVE_ERR_GFX_FIT;
- goto done;
- }
- }
- // NOTE: Eventually, change this to allow sf_hicolor when !nf_hicolor and
- // have show function convert from 256-color to hicolor format.
- // HiColor will also need to disable hardware palette changes and
- // maintain 15-bit software palette along with 24-bit palette.
- if (nf_hicolor && !sf_hicolor) {
- result = MVE_ERR_GFX_FIT;
- goto done;
- }
- continue;
- }
-
- case mcmd_nfDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->SwapBytes();
- if (arg->advance) {
- nfAdvance();
- }
-
- nfDecomp(MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- continue;
- }
-
- case mcmd_sfShowFrame: {
- unsigned field = 0;
- marg_sfShowFrame *arg = (marg_sfShowFrame *)p;
- arg->SwapBytes();
-
- ++rm_FrameCount;
-
- if (hdr.minor >= 1) {
- field = arg->field;
- }
-
- if (arg->pal_count && !DecompChg_chgs && !sf_hicolor) {
- palClrPalette(arg->pal_start, arg->pal_count);
- } else {
- palSetPalette(arg->pal_start, arg->pal_count);
- }
-
- if (DecompChg_chgs) {
- sfShowFrameChg(rm_dx, rm_dy, DecompChg_chgs);
- } else {
- if (sync_late && arg->pal_count == 0) {
- sync_FrameDropped = true;
- ++rm_FrameDropCount;
- } else {
- sfShowFrame(rm_dx, rm_dy, field);
- }
- }
-
- if (arg->pal_count && !DecompChg_chgs && !sf_hicolor) {
- palSetPalette(arg->pal_start, arg->pal_count);
- }
-
- goto FrameDone;
- }
-
- case mcmd_sndAdd:
- case mcmd_sndSilence: {
- marg_sndAdd *arg = (marg_sndAdd *)p;
- arg->SwapBytes();
- if (arg->TrackMask & rm_track_bit)
- sndAdd((hdr.major == mcmd_sndAdd ? MCMD_DATA(arg) : (uint8_t *)NULL), arg->qty);
- continue;
- }
-
- case mcmd_gfxMode: {
- marg_gfxMode *arg = (marg_gfxMode *)p;
- arg->SwapBytes();
- if (sf_auto) {
- int16_t mode = arg->mode;
- if (opt_fastmode && (opt_fastmode & 4) == 0)
- mode |= 0x8000;
- if (sf_auto_mode != mode)
- if (!MVE_gfxMode(mode)) {
- result = MVE_ERR_GFX_FAIL;
- goto done;
- }
- sf_auto = true;
- sf_auto_mode = mode;
- }
- continue;
- }
-
- case mcmd_palMakeSynthPalette: {
- marg_palMakeSynthPalette *arg = (marg_palMakeSynthPalette *)p;
- arg->SwapBytes();
- palMakeSynthPalette(arg->base_r, arg->range_r, arg->range_rb, arg->base_g, arg->range_g, arg->range_gb);
- continue;
- }
-
- case mcmd_palLoadPalette: {
- marg_palLoadPalette *arg = (marg_palLoadPalette *)p;
- arg->SwapBytes();
- palLoadPalette(MCMD_DATA(arg), arg->start, arg->count);
- continue;
- }
-
- case mcmd_palLoadCompPalette: {
- palLoadCompPalette(p);
- continue;
- }
-
- case mcmd_nfChanges: {
- DecompChg_chgs = (uint16_t *)p;
- continue;
- }
- case mcmd_nfParms: {
- DecompChg_parms = (uint16_t *)p;
- continue;
- }
- case mcmd_nfDecompChg: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->SwapBytes();
- if (arg->advance) {
- nfAdvance();
- }
-
- nfDecompChg(DecompChg_chgs, DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- continue;
- }
- case mcmd_nfPkDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->SwapBytes();
- if (hdr.minor < 3) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
-
- if (arg->advance) {
- nfAdvance();
- }
-
- if (nf_hicolor) {
- if (opt_fastmode) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
-
- nfHPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- } else if ((opt_fastmode & 3) == 1) {
- // Half mode (half height, even lines only)
- nfPkDecompH((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- } else if ((opt_fastmode & 3) == 2) {
- // Support for dithered mode disabled...
- // so just use half mode instead
- nfPkDecompH((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- } else // opt_fastmode==0
- {
- // Normal mode
- nfPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- }
- continue;
- }
- }
- break;
- }
- }
-done: // Error
- MVE_rmEndMovie();
-
-movie_eof: // End of movie
- return result;
-
-FrameDone: // Done with frame, return to caller for between frame processing
- rm_p = p;
- rm_len = len;
- return 0;
-}
-
-void MVE_rmEndMovie(void) {
- if (rm_active) {
- syncWait();
- syncRelease();
- sndReset();
- rm_active = false;
- }
-}
-
-int MVE_RunMovie(int hFile, int dx, int dy, unsigned track) {
- int result;
- result = MVE_rmPrepMovie(hFile, dx, dy, track);
- while (!result) {
- result = MVE_rmStepMovie();
- logLabel("StartUser");
- while (!result) {
- result = (*rm_ctl)();
- if (result != MVE_CTL_HOLD)
- break;
- result = MVE_rmHoldMovie();
- }
- logLabel("EndUser");
- }
- MVE_rmEndMovie();
- return (result == MVE_ERR_EOF) ? 0 : result;
-}
-
-int MVE_RunMovieContinue(int hFile, int dx, int dy, unsigned track) {
- int result;
- result = MVE_rmPrepMovie(hFile, dx, dy, track);
- while (!result) {
- result = MVE_rmStepMovie();
- logLabel("StartUser");
- while (!result) {
- result = (*rm_ctl)();
- if (result != MVE_CTL_HOLD)
- break;
- result = MVE_rmHoldMovie();
- }
- logLabel("EndUser");
- }
- // Continue version doesn't call MVE_rmEndMovie;
- return (result == MVE_ERR_EOF) ? 0 : result;
-}
-
-void MVE_ReleaseMem(void) {
- MVE_rmEndMovie();
- ioRelease();
- sndRelease();
- nfRelease();
-}
-
-//----------------------------------------------------------------------
-
-const char *MVE_strerror(int code) {
- const char *errors[] = {
- "Movie aborted with special code",
- "Movie aborted",
- "Movie completed normally", // 0
- "Movie completed normally", //-1
- "File I/O error or Unable to allocate I/O buffers",
- "Unable to create timer",
- "Unable to allocate sound buffers",
- "Unable to allocate video buffers",
- "Insufficient screen resolution for movie",
- "Unable to setup graphics mode used by movie",
- "Invalid movie file",
- "Incorrect screen color mode",
- "StepMovie() without PrepMovie()",
- "Unable to initialize Linux Draw System",
- "Unable to lock window surface",
- "Unknown movie error code"
- };
-
- if (code >= MVE_CTL_EXIT + 1)
- code = MVE_CTL_EXIT + 1;
- if (code <= MVE_ERR_LAST - 1)
- code = MVE_ERR_LAST - 1;
- return errors[MVE_CTL_EXIT + 1 - code];
-}
-
-//----------------------------------------------------------------------
-// Frame Reader
-//--------------
-
-struct MVE_frStreamRec {
- int (*callback)(unsigned op, unsigned subop, void *buf);
-
- // I/O Stream state
- unsigned (*io_read)(int handle, void *buf, unsigned count);
- MemRec io_mem_buf;
- int io_handle;
- ioHdrRec io_next_hdr;
- uint8_t *p;
- unsigned len;
-
- // NextFrame working storage
- bool nf_memory_mode;
-
- MemRec nf_mem_buf1;
- MemRec nf_mem_buf2;
- uint8_t *nf_buf_cur;
- uint8_t *nf_buf_prv;
- // NextFrame parameters
- uint8_t nf_wqty; // (width/SWIDTH)
- uint8_t nf_hqty; // (height/SHEIGHT)
- uint8_t nf_fqty; // Number of fields
- unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
- // NextFrame derived quantities
- unsigned nf_width; // wqty * SWIDTH
- unsigned nf_height; // hqty * SHEIGHT;
- unsigned nf_new_line; // width - SWIDTH
- unsigned nf_new_row0; // SHEIGHT*width*2-width
- unsigned nf_back_right; // (SHEIGHT-1)*width
- // Palette
- uint8_t pal_tbl[3 * 256];
- unsigned pal_start, pal_count;
-
-};
-
-static void frLoad(MVE_frStream frs) {
- io_read = frs->io_read;
- io_mem_buf = frs->io_mem_buf;
- io_handle = frs->io_handle;
- io_next_hdr = frs->io_next_hdr;
-
- nf_memory_mode = frs->nf_memory_mode;
- nf_mem_buf1 = frs->nf_mem_buf1;
- nf_mem_buf2 = frs->nf_mem_buf2;
- nf_buf_cur = frs->nf_buf_cur;
- nf_buf_prv = frs->nf_buf_prv;
- nf_wqty = frs->nf_wqty;
- nf_hqty = frs->nf_hqty;
- nf_fqty = frs->nf_fqty;
- nf_hicolor = frs->nf_hicolor;
- nf_width = frs->nf_width;
- nf_height = frs->nf_height;
- nf_new_line = frs->nf_new_line;
- nf_new_row0 = frs->nf_new_row0;
- nf_back_right = frs->nf_back_right;
-}
-
-static void frSave(MVE_frStream frs) {
- frs->io_read = io_read;
- frs->io_mem_buf = io_mem_buf;
- frs->io_handle = io_handle;
- frs->io_next_hdr = io_next_hdr;
-
- frs->nf_memory_mode = nf_memory_mode;
- frs->nf_mem_buf1 = nf_mem_buf1;
- frs->nf_mem_buf2 = nf_mem_buf2;
- frs->nf_buf_cur = nf_buf_cur;
- frs->nf_buf_prv = nf_buf_prv;
- frs->nf_wqty = nf_wqty;
- frs->nf_hqty = nf_hqty;
- frs->nf_fqty = nf_fqty;
- frs->nf_hicolor = nf_hicolor;
- frs->nf_width = nf_width;
- frs->nf_height = nf_height;
- frs->nf_new_line = nf_new_line;
- frs->nf_new_row0 = nf_new_row0;
- frs->nf_back_right = nf_back_right;
-}
-
-MVE_frStream MVE_frOpen(unsigned (*fn_read)(int handle, void *buf, unsigned count), int handle,
- int (*fr_callback)(unsigned, unsigned, void *buf)) {
- MVE_frStream frs;
- MVE_frStreamRec save;
- bool failed = false;
-
- if (!mem_alloc)
- return (MVE_frStream)NULL;
-
- frs = (struct MVE_frStreamRec *)(*mem_alloc)(sizeof(*frs));
- if (!frs)
- return frs;
- memset(frs, 0, sizeof(*frs));
-
- frSave(&save);
- frLoad(frs);
-
- MVE_ioCallbacks(fn_read);
- failed = !ioReset(handle);
- frs->callback = fr_callback;
-
- if (!failed) {
- frs->p = ioNextRecord();
- frs->len = 0;
- }
-
- frSave(frs);
- frLoad(&save);
-
- if (failed) {
- MVE_frClose(frs);
- return (MVE_frStream)NULL;
- }
-
- return frs;
-}
-
-int MVE_frGet(MVE_frStream frs, uint8_t **pBuf, uint32_t *width, uint32_t *height,
- uint32_t *hicolor) {
- MVE_frStreamRec save;
- uint8_t *p;
- unsigned len;
- int result = 0;
-
- frSave(&save);
- frLoad(frs);
- p = frs->p;
- len = frs->len;
-
- for (;; p = ioNextRecord(), len = 0) {
- uint16_t *DecompChg_parms = (uint16_t *)NULL;
-
- if (!p) {
- result = MVE_ERR_IO;
- goto done;
- }
- for (;;) {
- mcmd_hdr hdr;
- p += len; // Advance past data of previous command
- hdr = *(mcmd_hdr *)p;
- hdr.SwapBytes();
- p += sizeof(hdr);
- len = hdr.len;
- switch (hdr.major) {
- default:
- if (frs->callback) {
- result = (*frs->callback)(hdr.major, hdr.minor, p);
- if (result)
- goto done;
- }
- continue;
-
- case mcmd_end:
- result = MVE_ERR_EOF;
- goto done;
-
- case mcmd_next:
- break;
-
- case mcmd_nfConfig: {
- marg_nfConfig *arg = (marg_nfConfig *)p;
- arg->SwapBytes();
- unsigned hicolor = hdr.minor >= 2 ? arg->hicolor : 0;
- unsigned opt_fastmode_save = opt_fastmode;
- opt_fastmode = 0;
- if (hicolor || (hdr.minor >= 1 && arg->fqty != 1) ||
- !nfConfig(arg->wqty, arg->hqty, (hdr.minor >= 1) ? arg->fqty : 1, hicolor)) {
- opt_fastmode = opt_fastmode_save;
- result = MVE_ERR_NF;
- goto done;
- }
- opt_fastmode = opt_fastmode_save;
- continue;
- }
-
- case mcmd_sfShowFrame: {
- unsigned field = 0;
- marg_sfShowFrame *arg = (marg_sfShowFrame *)p;
- arg->SwapBytes();
- if (hdr.minor >= 1)
- field = arg->field;
- if (field) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- *pBuf = nf_buf_cur;
- *width = nf_width;
- *height = nf_height;
- *hicolor = nf_hicolor;
- frs->pal_start = arg->pal_start;
- frs->pal_count = arg->pal_count;
- goto done;
- }
-
- case mcmd_nfParms: {
- DecompChg_parms = (uint16_t *)p;
- continue;
- }
-
- case mcmd_nfPkDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->SwapBytes();
- if (hdr.minor < 3) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- if (arg->advance) {
- nfAdvance();
- }
- if (nf_hicolor) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- nfPkConfig();
- nfPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- continue;
- }
- case mcmd_palLoadPalette: {
- marg_palLoadPalette *arg = (marg_palLoadPalette *)p;
- arg->SwapBytes();
- memcpy(&frs->pal_tbl[arg->start * 3], MCMD_DATA(arg), arg->count * 3);
- continue;
- }
- }
- break;
- }
- }
-
-done:
- frSave(frs);
- frs->p = p;
- frs->len = len;
- frLoad(&save);
- nfPkConfig();
- if (result)
- frs->pal_start = frs->pal_count = 0;
- return result;
-}
-
-void MVE_frPal(MVE_frStream frs, uint8_t **p, unsigned *start, unsigned *count) {
- *p = frs->pal_tbl;
- *start = frs->pal_start;
- *count = frs->pal_count;
-}
-
-void MVE_frClose(MVE_frStream frs) {
- MVE_frStreamRec save;
-
- frSave(&save);
- frLoad(frs);
-
- ioRelease();
- nfRelease();
-
- frLoad(&save);
- if (mem_free) {
- (*mem_free)(frs);
- }
-}
diff --git a/libmve/mvelibl.h b/libmve/mvelibl.h
deleted file mode 100644
index 0540ef4d..00000000
--- a/libmve/mvelibl.h
+++ /dev/null
@@ -1,277 +0,0 @@
-
-/*
-** mvelibl.h
-**
-** Interplay Movie File (MVE) Player
-** Library Definitions (32-Bit Linux Version)
-** Written by Paul Allen Edelstein, Interplay Productions.
-** Partial Linux port by Jeff Slutter, Outrage Entertainment.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-*/
-#ifndef MVELIB_H_INCLUDED
-#define MVELIB_H_INCLUDED
-
-#include
-
-#include "SystemInterfaces.h"
-#include "lnxdsound.h"
-
-// Call this function to provide hooks into your memory management.
-typedef void *(mve_cb_alloc)(unsigned size);
-typedef void(mve_cb_free)(void *p);
-void MVE_memCallbacks(mve_cb_alloc *fn_alloc, mve_cb_free *fn_free);
-
-// This function remains from the DOS version of mvelib.
-// It allows you to provide a preallocated buffer for file I/O,
-// but under Windows there's no real point to doing this.
-void MVE_memIO(void *p, unsigned size);
-
-// Call this function to provide hook into your file io.
-typedef unsigned mve_cb_read(int handle, void *buf, unsigned count);
-void MVE_ioCallbacks(mve_cb_read *fn_read);
-
-// Call this function to provide hook into your digital sound driver.
-// Call with NULL if no sound support is available (default).
-void MVE_sndInit(ISoundDevice *lpDS);
-
-// Volume controls.
-// These functions are equivalent to the IDirectSoundBuffer
-// SetVolume and SetPan functions. They take effect immediately
-// and do NOT reset when a new movie starts.
-// Volume ranges from 0 (0 db, no volume change) to -10,000 (-100db, essentially silent).
-// Pan ranges from -10,000 (left full volume, right -100db), thru 0 (both full),
-// thru 10,000 (left -100db, right full volume).
-// The default value for volume and pan is zero.
-void MVE_dsbSetVolume(int32_t lVolume);
-void MVE_dsbSetPan(int32_t lPan);
-
-// Only call this function to configure software to work with a Super VGA
-// mode if you do not have VESA support.
-// Restrictions/Assumptions:
-// 64K >= WinSize >= WinGran
-// WinSize % WinGran == 0
-// WinGran of 64K is represented by 0
-// SetBank is address of function with following protocol:
-// bh: 0=Set window, 1=Get Window
-// bl: Window number (0 or 1)
-// dx: Window position in video memory in units of WinGran.
-// on return, registers AX and DX are destroyed.
-//
-// Hicolor is 0 for 8-bit color, 1 for 15-bit rgb color, 2
-// for byte swapped 15-bit rgb color.
-//
-// Note: 16-bit WriteWinSeg replaced with 32-bit WriteWinPtr
-//
-// The functionality of the following function is reduced in the Windows
-// version of the player. Call it as follows:
-// MVE_sfSVGA(w,h,w,0,NULL,0,0,NULL,hicolor)
-// where w and h are the width and height of your window,
-// and hicolor is a boolean which indicates if the screen
-// is operating in hi color, rather than 8-bit paletted color.
-// Under windows, the information provided by this function
-// is just used for window centering and for determining
-// how and when to do palette callbacks.
-void MVE_sfSVGA(unsigned w, unsigned h, unsigned LineWidth, unsigned WriteWin, uint8_t *WriteWinPtr,
- uint32_t WinSize, unsigned WinGran, void *SetBank, unsigned hicolor);
-
-// This function alters the display from 640x480 or 640x400 to 640x350 resolution.
-void MVE_ForceVres350(void);
-
-// This function alters the display from 640x480/400/350 to 640x240/200/175.
-void MVE_ForceVresHalf(void);
-
-// **NOTE** There still need to be calls to restore original screen resolution
-// after using MVE_ForceVres350() or MVE_ForceVresHalf()!
-// Only call this function to either
-// 1. Replace method of copying frame to screen (perhaps for a nonstandard
-// screen format).
-// 2. Wrap your own code around the transfer of frame to screen
-// or modify which portions of the screen are updated.
-// This function replaces calls to the default MVE_ShowFrame function
-// with calls to your function, which can itself call MVE_ShowFrame.
-typedef void (*mve_cb_ShowFrame)(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t sx,
- uint32_t sy, uint32_t w, uint32_t h, uint32_t dstx, uint32_t dsty,
- uint32_t hicolor);
-void MVE_sfCallbacks(mve_cb_ShowFrame fn_ShowFrame);
-
-typedef void mve_cb_SetPalette(uint8_t *p, unsigned start, unsigned count);
-void MVE_palCallbacks(mve_cb_SetPalette *fn_SetPalette);
-
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-
-// Configure the software for a graphics mode, optionally setting the
-// display to that mode (see the MVE_GFX_xxx constants defined below).
-bool MVE_gfxMode(int16_t mode);
-
-// Reset the screen to text mode (usually done before exiting a program).
-void MVE_gfxReset(void);
-
-// Set line for split screen graphics
-// {Use vbe_SetDisplayStart(x,y) to set vid buf for upper screen}
-void MVE_gfxSetSplit(unsigned line);
-
-// Setup double buffering
-void MVE_gfxSetDoubleBuffer(unsigned y1, unsigned y2, unsigned vis);
-
-// Get double buffering state
-void MVE_gfxGetDoubleBuffer(unsigned *vis_y, unsigned *hid_y);
-
-// Enable double buffering for auto screen modes
-void MVE_sfAutoDoubleBuffer(unsigned on);
-
-// Wait for video retrace off (0) or on (1)
-void MVE_gfxWaitRetrace(unsigned state);
-
-//---------------------------------------------
-// Establish callback for user control of movie playback.
-typedef int mve_cb_ctl(void);
-void MVE_rmCallbacks(mve_cb_ctl *fn_ctl);
-
-// Specify playback fastmode option (default is MVE_RM_NORMAL).
-#define MVE_RM_NORMAL 0 // Normal playback
-#define MVE_RM_HALF 1 // Half height (even lines only)
-#define MVE_RM_DITHERED 2 // Half height (dither between lines)
-#define MVE_RM_HALF_2 5 // Full height, even lines only
-#define MVE_RM_DITHERED_2 6 // Full height, dither, even lines only
-
-void MVE_rmFastMode(int mode);
-
-// Specifying horizontal magnification:
-// 3: 4/3 horizontal magnification
-// 4: normal
-void MVE_rmHScale(int hscale);
-
-// Get frame count and number of dropped frames from last movie played.
-void MVE_rmFrameCounts(unsigned *FrameCount, unsigned *FrameDropCount);
-
-// Dump timing statistics (if enabled).
-void MVE_logDumpStats(void);
-
-// Run a compressed movie by reading data starting at the current
-// position in the file specified by handle hFile.
-// The movie window is displaced by dx,dy from the upper left hand corner
-// or is centered if dx,dy is -1,-1.
-// track specifies which audio track to play (usually 0 for a single
-// audio track).
-//
-// Returns an error/result code.
-//
-// Memory may be dynamically allocated while movie runs.
-int MVE_RunMovie(int hFile, int dx, int dy, unsigned track);
-
-// MVE_RunMovieContinue is the same as MVE_RunMovie except that it does not
-// automatically call MVE_rmEndMovie(). This may improve the smoothness
-// of immediately playing another movie afterwards.
-int MVE_RunMovieContinue(int hFile, int dx, int dy, unsigned track);
-
-// Alternative to using MVE_RunMovie() and MVE_rmCallbacks().
-// Call MVE_rmPrepMovie() to prepare movie for playing.
-// Call MVE_rmStepMovie() to display next frame of movie until nonzero
-// result is returned (MVE_ERR_EOF for no next frame or some other error).
-// Call MVE_rmHoldMovie() to hold on current frame (and pause audio).
-// Call MVE_rmEndMovie() to abort movie.
-// All functions except MVE_rmEndMovie() return an error code.
-int MVE_rmPrepMovie(int hFile, int dx, int dy, unsigned track);
-int MVE_rmStepMovie(void);
-int MVE_rmHoldMovie(void);
-void MVE_rmEndMovie(void);
-
-// Frame Reader Streams
-// This is a special interface to the movie system which
-// allows a movie file to be opened as a stream from which
-// its frames may be retrieved. Audio and timing information
-// are ignored. For 256-color screen applications, palette
-// information is also typically ignored, and movies with a common
-// predefined palette are used. However, for hi-color screen
-// applications, an interface to obtain palette information has
-// been provided. This system is intended for use by video sprites
-// played off of the hard drive or out of memory.
-typedef struct MVE_frStreamRec* MVE_frStream;
-
-// MVE_frOpen
-// Before calling this function, be sure to call MVE_memCallbacks()
-// and MVE_rmDirectDraw().
-// fn_read specifies a file reader similar to the one
-// used by MVE_ioCallbacks().
-// handle specifies a file handle for an already opened
-// movie file. It is used by the file reader and is similar
-// to hFile argument used by MVE_RunMovie() and MVE_rmPrepMovie().
-// fr_callback is normally NULL, but can be used to supply
-// a handler for user data which has been interleaved into
-// the movie stream.
-//
-// If the movie file is invalid or the call otherwise fails,
-// NULL is returned.
-MVE_frStream MVE_frOpen(unsigned (*fn_read)(int handle, void *buf, unsigned count), int handle,
- int (*fr_callback)(unsigned op, unsigned subop, void *buf));
-
-// MVE_frGet
-// Returns the next frame from the specified frame reader stream
-// a nonzero error code {the same codes as returned by MVE_RunMovie()
-// and MVE_rmStepMovie()}.
-// If successful, MVE_frGet(frs, &buf, &w, &h) returns a pointer
-// to a surface containing the frame in pBuf,
-// and its width and height in w and h.
-int MVE_frGet(MVE_frStream frs, uint8_t **pBuf, uint32_t *width, uint32_t *height, uint32_t *hicolor);
-
-// MVE_frPal
-// After each successful call to MVE_frGet(), this call may be used to
-// obtain corresponding palette information. It returns a pointer to the
-// entire current palette for the frame, and the subportion of the palette
-// which has changed this frame is identified by start and count (they will
-// both be zero on frames for which the palette has not changed).
-//
-// Paltbl points to 256*3 bytes of 6-bit r,g,b triples.
-// Start ranges from 0 to 255. Count from 0 to 256.
-//
-// These conventions are similar to those used by the palette callback arguments
-// with the standard player interface, except that this interface requires
-// polling each frame instead, and must be passed pointers to the variables where
-// the values will be returned.
-//
-void MVE_frPal(MVE_frStream frs, uint8_t **pPaltbl, unsigned *pStart, unsigned *pCount);
-
-// MVE_frClose
-// Closes the specified Frame Reader Stream frs.
-// Frees all storage associated with the stream.
-// The specified frs must not be used after this call.
-// Note that the open file handle specified in MVE_frOpen() is
-// not closed by this call...that is the caller's responsibility.
-void MVE_frClose(MVE_frStream frs);
-
-// Release any memory dynamically allocated by MVE_RunMovie.
-void MVE_ReleaseMem(void);
-
-// Return string corresponding to MVE_RunMovie result code.
-const char *MVE_strerror(int code);
-
-// RunMovie callback control code and result codes.
-// Codes > 1 are user defined.
-#define MVE_CTL_HOLD -1 // Returned by rmCtl() to hold current frame
-#define MVE_CTL_EXIT 1 // Returned by rmCtl() to end movie
-
-#define MVE_ERR_EOF -1 // Returned by StepMovie() for end of movie
-#define MVE_ERR_IO -2 // File I/O error or unable to alloc memory.
-#define MVE_ERR_SYNC -3 // Timer error.
-#define MVE_ERR_SND -4 // Unable to allocate memory for sound
-#define MVE_ERR_NF -5 // Unable to allocate memory for video
-#define MVE_ERR_GFX_FIT -6 // Screen size too small for movie
-#define MVE_ERR_GFX_FAIL -7 // Failed to set desired graphics mode
-#define MVE_ERR_BADFMT -8 // Not a MVE file or unacceptable version
-#define MVE_ERR_GFX_CLR -9 // Incorrect screen color mode
-#define MVE_ERR_PREP -10 // StepMovie() without PrepMovie()
-#define MVE_ERR_LD -11 // Unable to initialize Draw system (DirectDraw, etc)
-#define MVE_ERR_LOST -12 // Direct Draw Surface Lost
-
-#define MVE_ERR_LAST -12
-
-#endif
diff --git a/libmve/mvelibwa.asm b/libmve/mvelibwa.asm
deleted file mode 100644
index 10cdd9ba..00000000
--- a/libmve/mvelibwa.asm
+++ /dev/null
@@ -1,15054 +0,0 @@
-; mvelibwa.c
-;
-; Interplay Movie (MVE) File Player Library (32-Bit Win95 Version)
-; Assembly Language Components
-; Written by Paul Allen Edelstein
-;
-; (c) 1997 Interplay Productions. All Rights Reserved.
-; This file is confidential and consists of proprietary information
-; of Interplay Productions. This file and associated libraries
-; may not, in whole or in part, be disclosed to third parties,
-; incorporated into any software product which is not being created
-; for Interplay Productions, copied or duplicated in any form,
-; without the prior written permission of Interplay Productions.
-; Further, you may not reverse engineer, decompile or otherwise
-; attempt to derive source code of this material.
-;
-
-; .386
- .486 ; I only need .386, but I wanted the 486 cycle timings
-ifdef SYMANTEC
- .MODEL SMALL, C
-DGROUP group _TEXT, _DATA
-else
- .MODEL FLAT, C
-endif
-
-;;--- Options ---
-
-ONLYNEW equ 0 ; For debug, disables motion comp
-LOGGING equ 0 ; Log timing statistics
-PARTIAL equ 1 ; Support for partial updates
-PKDATA equ 1 ; Support for packed data
-HICOLOR equ 1 ; Support for HiColor
-INTERP equ 0 ; Interpolated squares
- ; 0:none (4x4x8), 1:generic dither,
- ; 2:direction dither, 3:blend
-COMPOPS equ 1 ; Compressed opcode table
-SCALING equ 1 ; Scaling support
-DECOMPD equ 0 ; Support for dithered half vert res
-TRANS16 equ 1 ; Support for translating 16-bit rgb format
-
-;;--- Types ---
-
-PTRBYTE TYPEDEF PTR BYTE
-PTRWORD TYPEDEF PTR WORD
-PTRDWORD TYPEDEF PTR DWORD
-PTRPROC TYPEDEF PTR PROC
-
-;;--- Constants ---
-
-; Width and height of sections in pixels.
-SWIDTH equ 8
-SHEIGHT equ 8
-
-LOG2_SWIDTH equ 3
-LOG2_SHEIGHT equ 3
-
-;;---
-
-EXTERN pal_tbl:BYTE ; unsigned char pal_tbl[3*256];
-EXTERN pal15_tbl:WORD ; unsigned short pal15_tbl[256];
-if INTERP eq 3
-EXTERN blend_tbl: PTRDWORD ; unsigned *blend_tbl;
-endif
- .data
-
- BYTE "(c) 1997 Interplay Productions. All Rights Reserved.\n"
- BYTE "This file is confidential and consists of proprietary information\n"
- BYTE "of Interplay Productions. This file and associated libraries\n"
- BYTE "may not, in whole or in part, be disclosed to third parties,\n"
- BYTE "incorporated into any software product which is not being created\n"
- BYTE "for Interplay Productions, copied or duplicated in any form,\n"
- BYTE "without the prior written permission of Interplay Productions.\n"
- BYTE "Further, you may not reverse engineer, decompile or otherwise\n"
- BYTE "attempt to derive source code of this material.\n",0
-
- .code
-
-PUBLIC mveliba_start, mveliba_end
-
-mveliba_start:
-
-;----------------------------------------------------------------------
-; Logging Support
-;-----------------
-
-if LOGGING
-
-;void logLabel(char *label)
-;
-logLabel PROTO lbl:PTRBYTE
-
-LOG_LABEL MACRO msg
-LOCAL lbl
- .data
-lbl BYTE msg,0
- .code
- INVOKE logLabel, offset lbl
- ENDM
-
-else
-
-LOG_LABEL MACRO msg
- ENDM
-
-endif
-
-;--------------------------------------------------------------------
-; Sound Management
-;--------------------
-
-EXTERN snd_8to16: WORD ; short snd_8to16[256];
-
-;unsigned sndDecompM16(unsigned short *dst, unsigned char *src,
-; unsigned len, unsigned prev);
-;
-;Decompresses a mono stream containing len samples
-;(src is len bytes, dst is len*2 bytes)
-;prev is the previous decompression state or zero.
-;Returns new decompression state.
-;
-sndDecompM16 PROC USES ESI EDI EBX, \
- dst:PTRWORD, src:PTRBYTE, len:DWORD, prev:DWORD
- mov eax, prev
-
- mov ecx, len
- jecxz done
-
- mov esi, src
- mov edi, dst
-
- xor ebx, ebx
-
-lp: mov bl, byte ptr [esi]
- add esi, 1
- add ax, word ptr snd_8to16[ebx*2]
- mov word ptr [edi], ax
- add edi, 2
- dec ecx
- jnz lp
-
-done: ret
-sndDecompM16 ENDP
-
-;unsigned sndDecompS16(unsigned short *dst, unsigned char *src,
-; unsigned len, unsigned prev);
-;
-;Decompresses a stereo stream containing len samples
-;(src is len*2 bytes, dst is len*4 bytes)
-;prev is the previous decompression state or zero
-; (It encodes the 16-bit states of the two stereo channels
-; in its low and high order 16-bit halves.)
-;Returns new decompression state.
-;
-sndDecompS16 PROC USES ESI EDI EBX, \
- dst:PTRWORD, src:PTRBYTE, len:DWORD, prev:DWORD
- movzx eax, word ptr prev
- movzx edx, word ptr prev+2
-
- mov ecx, len
- jecxz done
-
- mov esi, src
- mov edi, dst
-
- xor ebx, ebx
-
-lp: mov bl, byte ptr [esi]
- add esi, 1
- add ax, word ptr snd_8to16[ebx*2]
- mov word ptr [edi], ax
- add edi, 2
-
- mov bl, byte ptr [esi]
- add esi, 1
- add dx, word ptr snd_8to16[ebx*2]
- mov word ptr [edi], dx
- add edi, 2
-
- dec ecx
- jnz lp
-
-done: shl edx, 16
- or eax, edx
- ret
-sndDecompS16 ENDP
-
-;--------------------------------------------------------------------
-; NextFrame (Video Decompression)
-;----------------------------------
-
-;; NextFrame working storage
- ; MemRec nf_mem_buf1;
- ; MemRec nf_mem_buf2;
-EXTERN nf_buf_cur: PTRBYTE ; unsigned char* nf_buf_cur;
-EXTERN nf_buf_prv: PTRBYTE ; unsigned char* nf_buf_prv;
-
-;; NextFrame parameters
-EXTERN nf_wqty: BYTE ;unsigned char nf_wqty; // (width/SWIDTH)
-EXTERN nf_hqty: BYTE ;unsigned char nf_hqty; // (height/SHEIGHT)
-EXTERN nf_fqty: BYTE ;unsigned char nf_fqty; // Number of fields
-if HICOLOR
-EXTERN nf_hicolor: DWORD ;unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
-endif
-;;
-EXTERN nf_width: DWORD ;unsigned nf_width; // wqty * SWIDTH
-EXTERN nf_height: DWORD ;unsigned nf_height; // hqty * SHEIGHT;
-EXTERN nf_new_line: DWORD ;unsigned nf_new_line; // width - SWIDTH
-EXTERN nf_new_row0: DWORD ;unsigned nf_new_row0; // SHEIGHT*width*2-width
-EXTERN nf_back_right: DWORD ;unsigned nf_back_right; // (SHEIGHT-1)*width
-
-;; Frame parameters
-;; Portion of current frame which has been updated
-;; and needs to be sent to screen.
-;;
-EXTERN nf_new_x: DWORD ;unsigned nf_new_x;
-EXTERN nf_new_y: DWORD ;unsigned nf_new_y;
-EXTERN nf_new_w: DWORD ;unsigned nf_new_w;
-EXTERN nf_new_h: DWORD ;unsigned nf_new_h;
-
-
-NF_DECOMP_INIT MACRO HI_COLOR_FLAG: REQ
-
- mov ax, ds ; Insure es==ds for symantec flat mode
- mov es, ax
-
- mov eax, nf_buf_prv ; DiffBufPtrs = nf_buf_prv - nf_buf_cur
- sub eax, nf_buf_cur
- mov DiffBufPtrs, eax
-
- xor ebx, ebx ; ebx = nf_fqty (convert to 32-bits)
- mov bl, nf_fqty
-
- mov eax, x ; nf_new_x = x*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- mov nf_new_x, eax
-
- mov eax, w ; nf_new_w = w*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- mov nf_new_w, eax
-
- mov eax, y ; nf_new_y = y*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov nf_new_y, eax
-
- mov eax, h ; nf_new_h = h*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov nf_new_h, eax
-
- mov eax, nf_new_row0 ; new_row = nf_new_row0 - nf_new_w;
- sub eax, nf_new_w
- mov new_row, eax
-
- ;; Move to correct place in current buffer
- mov eax, nf_buf_cur ; tbuf = nf_buf_cur
- mov tbuf, eax
- .if x || y ; if (x||y)
- mov eax, nf_new_y ; tbuf += nf_new_y*nf_width + nf_new_x;
- mul nf_width
- add eax, nf_new_x
- add tbuf, eax
- .endif
-
- ENDM ; DECOMP_INIT
-
-
-DECOMP_BODY MACRO HI_COLOR_FLAG:REQ
-
- LOCAL HI_COLOR_SCALE
-HI_COLOR_SCALE equ HI_COLOR_FLAG+1
-
- NF_DECOMP_INIT HI_COLOR_FLAG
-
- mov eax, w ; parms_sz = (w*h*nf_fqty)<<1
- mul h
- mul ebx ;nf_fqty
- shl eax, 1
- mov parms_sz, eax
-
- ; esi indexes comp (to get new section data)
- ; edi indexes current screen buffer
- ; edx is a frequently used constant
- ; ebx indexes section params
- mov edi, tbuf
- mov edx, nf_new_line ; width - SWIDTH
- mov ebx, comp ; Parms index
- mov esi, ebx
- add esi, parms_sz ; Skip over flags (w*h*2)
-
- ; Iterate over params and copy new hires data to appropriate sections.
- mov cl, nf_fqty
-ns_0f: push ecx
- push edi
- mov ch, byte ptr h
-ns_0: mov cl, byte ptr w
-ns_1: cmp word ptr [ebx],0
- je ns_10
- add edi, SWIDTH*HI_COLOR_SCALE
-ns_2: add ebx, 2
- dec cl
- jnz ns_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ns_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ns_0f
- jmp ns_99
-
- ; Copy new data to one section
- ; Enter with esi pointing to source data, edi to screen section.
-
- ; Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
-ns_10:
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- jmp ns_2
-
-ns_99:
-
-ife ONLYNEW ; if !ONLYNEW
- ; Iterate over flags and motion source addresses from params
- ; to determine which sections to move.
- ; ebx indexes params.
- ; esi indexes source from buffer
- ; esi will be computed as +- 16K relative to edi.
-
- sub ebx, parms_sz ; Move back to start of section parms
- mov edi, tbuf
- mov cl, nf_fqty
- xor esi, esi
-ms_0f: push ecx
- push edi
- mov ch, byte ptr h
-ms_0: mov cl, byte ptr w
-ms_1: or si, [ebx]
- jg ms_10
- jl ms_j30
- add edi, SWIDTH*HI_COLOR_SCALE
-ms_2: add ebx, 2
- dec cl
- jnz ms_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_0f
- jmp ms_99
-
-ms_j30: jmp ms_30
-
- ; Move one section from current screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_10: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-04000h*HI_COLOR_SCALE+edi]
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- jmp ms_2
-
-
-ms_20f: push ecx
- push edi
- mov ch, byte ptr h
-ms_20: mov cl, byte ptr w
-ms_21: or si, [ebx]
- jl ms_30
- jg ms_j10
- add edi, SWIDTH*HI_COLOR_SCALE
-ms_22: add ebx, 2
- dec cl
- jnz ms_21
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_20
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_20f
- jmp ms_99
-
-ms_j10: jmp ms_10
-
- ; Move one section from previous screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_30: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-0C000h*HI_COLOR_SCALE+edi]
- add esi, DiffBufPtrs ; and point to other buffer
-
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- jmp ms_22
-
-ms_99:
-endif ; #endif !ONLYNEW
- ENDM ; DECOMP_BODY
-
-if PARTIAL
-
-DECOMP_CHG_BODY MACRO HI_COLOR_FLAG:REQ
-
- LOCAL HI_COLOR_SCALE
-HI_COLOR_SCALE equ HI_COLOR_FLAG+1
-
- NF_DECOMP_INIT HI_COLOR_FLAG
-
- ; esi indexes comp (to get new section data)
- ; edi indexes current screen buffer
- ; edx is a frequently used constant
- ; ebx indexes section params
- mov edi, tbuf
- mov edx, nf_new_line ; width - SWIDTH
- mov esi, comp
- mov ebx, parms
-
- ; Iterate over params and copy new hires data to appropriate sections.
-
- mov eax, chgs
- mov pChgs, eax
- mov eax, 0
- mov cl, nf_fqty
-ns_0f: push ecx
- push edi
- mov ch, byte ptr h
-ns_0: mov cl, byte ptr w
-ns_1: add ax, ax
- ja ns_1b
- jz ns_5
- cmp word ptr [ebx],0
- je ns_10
- add ebx, 2
-ns_1b: add edi, SWIDTH*HI_COLOR_SCALE
-ns_2: dec cl
- jnz ns_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ns_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ns_0f
- jmp ns_99
-
-ns_5: mov eax, pChgs
- add pChgs, 2
- mov ax, [eax]
- jmp ns_1
-
- ; Copy new data to one section
- ; Enter with ds:si pointing to source data, es:di to screen section.
-
- ; Assumes SWIDTH=8 (16-bit data) and SHEIGHT=8
-ns_10:
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- add ebx, 2
- jmp ns_2
-
-ns_99:
-
-ife ONLYNEW ; if !ONLYNEW
- ; Iterate over flags and motion source addresses from params
- ; to determine which sections to move.
- ; ebx indexes params.
- ; esi indexes source from buffer
- ; esi will be computed as +- 16K relative to edi.
-
- mov edi, tbuf
- mov ebx, parms
-
- mov eax, chgs
- mov pChgs, eax
- mov eax, 0
- mov cl, byte ptr nf_fqty
- xor esi, esi
-ms_0f: push ecx
- push edi
- mov ch, byte ptr h
-ms_0: mov cl, byte ptr w
-ms_1: add ax, ax
- ja ms_1b
- jz ms_5
- or si, [ebx]
- jg ms_10
- jl ms_j30
- add ebx, 2
-ms_1b: add edi, SWIDTH*HI_COLOR_SCALE
-ms_2: dec cl
- jnz ms_1
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_0
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_0f
- jmp ms_99
-
-ms_5: mov eax, pChgs
- add pChgs, 2
- mov ax, word ptr [eax]
- jmp ms_1
-
-
-ms_j30: jmp ms_30
-
- ; Move one section from current screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_10: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-04000h*HI_COLOR_SCALE+edi]
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- xor esi, esi ; Reset esi to zero
- add ebx, 2
- jmp ms_2
-
-
-ms_20f: push ecx
- push edi
- mov ch, byte ptr h
-ms_20: mov cl, byte ptr w
-ms_21: add ax, ax
- ja ms_21b
- jz ms_25
- or si, [ebx]
- jl ms_30
- jg ms_j10
- add ebx, 2
-ms_21b: add edi, SWIDTH*HI_COLOR_SCALE
-ms_22: dec cl
- jnz ms_21
- add edi, new_row ; SHEIGHT*width - SWIDTH*w
- dec ch
- jnz ms_20
- pop edi
- pop ecx
- add edi, nf_width
- dec cl
- jnz ms_20f
- jmp ms_99
-
-ms_25: mov eax, pChgs
- add pChgs, 2
- mov ax, [eax]
- jmp ms_21
-
-ms_j10: jmp ms_10
-
- ; Move one section from previous screen to current screen.
- ; Enter with
- ; edi pointing to destination screen section,
- ; relative value of source offset in esi.
-
- ; The following assumes SWIDTH==8 and SHEIGHT==8
-
-ms_30: ; Make esi absolute
- lea esi, [esi*HI_COLOR_SCALE-0C000h*HI_COLOR_SCALE+edi]
- add esi, DiffBufPtrs ; and point to other buffer
-
- REPEAT 7
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
- add esi, edx
- add edi, edx
- ENDM
- REPEAT 2*HI_COLOR_SCALE
- movsd
- ENDM
-
- sub edi, nf_back_right ; (SHEIGHT-1)*width
- add ebx, 2
- xor esi, esi ; Reset esi to zero
- jmp ms_22
-
-ms_99:
-endif ; !ONLYNEW
-
- ENDM ; DECOMP_CHG_BODY
-
-endif ; PARTIAL
-
-;;--- HiColor versions
-
-if HICOLOR
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-;
-
-;void
-;nfHiColorDecomp(unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfHiColorDecomp PROC USES ESI EDI EBX, \
- comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
-
- LOCAL parms_sz: DWORD
-
- LOG_LABEL "StartHiColorDecomp"
- DECOMP_BODY 1 ; HiColor
- LOG_LABEL "EndHiColorDecomp"
-
- ret
-nfHiColorDecomp ENDP
-
-if PARTIAL
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-; Chgs specifies which squares to update.
-; Parms are motion parms for squares to update.
-;
-;void
-;nfHiColorDecompChg(unsigned short *chgs,
-; unsigned short *parms,
-; unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfHiColorDecompChg PROC USES ESI EDI EBX, \
- chgs:PTRWORD, \
- parms:PTRWORD, \
- comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
-
- LOCAL pChgs: PTRBYTE
-
- LOG_LABEL "StartHiColorDecompChg"
- DECOMP_CHG_BODY 1 ; HiColor
- LOG_LABEL "EndHiColorDecompChg"
- ret
-nfHiColorDecompChg ENDP
-
-
-endif ; PARTIAL
-
-
-endif ; HICOLOR
-
-; Non-HiColor versions
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-;
-;void nfDecomp(unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfDecomp PROC USES ESI EDI EBX, \
- comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
-
- LOCAL parms_sz: DWORD
-
-if HICOLOR
- .if nf_hicolor
- INVOKE nfHiColorDecomp, comp,x,y,w,h
- ret
- .endif
-endif
-
- LOG_LABEL "StartDecomp"
- DECOMP_BODY 0 ; Not HiColor
- LOG_LABEL "EndDecomp"
-
- ret
-nfDecomp ENDP
-
-if PARTIAL
-
-; Decompress into subsection of current buffer specified
-; by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-; Chgs specifies which squares to update.
-; Parms are motion parms for squares to update.
-;
-;void
-;nfDecompChg(unsigned short *chgs,
-; unsigned short *parms,
-; unsigned char *comp,
-; unsigned x, unsigned y, unsigned w, unsigned h)
-;
-nfDecompChg PROC USES ESI EDI EBX, \
- chgs:PTRWORD, \
- parms:PTRWORD, \
- comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row: DWORD
- LOCAL DiffBufPtrs: DWORD
-
- LOCAL pChgs: PTRBYTE
-
-if HICOLOR
- .if nf_hicolor
- INVOKE nfHiColorDecompChg, chgs,parms,comp,x,y,w,h
- ret
- .endif
-endif
-
- LOG_LABEL "StartDecompChg"
- DECOMP_CHG_BODY 0 ; Not HiColor
- LOG_LABEL "EndDecompChg"
-
- ret
-nfDecompChg ENDP
-
-
-endif ; PARTIAL
-
-;----------------------------------------------------------------------
-
-if PKDATA
- .data
-
-if (INTERP eq 1) or (INTERP eq 2) ; *** Old version for dithering ***
-; luminace table for palette entries
-lum_tbl DWORD 256 DUP (0)
-endif
-
-; signed 8-bit y * nf_width
-nfpk_ShiftY DWORD 256 DUP (0)
-
-; Constant tables
-
-; 8-bit -8:7 x nf_width + -8:7
-nfpk_ShiftP1 LABEL WORD
-FOR y, <-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7>
- FOR x, <-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7>
- BYTE x,y
- ENDM
-ENDM
-
-; 8-bit to right and below in roughly 0:14*nf_width + -14:14 (-3 cases)
-; negative is
-; 8-bit to left and above in roughly -14:0*nf_width + -14:14 (-3 cases)
-nfpk_ShiftP2 LABEL WORD
-FOR y, <0,1,2,3,4,5,6,7>
- FOR x, <8,9,10,11,12,13,14>
- BYTE x,y
- ENDM
-ENDM
-FOR y, <8,9,10,11,12,13>
- FOR x, <-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1>
- BYTE x,y
- ENDM
- FOR x, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14>
- BYTE x,y
- ENDM
-ENDM
-FOR x, <-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1>
- BYTE x,14
-ENDM
-FOR x, <0,1,2,3,4,5,6,7,8,9,10,11>
- BYTE x,14
-ENDM
-
-nfpk_mov4l LABEL DWORD
-; mov ax, bx,cx
-MOV4L_REGS TEXTEQU >
-%FOR m4, MOV4L_REGS
-% FOR m3, MOV4L_REGS
-% FOR m2, MOV4L_REGS
-% FOR m1, MOV4L_REGS
- BYTE m2,m1,m4,m3
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfpk_mov8 LABEL DWORD
-; mov ax, bx/dx/cx/bp
-MOV8_REGS TEXTEQU >
-%FOR m4, MOV8_REGS
-% FOR m3, MOV8_REGS
-% FOR m2, MOV8_REGS
-% FOR m1, MOV8_REGS
- BYTE m2,m1,m4,m3
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfpk_mov4 LABEL DWORD
-; mov al, bl/bh/cl/ch
-MOV4_REGS0 TEXTEQU >
-; mov ah, bl/bh/cl/ch
-MOV4_REGS1 TEXTEQU >
-%FOR m4, MOV4_REGS1
-% FOR m3, MOV4_REGS0
-% FOR m2, MOV4_REGS1
-% FOR m1, MOV4_REGS0
- BYTE m3,m4,m1,m2
- ENDM
- ENDM
- ENDM
- ENDM
-
- .code
-
-; nfPkConfig initializes tables used by nfPkDecomp
-; which are dependent on screen size.
-nfPkConfig PROC USES ESI EDI EBX
-
- ; Build ShiftY table
- ;
- lea edi, nfpk_ShiftY
- mov ebx, nf_width
-
- mov eax, 0
- mov ecx, 128
-lp1: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp1
-
- mov eax, ebx
- shl eax, 7
- neg eax
- mov ecx, 128
-lp2: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp2
-
- ret
-nfPkConfig ENDP
-
-if (INTERP eq 1) or (INTERP eq 2)
-; nfPkPal initializes tables used by nfPkDecomp
-; which are dependent on palette.
-nfPkPal PROC USES ESI EDI EBX
-
- ; Build palette luminance table
- ;
- lea esi, pal_tbl
- lea edi, lum_tbl
- mov ecx, 256
-lp3: xor eax, eax
- xor ebx, ebx
- xor edx, edx
- mov al, [esi] ; r
- mov bl, [esi+1] ; g
- mov dl, [esi+2] ; b
- add esi, 3
- imul eax, 2990
- imul ebx, 5866
- imul edx, 1144
- add eax, ebx
- add eax, edx
- mov [edi], eax
- add edi, 4
- dec ecx
- jnz lp3
-
- ret
-nfPkPal ENDP
-
-elseif INTERP eq 3
-
-nfPkInterp1 MACRO left:REQ, right:REQ
- xor eax, eax
- mov al, left
- mov ah, right
- mov eax, [esi+eax*4]
- mov edx, eax
- mov dl, dh
- shl edx, 8
- mov dl, left
- mov [edi], edx
- mov ah, right
- ror eax, 16
- mov [edi+4], eax
- ENDM
-
-nfPkInterp2 MACRO left:REQ, right:REQ
- xor eax, eax
- mov al, left
- mov ah, right
- mov eax, [esi+eax*4]
- mov edx, eax
- mov dl, dh
- shl edx, 8
- mov dl, left
- mov [edi], edx
- mov [edi+ebp*1], edx
- mov ah, right
- ror eax, 16
- mov [edi+4], eax
- mov [edi+4+ebp*1], eax
- ENDM
-
-endif
-
-ifdef SYMANTEC
-EXTERN _data_bottom:PTRBYTE
-endif
-
-; Normal version
-;
-nfPkDecomp PROC USES ESI EDI EBX, \
- ops:PTRBYTE, comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row:DWORD
- LOCAL DiffBufPtrs:DWORD
-
- LOCAL nfpk_back_right: DWORD
- LOCAL wcnt:DWORD
-
- LOG_LABEL "StartPkDecomp"
-
-.data
-nfpk_OpTbl label dword
- dword offset nf0 ; Prev Same (0)
- dword offset nf1 ; No change (and copied to screen) (0)
- dword offset nf2 ; Near shift from older part of current buf (1)
- dword offset nf3 ; Near shift from newer part of current buf (1)
- dword offset nf4 ; Near shift from previous buffer (1)
- dword offset nf5 ; Far shift from previous buffer (2)
- dword offset nf6 ; Far shift from current buffer (2)
- ; [Or if COMPOPS, run of no changes (0)]
- dword offset nf7 ; 8x8x1 (10 bytes) or low 4x4x1 (4 bytes)
- dword offset nf8 ; 2x2 4x4x1 (16 bytes) or 2x1 4x8x1 (12 bytes) or 1x2 8x4x1 (12 bytes)
- dword offset nf9 ; 8x8x2 (20 bytes) or low 4x4x2 (8 bytes) or
- ; low 4x8x2 (12 bytes) or low 8x4x2 (12 bytes)
- dword offset nf10 ; 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- dword offset nf11 ; 8x8x8 (64 bytes)
- dword offset nf12 ; low 4x4x8 (16 bytes)
- dword offset nf13 ; 2x2 4x4x0 (ie 2x2x8) (4 bytes)
- dword offset nf14 ; 8x8x0 (1 byte)
- dword offset nf15 ; mix 8x8x0 (2 bytes)
-.code
-
-ifdef SYMANTEC
- mov ebx, ds ; Allow DS to access code
- mov ecx, 0
- mov ax, 3505h
- int 21h
-endif
-
- NF_DECOMP_INIT 0
-
- mov eax, nf_back_right
- sub eax, SWIDTH
- mov nfpk_back_right, eax
-
- mov esi, comp
- mov edi, tbuf
-nf_StartRow:
- mov eax, w
- shr eax, 1
- mov wcnt,eax
- ALIGN 4
-nf_NextPair:
- dec wcnt
- js nf_NextRow
- mov ebx, ops
- mov al, [ebx]
- inc ebx
- mov ops, ebx
-
- xor ebx, ebx
- mov bl, al
- shr bl, 4
- and eax, 0Fh
- push offset nf_NextPair
- push nfpk_OpTbl[ebx*4]
- jmp nfpk_OpTbl[eax*4]
-
-nf_NextRow:
- add edi, new_row
- dec h
- jnz nf_StartRow
- LOG_LABEL "EndPkDecomp"
-
-ifdef SYMANTEC
- mov ebx, ds ; Disable DS from accessing code
- mov ecx, offset DGROUP:_data_bottom[-1]
- mov ax, 3505h
- int 21h
-endif
- ret
-
-;----------------------------------------
- ALIGN 4
-if INTERP eq 0
-
-nf0: ; No change from previous buffer
- mov eax, DiffBufPtrs
- jmp nf_shift
-
-elseif INTERP eq 3
-nf0: ; Interpolated (1 byte)
- push ebp
-
- mov ebp, nf_width
- sub edi, ebp ; Get four corner colors
- mov bl, [edi-1] ; into bl,bh,cl,ch
- mov bh, [edi+7]
- mov cl, [edi+ebp*8-1]
- mov ch, [esi]
- inc esi
- add edi, ebp
-
- push esi
- mov esi, blend_tbl
-
- nfPkInterp1 bl,bh
- add edi, ebp
- push ebx
- push ecx
- xor eax, eax
- mov al, bl
- mov ah, cl
- mov edx, [esi+eax*4]
- mov al, bh
- mov ah, ch
- mov ecx, [esi+eax*4]
- mov ebx, edx
- nfPkInterp2 bh,ch
- lea edi, [edi+ebp*2]
- ror ebx, 16
- ror ecx, 16
- nfPkInterp2 bl,cl
- lea edi, [edi+ebp*2]
- nfPkInterp2 bh,ch
- lea edi, [edi+ebp*2]
- pop ecx
- pop ebx
- nfPkInterp1 cl,ch
-
- pop esi
- pop ebp
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-elseif INTERP eq 2
-
-nf0: ; Interpolated (1 byte)
- mov edx, nf_width
- sub edi, edx ; Get four corner colors
- sub edi, edx ;xxx
- mov bl, [edi-1] ; into bl,bh,cl,ch
- mov bh, [edi+7]
- mov cl, [edi+edx*8-1]
- mov ch, [esi]
- inc esi
- add edi, edx ;xxx
- add edi, edx
-
-; Get four luminances into eax, ebx, ebp, ecx
-; Use edx for temp, esi for closest luminance, edi for closest pair
- push ebx
- push ecx
- push esi
- push edi
- push ebp
-
- xor edx, edx
- mov dl, bl
- mov eax, lum_tbl[edx*4]
- mov dl, bh
- mov ebx, lum_tbl[edx*4]
- mov dl, cl
- mov ebp, lum_tbl[edx*4]
- mov dl, ch
- mov ecx, lum_tbl[edx*4]
-
- mov edx, eax
- sub edx, ebx
- jns nf0a
- neg edx
-nf0a: mov esi, edx
- mov edi, 0 ; Vert
-
- mov edx, eax
- sub edx, ebp
- jns nf0b
- neg edx
-nf0b: cmp edx, esi
- ja nf0c
- mov esi, edx
- mov edi, 1 ; Horiz
-
-nf0c: mov edx, eax
- sub edx, ecx
- jns nf0d
- neg edx
-nf0d: cmp edx, esi
- ja nf0e
- mov esi, edx
- mov edi, 2 ; \ Diag
-
-nf0e: mov edx, ebx
- sub edx, ebp
- jns nf0f
- neg edx
-nf0f: cmp edx, esi
- ja nf0g
- mov esi, edx ; / RDiag
- mov edi, 3
-
-nf0g:
- mov edx, ebx
- sub edx, ecx
- jns nf0h
- neg edx
-nf0h: cmp edx, esi
- ja nf0i
- mov esi, edx
- mov edi, 1 ; Horiz
-
-nf0i: mov edx, ebp
- sub edx, ecx
- jns nf0j
- neg edx
-nf0j: cmp edx, esi
- ja nf0k
- mov edi, 0
-
-nf0k: mov eax, edi
- pop ebp
- pop edi
- pop esi
- pop ecx
- pop ebx
- mov edx, nf_width
-
- cmp eax, 2
- jae nfdiag
- or eax, eax
- jz nf0_v
- jmp nf0_h
-
-nfdiag: jz nf0_d
- jmp nf0_r
-
-if 1 ; Newer versions of Vertical and Horizontal blend that use 0%,25%,50%,75%,100% instead of just 0%,50%,100%
-
-; Vertical blend
-; 0 1
-; 01010101 1
-; 00121013 2
-; 02010311 3
-; 20203131 4
-; 02021313 5
-; 23202331 6
-; 20332123 7
-;2 22233233 8
-;
-
-nf0_v:
- ; 3412 (low to high)
- ;------
- mov al, bl ; 0101 (1)
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, bh
- mov [edi], eax
- mov [edi+4], eax ; 0101
- add edi, edx
-
- mov al, bh ; 0012 (2)
- mov ah, cl
- shl eax, 8
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1013
- mov ah, ch
- shl eax, 16
- mov al, bh
- mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0201 (3)
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 0311
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2020 (4), 0202 (5)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- ror eax, 8
- mov [edi+edx], eax
- mov al, ch ; 3131, 1313
- mov ah, bh
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
- ror eax, 8
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
- mov al, cl ; 2320 (6)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, ch
- mov [edi], eax
- mov al, ch ; 2331
- mov ah, bh
- shl eax, 16
- mov al, cl
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 2033 (7)
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, cl ; 2123
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
- mov ah, cl ; 2223 (8)
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- shl eax, 16
- mov al, ch
- mov ah, cl
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-; Horizontal blend
-; 0 1
-; 00010111 1
-; 20101301 2
-; 02010131 3
-; 21201033 4
-; 02032113 5
-; 20323321 6
-; 02232313 7
-;2 23223233 8
-
-nf0_h:
- ; 3412 (low to high)
- ;------
- mov al, bl ; 0001 (1)
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 0111
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- ror eax, 8 ; 2010 (2)
- mov al, cl
- mov ah, bl
- mov [edi], eax
- rol eax, 8
- mov al, bh ; 1301
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0201 (3)
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 0131
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2120 (4)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, bh
- mov [edi], eax
- mov al, ch ; 1033
- mov ah, ch
- shl eax, 16
- mov al, bh
- mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 0203 (5)
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 2113
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
- ror eax, 8 ; 2032 (6)
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 3321
- mov ah, ch
- ror eax, 8
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 0223 (7)
- mov ah, ch
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 2313
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- shl eax, 16 ; 2322 (8)
- mov al, cl
- mov ah, ch
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- shl eax, 16
- mov al, ch
- mov ah, cl
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-else
-
-; Vertical blend
-;0 1
-; 00101011 1
-; 00010111 2
-; 20203131 3
-; 02021313 4
-; 20203131 5
-; 02021313 6
-; 22323233 7
-;2 22232333 8
-;
-nf0_v:
- push ebp
- ; 3412 (low to high)
- ;------
- mov al, bh ; 0010 (1)
- mov ah, bl
- shl eax, 16
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1011
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 0001 (2)
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 0111
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2020 (3+5)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov ebp, eax
- mov [edi], eax
- mov [edi+edx*2], eax
- mov al, ch ; 3131
- mov ah, bh
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
- mov [edi+edx*2+4], eax
- add edi, edx
-
- rol ebp, 8 ; 0202 (4+6)
- mov [edi], ebp
- mov [edi+edx*2], ebp
- rol eax, 8 ; 1313
- mov [edi+4], eax
- mov [edi+edx*2+4], eax
- add edi, edx
- lea edi, [edi+edx*2]
-
- mov al, ch ; 2232 (7)
- mov ah, cl
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2223 (8)
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 2333
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
-
- pop ebp
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-; Horizontal blend
-;0 1
-; 00101011 1
-; 00010111 2
-; 20101031 3
-; 02010113 4
-; 20323231 5
-; 02232313 6
-; 22323233 7
-;2 22232333 8
-;
-nf0_h:
- ; 3412 (low to high)
- ;------
- mov al, bh ; 0010 (1)
- mov ah, bl
- shl eax, 16
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1011
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 0001 (2)
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 0111
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- ror eax, 8 ; 2010 (3)
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, ch ; 1031
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0201 (4)
- mov ah, bh
- rol eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 0113
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, ch ; 2032 (5)
- mov ah, cl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, ch ; 3231
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 0223 (6)
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 2313
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, ch ; 2232 (7)
- mov ah, cl
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2223 (8)
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 2333
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-endif
-
-; \ Diagonal blend
-;0 1
-; 00010101 1
-; 00001313 2
-; 20303101 3
-; 02030313 4
-; 23203031 5
-; 02020333 6
-; 23232333 7
-;2 22023233 8
-;
-nf0_d:
- ; 3412 (low to high)
- ;------
- mov al, bl ; 0001 (1)
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov ah, bh ; 0101
- mov [edi+4], eax
- add edi, edx
-
- mov ah, bl ; 0000 (2)
- rol eax, 16
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1313
- mov ah, ch
- shl eax, 16
- mov al, bh
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, ch ; 2030 (3)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, bl ; 3101
- mov ah, bh
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0203 (4)
- mov ah, ch
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, bh ; 0313
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2320 (5)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, ch
- mov [edi], eax
- mov al, ch ; 3031
- mov ah, bh
- shl eax, 16
- mov al, ch
- mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0202 (6)
- mov ah, cl
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov ah, ch ; 0333
- shl eax, 16
- mov al, ch
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2323 (7)
- rol eax, 16
- mov al, cl
- mov [edi], eax
- mov al, ch ; 2333
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 2202 (8)
- mov ah, cl
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- shl eax, 16
- mov al, ch
- mov ah, cl
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-
-; / RDiagonal blend
-;0 1
-; 01010111 1
-; 20201111 2
-; 01021313 3
-; 20212131 4
-; 02121323 5
-; 22213131 6
-; 22232323 7
-;2 22323133 8
-;
-nf0_r:
- ; 3412 (low to high)
- ;------
- mov al, bl ; 0101 (1)
- mov ah, bh
- shl eax, 16
- mov al, bl
- mov ah, bh
- mov [edi], eax
- mov al, bh ; 0111
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2020 (2)
- mov ah, bl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1111
- mov ah, bh
- shl eax, 16
- mov al, bh
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
- mov al, bl ; 0102 (3)
- mov ah, cl
- rol eax, 16
- mov al, bl
- mov [edi], eax
- mov al, bh ; 1313
- mov ah, ch
- shl eax, 16
- mov al, bh
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2021 (4)
- mov ah, bh
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, ch ; 2131
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- ror eax, 8 ; 0212 (5)
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, cl ; 1323
- mov ah, ch
- shl eax, 16
- mov al, bh
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2221 (6)
- mov ah, bh
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 3131
- mov ah, bh
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
- mov al, cl ; 2223 (7)
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov ah, ch ; 2323
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
- rol eax, 8 ; 2232 (8)
- mov al, cl
- mov [edi], eax
- mov al, ch ; 3133
- mov ah, ch
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-elseif INTERP eq 1
-
-nf0: ; Interpolated (1 byte)
- mov edx, nf_width
- sub edi, edx ; Get four corner colors
- sub edi, edx ;xxx
- mov bl, [edi-1] ; into bl,bh,cl,ch
- mov bh, [edi+7]
- mov cl, [edi+edx*8-1]
- mov ch, [esi]
- inc esi
- add edi, edx ;xxx
- add edi, edx
-
-; Pattern for interpolating four corners:
-;0 1
-; 00101011 1
-; 00010111 2
-; 20023113 3
-; 02101031 4
-; 20323213 5
-; 02201331 6
-; 22232333 7
-;2 22323233 8
- ; 3412 (low to high)
- ;------
-nf0_1:
- mov al, bh ; 0010
- mov ah, bl
- shl eax, 16
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 1011
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
-nf0_2: rol eax, 8 ; 0001
- mov al, bl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 0111
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
-nf0_3: mov al, bl ; 2002
- mov ah, cl
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 3113
- mov ah, ch
- shl eax, 16
- mov al, ch
- mov ah, bh
- mov [edi+4], eax
- add edi, edx
-
-nf0_4: mov al, bh ; 0210
- mov ah, bl
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 1031
- mov ah, bh
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
-nf0_5: mov al, cl ; 2032
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, bl
- mov [edi], eax
- mov al, bh ; 3213
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
-nf0_6: mov al, cl ; 0220
- mov ah, bl
- shl eax, 16
- mov al, bl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 1331
- mov ah, bh
- shl eax, 16
- mov al, bh
- mov ah, ch
- mov [edi+4], eax
- add edi, edx
-
-nf0_7: mov al, cl ; 2223
- mov ah, ch
- shl eax, 16
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 2333
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
- add edi, edx
-
-nf0_8: ror eax, 8 ; 2232
- mov al, cl
- mov ah, cl
- mov [edi], eax
- mov al, ch ; 3233
- mov ah, ch
- rol eax, 16
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-endif
-
-;----------------------------------------
- ALIGN 4
-nf1: ; No change (and copied to screen)
- add edi, SWIDTH
- retn
-
-;----------------------------------------
- ALIGN 4
-nf2: ; Near shift from older part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
-nf_xyc_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- add eax, nfpk_ShiftY[ebx*4]
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf3: ; Near shift from newer part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
- neg al
- neg ah
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf4: ; Near shift from previous buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP1[eax*2]
- jmp nf_xyp_shift
-
-;----------------------------------------
- ALIGN 4
-nf5: ; Far shift from previous buffer
- mov ax, [esi]
- add esi, 2
-nf_xyp_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- add eax, nfpk_ShiftY[ebx*4]
- add eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-
-if COMPOPS
-
-nf6: ; Run of no changes (must only appear in first nibble opcodes)
- ; Next nibble k specifies 2k+4 squares with no changes
- add esp, 4 ; Next nibble is not an opcode
- add ebx, 2 ; (minimum of 4 squares)
- ALIGN 4
-nf6a: add edi, SWIDTH*2 ; Advance over two squares
- dec ebx
- jz nf6z ; Last pair of squares
- dec wcnt ; Same row?
- jns nf6a ; Yes
- add edi, new_row ; Advance to next row
- dec h ; Decrement row count (should never become zero here)
- mov eax, w ; Reset wcnt
- shr eax ,1
- dec eax
- mov wcnt, eax
- jmp nf6a
-
-nf6z: retn
-
-else
-
-nf6: ; Far shift from current buffer
- mov ax, [esi]
- add esi, 2
- jmp nf_xyc_shift
-
-endif
-
-;----------------------------------------
- ALIGN 4
-nf_shift:
-if 0 ;debug
- mov eax, 0
- mov ebx, eax
- jmp nf_solid
-endif
- mov ebx, esi ; save esi
- lea esi, [edi+eax]
- mov edx, nf_width
-
- REPEAT 7
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- add esi, edx
- add edi, edx
- ENDM
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- mov esi, ebx ; restore esi
- retn
-
-;----------------------------------------
- ALIGN 4
-nf7: ; 8x8x1 (10 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf23
-
-if 0 ;debug
- add esi, 10
- mov eax, 0fefefefeH
- mov ebx, eax
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf7_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_11-nf7_11)], bl
- mov [edx+(nf7_12-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_13-nf7_11)], bl
- mov [edx+(nf7_14-nf7_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_21-nf7_11)], bl
- mov [edx+(nf7_22-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_23-nf7_11)], bl
- mov [edx+(nf7_24-nf7_11)], bh
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_31-nf7_11)], bl
- mov [edx+(nf7_32-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_33-nf7_11)], bl
- mov [edx+(nf7_34-nf7_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_41-nf7_11)], bl
- mov [edx+(nf7_42-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_43-nf7_11)], bl
- mov [edx+(nf7_44-nf7_11)], bh
-
- lea edx, [edx+(nf7_51-nf7_11)]
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_51-nf7_51)], bl
- mov [edx+(nf7_52-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_53-nf7_51)], bl
- mov [edx+(nf7_54-nf7_51)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_61-nf7_51)], bl
- mov [edx+(nf7_62-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_63-nf7_51)], bl
- mov [edx+(nf7_64-nf7_51)], bh
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_71-nf7_51)], bl
- mov [edx+(nf7_72-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_73-nf7_51)], bl
- mov [edx+(nf7_74-nf7_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_81-nf7_51)], bl
- mov [edx+(nf7_82-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_83-nf7_51)], bl
- mov [edx+(nf7_84-nf7_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi,nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
- jmp nf7_0 ; flush prefetch
- ALIGN 4
-nf7_0:
-nf7_11: mov ax, bx
- shl eax, 16
-nf7_12: mov ax, bx
- mov [edi], eax
-nf7_13: mov ax, bx
- shl eax, 16
-nf7_14: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_21: mov ax, bx
- shl eax, 16
-nf7_22: mov ax, bx
- mov [edi], eax
-nf7_23: mov ax, bx
- shl eax, 16
-nf7_24: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_31: mov ax, bx
- shl eax, 16
-nf7_32: mov ax, bx
- mov [edi], eax
-nf7_33: mov ax, bx
- shl eax, 16
-nf7_34: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_41: mov ax, bx
- shl eax, 16
-nf7_42: mov ax, bx
- mov [edi], eax
-nf7_43: mov ax, bx
- shl eax, 16
-nf7_44: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_51: mov ax, bx
- shl eax, 16
-nf7_52: mov ax, bx
- mov [edi], eax
-nf7_53: mov ax, bx
- shl eax, 16
-nf7_54: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_61: mov ax, bx
- shl eax, 16
-nf7_62: mov ax, bx
- mov [edi], eax
-nf7_63: mov ax, bx
- shl eax, 16
-nf7_64: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_71: mov ax, bx
- shl eax, 16
-nf7_72: mov ax, bx
- mov [edi], eax
-nf7_73: mov ax, bx
- shl eax, 16
-nf7_74: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_81: mov ax, bx
- shl eax, 16
-nf7_82: mov ax, bx
- mov [edi], eax
-nf7_83: mov ax, bx
- shl eax, 16
-nf7_84: mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 10
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf7+16
-nf23: ; low 4x4x1 (4 bytes)
-
- xor eax, eax
- lea ecx, nfpk_mov4l
- lea edx, byte ptr ds:nf23_11+2
-
- mov al, [esi+2]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_11-nf23_11)], bl
- mov [edx+(nf23_12-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_13-nf23_11)], bl
- mov [edx+(nf23_14-nf23_11)], bh
-
- mov al, [esi+2]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_31-nf23_11)], bl
- mov [edx+(nf23_32-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_33-nf23_11)], bl
- mov [edx+(nf23_34-nf23_11)], bh
-
-
- mov al, [esi+3]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_51-nf23_11)], bl
- mov [edx+(nf23_52-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_53-nf23_11)], bl
- mov [edx+(nf23_54-nf23_11)], bh
-
- mov al, [esi+3]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_71-nf23_11)], bl
- mov [edx+(nf23_72-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_73-nf23_11)], bl
- mov [edx+(nf23_74-nf23_11)], bh
-
- mov edx, nf_width
-
- ; load bx,cx with 00,11 color combinations
- mov bx, [esi]
- mov cl, bh
- mov bh, bl
- mov ch, cl
-
- jmp nf23_0 ; flush prefetch
- ALIGN 4
-nf23_0:
-
-nf23_11:mov ax, bx
- shl eax, 16
-nf23_12:mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
-nf23_13:mov ax, bx
- shl eax, 16
-nf23_14:mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf23_31:mov ax, bx
- shl eax, 16
-nf23_32:mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
-nf23_33:mov ax, bx
- shl eax, 16
-nf23_34:mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf23_51:mov ax, bx
- shl eax, 16
-nf23_52:mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
-nf23_53:mov ax, bx
- shl eax, 16
-nf23_54:mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf23_71:mov ax, bx
- shl eax, 16
-nf23_72:mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
-nf23_73:mov ax, bx
- shl eax, 16
-nf23_74:mov ax, bx
- mov [edi+4], eax
- add edi, edx
- mov [edi+4], eax
-
- sub edi, nfpk_back_right
- add esi, 4
- retn
-
-;----------------------------------------
- ALIGN 4
-nf8: ; 2x2 4x4x1 (16 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf24
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf8_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_11-nf8_11)], bl
- mov [edx+(nf8_12-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_13-nf8_11)], bl
- mov [edx+(nf8_14-nf8_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_21-nf8_11)], bl
- mov [edx+(nf8_22-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_23-nf8_11)], bl
- mov [edx+(nf8_24-nf8_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_31-nf8_11)], bl
- mov [edx+(nf8_32-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_33-nf8_11)], bl
- mov [edx+(nf8_34-nf8_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_41-nf8_11)], bl
- mov [edx+(nf8_42-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_43-nf8_11)], bl
- mov [edx+(nf8_44-nf8_11)], bh
-
- add edx, nf8_51-nf8_11
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_51-nf8_51)], bl
- mov [edx+(nf8_52-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_53-nf8_51)], bl
- mov [edx+(nf8_54-nf8_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_61-nf8_51)], bl
- mov [edx+(nf8_62-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_63-nf8_51)], bl
- mov [edx+(nf8_64-nf8_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_71-nf8_51)], bl
- mov [edx+(nf8_72-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_73-nf8_51)], bl
- mov [edx+(nf8_74-nf8_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_81-nf8_51)], bl
- mov [edx+(nf8_82-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_83-nf8_51)], bl
- mov [edx+(nf8_84-nf8_51)], bh
-
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf8_0 ; flush prefetch
- ALIGN 4
-nf8_0:
-nf8_11: mov ax, bx
- shl eax, 16
-nf8_12: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_13: mov ax, bx
- shl eax, 16
-nf8_14: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_21: mov ax, bx
- shl eax, 16
-nf8_22: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_23: mov ax, bx
- shl eax, 16
-nf8_24: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+4]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_31: mov ax, bx
- shl eax, 16
-nf8_32: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_33: mov ax, bx
- shl eax, 16
-nf8_34: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_41: mov ax, bx
- shl eax, 16
-nf8_42: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_43: mov ax, bx
- shl eax, 16
-nf8_44: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*8-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+8]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_51: mov ax, bx
- shl eax, 16
-nf8_52: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_53: mov ax, bx
- shl eax, 16
-nf8_54: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_61: mov ax, bx
- shl eax, 16
-nf8_62: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_63: mov ax, bx
- shl eax, 16
-nf8_64: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+12]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_71: mov ax, bx
- shl eax, 16
-nf8_72: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_73: mov ax, bx
- shl eax, 16
-nf8_74: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_81: mov ax, bx
- shl eax, 16
-nf8_82: mov ax, bx
- mov [edi], eax
- add edi, esi
-nf8_83: mov ax, bx
- shl eax, 16
-nf8_84: mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+16
-nf24: ; 2x1 4x8x1 (12 bytes)
-
- mov ax, [esi+6]
- cmp al, ah
- ja nf40
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf24_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_11-nf24_11)], bl
- mov [edx+(nf24_12-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_13-nf24_11)], bl
- mov [edx+(nf24_14-nf24_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_21-nf24_11)], bl
- mov [edx+(nf24_22-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_23-nf24_11)], bl
- mov [edx+(nf24_24-nf24_11)], bh
-
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_31-nf24_11)], bl
- mov [edx+(nf24_32-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_33-nf24_11)], bl
- mov [edx+(nf24_34-nf24_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_41-nf24_11)], bl
- mov [edx+(nf24_42-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_43-nf24_11)], bl
- mov [edx+(nf24_44-nf24_11)], bh
-
- add edx, nf24_51-nf24_11
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_51-nf24_51)], bl
- mov [edx+(nf24_52-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_53-nf24_51)], bl
- mov [edx+(nf24_54-nf24_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_61-nf24_51)], bl
- mov [edx+(nf24_62-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_63-nf24_51)], bl
- mov [edx+(nf24_64-nf24_51)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_71-nf24_51)], bl
- mov [edx+(nf24_72-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_73-nf24_51)], bl
- mov [edx+(nf24_74-nf24_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_81-nf24_51)], bl
- mov [edx+(nf24_82-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_83-nf24_51)], bl
- mov [edx+(nf24_84-nf24_51)], bh
-
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf24_0 ; flush prefetch
- ALIGN 4
-nf24_0:
-nf24_11:mov ax, bx
- shl eax, 16
-nf24_12:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_13:mov ax, bx
- shl eax, 16
-nf24_14:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_21:mov ax, bx
- shl eax, 16
-nf24_22:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_23:mov ax, bx
- shl eax, 16
-nf24_24:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_31:mov ax, bx
- shl eax, 16
-nf24_32:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_33:mov ax, bx
- shl eax, 16
-nf24_34:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_41:mov ax, bx
- shl eax, 16
-nf24_42:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_43:mov ax, bx
- shl eax, 16
-nf24_44:mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*8-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf24_51:mov ax, bx
- shl eax, 16
-nf24_52:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_53:mov ax, bx
- shl eax, 16
-nf24_54:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_61:mov ax, bx
- shl eax, 16
-nf24_62:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_63:mov ax, bx
- shl eax, 16
-nf24_64:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_71:mov ax, bx
- shl eax, 16
-nf24_72:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_73:mov ax, bx
- shl eax, 16
-nf24_74:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_81:mov ax, bx
- shl eax, 16
-nf24_82:mov ax, bx
- mov [edi], eax
- add edi, esi
-nf24_83:mov ax, bx
- shl eax, 16
-nf24_84:mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+32
-nf40: ; 1x2 8x4x1 (12 bytes)
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf40_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_11-nf40_11)], bl
- mov [edx+(nf40_12-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_13-nf40_11)], bl
- mov [edx+(nf40_14-nf40_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_21-nf40_11)], bl
- mov [edx+(nf40_22-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_23-nf40_11)], bl
- mov [edx+(nf40_24-nf40_11)], bh
-
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_31-nf40_11)], bl
- mov [edx+(nf40_32-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_33-nf40_11)], bl
- mov [edx+(nf40_34-nf40_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_41-nf40_11)], bl
- mov [edx+(nf40_42-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_43-nf40_11)], bl
- mov [edx+(nf40_44-nf40_11)], bh
-
- add edx, nf40_51-nf40_11
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_51-nf40_51)], bl
- mov [edx+(nf40_52-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_53-nf40_51)], bl
- mov [edx+(nf40_54-nf40_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_61-nf40_51)], bl
- mov [edx+(nf40_62-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_63-nf40_51)], bl
- mov [edx+(nf40_64-nf40_51)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_71-nf40_51)], bl
- mov [edx+(nf40_72-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_73-nf40_51)], bl
- mov [edx+(nf40_74-nf40_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_81-nf40_51)], bl
- mov [edx+(nf40_82-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_83-nf40_51)], bl
- mov [edx+(nf40_84-nf40_51)], bh
-
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf40_0 ; flush prefetch
- ALIGN 4
-nf40_0:
-nf40_11:mov ax, bx
- shl eax, 16
-nf40_12:mov ax, bx
- mov [edi], eax
-nf40_13:mov ax, bx
- shl eax, 16
-nf40_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_21:mov ax, bx
- shl eax, 16
-nf40_22:mov ax, bx
- mov [edi], eax
-nf40_23:mov ax, bx
- shl eax, 16
-nf40_24:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_31:mov ax, bx
- shl eax, 16
-nf40_32:mov ax, bx
- mov [edi], eax
-nf40_33:mov ax, bx
- shl eax, 16
-nf40_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_41:mov ax, bx
- shl eax, 16
-nf40_42:mov ax, bx
- mov [edi], eax
-nf40_43:mov ax, bx
- shl eax, 16
-nf40_44:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf40_51:mov ax, bx
- shl eax, 16
-nf40_52:mov ax, bx
- mov [edi], eax
-nf40_53:mov ax, bx
- shl eax, 16
-nf40_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_61:mov ax, bx
- shl eax, 16
-nf40_62:mov ax, bx
- mov [edi], eax
-nf40_63:mov ax, bx
- shl eax, 16
-nf40_64:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_71:mov ax, bx
- shl eax, 16
-nf40_72:mov ax, bx
- mov [edi], eax
-nf40_73:mov ax, bx
- shl eax, 16
-nf40_74:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_81:mov ax, bx
- shl eax, 16
-nf40_82:mov ax, bx
- mov [edi], eax
-nf40_83:mov ax, bx
- shl eax, 16
-nf40_84:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf9: ; 8x8x2 (20 bytes)
-
- mov eax, [esi]
- cmp al, ah
- ja nf41
-
- shr eax, 16
- cmp al, ah
- ja nf25
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf9_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_11-nf9_11)], bl
- mov [edx+(nf9_12-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_13-nf9_11)], bl
- mov [edx+(nf9_14-nf9_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_15-nf9_11)], bl
- mov [edx+(nf9_16-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_17-nf9_11)], bl
- mov [edx+(nf9_18-nf9_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_21-nf9_11)], bl
- mov [edx+(nf9_22-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_23-nf9_11)], bl
- mov [edx+(nf9_24-nf9_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_25-nf9_11)], bl
- mov [edx+(nf9_26-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_27-nf9_11)], bl
- mov [edx+(nf9_28-nf9_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_31-nf9_11)], bl
- mov [edx+(nf9_32-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_33-nf9_11)], bl
- mov [edx+(nf9_34-nf9_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_35-nf9_11)], bl
- mov [edx+(nf9_36-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_37-nf9_11)], bl
- mov [edx+(nf9_38-nf9_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_41-nf9_11)], bl
- mov [edx+(nf9_42-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_43-nf9_11)], bl
- mov [edx+(nf9_44-nf9_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_45-nf9_11)], bl
- mov [edx+(nf9_46-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_47-nf9_11)], bl
- mov [edx+(nf9_48-nf9_11)], bh
-
-
- lea edx, [edx+(nf9_51-nf9_11)]
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_51-nf9_51)], bl
- mov [edx+(nf9_52-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_53-nf9_51)], bl
- mov [edx+(nf9_54-nf9_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_55-nf9_51)], bl
- mov [edx+(nf9_56-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_57-nf9_51)], bl
- mov [edx+(nf9_58-nf9_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_61-nf9_51)], bl
- mov [edx+(nf9_62-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_63-nf9_51)], bl
- mov [edx+(nf9_64-nf9_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_65-nf9_51)], bl
- mov [edx+(nf9_66-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_67-nf9_51)], bl
- mov [edx+(nf9_68-nf9_51)], bh
-
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_71-nf9_51)], bl
- mov [edx+(nf9_72-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_73-nf9_51)], bl
- mov [edx+(nf9_74-nf9_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_75-nf9_51)], bl
- mov [edx+(nf9_76-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_77-nf9_51)], bl
- mov [edx+(nf9_78-nf9_51)], bh
-
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_81-nf9_51)], bl
- mov [edx+(nf9_82-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_83-nf9_51)], bl
- mov [edx+(nf9_84-nf9_51)], bh
-
- mov al, [esi+19]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_85-nf9_51)], bl
- mov [edx+(nf9_86-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_87-nf9_51)], bl
- mov [edx+(nf9_88-nf9_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf9_0 ; flush prefetch
- ALIGN 4
-nf9_0:
-nf9_11: mov al, bl
-nf9_12: mov ah, bl
- shl eax, 16
-nf9_13: mov al, bl
-nf9_14: mov ah, bl
- mov [edi], eax
-
-nf9_15: mov al, bl
-nf9_16: mov ah, bl
- shl eax, 16
-nf9_17: mov al, bl
-nf9_18: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_21: mov al, bl
-nf9_22: mov ah, bl
- shl eax, 16
-nf9_23: mov al, bl
-nf9_24: mov ah, bl
- mov [edi], eax
-
-nf9_25: mov al, bl
-nf9_26: mov ah, bl
- shl eax, 16
-nf9_27: mov al, bl
-nf9_28: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_31: mov al, bl
-nf9_32: mov ah, bl
- shl eax, 16
-nf9_33: mov al, bl
-nf9_34: mov ah, bl
- mov [edi], eax
-
-nf9_35: mov al, bl
-nf9_36: mov ah, bl
- shl eax, 16
-nf9_37: mov al, bl
-nf9_38: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_41: mov al, bl
-nf9_42: mov ah, bl
- shl eax, 16
-nf9_43: mov al, bl
-nf9_44: mov ah, bl
- mov [edi], eax
-
-nf9_45: mov al, bl
-nf9_46: mov ah, bl
- shl eax, 16
-nf9_47: mov al, bl
-nf9_48: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_51: mov al, bl
-nf9_52: mov ah, bl
- shl eax, 16
-nf9_53: mov al, bl
-nf9_54: mov ah, bl
- mov [edi], eax
-
-nf9_55: mov al, bl
-nf9_56: mov ah, bl
- shl eax, 16
-nf9_57: mov al, bl
-nf9_58: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_61: mov al, bl
-nf9_62: mov ah, bl
- shl eax, 16
-nf9_63: mov al, bl
-nf9_64: mov ah, bl
- mov [edi], eax
-
-nf9_65: mov al, bl
-nf9_66: mov ah, bl
- shl eax, 16
-nf9_67: mov al, bl
-nf9_68: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_71: mov al, bl
-nf9_72: mov ah, bl
- shl eax, 16
-nf9_73: mov al, bl
-nf9_74: mov ah, bl
- mov [edi], eax
-
-nf9_75: mov al, bl
-nf9_76: mov ah, bl
- shl eax, 16
-nf9_77: mov al, bl
-nf9_78: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_81: mov al, bl
-nf9_82: mov ah, bl
- shl eax, 16
-nf9_83: mov al, bl
-nf9_84: mov ah, bl
- mov [edi], eax
-
-nf9_85: mov al, bl
-nf9_86: mov ah, bl
- shl eax, 16
-nf9_87: mov al, bl
-nf9_88: mov ah, bl
- mov [edi+4], eax
-
- add esi, 20
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+16
-nf25: ; low 4x4x2 (8 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 8
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf25_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_14-nf25_11)], bl
- mov [edx+(nf25_13-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_12-nf25_11)], bl
- mov [edx+(nf25_11-nf25_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_24-nf25_11)], bl
- mov [edx+(nf25_23-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_22-nf25_11)], bl
- mov [edx+(nf25_21-nf25_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_34-nf25_11)], bl
- mov [edx+(nf25_33-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_32-nf25_11)], bl
- mov [edx+(nf25_31-nf25_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_44-nf25_11)], bl
- mov [edx+(nf25_43-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_42-nf25_11)], bl
- mov [edx+(nf25_41-nf25_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf25_0 ; flush prefetch
- ALIGN 4
-nf25_0:
-nf25_11:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_12:mov al, bl
- mov ah, al
- mov [edi], eax
- mov [edi+edx], eax
-nf25_13:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_14:mov al, bl
- mov ah, al
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf25_21:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_22:mov al, bl
- mov ah, al
- mov [edi], eax
- mov [edi+edx], eax
-nf25_23:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_24:mov al, bl
- mov ah, al
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf25_31:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_32:mov al, bl
- mov ah, al
- mov [edi], eax
- mov [edi+edx], eax
-nf25_33:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_34:mov al, bl
- mov ah, al
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf25_41:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_42:mov al, bl
- mov ah, al
- mov [edi], eax
- mov [edi+edx], eax
-nf25_43:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_44:mov al, bl
- mov ah, al
- mov [edi+4], eax
- mov [edi+edx+4], eax
- add edi, edx
-
- add esi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+32
-nf41: ; low 4x8x2 (12 bytes)
- shr eax, 16
- cmp al, ah
- ja nf57
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf41_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_14-nf41_11)], bl
- mov [edx+(nf41_13-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_12-nf41_11)], bl
- mov [edx+(nf41_11-nf41_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_24-nf41_11)], bl
- mov [edx+(nf41_23-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_22-nf41_11)], bl
- mov [edx+(nf41_21-nf41_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_34-nf41_11)], bl
- mov [edx+(nf41_33-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_32-nf41_11)], bl
- mov [edx+(nf41_31-nf41_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_44-nf41_11)], bl
- mov [edx+(nf41_43-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_42-nf41_11)], bl
- mov [edx+(nf41_41-nf41_11)], bh
-
- lea edx, [edx+(nf41_51-nf41_11)]
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_54-nf41_51)], bl
- mov [edx+(nf41_53-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_52-nf41_51)], bl
- mov [edx+(nf41_51-nf41_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_64-nf41_51)], bl
- mov [edx+(nf41_63-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_62-nf41_51)], bl
- mov [edx+(nf41_61-nf41_51)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_74-nf41_51)], bl
- mov [edx+(nf41_73-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_72-nf41_51)], bl
- mov [edx+(nf41_71-nf41_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_84-nf41_51)], bl
- mov [edx+(nf41_83-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_82-nf41_51)], bl
- mov [edx+(nf41_81-nf41_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf41_0 ; flush prefetch
- ALIGN 4
-nf41_0:
-nf41_11:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_12:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_13:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_14:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_21:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_22:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_23:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_24:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_31:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_32:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_33:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_34:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_41:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_42:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_43:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_44:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_51:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_52:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_53:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_54:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_61:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_62:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_63:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_64:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_71:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_72:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_73:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_74:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_81:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_82:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_83:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_84:mov al, bl
- mov ah, al
- mov [edi+4], eax
-
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+48
-nf57: ; low 8x4x2 (12 bytes)
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf57_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_11-nf57_11)], bl
- mov [edx+(nf57_12-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_13-nf57_11)], bl
- mov [edx+(nf57_14-nf57_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_15-nf57_11)], bl
- mov [edx+(nf57_16-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_17-nf57_11)], bl
- mov [edx+(nf57_18-nf57_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_21-nf57_11)], bl
- mov [edx+(nf57_22-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_23-nf57_11)], bl
- mov [edx+(nf57_24-nf57_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_25-nf57_11)], bl
- mov [edx+(nf57_26-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_27-nf57_11)], bl
- mov [edx+(nf57_28-nf57_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_31-nf57_11)], bl
- mov [edx+(nf57_32-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_33-nf57_11)], bl
- mov [edx+(nf57_34-nf57_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_35-nf57_11)], bl
- mov [edx+(nf57_36-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_37-nf57_11)], bl
- mov [edx+(nf57_38-nf57_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_41-nf57_11)], bl
- mov [edx+(nf57_42-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_43-nf57_11)], bl
- mov [edx+(nf57_44-nf57_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_45-nf57_11)], bl
- mov [edx+(nf57_46-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_47-nf57_11)], bl
- mov [edx+(nf57_48-nf57_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf57_0 ; flush prefetch
- ALIGN 4
-nf57_0:
-nf57_11:mov al, bl
-nf57_12:mov ah, bl
- shl eax, 16
-nf57_13:mov al, bl
-nf57_14:mov ah, bl
- mov [edi], eax
- mov [edi+edx], eax
-
-nf57_15:mov al, bl
-nf57_16:mov ah, bl
- shl eax, 16
-nf57_17:mov al, bl
-nf57_18:mov ah, bl
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf57_21:mov al, bl
-nf57_22:mov ah, bl
- shl eax, 16
-nf57_23:mov al, bl
-nf57_24:mov ah, bl
- mov [edi], eax
- mov [edi+edx], eax
-
-nf57_25:mov al, bl
-nf57_26:mov ah, bl
- shl eax, 16
-nf57_27:mov al, bl
-nf57_28:mov ah, bl
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf57_31:mov al, bl
-nf57_32:mov ah, bl
- shl eax, 16
-nf57_33:mov al, bl
-nf57_34:mov ah, bl
- mov [edi], eax
- mov [edi+edx], eax
-
-nf57_35:mov al, bl
-nf57_36:mov ah, bl
- shl eax, 16
-nf57_37:mov al, bl
-nf57_38:mov ah, bl
- mov [edi+4], eax
- mov [edi+edx+4], eax
- lea edi, [edi+edx*2]
-
-nf57_41:mov al, bl
-nf57_42:mov ah, bl
- shl eax, 16
-nf57_43:mov al, bl
-nf57_44:mov ah, bl
- mov [edi], eax
- mov [edi+edx], eax
-
-nf57_45:mov al, bl
-nf57_46:mov ah, bl
- shl eax, 16
-nf57_47:mov al, bl
-nf57_48:mov ah, bl
- mov [edi+4], eax
- mov [edi+edx+4], eax
- add edi, edx
-
- add esi, 12
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf10: ; 2x2 4x4x2 (32 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf26
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf10_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_11-nf10_11)], bl
- mov [edx+(nf10_12-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_13-nf10_11)], bl
- mov [edx+(nf10_14-nf10_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_15-nf10_11)], bl
- mov [edx+(nf10_16-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_17-nf10_11)], bl
- mov [edx+(nf10_18-nf10_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_21-nf10_11)], bl
- mov [edx+(nf10_22-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_23-nf10_11)], bl
- mov [edx+(nf10_24-nf10_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_25-nf10_11)], bl
- mov [edx+(nf10_26-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_27-nf10_11)], bl
- mov [edx+(nf10_28-nf10_11)], bh
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_31-nf10_11)], bl
- mov [edx+(nf10_32-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_33-nf10_11)], bl
- mov [edx+(nf10_34-nf10_11)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_35-nf10_11)], bl
- mov [edx+(nf10_36-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_37-nf10_11)], bl
- mov [edx+(nf10_38-nf10_11)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_41-nf10_11)], bl
- mov [edx+(nf10_42-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_43-nf10_11)], bl
- mov [edx+(nf10_44-nf10_11)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_45-nf10_11)], bl
- mov [edx+(nf10_46-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_47-nf10_11)], bl
- mov [edx+(nf10_48-nf10_11)], bh
-
-
- lea edx, [edx+(nf10_51-nf10_11)]
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_51-nf10_51)], bl
- mov [edx+(nf10_52-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_53-nf10_51)], bl
- mov [edx+(nf10_54-nf10_51)], bh
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_55-nf10_51)], bl
- mov [edx+(nf10_56-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_57-nf10_51)], bl
- mov [edx+(nf10_58-nf10_51)], bh
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_61-nf10_51)], bl
- mov [edx+(nf10_62-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_63-nf10_51)], bl
- mov [edx+(nf10_64-nf10_51)], bh
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_65-nf10_51)], bl
- mov [edx+(nf10_66-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_67-nf10_51)], bl
- mov [edx+(nf10_68-nf10_51)], bh
-
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_71-nf10_51)], bl
- mov [edx+(nf10_72-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_73-nf10_51)], bl
- mov [edx+(nf10_74-nf10_51)], bh
-
- mov al, [esi+29]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_75-nf10_51)], bl
- mov [edx+(nf10_76-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_77-nf10_51)], bl
- mov [edx+(nf10_78-nf10_51)], bh
-
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_81-nf10_51)], bl
- mov [edx+(nf10_82-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_83-nf10_51)], bl
- mov [edx+(nf10_84-nf10_51)], bh
-
- mov al, [esi+31]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_85-nf10_51)], bl
- mov [edx+(nf10_86-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_87-nf10_51)], bl
- mov [edx+(nf10_88-nf10_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf10_0 ; flush prefetch
- ALIGN 4
-nf10_0:
-nf10_11:mov al, bl
-nf10_12:mov ah, bl
- shl eax, 16
-nf10_13:mov al, bl
-nf10_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_15:mov al, bl
-nf10_16:mov ah, bl
- shl eax, 16
-nf10_17:mov al, bl
-nf10_18:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_21:mov al, bl
-nf10_22:mov ah, bl
- shl eax, 16
-nf10_23:mov al, bl
-nf10_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_25:mov al, bl
-nf10_26:mov ah, bl
- shl eax, 16
-nf10_27:mov al, bl
-nf10_28:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+8]
- mov cx, [esi+10]
-
-nf10_31:mov al, bl
-nf10_32:mov ah, bl
- shl eax, 16
-nf10_33:mov al, bl
-nf10_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_35:mov al, bl
-nf10_36:mov ah, bl
- shl eax, 16
-nf10_37:mov al, bl
-nf10_38:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_41:mov al, bl
-nf10_42:mov ah, bl
- shl eax, 16
-nf10_43:mov al, bl
-nf10_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_45:mov al, bl
-nf10_46:mov ah, bl
- shl eax, 16
-nf10_47:mov al, bl
-nf10_48:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*8-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+16]
- mov cx, [esi+18]
-
-nf10_51:mov al, bl
-nf10_52:mov ah, bl
- shl eax, 16
-nf10_53:mov al, bl
-nf10_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_55:mov al, bl
-nf10_56:mov ah, bl
- shl eax, 16
-nf10_57:mov al, bl
-nf10_58:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_61:mov al, bl
-nf10_62:mov ah, bl
- shl eax, 16
-nf10_63:mov al, bl
-nf10_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_65:mov al, bl
-nf10_66:mov ah, bl
- shl eax, 16
-nf10_67:mov al, bl
-nf10_68:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+24]
- mov cx, [esi+26]
-
-nf10_71:mov al, bl
-nf10_72:mov ah, bl
- shl eax, 16
-nf10_73:mov al, bl
-nf10_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_75:mov al, bl
-nf10_76:mov ah, bl
- shl eax, 16
-nf10_77:mov al, bl
-nf10_78:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_81:mov al, bl
-nf10_82:mov ah, bl
- shl eax, 16
-nf10_83:mov al, bl
-nf10_84:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_85:mov al, bl
-nf10_86:mov ah, bl
- shl eax, 16
-nf10_87:mov al, bl
-nf10_88:mov ah, bl
- mov [edi], eax
-
- add esi, 32
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+16
-nf26: ; 2x1 4x8x2 (24 bytes)
-
- mov ax, [esi+12]
- cmp al, ah
- ja nf42
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf26_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_11-nf26_11)], bl
- mov [edx+(nf26_12-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_13-nf26_11)], bl
- mov [edx+(nf26_14-nf26_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_15-nf26_11)], bl
- mov [edx+(nf26_16-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_17-nf26_11)], bl
- mov [edx+(nf26_18-nf26_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_21-nf26_11)], bl
- mov [edx+(nf26_22-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_23-nf26_11)], bl
- mov [edx+(nf26_24-nf26_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_25-nf26_11)], bl
- mov [edx+(nf26_26-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_27-nf26_11)], bl
- mov [edx+(nf26_28-nf26_11)], bh
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_31-nf26_11)], bl
- mov [edx+(nf26_32-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_33-nf26_11)], bl
- mov [edx+(nf26_34-nf26_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_35-nf26_11)], bl
- mov [edx+(nf26_36-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_37-nf26_11)], bl
- mov [edx+(nf26_38-nf26_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_41-nf26_11)], bl
- mov [edx+(nf26_42-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_43-nf26_11)], bl
- mov [edx+(nf26_44-nf26_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_45-nf26_11)], bl
- mov [edx+(nf26_46-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_47-nf26_11)], bl
- mov [edx+(nf26_48-nf26_11)], bh
-
-
- lea edx, [edx+(nf26_51-nf26_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_51-nf26_51)], bl
- mov [edx+(nf26_52-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_53-nf26_51)], bl
- mov [edx+(nf26_54-nf26_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_55-nf26_51)], bl
- mov [edx+(nf26_56-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_57-nf26_51)], bl
- mov [edx+(nf26_58-nf26_51)], bh
-
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_61-nf26_51)], bl
- mov [edx+(nf26_62-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_63-nf26_51)], bl
- mov [edx+(nf26_64-nf26_51)], bh
-
- mov al, [esi+19]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_65-nf26_51)], bl
- mov [edx+(nf26_66-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_67-nf26_51)], bl
- mov [edx+(nf26_68-nf26_51)], bh
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_71-nf26_51)], bl
- mov [edx+(nf26_72-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_73-nf26_51)], bl
- mov [edx+(nf26_74-nf26_51)], bh
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_75-nf26_51)], bl
- mov [edx+(nf26_76-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_77-nf26_51)], bl
- mov [edx+(nf26_78-nf26_51)], bh
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_81-nf26_51)], bl
- mov [edx+(nf26_82-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_83-nf26_51)], bl
- mov [edx+(nf26_84-nf26_51)], bh
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_85-nf26_51)], bl
- mov [edx+(nf26_86-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_87-nf26_51)], bl
- mov [edx+(nf26_88-nf26_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf26_0 ; flush prefetch
- ALIGN 4
-nf26_0:
-nf26_11:mov al, bl
-nf26_12:mov ah, bl
- shl eax, 16
-nf26_13:mov al, bl
-nf26_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_15:mov al, bl
-nf26_16:mov ah, bl
- shl eax, 16
-nf26_17:mov al, bl
-nf26_18:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_21:mov al, bl
-nf26_22:mov ah, bl
- shl eax, 16
-nf26_23:mov al, bl
-nf26_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_25:mov al, bl
-nf26_26:mov ah, bl
- shl eax, 16
-nf26_27:mov al, bl
-nf26_28:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_31:mov al, bl
-nf26_32:mov ah, bl
- shl eax, 16
-nf26_33:mov al, bl
-nf26_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_35:mov al, bl
-nf26_36:mov ah, bl
- shl eax, 16
-nf26_37:mov al, bl
-nf26_38:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_41:mov al, bl
-nf26_42:mov ah, bl
- shl eax, 16
-nf26_43:mov al, bl
-nf26_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_45:mov al, bl
-nf26_46:mov ah, bl
- shl eax, 16
-nf26_47:mov al, bl
-nf26_48:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*8-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf26_51:mov al, bl
-nf26_52:mov ah, bl
- shl eax, 16
-nf26_53:mov al, bl
-nf26_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_55:mov al, bl
-nf26_56:mov ah, bl
- shl eax, 16
-nf26_57:mov al, bl
-nf26_58:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_61:mov al, bl
-nf26_62:mov ah, bl
- shl eax, 16
-nf26_63:mov al, bl
-nf26_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_65:mov al, bl
-nf26_66:mov ah, bl
- shl eax, 16
-nf26_67:mov al, bl
-nf26_68:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_71:mov al, bl
-nf26_72:mov ah, bl
- shl eax, 16
-nf26_73:mov al, bl
-nf26_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_75:mov al, bl
-nf26_76:mov ah, bl
- shl eax, 16
-nf26_77:mov al, bl
-nf26_78:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_81:mov al, bl
-nf26_82:mov ah, bl
- shl eax, 16
-nf26_83:mov al, bl
-nf26_84:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_85:mov al, bl
-nf26_86:mov ah, bl
- shl eax, 16
-nf26_87:mov al, bl
-nf26_88:mov ah, bl
- mov [edi], eax
-
- add esi, 24
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+32
-nf42: ; 1x2 8x4x2 (24 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf42_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_11-nf42_11)], bl
- mov [edx+(nf42_12-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_13-nf42_11)], bl
- mov [edx+(nf42_14-nf42_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_15-nf42_11)], bl
- mov [edx+(nf42_16-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_17-nf42_11)], bl
- mov [edx+(nf42_18-nf42_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_21-nf42_11)], bl
- mov [edx+(nf42_22-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_23-nf42_11)], bl
- mov [edx+(nf42_24-nf42_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_25-nf42_11)], bl
- mov [edx+(nf42_26-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_27-nf42_11)], bl
- mov [edx+(nf42_28-nf42_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_31-nf42_11)], bl
- mov [edx+(nf42_32-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_33-nf42_11)], bl
- mov [edx+(nf42_34-nf42_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_35-nf42_11)], bl
- mov [edx+(nf42_36-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_37-nf42_11)], bl
- mov [edx+(nf42_38-nf42_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_41-nf42_11)], bl
- mov [edx+(nf42_42-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_43-nf42_11)], bl
- mov [edx+(nf42_44-nf42_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_45-nf42_11)], bl
- mov [edx+(nf42_46-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_47-nf42_11)], bl
- mov [edx+(nf42_48-nf42_11)], bh
-
-
- lea edx, [edx+(nf42_51-nf42_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_51-nf42_51)], bl
- mov [edx+(nf42_52-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_53-nf42_51)], bl
- mov [edx+(nf42_54-nf42_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_55-nf42_51)], bl
- mov [edx+(nf42_56-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_57-nf42_51)], bl
- mov [edx+(nf42_58-nf42_51)], bh
-
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_61-nf42_51)], bl
- mov [edx+(nf42_62-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_63-nf42_51)], bl
- mov [edx+(nf42_64-nf42_51)], bh
-
- mov al, [esi+19]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_65-nf42_51)], bl
- mov [edx+(nf42_66-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_67-nf42_51)], bl
- mov [edx+(nf42_68-nf42_51)], bh
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_71-nf42_51)], bl
- mov [edx+(nf42_72-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_73-nf42_51)], bl
- mov [edx+(nf42_74-nf42_51)], bh
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_75-nf42_51)], bl
- mov [edx+(nf42_76-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_77-nf42_51)], bl
- mov [edx+(nf42_78-nf42_51)], bh
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_81-nf42_51)], bl
- mov [edx+(nf42_82-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_83-nf42_51)], bl
- mov [edx+(nf42_84-nf42_51)], bh
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_85-nf42_51)], bl
- mov [edx+(nf42_86-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_87-nf42_51)], bl
- mov [edx+(nf42_88-nf42_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf42_0 ; flush prefetch
- ALIGN 4
-nf42_0:
-nf42_11:mov al, bl
-nf42_12:mov ah, bl
- shl eax, 16
-nf42_13:mov al, bl
-nf42_14:mov ah, bl
- mov [edi], eax
-
-nf42_15:mov al, bl
-nf42_16:mov ah, bl
- shl eax, 16
-nf42_17:mov al, bl
-nf42_18:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_21:mov al, bl
-nf42_22:mov ah, bl
- shl eax, 16
-nf42_23:mov al, bl
-nf42_24:mov ah, bl
- mov [edi], eax
-
-nf42_25:mov al, bl
-nf42_26:mov ah, bl
- shl eax, 16
-nf42_27:mov al, bl
-nf42_28:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_31:mov al, bl
-nf42_32:mov ah, bl
- shl eax, 16
-nf42_33:mov al, bl
-nf42_34:mov ah, bl
- mov [edi], eax
-
-nf42_35:mov al, bl
-nf42_36:mov ah, bl
- shl eax, 16
-nf42_37:mov al, bl
-nf42_38:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_41:mov al, bl
-nf42_42:mov ah, bl
- shl eax, 16
-nf42_43:mov al, bl
-nf42_44:mov ah, bl
- mov [edi], eax
-
-nf42_45:mov al, bl
-nf42_46:mov ah, bl
- shl eax, 16
-nf42_47:mov al, bl
-nf42_48:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf42_51:mov al, bl
-nf42_52:mov ah, bl
- shl eax, 16
-nf42_53:mov al, bl
-nf42_54:mov ah, bl
- mov [edi], eax
-
-nf42_55:mov al, bl
-nf42_56:mov ah, bl
- shl eax, 16
-nf42_57:mov al, bl
-nf42_58:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_61:mov al, bl
-nf42_62:mov ah, bl
- shl eax, 16
-nf42_63:mov al, bl
-nf42_64:mov ah, bl
- mov [edi], eax
-
-nf42_65:mov al, bl
-nf42_66:mov ah, bl
- shl eax, 16
-nf42_67:mov al, bl
-nf42_68:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_71:mov al, bl
-nf42_72:mov ah, bl
- shl eax, 16
-nf42_73:mov al, bl
-nf42_74:mov ah, bl
- mov [edi], eax
-
-nf42_75:mov al, bl
-nf42_76:mov ah, bl
- shl eax, 16
-nf42_77:mov al, bl
-nf42_78:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_81:mov al, bl
-nf42_82:mov ah, bl
- shl eax, 16
-nf42_83:mov al, bl
-nf42_84:mov ah, bl
- mov [edi], eax
-
-nf42_85:mov al, bl
-nf42_86:mov ah, bl
- shl eax, 16
-nf42_87:mov al, bl
-nf42_88:mov ah, bl
- mov [edi+4], eax
-
- add esi, 24
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf11: ; 8x8x8 (64 bytes)
-if 0 ;debug
- add esi, 64
- mov eax, 0fefefefeH
-; mov ebx, eax
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
-
- mov eax, [esi] ;0
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+8] ;1
- mov [edi], eax
- mov eax, [esi+12]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+16] ;2
- mov [edi], eax
- mov eax, [esi+20]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+24] ;3
- mov [edi], eax
- mov eax, [esi+28]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+32] ;4
- mov [edi], eax
- mov eax, [esi+36]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+40] ;5
- mov [edi], eax
- mov eax, [esi+44]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+48] ;6
- mov [edi], eax
- mov eax, [esi+52]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+56] ;7
- mov [edi], eax
- mov eax, [esi+60]
- mov [edi+4], eax
-
- add esi, 64
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-;----------------------------------------
- ALIGN 4
-nf12: ; low 4x4x8 (16 bytes)
- mov edx, nf_width
-
- mov eax, [esi]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- mov [edi+edx], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov eax, [esi+4]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- mov [edi+edx], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov eax, [esi+8]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- mov [edi+edx], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov eax, [esi+12]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- mov [edi+edx], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- mov [edi+edx+4], ebx
- add edi, edx
-
- sub edi, nfpk_back_right
- add esi, 16
- retn
-
-;----------------------------------------
- ALIGN 4
-nf13: ; 2x2 4x4x0 (4 bytes)
- mov edx, nf_width
-
- mov cl, [esi]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+1]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- mov [edi+edx], eax
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
- mov [edi], eax
- mov [edi+4], ebx
- mov [edi+edx], eax
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov cl, [esi+2]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+3]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- mov [edi+edx], eax
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
- mov [edi], eax
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right
- add esi, 4
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf14: ; 8x8x0 (1 byte)
-if 0 ;debug
- jmp nf0
-endif
- mov bl, [esi] ; Copy color into 8 positions
- inc esi
- mov bh, bl
- mov eax, ebx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
- jmp nf_solid
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf15: ; mix 8x8x0 (2 bytes)
-if 0 ;debug
- inc esi
- jmp nf0
-endif
- mov bx, [esi] ; Copy 2 colors into 8 positions
- add esi, 2 ; in a checkerboard
- mov ax, bx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
- rol ebx, 8
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
-nf_solid:
- mov edx, nf_width
-
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-nfPkDecomp ENDP
-
-; Half vertical resolution version (skip odd lines)
-;
-nfPkDecompH PROC USES ESI EDI EBX, \
- ops:PTRBYTE, comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row:DWORD
- LOCAL DiffBufPtrs:DWORD
-
- LOCAL nfpk_back_right: DWORD
- LOCAL wcnt:DWORD
-
- LOG_LABEL "StartPkDecomp"
-
-.data
-nfpk_OpTblH label dword
- dword offset nf0 ; Prev Same (0)
- dword offset nf1 ; No change (and copied to screen) (0)
- dword offset nf2 ; Near shift from older part of current buf (1)
- dword offset nf3 ; Near shift from newer part of current buf (1)
- dword offset nf4 ; Near shift from previous buffer (1)
- dword offset nf5 ; Far shift from previous buffer (2)
- dword offset nf6 ; Far shift from current buffer (2)
- ; [Or if COMPOPS, run of no changes (0)]
- dword offset nf7 ; 8x8x1 (10 bytes) or low 4x4x1 (4 bytes)
- dword offset nf8 ; 2x2 4x4x1 (16 bytes) or 2x1 4x8x1 (12 bytes) or 1x2 8x4x1 (12 bytes)
- dword offset nf9 ; 8x8x2 (20 bytes) or low 4x4x2 (8 bytes) or
- ; low 4x8x2 (12 bytes) or low 8x4x2 (12 bytes)
- dword offset nf10 ; 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- dword offset nf11 ; 8x8x8 (64 bytes)
- dword offset nf12 ; low 4x4x8 (16 bytes)
- dword offset nf13 ; 2x2 4x4x0 (ie 2x2x8) (4 bytes)
- dword offset nf14 ; 8x8x0 (1 byte)
- dword offset nf15 ; mix 8x8x0 (2 bytes)
-.code
-
-ifdef SYMANTEC
- mov ebx, ds ; Allow DS to access code
- mov ecx, 0
- mov ax, 3505h
- int 21h
-endif
-
- NF_DECOMP_INIT 0
-
- mov eax, nf_width
- shl eax, 2
- sub eax, nf_new_w
- mov new_row, eax
-
- shr nf_new_h, 1
-
- mov eax, nf_width
- lea eax, [eax*2+eax-SWIDTH]
- mov nfpk_back_right, eax
-
- mov esi, comp
- mov edi, tbuf
-nf_StartRow:
- mov eax, w
- shr eax, 1
- mov wcnt,eax
- ALIGN 4
-nf_NextPair:
- dec wcnt
- js nf_NextRow
- mov ebx, ops
- mov al, [ebx]
- inc ebx
- mov ops, ebx
-
- xor ebx, ebx
- mov bl, al
- shr bl, 4
- and eax, 0Fh
- push offset nf_NextPair
- push nfpk_OpTblH[ebx*4]
- jmp nfpk_OpTblH[eax*4]
-
-nf_NextRow:
- add edi, new_row
- dec h
- jnz nf_StartRow
- LOG_LABEL "EndPkDecomp"
-
-ifdef SYMANTEC
- mov ebx, ds ; Disable DS from accessing code
- mov ecx, offset DGROUP:_data_bottom[-1]
- mov ax, 3505h
- int 21h
-endif
- ret
-
-;----------------------------------------
- ALIGN 4
-nf0: ; No change from previous buffer
- mov eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf1: ; No change (and copied to screen)
- add edi, SWIDTH
- retn
-
-;----------------------------------------
- ALIGN 4
-nf2: ; Near shift from older part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
-nf_xyc_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- add bl, 080h
- adc bl, 080h
- sar bl, 1
- add eax, nfpk_ShiftY[ebx*4]
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf3: ; Near shift from newer part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
- neg al
- neg ah
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf4: ; Near shift from previous buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP1[eax*2]
- jmp nf_xyp_shift
-
-;----------------------------------------
- ALIGN 4
-nf5: ; Far shift from previous buffer
- mov ax, [esi]
- add esi, 2
-nf_xyp_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- add bl, 080h
- adc bl, 080h
- sar bl, 1
- add eax, nfpk_ShiftY[ebx*4]
- add eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-
-if COMPOPS
-
-nf6: ; Run of no changes (must only appear in first nibble opcodes)
- ; Next nibble k specifies 2k+4 squares with no changes
- add esp, 4 ; Next nibble is not an opcode
- add ebx, 2 ; (minimum of 4 squares)
- ALIGN 4
-nf6a: add edi, SWIDTH*2 ; Advance over two squares
- dec ebx
- jz nf6z ; Last pair of squares
- dec wcnt ; Same row?
- jns nf6a ; Yes
- add edi, new_row ; Advance to next row
- dec h ; Decrement row count (should never become zero here)
- mov eax, w ; Reset wcnt
- shr eax ,1
- dec eax
- mov wcnt, eax
- jmp nf6a
-
-nf6z: retn
-
-else
-
-nf6: ; Far shift from current buffer
- mov ax, [esi]
- add esi, 2
- jmp nf_xyc_shift
-endif
-
-;----------------------------------------
- ALIGN 4
-nf_shift:
-if 0 ;debug
- mov eax, 0
- mov ebx, eax
- jmp nf_solid
-endif
- mov ebx, esi ; save esi
- lea esi, [edi+eax]
- mov edx, nf_width
-
- REPEAT 3
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- add esi, edx
- add edi, edx
- ENDM
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- mov esi, ebx ; restore esi
- retn
-
-;----------------------------------------
- ALIGN 4
-nf7: ; 8x8x1 (10 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf23
-
-if 0 ;debug
- add esi, 10
- mov eax, 0fefefefeH
- mov ebx, eax
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf7_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_11-nf7_11)], bl
- mov [edx+(nf7_12-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_13-nf7_11)], bl
- mov [edx+(nf7_14-nf7_11)], bh
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_31-nf7_11)], bl
- mov [edx+(nf7_32-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_33-nf7_11)], bl
- mov [edx+(nf7_34-nf7_11)], bh
-
- lea edx, [edx+(nf7_51-nf7_11)]
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_51-nf7_51)], bl
- mov [edx+(nf7_52-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_53-nf7_51)], bl
- mov [edx+(nf7_54-nf7_51)], bh
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_71-nf7_51)], bl
- mov [edx+(nf7_72-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_73-nf7_51)], bl
- mov [edx+(nf7_74-nf7_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi,nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
- jmp nf7_0 ; flush prefetch
- ALIGN 4
-nf7_0:
-nf7_11: mov ax, bx
- shl eax, 16
-nf7_12: mov ax, bx
- mov [edi], eax
-nf7_13: mov ax, bx
- shl eax, 16
-nf7_14: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_31: mov ax, bx
- shl eax, 16
-nf7_32: mov ax, bx
- mov [edi], eax
-nf7_33: mov ax, bx
- shl eax, 16
-nf7_34: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_51: mov ax, bx
- shl eax, 16
-nf7_52: mov ax, bx
- mov [edi], eax
-nf7_53: mov ax, bx
- shl eax, 16
-nf7_54: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_71: mov ax, bx
- shl eax, 16
-nf7_72: mov ax, bx
- mov [edi], eax
-nf7_73: mov ax, bx
- shl eax, 16
-nf7_74: mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 10
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf7+16
-nf23: ; low 4x4x1 (4 bytes)
-
- xor eax, eax
- lea ecx, nfpk_mov4l
- lea edx, byte ptr ds:nf23_11+2
-
- mov al, [esi+2]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_11-nf23_11)], bl
- mov [edx+(nf23_12-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_13-nf23_11)], bl
- mov [edx+(nf23_14-nf23_11)], bh
-
- mov al, [esi+2]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_31-nf23_11)], bl
- mov [edx+(nf23_32-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_33-nf23_11)], bl
- mov [edx+(nf23_34-nf23_11)], bh
-
-
- mov al, [esi+3]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_51-nf23_11)], bl
- mov [edx+(nf23_52-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_53-nf23_11)], bl
- mov [edx+(nf23_54-nf23_11)], bh
-
- mov al, [esi+3]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_71-nf23_11)], bl
- mov [edx+(nf23_72-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_73-nf23_11)], bl
- mov [edx+(nf23_74-nf23_11)], bh
-
- mov edx, nf_width
-
- ; load bx,cx with 00,11 color combinations
- mov bx, [esi]
- mov cl, bh
- mov bh, bl
- mov ch, cl
-
- jmp nf23_0 ; flush prefetch
- ALIGN 4
-nf23_0:
-
-nf23_11:mov ax, bx
- shl eax, 16
-nf23_12:mov ax, bx
- mov [edi], eax
-
-nf23_13:mov ax, bx
- shl eax, 16
-nf23_14:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_31:mov ax, bx
- shl eax, 16
-nf23_32:mov ax, bx
- mov [edi], eax
-
-nf23_33:mov ax, bx
- shl eax, 16
-nf23_34:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_51:mov ax, bx
- shl eax, 16
-nf23_52:mov ax, bx
- mov [edi], eax
-
-nf23_53:mov ax, bx
- shl eax, 16
-nf23_54:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_71:mov ax, bx
- shl eax, 16
-nf23_72:mov ax, bx
- mov [edi], eax
-
-nf23_73:mov ax, bx
- shl eax, 16
-nf23_74:mov ax, bx
- mov [edi+4], eax
-
- sub edi, nfpk_back_right
- add esi, 4
- retn
-
-;----------------------------------------
- ALIGN 4
-nf8: ; 2x2 4x4x1 (16 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf24
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf8_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_11-nf8_11)], bl
- mov [edx+(nf8_12-nf8_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_21-nf8_11)], bl
- mov [edx+(nf8_22-nf8_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_31-nf8_11)], bl
- mov [edx+(nf8_32-nf8_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_41-nf8_11)], bl
- mov [edx+(nf8_42-nf8_11)], bh
-
- add edx, nf8_51-nf8_11
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_51-nf8_51)], bl
- mov [edx+(nf8_52-nf8_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_61-nf8_51)], bl
- mov [edx+(nf8_62-nf8_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_71-nf8_51)], bl
- mov [edx+(nf8_72-nf8_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_81-nf8_51)], bl
- mov [edx+(nf8_82-nf8_51)], bh
-
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf8_0 ; flush prefetch
- ALIGN 4
-nf8_0:
-nf8_11: mov ax, bx
- shl eax, 16
-nf8_12: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_21: mov ax, bx
- shl eax, 16
-nf8_22: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+4]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_31: mov ax, bx
- shl eax, 16
-nf8_32: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_41: mov ax, bx
- shl eax, 16
-nf8_42: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*4-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+8]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_51: mov ax, bx
- shl eax, 16
-nf8_52: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_61: mov ax, bx
- shl eax, 16
-nf8_62: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+12]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_71: mov ax, bx
- shl eax, 16
-nf8_72: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_81: mov ax, bx
- shl eax, 16
-nf8_82: mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+16
-nf24: ; 2x1 4x8x1 (12 bytes)
-
- mov ax, [esi+6]
- cmp al, ah
- ja nf40
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf24_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_11-nf24_11)], bl
- mov [edx+(nf24_12-nf24_11)], bh
-
- mov al, [esi+3]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_21-nf24_11)], bl
- mov [edx+(nf24_22-nf24_11)], bh
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_31-nf24_11)], bl
- mov [edx+(nf24_32-nf24_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_41-nf24_11)], bl
- mov [edx+(nf24_42-nf24_11)], bh
-
- add edx, nf24_51-nf24_11
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_51-nf24_51)], bl
- mov [edx+(nf24_52-nf24_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_61-nf24_51)], bl
- mov [edx+(nf24_62-nf24_51)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_71-nf24_51)], bl
- mov [edx+(nf24_72-nf24_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_81-nf24_51)], bl
- mov [edx+(nf24_82-nf24_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf24_0 ; flush prefetch
- ALIGN 4
-nf24_0:
-nf24_11:mov ax, bx
- shl eax, 16
-nf24_12:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_21:mov ax, bx
- shl eax, 16
-nf24_22:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_31:mov ax, bx
- shl eax, 16
-nf24_32:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_41:mov ax, bx
- shl eax, 16
-nf24_42:mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*4-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf24_51:mov ax, bx
- shl eax, 16
-nf24_52:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_61:mov ax, bx
- shl eax, 16
-nf24_62:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_71:mov ax, bx
- shl eax, 16
-nf24_72:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_81:mov ax, bx
- shl eax, 16
-nf24_82:mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+32
-nf40: ; 1x2 8x4x1 (12 bytes)
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf40_11+2
-
- mov al, [esi+2]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_11-nf40_11)], bl
- mov [edx+(nf40_12-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_13-nf40_11)], bl
- mov [edx+(nf40_14-nf40_11)], bh
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_31-nf40_11)], bl
- mov [edx+(nf40_32-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_33-nf40_11)], bl
- mov [edx+(nf40_34-nf40_11)], bh
-
- add edx, nf40_51-nf40_11
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_51-nf40_51)], bl
- mov [edx+(nf40_52-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_53-nf40_51)], bl
- mov [edx+(nf40_54-nf40_51)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_71-nf40_51)], bl
- mov [edx+(nf40_72-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_73-nf40_51)], bl
- mov [edx+(nf40_74-nf40_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf40_0 ; flush prefetch
- ALIGN 4
-nf40_0:
-nf40_11:mov ax, bx
- shl eax, 16
-nf40_12:mov ax, bx
- mov [edi], eax
-nf40_13:mov ax, bx
- shl eax, 16
-nf40_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_31:mov ax, bx
- shl eax, 16
-nf40_32:mov ax, bx
- mov [edi], eax
-nf40_33:mov ax, bx
- shl eax, 16
-nf40_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf40_51:mov ax, bx
- shl eax, 16
-nf40_52:mov ax, bx
- mov [edi], eax
-nf40_53:mov ax, bx
- shl eax, 16
-nf40_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_71:mov ax, bx
- shl eax, 16
-nf40_72:mov ax, bx
- mov [edi], eax
-nf40_73:mov ax, bx
- shl eax, 16
-nf40_74:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf9: ; 8x8x2 (20 bytes)
-
- mov eax, [esi]
- cmp al, ah
- ja nf41
-
- shr eax, 16
- cmp al, ah
- ja nf25
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf9_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_11-nf9_11)], bl
- mov [edx+(nf9_12-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_13-nf9_11)], bl
- mov [edx+(nf9_14-nf9_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_15-nf9_11)], bl
- mov [edx+(nf9_16-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_17-nf9_11)], bl
- mov [edx+(nf9_18-nf9_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_31-nf9_11)], bl
- mov [edx+(nf9_32-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_33-nf9_11)], bl
- mov [edx+(nf9_34-nf9_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_35-nf9_11)], bl
- mov [edx+(nf9_36-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_37-nf9_11)], bl
- mov [edx+(nf9_38-nf9_11)], bh
-
- lea edx, [edx+(nf9_51-nf9_11)]
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_51-nf9_51)], bl
- mov [edx+(nf9_52-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_53-nf9_51)], bl
- mov [edx+(nf9_54-nf9_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_55-nf9_51)], bl
- mov [edx+(nf9_56-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_57-nf9_51)], bl
- mov [edx+(nf9_58-nf9_51)], bh
-
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_71-nf9_51)], bl
- mov [edx+(nf9_72-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_73-nf9_51)], bl
- mov [edx+(nf9_74-nf9_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_75-nf9_51)], bl
- mov [edx+(nf9_76-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_77-nf9_51)], bl
- mov [edx+(nf9_78-nf9_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf9_0 ; flush prefetch
- ALIGN 4
-nf9_0:
-nf9_11: mov al, bl
-nf9_12: mov ah, bl
- shl eax, 16
-nf9_13: mov al, bl
-nf9_14: mov ah, bl
- mov [edi], eax
-
-nf9_15: mov al, bl
-nf9_16: mov ah, bl
- shl eax, 16
-nf9_17: mov al, bl
-nf9_18: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_31: mov al, bl
-nf9_32: mov ah, bl
- shl eax, 16
-nf9_33: mov al, bl
-nf9_34: mov ah, bl
- mov [edi], eax
-
-nf9_35: mov al, bl
-nf9_36: mov ah, bl
- shl eax, 16
-nf9_37: mov al, bl
-nf9_38: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_51: mov al, bl
-nf9_52: mov ah, bl
- shl eax, 16
-nf9_53: mov al, bl
-nf9_54: mov ah, bl
- mov [edi], eax
-
-nf9_55: mov al, bl
-nf9_56: mov ah, bl
- shl eax, 16
-nf9_57: mov al, bl
-nf9_58: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_71: mov al, bl
-nf9_72: mov ah, bl
- shl eax, 16
-nf9_73: mov al, bl
-nf9_74: mov ah, bl
- mov [edi], eax
-
-nf9_75: mov al, bl
-nf9_76: mov ah, bl
- shl eax, 16
-nf9_77: mov al, bl
-nf9_78: mov ah, bl
- mov [edi+4], eax
-
- add esi, 20
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+16
-nf25: ; low 4x4x2 (8 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 8
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf25_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_14-nf25_11)], bl
- mov [edx+(nf25_13-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_12-nf25_11)], bl
- mov [edx+(nf25_11-nf25_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_24-nf25_11)], bl
- mov [edx+(nf25_23-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_22-nf25_11)], bl
- mov [edx+(nf25_21-nf25_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_34-nf25_11)], bl
- mov [edx+(nf25_33-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_32-nf25_11)], bl
- mov [edx+(nf25_31-nf25_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_44-nf25_11)], bl
- mov [edx+(nf25_43-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_42-nf25_11)], bl
- mov [edx+(nf25_41-nf25_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf25_0 ; flush prefetch
- ALIGN 4
-nf25_0:
-nf25_11:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_12:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_13:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_14:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_21:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_22:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_23:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_24:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_31:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_32:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_33:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_34:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_41:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_42:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_43:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_44:mov al, bl
- mov ah, al
- mov [edi+4], eax
-
- add esi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+32
-nf41: ; low 4x8x2 (12 bytes)
- shr eax, 16
- cmp al, ah
- ja nf57
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf41_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_14-nf41_11)], bl
- mov [edx+(nf41_13-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_12-nf41_11)], bl
- mov [edx+(nf41_11-nf41_11)], bh
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_34-nf41_11)], bl
- mov [edx+(nf41_33-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_32-nf41_11)], bl
- mov [edx+(nf41_31-nf41_11)], bh
-
- lea edx, [edx+(nf41_51-nf41_11)]
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_54-nf41_51)], bl
- mov [edx+(nf41_53-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_52-nf41_51)], bl
- mov [edx+(nf41_51-nf41_51)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_74-nf41_51)], bl
- mov [edx+(nf41_73-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_72-nf41_51)], bl
- mov [edx+(nf41_71-nf41_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf41_0 ; flush prefetch
- ALIGN 4
-nf41_0:
-nf41_11:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_12:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_13:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_14:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_31:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_32:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_33:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_34:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_51:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_52:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_53:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_54:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf41_71:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_72:mov al, bl
- mov ah, al
- mov [edi], eax
-nf41_73:mov ah, bl
- mov al, ah
- shl eax, 16
-nf41_74:mov al, bl
- mov ah, al
- mov [edi+4], eax
-
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+48
-nf57: ; low 8x4x2 (12 bytes)
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf57_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_11-nf57_11)], bl
- mov [edx+(nf57_12-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_13-nf57_11)], bl
- mov [edx+(nf57_14-nf57_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_15-nf57_11)], bl
- mov [edx+(nf57_16-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_17-nf57_11)], bl
- mov [edx+(nf57_18-nf57_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_21-nf57_11)], bl
- mov [edx+(nf57_22-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_23-nf57_11)], bl
- mov [edx+(nf57_24-nf57_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_25-nf57_11)], bl
- mov [edx+(nf57_26-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_27-nf57_11)], bl
- mov [edx+(nf57_28-nf57_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_31-nf57_11)], bl
- mov [edx+(nf57_32-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_33-nf57_11)], bl
- mov [edx+(nf57_34-nf57_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_35-nf57_11)], bl
- mov [edx+(nf57_36-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_37-nf57_11)], bl
- mov [edx+(nf57_38-nf57_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_41-nf57_11)], bl
- mov [edx+(nf57_42-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_43-nf57_11)], bl
- mov [edx+(nf57_44-nf57_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_45-nf57_11)], bl
- mov [edx+(nf57_46-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_47-nf57_11)], bl
- mov [edx+(nf57_48-nf57_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf57_0 ; flush prefetch
- ALIGN 4
-nf57_0:
-nf57_11:mov al, bl
-nf57_12:mov ah, bl
- shl eax, 16
-nf57_13:mov al, bl
-nf57_14:mov ah, bl
- mov [edi], eax
-
-nf57_15:mov al, bl
-nf57_16:mov ah, bl
- shl eax, 16
-nf57_17:mov al, bl
-nf57_18:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_21:mov al, bl
-nf57_22:mov ah, bl
- shl eax, 16
-nf57_23:mov al, bl
-nf57_24:mov ah, bl
- mov [edi], eax
-
-nf57_25:mov al, bl
-nf57_26:mov ah, bl
- shl eax, 16
-nf57_27:mov al, bl
-nf57_28:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_31:mov al, bl
-nf57_32:mov ah, bl
- shl eax, 16
-nf57_33:mov al, bl
-nf57_34:mov ah, bl
- mov [edi], eax
-
-nf57_35:mov al, bl
-nf57_36:mov ah, bl
- shl eax, 16
-nf57_37:mov al, bl
-nf57_38:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_41:mov al, bl
-nf57_42:mov ah, bl
- shl eax, 16
-nf57_43:mov al, bl
-nf57_44:mov ah, bl
- mov [edi], eax
-
-nf57_45:mov al, bl
-nf57_46:mov ah, bl
- shl eax, 16
-nf57_47:mov al, bl
-nf57_48:mov ah, bl
- mov [edi+4], eax
-
- add esi, 12
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf10: ; 2x2 4x4x2 (32 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf26
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf10_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_11-nf10_11)], bl
- mov [edx+(nf10_12-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_13-nf10_11)], bl
- mov [edx+(nf10_14-nf10_11)], bh
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_21-nf10_11)], bl
- mov [edx+(nf10_22-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_23-nf10_11)], bl
- mov [edx+(nf10_24-nf10_11)], bh
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_31-nf10_11)], bl
- mov [edx+(nf10_32-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_33-nf10_11)], bl
- mov [edx+(nf10_34-nf10_11)], bh
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_41-nf10_11)], bl
- mov [edx+(nf10_42-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_43-nf10_11)], bl
- mov [edx+(nf10_44-nf10_11)], bh
-
- lea edx, [edx+(nf10_51-nf10_11)]
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_51-nf10_51)], bl
- mov [edx+(nf10_52-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_53-nf10_51)], bl
- mov [edx+(nf10_54-nf10_51)], bh
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_61-nf10_51)], bl
- mov [edx+(nf10_62-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_63-nf10_51)], bl
- mov [edx+(nf10_64-nf10_51)], bh
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_71-nf10_51)], bl
- mov [edx+(nf10_72-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_73-nf10_51)], bl
- mov [edx+(nf10_74-nf10_51)], bh
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_81-nf10_51)], bl
- mov [edx+(nf10_82-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_83-nf10_51)], bl
- mov [edx+(nf10_84-nf10_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf10_0 ; flush prefetch
- ALIGN 4
-nf10_0:
-nf10_11:mov al, bl
-nf10_12:mov ah, bl
- shl eax, 16
-nf10_13:mov al, bl
-nf10_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_21:mov al, bl
-nf10_22:mov ah, bl
- shl eax, 16
-nf10_23:mov al, bl
-nf10_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+8]
- mov cx, [esi+10]
-
-nf10_31:mov al, bl
-nf10_32:mov ah, bl
- shl eax, 16
-nf10_33:mov al, bl
-nf10_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_41:mov al, bl
-nf10_42:mov ah, bl
- shl eax, 16
-nf10_43:mov al, bl
-nf10_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*4-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+16]
- mov cx, [esi+18]
-
-nf10_51:mov al, bl
-nf10_52:mov ah, bl
- shl eax, 16
-nf10_53:mov al, bl
-nf10_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_61:mov al, bl
-nf10_62:mov ah, bl
- shl eax, 16
-nf10_63:mov al, bl
-nf10_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+24]
- mov cx, [esi+26]
-
-nf10_71:mov al, bl
-nf10_72:mov ah, bl
- shl eax, 16
-nf10_73:mov al, bl
-nf10_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_81:mov al, bl
-nf10_82:mov ah, bl
- shl eax, 16
-nf10_83:mov al, bl
-nf10_84:mov ah, bl
- mov [edi], eax
-
- add esi, 32
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+16
-nf26: ; 2x1 4x8x2 (24 bytes)
-
- mov ax, [esi+12]
- cmp al, ah
- ja nf42
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf26_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_11-nf26_11)], bl
- mov [edx+(nf26_12-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_13-nf26_11)], bl
- mov [edx+(nf26_14-nf26_11)], bh
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_21-nf26_11)], bl
- mov [edx+(nf26_22-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_23-nf26_11)], bl
- mov [edx+(nf26_24-nf26_11)], bh
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_31-nf26_11)], bl
- mov [edx+(nf26_32-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_33-nf26_11)], bl
- mov [edx+(nf26_34-nf26_11)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_41-nf26_11)], bl
- mov [edx+(nf26_42-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_43-nf26_11)], bl
- mov [edx+(nf26_44-nf26_11)], bh
-
- lea edx, [edx+(nf26_51-nf26_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_51-nf26_51)], bl
- mov [edx+(nf26_52-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_53-nf26_51)], bl
- mov [edx+(nf26_54-nf26_51)], bh
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_61-nf26_51)], bl
- mov [edx+(nf26_62-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_63-nf26_51)], bl
- mov [edx+(nf26_64-nf26_51)], bh
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_71-nf26_51)], bl
- mov [edx+(nf26_72-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_73-nf26_51)], bl
- mov [edx+(nf26_74-nf26_51)], bh
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_81-nf26_51)], bl
- mov [edx+(nf26_82-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_83-nf26_51)], bl
- mov [edx+(nf26_84-nf26_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf26_0 ; flush prefetch
- ALIGN 4
-nf26_0:
-nf26_11:mov al, bl
-nf26_12:mov ah, bl
- shl eax, 16
-nf26_13:mov al, bl
-nf26_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_21:mov al, bl
-nf26_22:mov ah, bl
- shl eax, 16
-nf26_23:mov al, bl
-nf26_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_31:mov al, bl
-nf26_32:mov ah, bl
- shl eax, 16
-nf26_33:mov al, bl
-nf26_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_41:mov al, bl
-nf26_42:mov ah, bl
- shl eax, 16
-nf26_43:mov al, bl
-nf26_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*4-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf26_51:mov al, bl
-nf26_52:mov ah, bl
- shl eax, 16
-nf26_53:mov al, bl
-nf26_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_61:mov al, bl
-nf26_62:mov ah, bl
- shl eax, 16
-nf26_63:mov al, bl
-nf26_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_71:mov al, bl
-nf26_72:mov ah, bl
- shl eax, 16
-nf26_73:mov al, bl
-nf26_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_81:mov al, bl
-nf26_82:mov ah, bl
- shl eax, 16
-nf26_83:mov al, bl
-nf26_84:mov ah, bl
- mov [edi], eax
-
- add esi, 24
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+32
-nf42: ; 1x2 8x4x2 (24 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf42_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_11-nf42_11)], bl
- mov [edx+(nf42_12-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_13-nf42_11)], bl
- mov [edx+(nf42_14-nf42_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_15-nf42_11)], bl
- mov [edx+(nf42_16-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_17-nf42_11)], bl
- mov [edx+(nf42_18-nf42_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_31-nf42_11)], bl
- mov [edx+(nf42_32-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_33-nf42_11)], bl
- mov [edx+(nf42_34-nf42_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_35-nf42_11)], bl
- mov [edx+(nf42_36-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_37-nf42_11)], bl
- mov [edx+(nf42_38-nf42_11)], bh
-
- lea edx, [edx+(nf42_51-nf42_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_51-nf42_51)], bl
- mov [edx+(nf42_52-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_53-nf42_51)], bl
- mov [edx+(nf42_54-nf42_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_55-nf42_51)], bl
- mov [edx+(nf42_56-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_57-nf42_51)], bl
- mov [edx+(nf42_58-nf42_51)], bh
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_71-nf42_51)], bl
- mov [edx+(nf42_72-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_73-nf42_51)], bl
- mov [edx+(nf42_74-nf42_51)], bh
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_75-nf42_51)], bl
- mov [edx+(nf42_76-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_77-nf42_51)], bl
- mov [edx+(nf42_78-nf42_51)], bh
-
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf42_0 ; flush prefetch
- ALIGN 4
-nf42_0:
-nf42_11:mov al, bl
-nf42_12:mov ah, bl
- shl eax, 16
-nf42_13:mov al, bl
-nf42_14:mov ah, bl
- mov [edi], eax
-
-nf42_15:mov al, bl
-nf42_16:mov ah, bl
- shl eax, 16
-nf42_17:mov al, bl
-nf42_18:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_31:mov al, bl
-nf42_32:mov ah, bl
- shl eax, 16
-nf42_33:mov al, bl
-nf42_34:mov ah, bl
- mov [edi], eax
-
-nf42_35:mov al, bl
-nf42_36:mov ah, bl
- shl eax, 16
-nf42_37:mov al, bl
-nf42_38:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf42_51:mov al, bl
-nf42_52:mov ah, bl
- shl eax, 16
-nf42_53:mov al, bl
-nf42_54:mov ah, bl
- mov [edi], eax
-
-nf42_55:mov al, bl
-nf42_56:mov ah, bl
- shl eax, 16
-nf42_57:mov al, bl
-nf42_58:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_71:mov al, bl
-nf42_72:mov ah, bl
- shl eax, 16
-nf42_73:mov al, bl
-nf42_74:mov ah, bl
- mov [edi], eax
-
-nf42_75:mov al, bl
-nf42_76:mov ah, bl
- shl eax, 16
-nf42_77:mov al, bl
-nf42_78:mov ah, bl
- mov [edi+4], eax
-
- add esi, 24
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf11: ; 8x8x8 (64 bytes)
-if 0 ;debug
- add esi, 64
- mov eax, 0fefefefeH
-; mov ebx, eax
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
-
- mov eax, [esi] ;0
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+16] ;2
- mov [edi], eax
- mov eax, [esi+20]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+32] ;4
- mov [edi], eax
- mov eax, [esi+36]
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+48] ;6
- mov [edi], eax
- mov eax, [esi+52]
- mov [edi+4], eax
-
- add esi, 64
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-;----------------------------------------
- ALIGN 4
-nf12: ; low 4x4x8 (16 bytes)
- mov edx, nf_width
-
- mov eax, [esi]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+4]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+8]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+12]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right
- add esi, 16
- retn
-
-;----------------------------------------
- ALIGN 4
-nf13: ; 2x2 4x4x0 (4 bytes)
- mov edx, nf_width
-
- mov cl, [esi]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+1]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- mov [edi+edx], eax
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov cl, [esi+2]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+3]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right
- add esi, 4
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf14: ; 8x8x0 (1 byte)
- mov bl, [esi] ; Copy color into 8 positions
- inc esi
- mov bh, bl
- mov eax, ebx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
- jmp nf_solid
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf15: ; mix 8x8x0 (2 bytes)
- mov bx, [esi] ; Copy 2 colors into 8 positions
- add esi, 2 ; in a checkerboard
- mov ax, bx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
- rol ebx, 8
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
-nf_solid:
- mov edx, nf_width
-
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-nfPkDecompH ENDP
-
-if DECOMPD
-
-; Half vertical resolution version (dither between lines)
-;
-nfPkDecompD PROC USES ESI EDI EBX, \
- ops:PTRBYTE, comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row:DWORD
- LOCAL DiffBufPtrs:DWORD
-
- LOCAL nfpk_back_right: DWORD
- LOCAL wcnt:DWORD
-
- LOG_LABEL "StartPkDecomp"
-
-.data
-nfpk_OpTblD label dword
- dword offset nf0 ; Prev Same (0)
- dword offset nf1 ; No change (and copied to screen) (0)
- dword offset nf2 ; Near shift from older part of current buf (1)
- dword offset nf3 ; Near shift from newer part of current buf (1)
- dword offset nf4 ; Near shift from previous buffer (1)
- dword offset nf5 ; Far shift from previous buffer (2)
- dword offset nf6 ; Far shift from current buffer (2)
- ; [Or if COMPOPS, run of no changes (0)]
- dword offset nf7 ; 8x8x1 (10 bytes) or low 4x4x1 (4 bytes)
- dword offset nf8 ; 2x2 4x4x1 (16 bytes) or 2x1 4x8x1 (12 bytes) or 1x2 8x4x1 (12 bytes)
- dword offset nf9 ; 8x8x2 (20 bytes) or low 4x4x2 (8 bytes) or
- ; low 4x8x2 (12 bytes) or low 8x4x2 (12 bytes)
- dword offset nf10 ; 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- dword offset nf11 ; 8x8x8 (64 bytes)
- dword offset nf12 ; low 4x4x8 (16 bytes)
- dword offset nf13 ; 2x2 4x4x0 (ie 2x2x8) (4 bytes)
- dword offset nf14 ; 8x8x0 (1 byte)
- dword offset nf15 ; mix 8x8x0 (2 bytes)
-.code
-
-ifdef SYMANTEC
- mov ebx, ds ; Allow DS to access code
- mov ecx, 0
- mov ax, 3505h
- int 21h
-endif
-
- NF_DECOMP_INIT 0
-
- mov eax, nf_width
- shl eax, 2
- sub eax, nf_new_w
- mov new_row, eax
-
- shr nf_new_h, 1
-
- mov eax, nf_width
- lea eax, [eax*2+eax-SWIDTH]
- mov nfpk_back_right, eax
-
- mov esi, comp
- mov edi, tbuf
-nf_StartRow:
- mov eax, w
- shr eax, 1
- mov wcnt,eax
- ALIGN 4
-nf_NextPair:
- dec wcnt
- js nf_NextRow
- mov ebx, ops
- mov al, [ebx]
- inc ebx
- mov ops, ebx
-
- xor ebx, ebx
- mov bl, al
- shr bl, 4
- and eax, 0Fh
- push offset nf_NextPair
- push nfpk_OpTblD[ebx*4]
- jmp nfpk_OpTblD[eax*4]
-
-nf_NextRow:
- add edi, new_row
- dec h
- jnz nf_StartRow
- LOG_LABEL "EndPkDecomp"
-
-ifdef SYMANTEC
- mov ebx, ds ; Disable DS from accessing code
- mov ecx, offset DGROUP:_data_bottom[-1]
- mov ax, 3505h
- int 21h
-endif
- ret
-
-;----------------------------------------
- ALIGN 4
-nf0: ; No change from previous buffer
- mov eax, DiffBufPtrs
- jmp nf_shiftr
-
-;----------------------------------------
- ALIGN 4
-nf1: ; No change (and copied to screen)
- add edi, SWIDTH
- retn
-
-;----------------------------------------
- ALIGN 4
-nf2: ; Near shift from older part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
-nf_xyc_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- sar bl, 1
- pushf
- add eax, nfpk_ShiftY[ebx*4]
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf3: ; Near shift from newer part of current buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP2[eax*2]
- neg al
- neg ah
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf4: ; Near shift from previous buffer
- xor eax, eax
- mov al, [esi]
- inc esi
- mov ax, nfpk_ShiftP1[eax*2]
- jmp nf_xyp_shift
-
-;----------------------------------------
- ALIGN 4
-nf5: ; Far shift from previous buffer
- mov ax, [esi]
- add esi, 2
-nf_xyp_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24
- sar bl, 1
- pushf
- add eax, nfpk_ShiftY[ebx*4]
- add eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-
-if COMPOPS
-
-nf6: ; Run of no changes (must only appear in first nibble opcodes)
- ; Next nibble k specifies 2k+4 squares with no changes
- add esp, 4 ; Next nibble is not an opcode
- add ebx, 2 ; (minimum of 4 squares)
- ALIGN 4
-nf6a: add edi, SWIDTH*2 ; Advance over two squares
- dec ebx
- jz nf6z ; Last pair of squares
- dec wcnt ; Same row?
- jns nf6a ; Yes
- add edi, new_row ; Advance to next row
- dec h ; Decrement row count (should never become zero here)
- mov eax, w ; Reset wcnt
- shr eax ,1
- dec eax
- mov wcnt, eax
- jmp nf6a
-
-nf6z: retn
-
-else
-
-nf6: ; Far shift from current buffer
- mov ax, [esi]
- add esi, 2
- jmp nf_xyc_shift
-
-endif
-
-;----------------------------------------
- ALIGN 4
-nf_shift:
- popf
-if 0 ;debug
- mov eax, 0
- mov ebx, eax
- jmp nf_solid
-endif
- jc nf_shiftd
-
-nf_shiftr:
- mov ebx, esi ; save esi
- lea esi, [edi+eax]
- mov edx, nf_width
-
- REPEAT 3
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- add esi, edx
- add edi, edx
- ENDM
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- mov esi, ebx ; restore esi
- retn
-
-nf_shiftd:
- push esi
- lea esi, [edi+eax]
- mov edx, nf_width
- mov ebx, 000ff00ffH
-
- REPEAT 3
- mov eax, [esi]
- mov ecx, eax
- xor ecx, [esi+edx]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+4]
- mov ecx, eax
- xor ecx, [esi+edx+4]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
- add esi, edx
- add edi, edx
- ENDM
- mov eax, [esi]
- mov ecx, eax
- xor ecx, [esi+edx]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+4]
- mov ecx, eax
- xor ecx, [esi+edx+4]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- pop esi
- retn
-
-;----------------------------------------
- ALIGN 4
-nf7: ; 8x8x1 (10 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf23
-
-if 0 ;debug
- add esi, 10
- mov eax, 0fefefefeH
- mov ebx, eax
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf7_11+2
-
- mov al, [esi+2]
- mov bl, al
- xor bl, [esi+3]
- and bl, 0aaH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_11-nf7_11)], bl
- mov [edx+(nf7_12-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_13-nf7_11)], bl
- mov [edx+(nf7_14-nf7_11)], bh
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+5]
- and bl, 0aaH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_31-nf7_11)], bl
- mov [edx+(nf7_32-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_33-nf7_11)], bl
- mov [edx+(nf7_34-nf7_11)], bh
-
- lea edx, [edx+(nf7_51-nf7_11)]
-
- mov al, [esi+6]
- mov bl, al
- xor bl, [esi+7]
- and bl, 0aaH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_51-nf7_51)], bl
- mov [edx+(nf7_52-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_53-nf7_51)], bl
- mov [edx+(nf7_54-nf7_51)], bh
-
- mov al, [esi+8]
- mov bl, al
- xor bl, [esi+9]
- and bl, 0aaH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_71-nf7_51)], bl
- mov [edx+(nf7_72-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_73-nf7_51)], bl
- mov [edx+(nf7_74-nf7_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi,nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
- jmp nf7_0 ; flush prefetch
- ALIGN 4
-nf7_0:
-nf7_11: mov ax, bx
- shl eax, 16
-nf7_12: mov ax, bx
- mov [edi], eax
-nf7_13: mov ax, bx
- shl eax, 16
-nf7_14: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_31: mov ax, bx
- shl eax, 16
-nf7_32: mov ax, bx
- mov [edi], eax
-nf7_33: mov ax, bx
- shl eax, 16
-nf7_34: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_51: mov ax, bx
- shl eax, 16
-nf7_52: mov ax, bx
- mov [edi], eax
-nf7_53: mov ax, bx
- shl eax, 16
-nf7_54: mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf7_71: mov ax, bx
- shl eax, 16
-nf7_72: mov ax, bx
- mov [edi], eax
-nf7_73: mov ax, bx
- shl eax, 16
-nf7_74: mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 10
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf7+16
-nf23: ; low 4x4x1 (4 bytes)
-
- xor eax, eax
- lea ecx, nfpk_mov4l
- lea edx, byte ptr ds:nf23_11+2
-
- mov al, [esi+2]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_11-nf23_11)], bl
- mov [edx+(nf23_12-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_13-nf23_11)], bl
- mov [edx+(nf23_14-nf23_11)], bh
-
- mov al, [esi+2]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_31-nf23_11)], bl
- mov [edx+(nf23_32-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_33-nf23_11)], bl
- mov [edx+(nf23_34-nf23_11)], bh
-
-
- mov al, [esi+3]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_51-nf23_11)], bl
- mov [edx+(nf23_52-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_53-nf23_11)], bl
- mov [edx+(nf23_54-nf23_11)], bh
-
- mov al, [esi+3]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_71-nf23_11)], bl
- mov [edx+(nf23_72-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_73-nf23_11)], bl
- mov [edx+(nf23_74-nf23_11)], bh
-
- mov edx, nf_width
-
- ; load bx,cx with 00,11 color combinations
- mov bx, [esi]
- mov cl, bh
- mov bh, bl
- mov ch, cl
-
- jmp nf23_0 ; flush prefetch
- ALIGN 4
-nf23_0:
-
-nf23_11:mov ax, bx
- shl eax, 16
-nf23_12:mov ax, bx
- mov [edi], eax
-
-nf23_13:mov ax, bx
- shl eax, 16
-nf23_14:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_31:mov ax, bx
- shl eax, 16
-nf23_32:mov ax, bx
- mov [edi], eax
-
-nf23_33:mov ax, bx
- shl eax, 16
-nf23_34:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_51:mov ax, bx
- shl eax, 16
-nf23_52:mov ax, bx
- mov [edi], eax
-
-nf23_53:mov ax, bx
- shl eax, 16
-nf23_54:mov ax, bx
- mov [edi+4], eax
- add edi, edx
-
-nf23_71:mov ax, bx
- shl eax, 16
-nf23_72:mov ax, bx
- mov [edi], eax
-
-nf23_73:mov ax, bx
- shl eax, 16
-nf23_74:mov ax, bx
- mov [edi+4], eax
-
- sub edi, nfpk_back_right
- add esi, 4
- retn
-
-;----------------------------------------
- ALIGN 4
-nf8: ; 2x2 4x4x1 (16 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf24
-
- ; Note: This could be made faster with a new (16 16-bit entry) table.
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf8_11+2
-
- mov al, [esi+2]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_11-nf8_11)], bl
- mov [edx+(nf8_12-nf8_11)], bh
-
- mov al, [esi+3]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_21-nf8_11)], bl
- mov [edx+(nf8_22-nf8_11)], bh
-
-
- mov al, [esi+6]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_31-nf8_11)], bl
- mov [edx+(nf8_32-nf8_11)], bh
-
- mov al, [esi+7]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_41-nf8_11)], bl
- mov [edx+(nf8_42-nf8_11)], bh
-
- add edx, nf8_51-nf8_11
-
- mov al, [esi+10]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_51-nf8_51)], bl
- mov [edx+(nf8_52-nf8_51)], bh
-
- mov al, [esi+11]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_61-nf8_51)], bl
- mov [edx+(nf8_62-nf8_51)], bh
-
-
- mov al, [esi+14]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_71-nf8_51)], bl
- mov [edx+(nf8_72-nf8_51)], bh
-
- mov al, [esi+15]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_81-nf8_51)], bl
- mov [edx+(nf8_82-nf8_51)], bh
-
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf8_0 ; flush prefetch
- ALIGN 4
-nf8_0:
-nf8_11: mov ax, bx
- shl eax, 16
-nf8_12: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_21: mov ax, bx
- shl eax, 16
-nf8_22: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+4]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_31: mov ax, bx
- shl eax, 16
-nf8_32: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_41: mov ax, bx
- shl eax, 16
-nf8_42: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*4-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+8]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_51: mov ax, bx
- shl eax, 16
-nf8_52: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_61: mov ax, bx
- shl eax, 16
-nf8_62: mov ax, bx
- mov [edi], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+12]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf8_71: mov ax, bx
- shl eax, 16
-nf8_72: mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf8_81: mov ax, bx
- shl eax, 16
-nf8_82: mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+16
-nf24: ; 2x1 4x8x1 (12 bytes)
-
- mov ax, [esi+6]
- cmp al, ah
- ja nf40
-
- ; Note: This could be made faster with a new (16 16-bit entry) table.
-
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf24_11+2
-
- mov al, [esi+2]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_11-nf24_11)], bl
- mov [edx+(nf24_12-nf24_11)], bh
-
- mov al, [esi+3]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_21-nf24_11)], bl
- mov [edx+(nf24_22-nf24_11)], bh
-
- mov al, [esi+4]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_31-nf24_11)], bl
- mov [edx+(nf24_32-nf24_11)], bh
-
- mov al, [esi+5]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_41-nf24_11)], bl
- mov [edx+(nf24_42-nf24_11)], bh
-
- add edx, nf24_51-nf24_11
-
- mov al, [esi+8]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_51-nf24_51)], bl
- mov [edx+(nf24_52-nf24_51)], bh
-
- mov al, [esi+9]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_61-nf24_51)], bl
- mov [edx+(nf24_62-nf24_51)], bh
-
- mov al, [esi+10]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_71-nf24_51)], bl
- mov [edx+(nf24_72-nf24_51)], bh
-
- mov al, [esi+11]
- mov bl, al
- shr bl, 4
- xor bl, al
- and bl, 0aH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_81-nf24_51)], bl
- mov [edx+(nf24_82-nf24_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf24_0 ; flush prefetch
- ALIGN 4
-nf24_0:
-nf24_11:mov ax, bx
- shl eax, 16
-nf24_12:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_21:mov ax, bx
- shl eax, 16
-nf24_22:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_31:mov ax, bx
- shl eax, 16
-nf24_32:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_41:mov ax, bx
- shl eax, 16
-nf24_42:mov ax, bx
- mov [edi], eax
- add edi, esi
-
- lea eax, [esi*4-4]
- sub edi, eax
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf24_51:mov ax, bx
- shl eax, 16
-nf24_52:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_61:mov ax, bx
- shl eax, 16
-nf24_62:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_71:mov ax, bx
- shl eax, 16
-nf24_72:mov ax, bx
- mov [edi], eax
- add edi, esi
-
-nf24_81:mov ax, bx
- shl eax, 16
-nf24_82:mov ax, bx
- mov [edi], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+32
-nf40: ; 1x2 8x4x1 (12 bytes)
- xor eax, eax
- lea ecx, nfpk_mov8
- lea edx, byte ptr ds:nf40_11+2
-
- mov al, [esi+2]
- mov bl, al
- xor bl, [esi+3]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_11-nf40_11)], bl
- mov [edx+(nf40_12-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_13-nf40_11)], bl
- mov [edx+(nf40_14-nf40_11)], bh
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+5]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_31-nf40_11)], bl
- mov [edx+(nf40_32-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_33-nf40_11)], bl
- mov [edx+(nf40_34-nf40_11)], bh
-
- add edx, nf40_51-nf40_11
-
- mov al, [esi+8]
- mov bl, al
- xor bl, [esi+9]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_51-nf40_51)], bl
- mov [edx+(nf40_52-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_53-nf40_51)], bl
- mov [edx+(nf40_54-nf40_51)], bh
-
- mov al, [esi+10]
- mov bl, al
- xor bl, [esi+11]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_71-nf40_51)], bl
- mov [edx+(nf40_72-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_73-nf40_51)], bl
- mov [edx+(nf40_74-nf40_51)], bh
-
- push ebp
- push esi
- ; load bx,dx,cx,bp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
- mov cx, [esi]
- mov esi, nf_width
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
- jmp nf40_0 ; flush prefetch
- ALIGN 4
-nf40_0:
-nf40_11:mov ax, bx
- shl eax, 16
-nf40_12:mov ax, bx
- mov [edi], eax
-nf40_13:mov ax, bx
- shl eax, 16
-nf40_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_31:mov ax, bx
- shl eax, 16
-nf40_32:mov ax, bx
- mov [edi], eax
-nf40_33:mov ax, bx
- shl eax, 16
-nf40_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- mov eax, [esp]
- mov cx, [eax+6]
- mov bl,cl
- mov bh,cl
- mov dl,ch
- mov dh,cl
- mov al,ch
- mov ah,ch
- mov ebp,eax
-
-nf40_51:mov ax, bx
- shl eax, 16
-nf40_52:mov ax, bx
- mov [edi], eax
-nf40_53:mov ax, bx
- shl eax, 16
-nf40_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf40_71:mov ax, bx
- shl eax, 16
-nf40_72:mov ax, bx
- mov [edi], eax
-nf40_73:mov ax, bx
- shl eax, 16
-nf40_74:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf9: ; 8x8x2 (20 bytes)
-
- mov eax, [esi]
- cmp al, ah
- ja nf41
-
- shr eax, 16
- cmp al, ah
- ja nf25
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf9_11+1
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+6]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_11-nf9_11)], bl
- mov [edx+(nf9_12-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_13-nf9_11)], bl
- mov [edx+(nf9_14-nf9_11)], bh
-
- mov al, [esi+5]
- mov bl, al
- xor bl, [esi+7]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_15-nf9_11)], bl
- mov [edx+(nf9_16-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_17-nf9_11)], bl
- mov [edx+(nf9_18-nf9_11)], bh
-
-
- mov al, [esi+8]
- mov bl, al
- xor bl, [esi+10]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_31-nf9_11)], bl
- mov [edx+(nf9_32-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_33-nf9_11)], bl
- mov [edx+(nf9_34-nf9_11)], bh
-
- mov al, [esi+9]
- mov bl, al
- xor bl, [esi+11]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_35-nf9_11)], bl
- mov [edx+(nf9_36-nf9_11)], bh
- shr ebx, 16
- mov [edx+(nf9_37-nf9_11)], bl
- mov [edx+(nf9_38-nf9_11)], bh
-
- lea edx, [edx+(nf9_51-nf9_11)]
-
- mov al, [esi+12]
- mov bl, al
- xor bl, [esi+14]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_51-nf9_51)], bl
- mov [edx+(nf9_52-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_53-nf9_51)], bl
- mov [edx+(nf9_54-nf9_51)], bh
-
- mov al, [esi+13]
- mov bl, al
- xor bl, [esi+15]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_55-nf9_51)], bl
- mov [edx+(nf9_56-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_57-nf9_51)], bl
- mov [edx+(nf9_58-nf9_51)], bh
-
-
- mov al, [esi+16]
- mov bl, al
- xor bl, [esi+18]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_71-nf9_51)], bl
- mov [edx+(nf9_72-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_73-nf9_51)], bl
- mov [edx+(nf9_74-nf9_51)], bh
-
- mov al, [esi+17]
- mov bl, al
- xor bl, [esi+19]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_75-nf9_51)], bl
- mov [edx+(nf9_76-nf9_51)], bh
- shr ebx, 16
- mov [edx+(nf9_77-nf9_51)], bl
- mov [edx+(nf9_78-nf9_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf9_0 ; flush prefetch
- ALIGN 4
-nf9_0:
-nf9_11: mov al, bl
-nf9_12: mov ah, bl
- shl eax, 16
-nf9_13: mov al, bl
-nf9_14: mov ah, bl
- mov [edi], eax
-
-nf9_15: mov al, bl
-nf9_16: mov ah, bl
- shl eax, 16
-nf9_17: mov al, bl
-nf9_18: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_31: mov al, bl
-nf9_32: mov ah, bl
- shl eax, 16
-nf9_33: mov al, bl
-nf9_34: mov ah, bl
- mov [edi], eax
-
-nf9_35: mov al, bl
-nf9_36: mov ah, bl
- shl eax, 16
-nf9_37: mov al, bl
-nf9_38: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_51: mov al, bl
-nf9_52: mov ah, bl
- shl eax, 16
-nf9_53: mov al, bl
-nf9_54: mov ah, bl
- mov [edi], eax
-
-nf9_55: mov al, bl
-nf9_56: mov ah, bl
- shl eax, 16
-nf9_57: mov al, bl
-nf9_58: mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf9_71: mov al, bl
-nf9_72: mov ah, bl
- shl eax, 16
-nf9_73: mov al, bl
-nf9_74: mov ah, bl
- mov [edi], eax
-
-nf9_75: mov al, bl
-nf9_76: mov ah, bl
- shl eax, 16
-nf9_77: mov al, bl
-nf9_78: mov ah, bl
- mov [edi+4], eax
-
- add esi, 20
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+16
-nf25: ; low 4x4x2 (8 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 8
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf25_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_14-nf25_11)], bl
- mov [edx+(nf25_13-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_12-nf25_11)], bl
- mov [edx+(nf25_11-nf25_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_24-nf25_11)], bl
- mov [edx+(nf25_23-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_22-nf25_11)], bl
- mov [edx+(nf25_21-nf25_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_34-nf25_11)], bl
- mov [edx+(nf25_33-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_32-nf25_11)], bl
- mov [edx+(nf25_31-nf25_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_44-nf25_11)], bl
- mov [edx+(nf25_43-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_42-nf25_11)], bl
- mov [edx+(nf25_41-nf25_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf25_0 ; flush prefetch
- ALIGN 4
-nf25_0:
-nf25_11:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_12:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_13:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_14:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_21:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_22:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_23:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_24:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_31:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_32:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_33:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_34:mov al, bl
- mov ah, al
- mov [edi+4], eax
- add edi, edx
-
-nf25_41:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_42:mov al, bl
- mov ah, al
- mov [edi], eax
-nf25_43:mov ah, bl
- mov al, ah
- shl eax, 16
-nf25_44:mov al, bl
- mov ah, al
- mov [edi+4], eax
-
- add esi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+32
-nf41: ; low 4x8x2 (12 bytes)
- shr eax, 16
- cmp al, ah
- ja nf57
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 12
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf41_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_14-nf41_11)], bl
- mov [edx+(nf41_13-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_12-nf41_11)], bl
- mov [edx+(nf41_11-nf41_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_24-nf41_11)], bl
- mov [edx+(nf41_23-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_22-nf41_11)], bl
- mov [edx+(nf41_21-nf41_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_34-nf41_11)], bl
- mov [edx+(nf41_33-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_32-nf41_11)], bl
- mov [edx+(nf41_31-nf41_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_44-nf41_11)], bl
- mov [edx+(nf41_43-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_42-nf41_11)], bl
- mov [edx+(nf41_41-nf41_11)], bh
-
- lea edx, [edx+(nf41_51-nf41_11)]
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_54-nf41_51)], bl
- mov [edx+(nf41_53-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_52-nf41_51)], bl
- mov [edx+(nf41_51-nf41_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_64-nf41_51)], bl
- mov [edx+(nf41_63-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_62-nf41_51)], bl
- mov [edx+(nf41_61-nf41_51)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_74-nf41_51)], bl
- mov [edx+(nf41_73-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_72-nf41_51)], bl
- mov [edx+(nf41_71-nf41_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_84-nf41_51)], bl
- mov [edx+(nf41_83-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_82-nf41_51)], bl
- mov [edx+(nf41_81-nf41_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf41_0 ; flush prefetch
- ALIGN 4
-nf41_0:
-nf41_11:mov ah, bl
- mov al, ah
-nf41_21:mov ah, bl
- shl eax, 16
-nf41_22:mov al, bl
- mov ah, al
-nf41_12:mov al, bl
- mov [edi], eax
-nf41_13:mov ah, bl
- mov al, ah
-nf41_23:mov ah, bl
- shl eax, 16
-nf41_24:mov al, bl
- mov ah, al
-nf41_14:mov al, bl
- mov [edi+4], eax
- add edi, edx
-
-nf41_31:mov ah, bl
- mov al, ah
-nf41_41:mov ah, bl
- shl eax, 16
-nf41_42:mov al, bl
- mov ah, al
-nf41_32:mov al, bl
- mov [edi], eax
-nf41_33:mov ah, bl
- mov al, ah
-nf41_43:mov ah, bl
- shl eax, 16
-nf41_44:mov al, bl
- mov ah, al
-nf41_34:mov al, bl
- mov [edi+4], eax
- add edi, edx
-
-nf41_51:mov ah, bl
- mov al, ah
-nf41_61:mov ah, bl
- shl eax, 16
-nf41_62:mov al, bl
- mov ah, al
-nf41_52:mov al, bl
- mov [edi], eax
-nf41_53:mov ah, bl
- mov al, ah
-nf41_63:mov ah, bl
- shl eax, 16
-nf41_64:mov al, bl
- mov ah, al
-nf41_54:mov al, bl
- mov [edi+4], eax
- add edi, edx
-
-nf41_71:mov ah, bl
- mov al, ah
-nf41_81:mov ah, bl
- shl eax, 16
-nf41_82:mov al, bl
- mov ah, al
-nf41_72:mov al, bl
- mov [edi], eax
-nf41_73:mov ah, bl
- mov al, ah
-nf41_83:mov ah, bl
- shl eax, 16
-nf41_84:mov al, bl
- mov ah, al
-nf41_74:mov al, bl
- mov [edi+4], eax
-
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+48
-nf57: ; low 8x4x2 (12 bytes)
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf57_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_11-nf57_11)], bl
- mov [edx+(nf57_12-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_13-nf57_11)], bl
- mov [edx+(nf57_14-nf57_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_15-nf57_11)], bl
- mov [edx+(nf57_16-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_17-nf57_11)], bl
- mov [edx+(nf57_18-nf57_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_21-nf57_11)], bl
- mov [edx+(nf57_22-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_23-nf57_11)], bl
- mov [edx+(nf57_24-nf57_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_25-nf57_11)], bl
- mov [edx+(nf57_26-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_27-nf57_11)], bl
- mov [edx+(nf57_28-nf57_11)], bh
-
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_31-nf57_11)], bl
- mov [edx+(nf57_32-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_33-nf57_11)], bl
- mov [edx+(nf57_34-nf57_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_35-nf57_11)], bl
- mov [edx+(nf57_36-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_37-nf57_11)], bl
- mov [edx+(nf57_38-nf57_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_41-nf57_11)], bl
- mov [edx+(nf57_42-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_43-nf57_11)], bl
- mov [edx+(nf57_44-nf57_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_45-nf57_11)], bl
- mov [edx+(nf57_46-nf57_11)], bh
- shr ebx, 16
- mov [edx+(nf57_47-nf57_11)], bl
- mov [edx+(nf57_48-nf57_11)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf57_0 ; flush prefetch
- ALIGN 4
-nf57_0:
-nf57_11:mov al, bl
-nf57_12:mov ah, bl
- shl eax, 16
-nf57_13:mov al, bl
-nf57_14:mov ah, bl
- mov [edi], eax
-
-nf57_15:mov al, bl
-nf57_16:mov ah, bl
- shl eax, 16
-nf57_17:mov al, bl
-nf57_18:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_21:mov al, bl
-nf57_22:mov ah, bl
- shl eax, 16
-nf57_23:mov al, bl
-nf57_24:mov ah, bl
- mov [edi], eax
-
-nf57_25:mov al, bl
-nf57_26:mov ah, bl
- shl eax, 16
-nf57_27:mov al, bl
-nf57_28:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_31:mov al, bl
-nf57_32:mov ah, bl
- shl eax, 16
-nf57_33:mov al, bl
-nf57_34:mov ah, bl
- mov [edi], eax
-
-nf57_35:mov al, bl
-nf57_36:mov ah, bl
- shl eax, 16
-nf57_37:mov al, bl
-nf57_38:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf57_41:mov al, bl
-nf57_42:mov ah, bl
- shl eax, 16
-nf57_43:mov al, bl
-nf57_44:mov ah, bl
- mov [edi], eax
-
-nf57_45:mov al, bl
-nf57_46:mov ah, bl
- shl eax, 16
-nf57_47:mov al, bl
-nf57_48:mov ah, bl
- mov [edi+4], eax
-
- add esi, 12
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf10: ; 2x2 4x4x2 (32 bytes)
-
- mov ax, [esi]
- cmp al, ah
- ja nf26
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf10_11+1
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+5]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_11-nf10_11)], bl
- mov [edx+(nf10_12-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_13-nf10_11)], bl
- mov [edx+(nf10_14-nf10_11)], bh
-
- mov al, [esi+6]
- mov bl, al
- xor bl, [esi+7]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_21-nf10_11)], bl
- mov [edx+(nf10_22-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_23-nf10_11)], bl
- mov [edx+(nf10_24-nf10_11)], bh
-
- mov al, [esi+12]
- mov bl, al
- xor bl, [esi+13]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_31-nf10_11)], bl
- mov [edx+(nf10_32-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_33-nf10_11)], bl
- mov [edx+(nf10_34-nf10_11)], bh
-
- mov al, [esi+14]
- mov bl, al
- xor bl, [esi+15]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_41-nf10_11)], bl
- mov [edx+(nf10_42-nf10_11)], bh
- shr ebx, 16
- mov [edx+(nf10_43-nf10_11)], bl
- mov [edx+(nf10_44-nf10_11)], bh
-
- lea edx, [edx+(nf10_51-nf10_11)]
-
- mov al, [esi+20]
- mov bl, al
- xor bl, [esi+21]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_51-nf10_51)], bl
- mov [edx+(nf10_52-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_53-nf10_51)], bl
- mov [edx+(nf10_54-nf10_51)], bh
-
- mov al, [esi+22]
- mov bl, al
- xor bl, [esi+23]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_61-nf10_51)], bl
- mov [edx+(nf10_62-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_63-nf10_51)], bl
- mov [edx+(nf10_64-nf10_51)], bh
-
- mov al, [esi+28]
- mov bl, al
- xor bl, [esi+29]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_71-nf10_51)], bl
- mov [edx+(nf10_72-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_73-nf10_51)], bl
- mov [edx+(nf10_74-nf10_51)], bh
-
- mov al, [esi+30]
- mov bl, al
- xor bl, [esi+31]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_81-nf10_51)], bl
- mov [edx+(nf10_82-nf10_51)], bh
- shr ebx, 16
- mov [edx+(nf10_83-nf10_51)], bl
- mov [edx+(nf10_84-nf10_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf10_0 ; flush prefetch
- ALIGN 4
-nf10_0:
-nf10_11:mov al, bl
-nf10_12:mov ah, bl
- shl eax, 16
-nf10_13:mov al, bl
-nf10_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_21:mov al, bl
-nf10_22:mov ah, bl
- shl eax, 16
-nf10_23:mov al, bl
-nf10_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+8]
- mov cx, [esi+10]
-
-nf10_31:mov al, bl
-nf10_32:mov ah, bl
- shl eax, 16
-nf10_33:mov al, bl
-nf10_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_41:mov al, bl
-nf10_42:mov ah, bl
- shl eax, 16
-nf10_43:mov al, bl
-nf10_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*4-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+16]
- mov cx, [esi+18]
-
-nf10_51:mov al, bl
-nf10_52:mov ah, bl
- shl eax, 16
-nf10_53:mov al, bl
-nf10_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_61:mov al, bl
-nf10_62:mov ah, bl
- shl eax, 16
-nf10_63:mov al, bl
-nf10_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+24]
- mov cx, [esi+26]
-
-nf10_71:mov al, bl
-nf10_72:mov ah, bl
- shl eax, 16
-nf10_73:mov al, bl
-nf10_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf10_81:mov al, bl
-nf10_82:mov ah, bl
- shl eax, 16
-nf10_83:mov al, bl
-nf10_84:mov ah, bl
- mov [edi], eax
-
- add esi, 32
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+16
-nf26: ; 2x1 4x8x2 (24 bytes)
-
- mov ax, [esi+12]
- cmp al, ah
- ja nf42
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
-
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf26_11+1
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+5]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_11-nf26_11)], bl
- mov [edx+(nf26_12-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_13-nf26_11)], bl
- mov [edx+(nf26_14-nf26_11)], bh
-
- mov al, [esi+6]
- mov bl, al
- xor bl, [esi+7]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_21-nf26_11)], bl
- mov [edx+(nf26_22-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_23-nf26_11)], bl
- mov [edx+(nf26_24-nf26_11)], bh
-
- mov al, [esi+8]
- mov bl, al
- xor bl, [esi+9]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_31-nf26_11)], bl
- mov [edx+(nf26_32-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_33-nf26_11)], bl
- mov [edx+(nf26_34-nf26_11)], bh
-
- mov al, [esi+10]
- mov bl, al
- xor bl, [esi+11]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_41-nf26_11)], bl
- mov [edx+(nf26_42-nf26_11)], bh
- shr ebx, 16
- mov [edx+(nf26_43-nf26_11)], bl
- mov [edx+(nf26_44-nf26_11)], bh
-
- lea edx, [edx+(nf26_51-nf26_11)]
-
- mov al, [esi+16]
- mov bl, al
- xor bl, [esi+17]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_51-nf26_51)], bl
- mov [edx+(nf26_52-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_53-nf26_51)], bl
- mov [edx+(nf26_54-nf26_51)], bh
-
- mov al, [esi+18]
- mov bl, al
- xor bl, [esi+19]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_61-nf26_51)], bl
- mov [edx+(nf26_62-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_63-nf26_51)], bl
- mov [edx+(nf26_64-nf26_51)], bh
-
- mov al, [esi+20]
- mov bl, al
- xor bl, [esi+21]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_71-nf26_51)], bl
- mov [edx+(nf26_72-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_73-nf26_51)], bl
- mov [edx+(nf26_74-nf26_51)], bh
-
- mov al, [esi+22]
- mov bl, al
- xor bl, [esi+23]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_81-nf26_51)], bl
- mov [edx+(nf26_82-nf26_51)], bh
- shr ebx, 16
- mov [edx+(nf26_83-nf26_51)], bl
- mov [edx+(nf26_84-nf26_51)], bh
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf26_0 ; flush prefetch
- ALIGN 4
-nf26_0:
-nf26_11:mov al, bl
-nf26_12:mov ah, bl
- shl eax, 16
-nf26_13:mov al, bl
-nf26_14:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_21:mov al, bl
-nf26_22:mov ah, bl
- shl eax, 16
-nf26_23:mov al, bl
-nf26_24:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_31:mov al, bl
-nf26_32:mov ah, bl
- shl eax, 16
-nf26_33:mov al, bl
-nf26_34:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_41:mov al, bl
-nf26_42:mov ah, bl
- shl eax, 16
-nf26_43:mov al, bl
-nf26_44:mov ah, bl
- mov [edi], eax
- add edi, edx
-
- lea eax, [edx*4-4]
- sub edi, eax
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf26_51:mov al, bl
-nf26_52:mov ah, bl
- shl eax, 16
-nf26_53:mov al, bl
-nf26_54:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_61:mov al, bl
-nf26_62:mov ah, bl
- shl eax, 16
-nf26_63:mov al, bl
-nf26_64:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_71:mov al, bl
-nf26_72:mov ah, bl
- shl eax, 16
-nf26_73:mov al, bl
-nf26_74:mov ah, bl
- mov [edi], eax
- add edi, edx
-
-nf26_81:mov al, bl
-nf26_82:mov ah, bl
- shl eax, 16
-nf26_83:mov al, bl
-nf26_84:mov ah, bl
- mov [edi], eax
-
- add esi, 24
- sub edi, 4
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+32
-nf42: ; 1x2 8x4x2 (24 bytes)
-
-if 0 ;debug
- mov eax, 0
- mov ebx, 0
- add esi, 24
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfpk_mov4
- lea edx, byte ptr ds:nf42_11+1
-
- mov al, [esi+4]
- mov bl, al
- xor bl, [esi+6]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_11-nf42_11)], bl
- mov [edx+(nf42_12-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_13-nf42_11)], bl
- mov [edx+(nf42_14-nf42_11)], bh
-
- mov al, [esi+5]
- mov bl, al
- xor bl, [esi+7]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_15-nf42_11)], bl
- mov [edx+(nf42_16-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_17-nf42_11)], bl
- mov [edx+(nf42_18-nf42_11)], bh
-
-
- mov al, [esi+8]
- mov bl, al
- xor bl, [esi+10]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_31-nf42_11)], bl
- mov [edx+(nf42_32-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_33-nf42_11)], bl
- mov [edx+(nf42_34-nf42_11)], bh
-
- mov al, [esi+9]
- mov bl, al
- xor bl, [esi+11]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_35-nf42_11)], bl
- mov [edx+(nf42_36-nf42_11)], bh
- shr ebx, 16
- mov [edx+(nf42_37-nf42_11)], bl
- mov [edx+(nf42_38-nf42_11)], bh
-
-
- lea edx, [edx+(nf42_51-nf42_11)]
-
- mov al, [esi+16]
- mov bl, al
- xor bl, [esi+18]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_51-nf42_51)], bl
- mov [edx+(nf42_52-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_53-nf42_51)], bl
- mov [edx+(nf42_54-nf42_51)], bh
-
- mov al, [esi+17]
- mov bl, al
- xor bl, [esi+19]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_55-nf42_51)], bl
- mov [edx+(nf42_56-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_57-nf42_51)], bl
- mov [edx+(nf42_58-nf42_51)], bh
-
-
- mov al, [esi+20]
- mov bl, al
- xor bl, [esi+22]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_71-nf42_51)], bl
- mov [edx+(nf42_72-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_73-nf42_51)], bl
- mov [edx+(nf42_74-nf42_51)], bh
-
- mov al, [esi+21]
- mov bl, al
- xor bl, [esi+23]
- and bl, 0ccH
- xor al, bl
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_75-nf42_51)], bl
- mov [edx+(nf42_76-nf42_51)], bh
- shr ebx, 16
- mov [edx+(nf42_77-nf42_51)], bl
- mov [edx+(nf42_78-nf42_51)], bh
-
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi]
- mov cx, [esi+2]
-
- mov edx, nf_width
- jmp nf42_0 ; flush prefetch
- ALIGN 4
-nf42_0:
-nf42_11:mov al, bl
-nf42_12:mov ah, bl
- shl eax, 16
-nf42_13:mov al, bl
-nf42_14:mov ah, bl
- mov [edi], eax
-
-nf42_15:mov al, bl
-nf42_16:mov ah, bl
- shl eax, 16
-nf42_17:mov al, bl
-nf42_18:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_31:mov al, bl
-nf42_32:mov ah, bl
- shl eax, 16
-nf42_33:mov al, bl
-nf42_34:mov ah, bl
- mov [edi], eax
-
-nf42_35:mov al, bl
-nf42_36:mov ah, bl
- shl eax, 16
-nf42_37:mov al, bl
-nf42_38:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
- ; Load bl,bh,cl,ch with four colors
- mov bx, [esi+12]
- mov cx, [esi+14]
-
-nf42_51:mov al, bl
-nf42_52:mov ah, bl
- shl eax, 16
-nf42_53:mov al, bl
-nf42_54:mov ah, bl
- mov [edi], eax
-
-nf42_55:mov al, bl
-nf42_56:mov ah, bl
- shl eax, 16
-nf42_57:mov al, bl
-nf42_58:mov ah, bl
- mov [edi+4], eax
- add edi, edx
-
-nf42_71:mov al, bl
-nf42_72:mov ah, bl
- shl eax, 16
-nf42_73:mov al, bl
-nf42_74:mov ah, bl
- mov [edi], eax
-
-nf42_75:mov al, bl
-nf42_76:mov ah, bl
- shl eax, 16
-nf42_77:mov al, bl
-nf42_78:mov ah, bl
- mov [edi+4], eax
-
- add esi, 24
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf11: ; 8x8x8 (64 bytes)
-if 0 ;debug
- add esi, 64
- mov eax, 0fefefefeH
-; mov ebx, eax
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
- mov ebx, 0ff00ff00H
-
- mov eax, [esi] ;0
- mov ecx, eax
- xor ecx, [esi+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+4]
- mov ecx, eax
- xor ecx, [esi+4+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+16] ;2
- mov ecx, eax
- xor ecx, [esi+16+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+20]
- mov ecx, eax
- xor ecx, [esi+20+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+32] ;4
- mov ecx, eax
- xor ecx, [esi+32+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+36]
- mov ecx, eax
- xor ecx, [esi+36+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
- add edi, edx
- mov eax, [esi+48] ;6
- mov ecx, eax
- xor ecx, [esi+48+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi], eax
- mov eax, [esi+52]
- mov ecx, eax
- xor ecx, [esi+52+8]
- and ecx, ebx
- xor eax, ecx
- mov [edi+4], eax
-
- add esi, 64
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-;----------------------------------------
- ALIGN 4
-nf12: ; low 4x4x8 (16 bytes)
- mov edx, nf_width
-
- mov eax, [esi]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+4]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+8]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
- add edi, edx
-
- mov eax, [esi+12]
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi], ebx
- shr eax, 16
- mov bl, ah
- mov bh, ah
- shl ebx, 16
- mov bl, al
- mov bh, al
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right
- add esi, 16
- retn
-
-;----------------------------------------
- ALIGN 4
-nf13: ; 2x2 4x4x0 (4 bytes)
- mov edx, nf_width
-
- mov cl, [esi]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+1]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- mov [edi+edx], eax
- mov [edi+edx+4], ebx
- lea edi, [edi+edx*2]
-
- mov cl, [esi+2]
- mov ch, cl
- mov eax, ecx
- shl eax, 16
- mov ax, cx
-
- mov cl, [esi+3]
- mov ch, cl
- mov ebx, ecx
- shl ebx, 16
- mov bx, cx
-
- mov [edi], eax
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right
- add esi, 4
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf14: ; 8x8x0 (1 byte)
- mov bl, [esi] ; Copy color into 8 positions
- inc esi
- mov bh, bl
- mov eax, ebx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
- jmp nf_solid
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf15: ; mix 8x8x0 (2 bytes)
- mov bx, [esi] ; Copy 2 colors into 8 positions
- add esi, 2 ; in a checkerboard
- mov ax, bx
- shl eax, 16
- mov ax, bx
- mov ebx, eax
- rol ebx, 8
-if 0 ;debug
- mov eax, 080808080h
- mov ebx, eax
-endif
-nf_solid:
- mov edx, nf_width
-
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- add edi, edx
- mov [edi], eax
- mov [edi+4], eax
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-nfPkDecompD ENDP
-
-endif
-
-;---
-
- .data
-
-; Constant tables
-
-nfhpk_mov4l LABEL DWORD
-; low 4x1 in 8x1 (patch +1)
-; mov eax, ebx/ecx
-MOVH4L_REGS TEXTEQU >
-%FOR m4, MOVH4L_REGS
-% FOR m3, MOVH4L_REGS
-% FOR m2, MOVH4L_REGS
-% FOR m1, MOVH4L_REGS
- BYTE m1,m2,m3,m4
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfhpk_mov8 LABEL DWORD
-; 8x1 (each two bits select a pair of colors in a reg)
-; low 4x2 in 8x2 (each two bits select a duplicated color in reg)
-; (patch +1)
-; mov ds:[edi+0/4/8/12], ebx/edx/ecx/ebp
-; Note: Patched code specifies mov [ebp+0]... instead
-; of mov [edi+0]... to insure that 8-bit offsets are
-; used by the assembler even for offset of zero.
-;
-MOVH8_REGS TEXTEQU >
-%FOR m4, MOVH8_REGS
-% FOR m3, MOVH8_REGS
-% FOR m2, MOVH8_REGS
-% FOR m1, MOVH8_REGS
- BYTE m1+047h,m2+047h,m3+047h,m4+047h
- ENDM
- ENDM
- ENDM
- ENDM
-
-nfhpk_mov4 LABEL DWORD
-; 4x2 (patch +2)
-; mov ax, bx/dx/cx/bp
-; low 4x2 in 8x2 (patch +1)
-; mov eax, ebx/edx/ecx/ebp
-MOVH4_REGS TEXTEQU >
-%FOR m4, MOVH4_REGS
-% FOR m3, MOVH4_REGS
-% FOR m2, MOVH4_REGS
-% FOR m1, MOVH4_REGS
- BYTE m1,m2,m3,m4
- ENDM
- ENDM
- ENDM
- ENDM
-
- .code
-
-; Normal version (HiColor)
-;
-
-if TRANS16
-
-if 0
-Trans16 MACRO dst:req, idx:req, mask
- mov dst, [idx]
- ifnb
- and dst, 07FFFh
- endif
- ENDM
-elseif 0
-Trans16 MACRO dst:req, idx:req, mask
- mov dst, [idx]
- mov ax, dst
- and ax, 0FFE0h
- add dst, ax
- ENDM
-else
-EXTERN nf_trans16_lo: WORD
-EXTERN nf_trans16_hi: WORD
-Trans16 MACRO dst:req, idx:req, mask
- xor eax, eax
- mov al, [idx]
- mov dst, nf_trans16_lo[eax*2]
- xor eax, eax
- mov al, [idx+1]
- or dst, nf_trans16_hi[eax*2]
- ENDM
-endif
-
-else
-
-Trans16 MACRO dst:req, idx:req, mask
- mov dst, [idx]
- ifnb
- and dst, 07FFFh
- endif
- ENDM
-
-endif
-
-nfHPkDecomp PROC USES ESI EDI EBX, \
- ops:PTRBYTE, comp:PTRBYTE, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD
- LOCAL tbuf: PTRBYTE
- LOCAL new_row:DWORD
- LOCAL DiffBufPtrs:DWORD
-
- LOCAL nfpk_back_right: DWORD
- LOCAL wcnt:DWORD
- LOCAL bcomp:PTRBYTE
-
- LOG_LABEL "StartPkDecomp"
-
-.data
-nfhpk_OpTbl label dword
- dword offset nf0 ; Prev Same (0)
- dword offset nf1 ; No change (and copied to screen) (0)
- dword offset nf2 ; Near shift from older part of current buf (1)
- dword offset nf3 ; Near shift from newer part of current buf (1)
- dword offset nf4 ; Near shift from previous buffer (1)
- dword offset nf5 ; Far shift from previous buffer (2)
- dword offset nf6 ; Far shift from current buffer (2)
- ; [Or if COMPOPS, run of no changes (0)]
- dword offset nf7 ; 8x8x1 (10 bytes) or low 4x4x1 (4 bytes)
- dword offset nf8 ; 2x2 4x4x1 (16 bytes) or 2x1 4x8x1 (12 bytes) or 1x2 8x4x1 (12 bytes)
- dword offset nf9 ; 8x8x2 (20 bytes) or low 4x4x2 (8 bytes) or
- ; low 4x8x2 (12 bytes) or low 8x4x2 (12 bytes)
- dword offset nf10 ; 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- dword offset nf11 ; 8x8x8 (64 bytes)
- dword offset nf12 ; low 4x4x8 (16 bytes)
- dword offset nf13 ; 2x2 4x4x0 (ie 2x2x8) (4 bytes)
- dword offset nf14 ; 8x8x0 (1 byte)
- dword offset nf15 ; mix 8x8x0 (2 bytes)
-.code
-
-ifdef SYMANTEC
- mov ebx, ds ; Allow DS to access code
- mov ecx, 0
- mov ax, 3505h
- int 21h
-endif
-
- NF_DECOMP_INIT 1
-
- mov eax, nf_back_right
- sub eax, SWIDTH*2
- mov nfpk_back_right, eax
-
- mov esi, comp
- mov edi, tbuf
-
- xor eax, eax
- mov ax, [esi]
- add eax, esi
- mov bcomp, eax
- add esi, 2
-
-nf_StartRow:
- mov eax, w
- shr eax, 1
- mov wcnt,eax
- ALIGN 4
-nf_NextPair:
- dec wcnt
- js nf_NextRow
- mov ebx, ops
- mov al, [ebx]
- inc ebx
- mov ops, ebx
-
- xor ebx, ebx
- mov bl, al
- shr bl, 4
- and eax, 0Fh
- push offset nf_NextPair
- push nfhpk_OpTbl[ebx*4]
- jmp nfhpk_OpTbl[eax*4]
-
-nf_NextRow:
- add edi, new_row
- dec h
- jnz nf_StartRow
- LOG_LABEL "EndPkDecomp"
-
-ifdef SYMANTEC
- mov ebx, ds ; Disable DS from accessing code
- mov ecx, offset DGROUP:_data_bottom[-1]
- mov ax, 3505h
- int 21h
-endif
- ret
-
-;----------------------------------------
- ALIGN 4
-nf0: ; No change from previous buffer
- mov eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf1: ; No change (and copied to screen)
-if 0 ;debug
- mov ebx, 0
- jmp nf_solid
-endif
- add edi, SWIDTH*2
- retn
-
-;----------------------------------------
- ALIGN 4
-nf2: ; Near shift from older part of current buffer
- xor eax, eax
- mov ebx, bcomp
- inc bcomp
- mov al, [ebx]
- mov ax, nfpk_ShiftP2[eax*2]
-nf_xyc_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24-1
- add eax, nfpk_ShiftY[ebx*4]
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf3: ; Near shift from newer part of current buffer
- xor eax, eax
- mov ebx, bcomp
- inc bcomp
- mov al, [ebx]
- mov ax, nfpk_ShiftP2[eax*2]
- neg al
- neg ah
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf4: ; Near shift from previous buffer
- xor eax, eax
- mov ebx, bcomp
- inc bcomp
- mov al, [ebx]
- mov ax, nfpk_ShiftP1[eax*2]
- jmp nf_xyp_shift
-
-;----------------------------------------
- ALIGN 4
-nf5: ; Far shift from previous buffer
- mov ax, [esi]
- add esi, 2
-nf_xyp_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24-1
- add eax, nfpk_ShiftY[ebx*4]
- add eax, DiffBufPtrs
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-
-nf6: ; Far shift from current buffer
- mov ax, [esi]
- add esi, 2
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf_shift:
-if 0 ;debug
- mov ebx, 0
- jmp nf_solid
-endif
- mov ebx, esi ; save esi
- lea esi, [edi+eax]
- mov edx, nf_width
-
- REPEAT 7
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- mov eax, [esi+8]
- mov [edi+8], eax
- mov eax, [esi+12]
- mov [edi+12], eax
- add esi, edx
- add edi, edx
- ENDM
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- mov eax, [esi+8]
- mov [edi+8], eax
- mov eax, [esi+12]
- mov [edi+12], eax
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- mov esi, ebx ; restore esi
- retn
-
-;----------------------------------------
- ALIGN 4
-nf7: ; 8x8x1 (12 bytes)
-
- test word ptr [esi], 08000h
- jnz nf23
-
-if 0 ;debug
- add esi, 12
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov8
- lea edx, byte ptr ds:nf7_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_11-nf7_11)], bl
- mov [edx+(nf7_12-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_13-nf7_11)], bl
- mov [edx+(nf7_14-nf7_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_21-nf7_11)], bl
- mov [edx+(nf7_22-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_23-nf7_11)], bl
- mov [edx+(nf7_24-nf7_11)], bh
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_31-nf7_11)], bl
- mov [edx+(nf7_32-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_33-nf7_11)], bl
- mov [edx+(nf7_34-nf7_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_41-nf7_11)], bl
- mov [edx+(nf7_42-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_43-nf7_11)], bl
- mov [edx+(nf7_44-nf7_11)], bh
-
- lea edx, [edx+(nf7_51-nf7_11)]
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_51-nf7_51)], bl
- mov [edx+(nf7_52-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_53-nf7_51)], bl
- mov [edx+(nf7_54-nf7_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_61-nf7_51)], bl
- mov [edx+(nf7_62-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_63-nf7_51)], bl
- mov [edx+(nf7_64-nf7_51)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_71-nf7_51)], bl
- mov [edx+(nf7_72-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_73-nf7_51)], bl
- mov [edx+(nf7_74-nf7_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_81-nf7_51)], bl
- mov [edx+(nf7_82-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_83-nf7_51)], bl
- mov [edx+(nf7_84-nf7_51)], bh
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-if TRANS16
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi
-else
- mov ecx, [esi]
-endif
- mov esi,nf_width
- mov edx, ecx
-
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf7_0 ; flush prefetch
- ALIGN 4
-nf7_0:
-nf7_11: mov [ebp+0], ebx
-nf7_12: mov [ebp+4], ebx
-nf7_13: mov [ebp+8], ebx
-nf7_14: mov [ebp+12], ebx
- add edi, esi
-
-nf7_21: mov [ebp+0], ebx
-nf7_22: mov [ebp+4], ebx
-nf7_23: mov [ebp+8], ebx
-nf7_24: mov [ebp+12], ebx
- add edi, esi
-
-nf7_31: mov [ebp+0], ebx
-nf7_32: mov [ebp+4], ebx
-nf7_33: mov [ebp+8], ebx
-nf7_34: mov [ebp+12], ebx
- add edi, esi
-
-nf7_41: mov [ebp+0], ebx
-nf7_42: mov [ebp+4], ebx
-nf7_43: mov [ebp+8], ebx
-nf7_44: mov [ebp+12], ebx
- add edi, esi
-
-nf7_51: mov [ebp+0], ebx
-nf7_52: mov [ebp+4], ebx
-nf7_53: mov [ebp+8], ebx
-nf7_54: mov [ebp+12], ebx
- add edi, esi
-
-nf7_61: mov [ebp+0], ebx
-nf7_62: mov [ebp+4], ebx
-nf7_63: mov [ebp+8], ebx
-nf7_64: mov [ebp+12], ebx
- add edi, esi
-
-nf7_71: mov [ebp+0], ebx
-nf7_72: mov [ebp+4], ebx
-nf7_73: mov [ebp+8], ebx
-nf7_74: mov [ebp+12], ebx
- add edi, esi
-
-nf7_81: mov [ebp+0], ebx
-nf7_82: mov [ebp+4], ebx
-nf7_83: mov [ebp+8], ebx
-nf7_84: mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf7+16
-nf23: ; low 4x4x1 (6 bytes)
-
-if 0 ;debug
- add esi, 6
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4l
- lea edx, byte ptr ds:nf23_11+1
-
- mov al, [esi+4]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_11-nf23_11)], bl
- mov [edx+(nf23_12-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_13-nf23_11)], bl
- mov [edx+(nf23_14-nf23_11)], bh
-
- mov al, [esi+4]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_31-nf23_11)], bl
- mov [edx+(nf23_32-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_33-nf23_11)], bl
- mov [edx+(nf23_34-nf23_11)], bh
-
-
- mov al, [esi+5]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_51-nf23_11)], bl
- mov [edx+(nf23_52-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_53-nf23_11)], bl
- mov [edx+(nf23_54-nf23_11)], bh
-
- mov al, [esi+5]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_71-nf23_11)], bl
- mov [edx+(nf23_72-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_73-nf23_11)], bl
- mov [edx+(nf23_74-nf23_11)], bh
-
- mov edx, nf_width
-
- ; load ebx,ecx with 00,11 color combinations
-if TRANS16
- Trans16 cx, esi, 1
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-else
- mov ebx, [esi]
- and ebx, 07FFF7FFFh
- mov ecx, ebx
- ror ebx, 16
- xchg bx,cx
-endif
-
- jmp nf23_0 ; flush prefetch
- ALIGN 4
-nf23_0:
-
-nf23_11:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_12:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_13:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_14:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_31:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_32:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_33:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_34:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_51:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_52:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_53:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_54:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_71:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_72:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_73:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_74:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- add edi, edx
-
- sub edi, nfpk_back_right
- add esi, 6
- retn
-
-;----------------------------------------
- ALIGN 4
-nf8: ; 2x2 4x4x1 (24 bytes)
-
- test word ptr [esi], 08000h
- jnz nf24
-
-if 0 ;debug
- add esi, 24
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov8
- lea edx, byte ptr ds:nf8_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_11-nf8_11)], bl
- mov [edx+(nf8_12-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_13-nf8_11)], bl
- mov [edx+(nf8_14-nf8_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_21-nf8_11)], bl
- mov [edx+(nf8_22-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_23-nf8_11)], bl
- mov [edx+(nf8_24-nf8_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_31-nf8_11)], bl
- mov [edx+(nf8_32-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_33-nf8_11)], bl
- mov [edx+(nf8_34-nf8_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_41-nf8_11)], bl
- mov [edx+(nf8_42-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_43-nf8_11)], bl
- mov [edx+(nf8_44-nf8_11)], bh
-
- add edx, nf8_51-nf8_11
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_51-nf8_51)], bl
- mov [edx+(nf8_52-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_53-nf8_51)], bl
- mov [edx+(nf8_54-nf8_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_61-nf8_51)], bl
- mov [edx+(nf8_62-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_63-nf8_51)], bl
- mov [edx+(nf8_64-nf8_51)], bh
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_71-nf8_51)], bl
- mov [edx+(nf8_72-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_73-nf8_51)], bl
- mov [edx+(nf8_74-nf8_51)], bh
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_81-nf8_51)], bl
- mov [edx+(nf8_82-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_83-nf8_51)], bl
- mov [edx+(nf8_84-nf8_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-if TRANS16
- Trans16 cx, esi+18+2
- shl ecx, 16
- Trans16 cx, esi+18
- push ecx
-
- Trans16 cx, esi+12+2
- shl ecx, 16
- Trans16 cx, esi+12
- push ecx
-
- Trans16 cx, esi+6+2
- shl ecx, 16
- Trans16 cx, esi+6
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi
-else
- mov ecx, [esi]
-endif
- mov esi,nf_width
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf8_0 ; flush prefetch
- ALIGN 4
-nf8_0:
-nf8_11: mov [ebp+0], ebx
-nf8_12: mov [ebp+4], ebx
- add edi, esi
-nf8_13: mov [ebp+0], ebx
-nf8_14: mov [ebp+4], ebx
- add edi, esi
-
-nf8_21: mov [ebp+0], ebx
-nf8_22: mov [ebp+4], ebx
- add edi, esi
-nf8_23: mov [ebp+0], ebx
-nf8_24: mov [ebp+4], ebx
- add edi, esi
-
-if TRANS16
- pop ecx
-else
- mov eax, [esp]
- mov ecx, [eax+6]
-endif
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-
-nf8_31: mov [ebp+0], ebx
-nf8_32: mov [ebp+4], ebx
- add edi, esi
-nf8_33: mov [ebp+0], ebx
-nf8_34: mov [ebp+4], ebx
- add edi, esi
-
-nf8_41: mov [ebp+0], ebx
-nf8_42: mov [ebp+4], ebx
- add edi, esi
-nf8_43: mov [ebp+0], ebx
-nf8_44: mov [ebp+4], ebx
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
-if TRANS16
- pop ecx
-else
- mov eax, [esp]
- mov ecx, [eax+12]
-endif
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf8_51: mov [ebp+0], ebx
-nf8_52: mov [ebp+4], ebx
- add edi, esi
-nf8_53: mov [ebp+0], ebx
-nf8_54: mov [ebp+4], ebx
- add edi, esi
-
-nf8_61: mov [ebp+0], ebx
-nf8_62: mov [ebp+4], ebx
- add edi, esi
-nf8_63: mov [ebp+0], ebx
-nf8_64: mov [ebp+4], ebx
- add edi, esi
-
-if TRANS16
- pop ecx
-else
- mov eax, [esp]
- mov ecx, [eax+18]
-endif
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf8_71: mov [ebp+0], ebx
-nf8_72: mov [ebp+4], ebx
- add edi, esi
-nf8_73: mov [ebp+0], ebx
-nf8_74: mov [ebp+4], ebx
- add edi, esi
-
-nf8_81: mov [ebp+0], ebx
-nf8_82: mov [ebp+4], ebx
- add edi, esi
-nf8_83: mov [ebp+0], ebx
-nf8_84: mov [ebp+4], ebx
-
- pop esi
- pop ebp
- add esi, 24
- sub edi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+16
-nf24: ; 2x1 4x8x1 (16 bytes)
-
- test word ptr [esi+8], 08000h
- jnz nf40
-
-if 0 ;debug
- add esi, 16
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov8
- lea edx, byte ptr ds:nf24_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_11-nf24_11)], bl
- mov [edx+(nf24_12-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_13-nf24_11)], bl
- mov [edx+(nf24_14-nf24_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_21-nf24_11)], bl
- mov [edx+(nf24_22-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_23-nf24_11)], bl
- mov [edx+(nf24_24-nf24_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_31-nf24_11)], bl
- mov [edx+(nf24_32-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_33-nf24_11)], bl
- mov [edx+(nf24_34-nf24_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_41-nf24_11)], bl
- mov [edx+(nf24_42-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_43-nf24_11)], bl
- mov [edx+(nf24_44-nf24_11)], bh
-
- add edx, nf24_51-nf24_11
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_51-nf24_51)], bl
- mov [edx+(nf24_52-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_53-nf24_51)], bl
- mov [edx+(nf24_54-nf24_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_61-nf24_51)], bl
- mov [edx+(nf24_62-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_63-nf24_51)], bl
- mov [edx+(nf24_64-nf24_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_71-nf24_51)], bl
- mov [edx+(nf24_72-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_73-nf24_51)], bl
- mov [edx+(nf24_74-nf24_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_81-nf24_51)], bl
- mov [edx+(nf24_82-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_83-nf24_51)], bl
- mov [edx+(nf24_84-nf24_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-if TRANS16
- Trans16 cx, esi+8+2
- shl ecx, 16
- Trans16 cx, esi+8
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi, 1
-else
- mov ecx, [esi]
- and ecx, 07FFF7FFFh
-endif
- mov esi,nf_width
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf24_0 ; flush prefetch
- ALIGN 4
-nf24_0:
-
-nf24_11:mov [ebp+0], ebx
-nf24_12:mov [ebp+4], ebx
- add edi, esi
-nf24_13:mov [ebp+0], ebx
-nf24_14:mov [ebp+4], ebx
- add edi, esi
-
-nf24_21:mov [ebp+0], ebx
-nf24_22:mov [ebp+4], ebx
- add edi, esi
-nf24_23:mov [ebp+0], ebx
-nf24_24:mov [ebp+4], ebx
- add edi, esi
-
-nf24_31:mov [ebp+0], ebx
-nf24_32:mov [ebp+4], ebx
- add edi, esi
-nf24_33:mov [ebp+0], ebx
-nf24_34:mov [ebp+4], ebx
- add edi, esi
-
-nf24_41:mov [ebp+0], ebx
-nf24_42:mov [ebp+4], ebx
- add edi, esi
-nf24_43:mov [ebp+0], ebx
-nf24_44:mov [ebp+4], ebx
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
-if TRANS16
- pop ecx
-else
- mov eax, [esp]
- mov ecx, [eax+8]
-endif
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf24_51:mov [ebp+0], ebx
-nf24_52:mov [ebp+4], ebx
- add edi, esi
-nf24_53:mov [ebp+0], ebx
-nf24_54:mov [ebp+4], ebx
- add edi, esi
-
-nf24_61:mov [ebp+0], ebx
-nf24_62:mov [ebp+4], ebx
- add edi, esi
-nf24_63:mov [ebp+0], ebx
-nf24_64:mov [ebp+4], ebx
- add edi, esi
-
-nf24_71:mov [ebp+0], ebx
-nf24_72:mov [ebp+4], ebx
- add edi, esi
-nf24_73:mov [ebp+0], ebx
-nf24_74:mov [ebp+4], ebx
- add edi, esi
-
-nf24_81:mov [ebp+0], ebx
-nf24_82:mov [ebp+4], ebx
- add edi, esi
-nf24_83:mov [ebp+0], ebx
-nf24_84:mov [ebp+4], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+32
-nf40: ; 1x2 8x4x1 (16 bytes)
-
-if 0 ;debug
- add esi, 16
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov8
- lea edx, byte ptr ds:nf40_11+1
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_11-nf40_11)], bl
- mov [edx+(nf40_12-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_13-nf40_11)], bl
- mov [edx+(nf40_14-nf40_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_21-nf40_11)], bl
- mov [edx+(nf40_22-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_23-nf40_11)], bl
- mov [edx+(nf40_24-nf40_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_31-nf40_11)], bl
- mov [edx+(nf40_32-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_33-nf40_11)], bl
- mov [edx+(nf40_34-nf40_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_41-nf40_11)], bl
- mov [edx+(nf40_42-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_43-nf40_11)], bl
- mov [edx+(nf40_44-nf40_11)], bh
-
- add edx, nf40_51-nf40_11
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_51-nf40_51)], bl
- mov [edx+(nf40_52-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_53-nf40_51)], bl
- mov [edx+(nf40_54-nf40_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_61-nf40_51)], bl
- mov [edx+(nf40_62-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_63-nf40_51)], bl
- mov [edx+(nf40_64-nf40_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_71-nf40_51)], bl
- mov [edx+(nf40_72-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_73-nf40_51)], bl
- mov [edx+(nf40_74-nf40_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_81-nf40_51)], bl
- mov [edx+(nf40_82-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_83-nf40_51)], bl
- mov [edx+(nf40_84-nf40_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-if TRANS16
- Trans16 cx, esi+8+2
- shl ecx, 16
- Trans16 cx, esi+8, 1
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi, 1
-else
- mov ecx, [esi]
- and ecx, 07FFF7FFFh
-endif
- mov esi,nf_width
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf40_0 ; flush prefetch
- ALIGN 4
-nf40_0:
-
-nf40_11:mov [ebp+0], ebx
-nf40_12:mov [ebp+4], ebx
-nf40_13:mov [ebp+8], ebx
-nf40_14:mov [ebp+12], ebx
- add edi, esi
-
-nf40_21:mov [ebp+0], ebx
-nf40_22:mov [ebp+4], ebx
-nf40_23:mov [ebp+8], ebx
-nf40_24:mov [ebp+12], ebx
- add edi, esi
-
-nf40_31:mov [ebp+0], ebx
-nf40_32:mov [ebp+4], ebx
-nf40_33:mov [ebp+8], ebx
-nf40_34:mov [ebp+12], ebx
- add edi, esi
-
-nf40_41:mov [ebp+0], ebx
-nf40_42:mov [ebp+4], ebx
-nf40_43:mov [ebp+8], ebx
-nf40_44:mov [ebp+12], ebx
- add edi, esi
-
-if TRANS16
- pop ecx
-else
- mov eax, [esp]
- mov ecx, [eax+8]
- and ecx, 07FFF7FFFh
-endif
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf40_51:mov [ebp+0], ebx
-nf40_52:mov [ebp+4], ebx
-nf40_53:mov [ebp+8], ebx
-nf40_54:mov [ebp+12], ebx
- add edi, esi
-
-nf40_61:mov [ebp+0], ebx
-nf40_62:mov [ebp+4], ebx
-nf40_63:mov [ebp+8], ebx
-nf40_64:mov [ebp+12], ebx
- add edi, esi
-
-nf40_71:mov [ebp+0], ebx
-nf40_72:mov [ebp+4], ebx
-nf40_73:mov [ebp+8], ebx
-nf40_74:mov [ebp+12], ebx
- add edi, esi
-
-nf40_81:mov [ebp+0], ebx
-nf40_82:mov [ebp+4], ebx
-nf40_83:mov [ebp+8], ebx
-nf40_84:mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf9: ; 8x8x2 (24 bytes)
-
- test word ptr [esi], 08000h
- jnz nf41
-
- test word ptr [esi+4], 08000h
- jnz nf25
-
-if 0 ;debug
- add esi, 24
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf9_11+2
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_11-nf9_11)], bh
- mov [edx+(nf9_12-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_13-nf9_11)], bh
- mov [edx+(nf9_14-nf9_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_15-nf9_11)], bh
- mov [edx+(nf9_16-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_17-nf9_11)], bh
- mov [edx+(nf9_18-nf9_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_21-nf9_11)], bh
- mov [edx+(nf9_22-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_23-nf9_11)], bh
- mov [edx+(nf9_24-nf9_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_25-nf9_11)], bh
- mov [edx+(nf9_26-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_27-nf9_11)], bh
- mov [edx+(nf9_28-nf9_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_31-nf9_11)], bh
- mov [edx+(nf9_32-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_33-nf9_11)], bh
- mov [edx+(nf9_34-nf9_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_35-nf9_11)], bh
- mov [edx+(nf9_36-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_37-nf9_11)], bh
- mov [edx+(nf9_38-nf9_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_41-nf9_11)], bh
- mov [edx+(nf9_42-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_43-nf9_11)], bh
- mov [edx+(nf9_44-nf9_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_45-nf9_11)], bh
- mov [edx+(nf9_46-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_47-nf9_11)], bh
- mov [edx+(nf9_48-nf9_11)], bl
-
-
- lea edx, [edx+(nf9_51-nf9_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_51-nf9_51)], bh
- mov [edx+(nf9_52-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_53-nf9_51)], bh
- mov [edx+(nf9_54-nf9_51)], bl
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_55-nf9_51)], bh
- mov [edx+(nf9_56-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_57-nf9_51)], bh
- mov [edx+(nf9_58-nf9_51)], bl
-
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_61-nf9_51)], bh
- mov [edx+(nf9_62-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_63-nf9_51)], bh
- mov [edx+(nf9_64-nf9_51)], bl
-
- mov al, [esi+19]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_65-nf9_51)], bh
- mov [edx+(nf9_66-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_67-nf9_51)], bh
- mov [edx+(nf9_68-nf9_51)], bl
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_71-nf9_51)], bh
- mov [edx+(nf9_72-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_73-nf9_51)], bh
- mov [edx+(nf9_74-nf9_51)], bl
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_75-nf9_51)], bh
- mov [edx+(nf9_76-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_77-nf9_51)], bh
- mov [edx+(nf9_78-nf9_51)], bl
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_81-nf9_51)], bh
- mov [edx+(nf9_82-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_83-nf9_51)], bh
- mov [edx+(nf9_84-nf9_51)], bl
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_85-nf9_51)], bh
- mov [edx+(nf9_86-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_87-nf9_51)], bh
- mov [edx+(nf9_88-nf9_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- Trans16 bx, esi
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-else
- mov bx, [esi]
- mov dx, [esi+2]
- mov cx, [esi+4]
- mov bp, [esi+6]
-endif
- mov esi, nf_width
-
- jmp nf9_0 ; flush prefetch
- ALIGN 4
-nf9_0:
-
-nf9_11: mov ax, bx
- shl eax, 16
-nf9_12: mov ax, bx
- mov [edi], eax
-nf9_13: mov ax, bx
- shl eax, 16
-nf9_14: mov ax, bx
- mov [edi+4], eax
-nf9_15: mov ax, bx
- shl eax, 16
-nf9_16: mov ax, bx
- mov [edi+8], eax
-nf9_17: mov ax, bx
- shl eax, 16
-nf9_18: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_21: mov ax, bx
- shl eax, 16
-nf9_22: mov ax, bx
- mov [edi], eax
-nf9_23: mov ax, bx
- shl eax, 16
-nf9_24: mov ax, bx
- mov [edi+4], eax
-nf9_25: mov ax, bx
- shl eax, 16
-nf9_26: mov ax, bx
- mov [edi+8], eax
-nf9_27: mov ax, bx
- shl eax, 16
-nf9_28: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_31: mov ax, bx
- shl eax, 16
-nf9_32: mov ax, bx
- mov [edi], eax
-nf9_33: mov ax, bx
- shl eax, 16
-nf9_34: mov ax, bx
- mov [edi+4], eax
-nf9_35: mov ax, bx
- shl eax, 16
-nf9_36: mov ax, bx
- mov [edi+8], eax
-nf9_37: mov ax, bx
- shl eax, 16
-nf9_38: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_41: mov ax, bx
- shl eax, 16
-nf9_42: mov ax, bx
- mov [edi], eax
-nf9_43: mov ax, bx
- shl eax, 16
-nf9_44: mov ax, bx
- mov [edi+4], eax
-nf9_45: mov ax, bx
- shl eax, 16
-nf9_46: mov ax, bx
- mov [edi+8], eax
-nf9_47: mov ax, bx
- shl eax, 16
-nf9_48: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_51: mov ax, bx
- shl eax, 16
-nf9_52: mov ax, bx
- mov [edi], eax
-nf9_53: mov ax, bx
- shl eax, 16
-nf9_54: mov ax, bx
- mov [edi+4], eax
-nf9_55: mov ax, bx
- shl eax, 16
-nf9_56: mov ax, bx
- mov [edi+8], eax
-nf9_57: mov ax, bx
- shl eax, 16
-nf9_58: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_61: mov ax, bx
- shl eax, 16
-nf9_62: mov ax, bx
- mov [edi], eax
-nf9_63: mov ax, bx
- shl eax, 16
-nf9_64: mov ax, bx
- mov [edi+4], eax
-nf9_65: mov ax, bx
- shl eax, 16
-nf9_66: mov ax, bx
- mov [edi+8], eax
-nf9_67: mov ax, bx
- shl eax, 16
-nf9_68: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_71: mov ax, bx
- shl eax, 16
-nf9_72: mov ax, bx
- mov [edi], eax
-nf9_73: mov ax, bx
- shl eax, 16
-nf9_74: mov ax, bx
- mov [edi+4], eax
-nf9_75: mov ax, bx
- shl eax, 16
-nf9_76: mov ax, bx
- mov [edi+8], eax
-nf9_77: mov ax, bx
- shl eax, 16
-nf9_78: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_81: mov ax, bx
- shl eax, 16
-nf9_82: mov ax, bx
- mov [edi], eax
-nf9_83: mov ax, bx
- shl eax, 16
-nf9_84: mov ax, bx
- mov [edi+4], eax
-nf9_85: mov ax, bx
- shl eax, 16
-nf9_86: mov ax, bx
- mov [edi+8], eax
-nf9_87: mov ax, bx
- shl eax, 16
-nf9_88: mov ax, bx
- mov [edi+12], eax
-
- pop esi
- pop ebp
- add esi, 24
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+16
-nf25: ; low 4x4x2 (12 bytes)
-
-if 0 ;debug
- add esi, 12
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf25_11+1
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_11-nf25_11)], bl
- mov [edx+(nf25_12-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_13-nf25_11)], bl
- mov [edx+(nf25_14-nf25_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_21-nf25_11)], bl
- mov [edx+(nf25_22-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_23-nf25_11)], bl
- mov [edx+(nf25_24-nf25_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_31-nf25_11)], bl
- mov [edx+(nf25_32-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_33-nf25_11)], bl
- mov [edx+(nf25_34-nf25_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_41-nf25_11)], bl
- mov [edx+(nf25_42-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_43-nf25_11)], bl
- mov [edx+(nf25_44-nf25_11)], bh
-
- push ebp
- push esi
- ; Load ebx,edx,ecx,ebp with four colors, duplicated in high order.
-if TRANS16
- Trans16 cx, esi
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd edx, ecx, 16
- mov dx, cx
- Trans16 cx, esi+4, 1
- shrd eax, ecx, 16
- mov ax, cx
- push eax
- Trans16 cx, esi+6
- shrd ebp, ecx, 16
- mov bp, cx
- pop ecx
-else
- mov ax, [esi]
- shrd ebx, eax, 16
- mov bx, ax
- mov ax, [esi+2]
- shrd edx, eax, 16
- mov dx, ax
- mov ax, [esi+4]
- and eax, 07fffh
- shrd ecx, eax, 16
- mov cx, ax
- mov ax, [esi+6]
- shrd ebp, eax, 16
- mov bp, ax
-endif
- mov esi, nf_width
-
- jmp nf25_0 ; flush prefetch
- ALIGN 4
-nf25_0:
-
-nf25_11:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_12:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_13:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_14:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_21:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_22:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_23:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_24:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_31:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_32:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_33:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_34:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_41:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_42:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_43:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_44:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
-
- add edi, esi
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+32
-nf41: ; low 4x8x2 (16 bytes)
- test word ptr [esi+4], 08000h
- jnz nf57
-
-if 0 ;debug
- add esi, 16
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov8
- lea edx, byte ptr ds:nf41_11+1
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_11-nf41_11)], bl
- mov [edx+(nf41_12-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_13-nf41_11)], bl
- mov [edx+(nf41_14-nf41_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_21-nf41_11)], bl
- mov [edx+(nf41_22-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_23-nf41_11)], bl
- mov [edx+(nf41_24-nf41_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_31-nf41_11)], bl
- mov [edx+(nf41_32-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_33-nf41_11)], bl
- mov [edx+(nf41_34-nf41_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_41-nf41_11)], bl
- mov [edx+(nf41_42-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_43-nf41_11)], bl
- mov [edx+(nf41_44-nf41_11)], bh
-
- lea edx, [edx+(nf41_51-nf41_11)]
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_51-nf41_51)], bl
- mov [edx+(nf41_52-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_53-nf41_51)], bl
- mov [edx+(nf41_54-nf41_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_61-nf41_51)], bl
- mov [edx+(nf41_62-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_63-nf41_51)], bl
- mov [edx+(nf41_64-nf41_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_71-nf41_51)], bl
- mov [edx+(nf41_72-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_73-nf41_51)], bl
- mov [edx+(nf41_74-nf41_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_81-nf41_51)], bl
- mov [edx+(nf41_82-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_83-nf41_51)], bl
- mov [edx+(nf41_84-nf41_51)], bh
-
- push ebp
- push esi
- ; Load ebx,edx,ecx,ebp with four colors, duplicated in high order.
-if TRANS16
- Trans16 cx, esi, 1
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd edx, ecx, 16
- mov dx, cx
- Trans16 cx, esi+4
- shrd eax, ecx, 16
- mov ax, cx
- push eax
- Trans16 cx, esi+6
- shrd ebp, ecx, 16
- mov bp, cx
- pop ecx
-else
- mov ax, [esi]
- and eax, 07fffh
- shrd ebx, eax, 16
- mov bx, ax
- mov ax, [esi+2]
- shrd edx, eax, 16
- mov dx, ax
- mov ax, [esi+4]
- shrd ecx, eax, 16
- mov cx, ax
- mov ax, [esi+6]
- shrd ebp, eax, 16
- mov bp, ax
-endif
- mov esi, nf_width
-
- jmp nf41_0 ; flush prefetch
- ALIGN 4
-nf41_0:
-
-nf41_11:mov [ebp+0], ebx
-nf41_12:mov [ebp+4], ebx
-nf41_13:mov [ebp+8], ebx
-nf41_14:mov [ebp+12], ebx
- add edi, esi
-
-nf41_21:mov [ebp+0], ebx
-nf41_22:mov [ebp+4], ebx
-nf41_23:mov [ebp+8], ebx
-nf41_24:mov [ebp+12], ebx
- add edi, esi
-
-nf41_31:mov [ebp+0], ebx
-nf41_32:mov [ebp+4], ebx
-nf41_33:mov [ebp+8], ebx
-nf41_34:mov [ebp+12], ebx
- add edi, esi
-
-nf41_41:mov [ebp+0], ebx
-nf41_42:mov [ebp+4], ebx
-nf41_43:mov [ebp+8], ebx
-nf41_44:mov [ebp+12], ebx
- add edi, esi
-
-nf41_51:mov [ebp+0], ebx
-nf41_52:mov [ebp+4], ebx
-nf41_53:mov [ebp+8], ebx
-nf41_54:mov [ebp+12], ebx
- add edi, esi
-
-nf41_61:mov [ebp+0], ebx
-nf41_62:mov [ebp+4], ebx
-nf41_63:mov [ebp+8], ebx
-nf41_64:mov [ebp+12], ebx
- add edi, esi
-
-nf41_71:mov [ebp+0], ebx
-nf41_72:mov [ebp+4], ebx
-nf41_73:mov [ebp+8], ebx
-nf41_74:mov [ebp+12], ebx
- add edi, esi
-
-nf41_81:mov [ebp+0], ebx
-nf41_82:mov [ebp+4], ebx
-nf41_83:mov [ebp+8], ebx
-nf41_84:mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+48
-nf57: ; low 8x4x2 (16 bytes)
-if 0 ;debug
- add esi, 16
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf57_11+2
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_11-nf57_11)], bh
- mov [edx+(nf57_12-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_13-nf57_11)], bh
- mov [edx+(nf57_14-nf57_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_15-nf57_11)], bh
- mov [edx+(nf57_16-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_17-nf57_11)], bh
- mov [edx+(nf57_18-nf57_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_21-nf57_11)], bh
- mov [edx+(nf57_22-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_23-nf57_11)], bh
- mov [edx+(nf57_24-nf57_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_25-nf57_11)], bh
- mov [edx+(nf57_26-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_27-nf57_11)], bh
- mov [edx+(nf57_28-nf57_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_31-nf57_11)], bh
- mov [edx+(nf57_32-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_33-nf57_11)], bh
- mov [edx+(nf57_34-nf57_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_35-nf57_11)], bh
- mov [edx+(nf57_36-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_37-nf57_11)], bh
- mov [edx+(nf57_38-nf57_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_41-nf57_11)], bh
- mov [edx+(nf57_42-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_43-nf57_11)], bh
- mov [edx+(nf57_44-nf57_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_45-nf57_11)], bh
- mov [edx+(nf57_46-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_47-nf57_11)], bh
- mov [edx+(nf57_48-nf57_11)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- Trans16 bx, esi, 1
- Trans16 dx, esi+2
- Trans16 cx, esi+4, 1
- Trans16 bp, esi+6
-else
- mov bx, [esi]
- and ebx, 07fffh
- mov dx, [esi+2]
- mov cx, [esi+4]
- and ecx, 07fffh
- mov bp, [esi+6]
-endif
- mov esi, nf_width
-
- jmp nf57_0 ; flush prefetch
- ALIGN 4
-nf57_0:
-
-nf57_11:mov ax, bx
- shl eax, 16
-nf57_12:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_13:mov ax, bx
- shl eax, 16
-nf57_14:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_15:mov ax, bx
- shl eax, 16
-nf57_16:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_17:mov ax, bx
- shl eax, 16
-nf57_18:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_21:mov ax, bx
- shl eax, 16
-nf57_22:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_23:mov ax, bx
- shl eax, 16
-nf57_24:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_25:mov ax, bx
- shl eax, 16
-nf57_26:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_27:mov ax, bx
- shl eax, 16
-nf57_28:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_31:mov ax, bx
- shl eax, 16
-nf57_32:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_33:mov ax, bx
- shl eax, 16
-nf57_34:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_35:mov ax, bx
- shl eax, 16
-nf57_36:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_37:mov ax, bx
- shl eax, 16
-nf57_38:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_41:mov ax, bx
- shl eax, 16
-nf57_42:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_43:mov ax, bx
- shl eax, 16
-nf57_44:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_45:mov ax, bx
- shl eax, 16
-nf57_46:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_47:mov ax, bx
- shl eax, 16
-nf57_48:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- add edi, esi
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf10: ; 2x2 4x4x2 (48 bytes)
-
- test word ptr [esi], 08000h
- jnz nf26
-
-if 0 ;debug
- add esi, 48
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf10_11+2
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_11-nf10_11)], bh
- mov [edx+(nf10_12-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_13-nf10_11)], bh
- mov [edx+(nf10_14-nf10_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_15-nf10_11)], bh
- mov [edx+(nf10_16-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_17-nf10_11)], bh
- mov [edx+(nf10_18-nf10_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_21-nf10_11)], bh
- mov [edx+(nf10_22-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_23-nf10_11)], bh
- mov [edx+(nf10_24-nf10_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_25-nf10_11)], bh
- mov [edx+(nf10_26-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_27-nf10_11)], bh
- mov [edx+(nf10_28-nf10_11)], bl
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_31-nf10_11)], bh
- mov [edx+(nf10_32-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_33-nf10_11)], bh
- mov [edx+(nf10_34-nf10_11)], bl
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_35-nf10_11)], bh
- mov [edx+(nf10_36-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_37-nf10_11)], bh
- mov [edx+(nf10_38-nf10_11)], bl
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_41-nf10_11)], bh
- mov [edx+(nf10_42-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_43-nf10_11)], bh
- mov [edx+(nf10_44-nf10_11)], bl
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_45-nf10_11)], bh
- mov [edx+(nf10_46-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_47-nf10_11)], bh
- mov [edx+(nf10_48-nf10_11)], bl
-
-
- lea edx, [edx+(nf10_51-nf10_11)]
-
- mov al, [esi+32]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_51-nf10_51)], bh
- mov [edx+(nf10_52-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_53-nf10_51)], bh
- mov [edx+(nf10_54-nf10_51)], bl
-
- mov al, [esi+33]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_55-nf10_51)], bh
- mov [edx+(nf10_56-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_57-nf10_51)], bh
- mov [edx+(nf10_58-nf10_51)], bl
-
-
- mov al, [esi+34]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_61-nf10_51)], bh
- mov [edx+(nf10_62-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_63-nf10_51)], bh
- mov [edx+(nf10_64-nf10_51)], bl
-
- mov al, [esi+35]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_65-nf10_51)], bh
- mov [edx+(nf10_66-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_67-nf10_51)], bh
- mov [edx+(nf10_68-nf10_51)], bl
-
-
- mov al, [esi+44]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_71-nf10_51)], bh
- mov [edx+(nf10_72-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_73-nf10_51)], bh
- mov [edx+(nf10_74-nf10_51)], bl
-
- mov al, [esi+45]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_75-nf10_51)], bh
- mov [edx+(nf10_76-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_77-nf10_51)], bh
- mov [edx+(nf10_78-nf10_51)], bl
-
-
- mov al, [esi+46]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_81-nf10_51)], bh
- mov [edx+(nf10_82-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_83-nf10_51)], bh
- mov [edx+(nf10_84-nf10_51)], bl
-
- mov al, [esi+47]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_85-nf10_51)], bh
- mov [edx+(nf10_86-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_87-nf10_51)], bh
- mov [edx+(nf10_88-nf10_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- Trans16 bx, esi
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-else
- mov bx, [esi]
- mov dx, [esi+2]
- mov cx, [esi+4]
- mov bp, [esi+6]
-endif
- mov esi, nf_width
-
- jmp nf10_0 ; flush prefetch
- ALIGN 4
-nf10_0:
-
-nf10_11:mov ax, bx
- shl eax, 16
-nf10_12:mov ax, bx
- mov [edi], eax
-nf10_13:mov ax, bx
- shl eax, 16
-nf10_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_15:mov ax, bx
- shl eax, 16
-nf10_16:mov ax, bx
- mov [edi], eax
-nf10_17:mov ax, bx
- shl eax, 16
-nf10_18:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_21:mov ax, bx
- shl eax, 16
-nf10_22:mov ax, bx
- mov [edi], eax
-nf10_23:mov ax, bx
- shl eax, 16
-nf10_24:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_25:mov ax, bx
- shl eax, 16
-nf10_26:mov ax, bx
- mov [edi], eax
-nf10_27:mov ax, bx
- shl eax, 16
-nf10_28:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- mov esi, [esp]
- Trans16 bx, esi+12
- Trans16 dx, esi+14
- Trans16 cx, esi+16
- Trans16 bp, esi+18
- mov esi, nf_width
-else
- mov eax, [esp]
- mov bx, [eax+12]
- mov dx, [eax+14]
- mov cx, [eax+16]
- mov bp, [eax+18]
-endif
-
-nf10_31:mov ax, bx
- shl eax, 16
-nf10_32:mov ax, bx
- mov [edi], eax
-nf10_33:mov ax, bx
- shl eax, 16
-nf10_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_35:mov ax, bx
- shl eax, 16
-nf10_36:mov ax, bx
- mov [edi], eax
-nf10_37:mov ax, bx
- shl eax, 16
-nf10_38:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_41:mov ax, bx
- shl eax, 16
-nf10_42:mov ax, bx
- mov [edi], eax
-nf10_43:mov ax, bx
- shl eax, 16
-nf10_44:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_45:mov ax, bx
- shl eax, 16
-nf10_46:mov ax, bx
- mov [edi], eax
-nf10_47:mov ax, bx
- shl eax, 16
-nf10_48:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- mov esi, [esp]
- Trans16 bx, esi+24
- Trans16 dx, esi+26
- Trans16 cx, esi+28
- Trans16 bp, esi+30
- mov esi, nf_width
-else
- mov eax, [esp]
- mov bx, [eax+24]
- mov dx, [eax+26]
- mov cx, [eax+28]
- mov bp, [eax+30]
-endif
-
-nf10_51:mov ax, bx
- shl eax, 16
-nf10_52:mov ax, bx
- mov [edi], eax
-nf10_53:mov ax, bx
- shl eax, 16
-nf10_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_55:mov ax, bx
- shl eax, 16
-nf10_56:mov ax, bx
- mov [edi], eax
-nf10_57:mov ax, bx
- shl eax, 16
-nf10_58:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_61:mov ax, bx
- shl eax, 16
-nf10_62:mov ax, bx
- mov [edi], eax
-nf10_63:mov ax, bx
- shl eax, 16
-nf10_64:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_65:mov ax, bx
- shl eax, 16
-nf10_66:mov ax, bx
- mov [edi], eax
-nf10_67:mov ax, bx
- shl eax, 16
-nf10_68:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- mov esi, [esp]
- Trans16 bx, esi+36
- Trans16 dx, esi+38
- Trans16 cx, esi+40
- Trans16 bp, esi+42
- mov esi, nf_width
-else
- mov eax, [esp]
- mov bx, [eax+36]
- mov dx, [eax+38]
- mov cx, [eax+40]
- mov bp, [eax+42]
-endif
-
-nf10_71:mov ax, bx
- shl eax, 16
-nf10_72:mov ax, bx
- mov [edi], eax
-nf10_73:mov ax, bx
- shl eax, 16
-nf10_74:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_75:mov ax, bx
- shl eax, 16
-nf10_76:mov ax, bx
- mov [edi], eax
-nf10_77:mov ax, bx
- shl eax, 16
-nf10_78:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_81:mov ax, bx
- shl eax, 16
-nf10_82:mov ax, bx
- mov [edi], eax
-nf10_83:mov ax, bx
- shl eax, 16
-nf10_84:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_85:mov ax, bx
- shl eax, 16
-nf10_86:mov ax, bx
- mov [edi], eax
-nf10_87:mov ax, bx
- shl eax, 16
-nf10_88:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 48
- sub edi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+16
-nf26: ; 2x1 4x8x2 (32 bytes)
-
- test word ptr [esi+16], 08000h
- jnz nf42
-
-if 0 ;debug
- add esi, 32
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf26_11+2
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_11-nf26_11)], bh
- mov [edx+(nf26_12-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_13-nf26_11)], bh
- mov [edx+(nf26_14-nf26_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_15-nf26_11)], bh
- mov [edx+(nf26_16-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_17-nf26_11)], bh
- mov [edx+(nf26_18-nf26_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_21-nf26_11)], bh
- mov [edx+(nf26_22-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_23-nf26_11)], bh
- mov [edx+(nf26_24-nf26_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_25-nf26_11)], bh
- mov [edx+(nf26_26-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_27-nf26_11)], bh
- mov [edx+(nf26_28-nf26_11)], bl
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_31-nf26_11)], bh
- mov [edx+(nf26_32-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_33-nf26_11)], bh
- mov [edx+(nf26_34-nf26_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_35-nf26_11)], bh
- mov [edx+(nf26_36-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_37-nf26_11)], bh
- mov [edx+(nf26_38-nf26_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_41-nf26_11)], bh
- mov [edx+(nf26_42-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_43-nf26_11)], bh
- mov [edx+(nf26_44-nf26_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_45-nf26_11)], bh
- mov [edx+(nf26_46-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_47-nf26_11)], bh
- mov [edx+(nf26_48-nf26_11)], bl
-
-
- lea edx, [edx+(nf26_51-nf26_11)]
-
- mov al, [esi+24]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_51-nf26_51)], bh
- mov [edx+(nf26_52-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_53-nf26_51)], bh
- mov [edx+(nf26_54-nf26_51)], bl
-
- mov al, [esi+25]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_55-nf26_51)], bh
- mov [edx+(nf26_56-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_57-nf26_51)], bh
- mov [edx+(nf26_58-nf26_51)], bl
-
-
- mov al, [esi+26]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_61-nf26_51)], bh
- mov [edx+(nf26_62-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_63-nf26_51)], bh
- mov [edx+(nf26_64-nf26_51)], bl
-
- mov al, [esi+27]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_65-nf26_51)], bh
- mov [edx+(nf26_66-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_67-nf26_51)], bh
- mov [edx+(nf26_68-nf26_51)], bl
-
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_71-nf26_51)], bh
- mov [edx+(nf26_72-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_73-nf26_51)], bh
- mov [edx+(nf26_74-nf26_51)], bl
-
- mov al, [esi+29]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_75-nf26_51)], bh
- mov [edx+(nf26_76-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_77-nf26_51)], bh
- mov [edx+(nf26_78-nf26_51)], bl
-
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_81-nf26_51)], bh
- mov [edx+(nf26_82-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_83-nf26_51)], bh
- mov [edx+(nf26_84-nf26_51)], bl
-
- mov al, [esi+31]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_85-nf26_51)], bh
- mov [edx+(nf26_86-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_87-nf26_51)], bh
- mov [edx+(nf26_88-nf26_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- Trans16 bx, esi, 1
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-else
- mov bx, [esi]
- and ebx, 07fffh
- mov dx, [esi+2]
- mov cx, [esi+4]
- mov bp, [esi+6]
-endif
- mov esi, nf_width
-
- jmp nf26_0 ; flush prefetch
- ALIGN 4
-nf26_0:
-
-nf26_11:mov ax, bx
- shl eax, 16
-nf26_12:mov ax, bx
- mov [edi], eax
-nf26_13:mov ax, bx
- shl eax, 16
-nf26_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_15:mov ax, bx
- shl eax, 16
-nf26_16:mov ax, bx
- mov [edi], eax
-nf26_17:mov ax, bx
- shl eax, 16
-nf26_18:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_21:mov ax, bx
- shl eax, 16
-nf26_22:mov ax, bx
- mov [edi], eax
-nf26_23:mov ax, bx
- shl eax, 16
-nf26_24:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_25:mov ax, bx
- shl eax, 16
-nf26_26:mov ax, bx
- mov [edi], eax
-nf26_27:mov ax, bx
- shl eax, 16
-nf26_28:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_31:mov ax, bx
- shl eax, 16
-nf26_32:mov ax, bx
- mov [edi], eax
-nf26_33:mov ax, bx
- shl eax, 16
-nf26_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_35:mov ax, bx
- shl eax, 16
-nf26_36:mov ax, bx
- mov [edi], eax
-nf26_37:mov ax, bx
- shl eax, 16
-nf26_38:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_41:mov ax, bx
- shl eax, 16
-nf26_42:mov ax, bx
- mov [edi], eax
-nf26_43:mov ax, bx
- shl eax, 16
-nf26_44:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_45:mov ax, bx
- shl eax, 16
-nf26_46:mov ax, bx
- mov [edi], eax
-nf26_47:mov ax, bx
- shl eax, 16
-nf26_48:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- mov esi, [esp]
- Trans16 bx, esi+16
- Trans16 dx, esi+18
- Trans16 cx, esi+20
- Trans16 bp, esi+22
- mov esi, nf_width
-else
- mov eax, [esp]
- mov bx, [eax+16]
- mov dx, [eax+18]
- mov cx, [eax+20]
- mov bp, [eax+22]
-endif
-
-nf26_51:mov ax, bx
- shl eax, 16
-nf26_52:mov ax, bx
- mov [edi], eax
-nf26_53:mov ax, bx
- shl eax, 16
-nf26_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_55:mov ax, bx
- shl eax, 16
-nf26_56:mov ax, bx
- mov [edi], eax
-nf26_57:mov ax, bx
- shl eax, 16
-nf26_58:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_61:mov ax, bx
- shl eax, 16
-nf26_62:mov ax, bx
- mov [edi], eax
-nf26_63:mov ax, bx
- shl eax, 16
-nf26_64:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_65:mov ax, bx
- shl eax, 16
-nf26_66:mov ax, bx
- mov [edi], eax
-nf26_67:mov ax, bx
- shl eax, 16
-nf26_68:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_71:mov ax, bx
- shl eax, 16
-nf26_72:mov ax, bx
- mov [edi], eax
-nf26_73:mov ax, bx
- shl eax, 16
-nf26_74:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_75:mov ax, bx
- shl eax, 16
-nf26_76:mov ax, bx
- mov [edi], eax
-nf26_77:mov ax, bx
- shl eax, 16
-nf26_78:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_81:mov ax, bx
- shl eax, 16
-nf26_82:mov ax, bx
- mov [edi], eax
-nf26_83:mov ax, bx
- shl eax, 16
-nf26_84:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_85:mov ax, bx
- shl eax, 16
-nf26_86:mov ax, bx
- mov [edi], eax
-nf26_87:mov ax, bx
- shl eax, 16
-nf26_88:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 32
- sub edi, 8
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+32
-nf42: ; 1x2 8x4x2 (32 bytes)
-
-if 0 ;debug
- add esi, 32
- mov ebx, 0
- jmp nf_solid
-endif
- xor eax, eax
- lea ecx, nfhpk_mov4
- lea edx, byte ptr ds:nf42_11+2
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_11-nf42_11)], bh
- mov [edx+(nf42_12-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_13-nf42_11)], bh
- mov [edx+(nf42_14-nf42_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_15-nf42_11)], bh
- mov [edx+(nf42_16-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_17-nf42_11)], bh
- mov [edx+(nf42_18-nf42_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_21-nf42_11)], bh
- mov [edx+(nf42_22-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_23-nf42_11)], bh
- mov [edx+(nf42_24-nf42_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_25-nf42_11)], bh
- mov [edx+(nf42_26-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_27-nf42_11)], bh
- mov [edx+(nf42_28-nf42_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_31-nf42_11)], bh
- mov [edx+(nf42_32-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_33-nf42_11)], bh
- mov [edx+(nf42_34-nf42_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_35-nf42_11)], bh
- mov [edx+(nf42_36-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_37-nf42_11)], bh
- mov [edx+(nf42_38-nf42_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_41-nf42_11)], bh
- mov [edx+(nf42_42-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_43-nf42_11)], bh
- mov [edx+(nf42_44-nf42_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_45-nf42_11)], bh
- mov [edx+(nf42_46-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_47-nf42_11)], bh
- mov [edx+(nf42_48-nf42_11)], bl
-
-
- lea edx, [edx+(nf42_51-nf42_11)]
-
- mov al, [esi+24]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_51-nf42_51)], bh
- mov [edx+(nf42_52-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_53-nf42_51)], bh
- mov [edx+(nf42_54-nf42_51)], bl
-
- mov al, [esi+25]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_55-nf42_51)], bh
- mov [edx+(nf42_56-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_57-nf42_51)], bh
- mov [edx+(nf42_58-nf42_51)], bl
-
-
- mov al, [esi+26]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_61-nf42_51)], bh
- mov [edx+(nf42_62-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_63-nf42_51)], bh
- mov [edx+(nf42_64-nf42_51)], bl
-
- mov al, [esi+27]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_65-nf42_51)], bh
- mov [edx+(nf42_66-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_67-nf42_51)], bh
- mov [edx+(nf42_68-nf42_51)], bl
-
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_71-nf42_51)], bh
- mov [edx+(nf42_72-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_73-nf42_51)], bh
- mov [edx+(nf42_74-nf42_51)], bl
-
- mov al, [esi+29]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_75-nf42_51)], bh
- mov [edx+(nf42_76-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_77-nf42_51)], bh
- mov [edx+(nf42_78-nf42_51)], bl
-
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_81-nf42_51)], bh
- mov [edx+(nf42_82-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_83-nf42_51)], bh
- mov [edx+(nf42_84-nf42_51)], bl
-
- mov al, [esi+31]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_85-nf42_51)], bh
- mov [edx+(nf42_86-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_87-nf42_51)], bh
- mov [edx+(nf42_88-nf42_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- Trans16 bx, esi, 1
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-else
- mov bx, [esi]
- and ebx, 07fffh
- mov dx, [esi+2]
- mov cx, [esi+4]
- mov bp, [esi+6]
-endif
- mov esi, nf_width
-
- jmp nf42_0 ; flush prefetch
- ALIGN 4
-nf42_0:
-
-nf42_11:mov ax, bx
- shl eax, 16
-nf42_12:mov ax, bx
- mov [edi], eax
-nf42_13:mov ax, bx
- shl eax, 16
-nf42_14:mov ax, bx
- mov [edi+4], eax
-nf42_15:mov ax, bx
- shl eax, 16
-nf42_16:mov ax, bx
- mov [edi+8], eax
-nf42_17:mov ax, bx
- shl eax, 16
-nf42_18:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_21:mov ax, bx
- shl eax, 16
-nf42_22:mov ax, bx
- mov [edi], eax
-nf42_23:mov ax, bx
- shl eax, 16
-nf42_24:mov ax, bx
- mov [edi+4], eax
-nf42_25:mov ax, bx
- shl eax, 16
-nf42_26:mov ax, bx
- mov [edi+8], eax
-nf42_27:mov ax, bx
- shl eax, 16
-nf42_28:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_31:mov ax, bx
- shl eax, 16
-nf42_32:mov ax, bx
- mov [edi], eax
-nf42_33:mov ax, bx
- shl eax, 16
-nf42_34:mov ax, bx
- mov [edi+4], eax
-nf42_35:mov ax, bx
- shl eax, 16
-nf42_36:mov ax, bx
- mov [edi+8], eax
-nf42_37:mov ax, bx
- shl eax, 16
-nf42_38:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_41:mov ax, bx
- shl eax, 16
-nf42_42:mov ax, bx
- mov [edi], eax
-nf42_43:mov ax, bx
- shl eax, 16
-nf42_44:mov ax, bx
- mov [edi+4], eax
-nf42_45:mov ax, bx
- shl eax, 16
-nf42_46:mov ax, bx
- mov [edi+8], eax
-nf42_47:mov ax, bx
- shl eax, 16
-nf42_48:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-if TRANS16
- mov esi, [esp]
- Trans16 bx, esi+16, 1
- Trans16 dx, esi+18
- Trans16 cx, esi+20
- Trans16 bp, esi+22
- mov esi, nf_width
-else
- mov eax, [esp]
- mov bx, [eax+16]
- and ebx, 07fffh
- mov dx, [eax+18]
- mov cx, [eax+20]
- mov bp, [eax+22]
-endif
-
-nf42_51:mov ax, bx
- shl eax, 16
-nf42_52:mov ax, bx
- mov [edi], eax
-nf42_53:mov ax, bx
- shl eax, 16
-nf42_54:mov ax, bx
- mov [edi+4], eax
-nf42_55:mov ax, bx
- shl eax, 16
-nf42_56:mov ax, bx
- mov [edi+8], eax
-nf42_57:mov ax, bx
- shl eax, 16
-nf42_58:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_61:mov ax, bx
- shl eax, 16
-nf42_62:mov ax, bx
- mov [edi], eax
-nf42_63:mov ax, bx
- shl eax, 16
-nf42_64:mov ax, bx
- mov [edi+4], eax
-nf42_65:mov ax, bx
- shl eax, 16
-nf42_66:mov ax, bx
- mov [edi+8], eax
-nf42_67:mov ax, bx
- shl eax, 16
-nf42_68:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_71:mov ax, bx
- shl eax, 16
-nf42_72:mov ax, bx
- mov [edi], eax
-nf42_73:mov ax, bx
- shl eax, 16
-nf42_74:mov ax, bx
- mov [edi+4], eax
-nf42_75:mov ax, bx
- shl eax, 16
-nf42_76:mov ax, bx
- mov [edi+8], eax
-nf42_77:mov ax, bx
- shl eax, 16
-nf42_78:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_81:mov ax, bx
- shl eax, 16
-nf42_82:mov ax, bx
- mov [edi], eax
-nf42_83:mov ax, bx
- shl eax, 16
-nf42_84:mov ax, bx
- mov [edi+4], eax
-nf42_85:mov ax, bx
- shl eax, 16
-nf42_86:mov ax, bx
- mov [edi+8], eax
-nf42_87:mov ax, bx
- shl eax, 16
-nf42_88:mov ax, bx
- mov [edi+12], eax
-
- pop esi
- pop ebp
- add esi, 32
- sub edi, nfpk_back_right
- retn
-
-;----------------------------------------
- ALIGN 4
-nf11: ; 8x8x16 (128 bytes)
-if 0 ;debug
- add esi, 128
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
-
-if TRANS16
-
-Trans16Blk MACRO idx
- Trans16 bx, idx
- mov [edi], bx
- Trans16 bx, idx+2
- mov [edi+2], bx
- Trans16 bx, idx+4
- mov [edi+4], bx
- Trans16 bx, idx+6
- mov [edi+6], bx
- Trans16 bx, idx+8
- mov [edi+8], bx
- Trans16 bx, idx+10
- mov [edi+10], bx
- Trans16 bx, idx+12
- mov [edi+12], bx
- Trans16 bx, idx+14
- mov [edi+14], bx
- ENDM
-
- Trans16Blk esi ;0
- add edi, edx
- Trans16Blk esi+16 ;1
- add edi, edx
- Trans16Blk esi+32 ;2
- add edi, edx
- Trans16Blk esi+48 ;3
- add edi, edx
- Trans16Blk esi+64 ;4
- add edi, edx
- Trans16Blk esi+80 ;5
- add edi, edx
- Trans16Blk esi+96 ;6
- add edi, edx
- Trans16Blk esi+112 ;7
-else
- mov eax, [esi] ;0
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- mov eax, [esi+8]
- mov [edi+8], eax
- mov eax, [esi+12]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+16] ;1
- mov [edi], eax
- mov eax, [esi+20]
- mov [edi+4], eax
- mov eax, [esi+24]
- mov [edi+8], eax
- mov eax, [esi+28]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+32] ;2
- mov [edi], eax
- mov eax, [esi+36]
- mov [edi+4], eax
- mov eax, [esi+40]
- mov [edi+8], eax
- mov eax, [esi+44]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+48] ;3
- mov [edi], eax
- mov eax, [esi+52]
- mov [edi+4], eax
- mov eax, [esi+56]
- mov [edi+8], eax
- mov eax, [esi+60]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+64] ;4
- mov [edi], eax
- mov eax, [esi+68]
- mov [edi+4], eax
- mov eax, [esi+72]
- mov [edi+8], eax
- mov eax, [esi+76]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+80] ;5
- mov [edi], eax
- mov eax, [esi+84]
- mov [edi+4], eax
- mov eax, [esi+88]
- mov [edi+8], eax
- mov eax, [esi+92]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+96] ;6
- mov [edi], eax
- mov eax, [esi+100]
- mov [edi+4], eax
- mov eax, [esi+104]
- mov [edi+8], eax
- mov eax, [esi+108]
- mov [edi+12], eax
- add edi, edx
- mov eax, [esi+112] ;7
- mov [edi], eax
- mov eax, [esi+116]
- mov [edi+4], eax
- mov eax, [esi+120]
- mov [edi+8], eax
- mov eax, [esi+124]
- mov [edi+12], eax
-endif
-
- add esi, 128
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
- retn
-
-;----------------------------------------
- ALIGN 4
-nf12: ; low 4x4x16 (32 bytes)
-if 0 ;debug
- add esi, 32
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
-
- Trans16 bx, esi
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+2
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+4
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+6
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+8
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+10
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+12
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+14
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+16
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+18
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+20
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+22
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+24
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+26
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+28
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+30
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- add edi, edx
-
- sub edi, nfpk_back_right
- add esi, 32
- retn
-
-;----------------------------------------
- ALIGN 4
-nf13: ; 2x2 4x4x0 (8 bytes)
-if 0 ;debug
- add esi, 8
- mov ebx, 0
- jmp nf_solid
-endif
- mov edx, nf_width
-
-if TRANS16
- Trans16 cx, esi
- shrd ebx, ecx, 16
- mov bx, cx
-
- Trans16 cx, esi+2
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-else
- mov ax, [esi]
- shrd ebx, eax, 16
- mov bx, ax
-
- mov ax, [esi+2]
- shrd ecx, eax, 16
- mov cx, ax
-endif
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
-
-if TRANS16
- Trans16 cx, esi+4
- shrd ebx, ecx, 16
- mov bx, cx
-
- Trans16 cx, esi+6
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-else
- mov ax, [esi+4]
- shrd ebx, eax, 16
- mov bx, ax
-
- mov ax, [esi+6]
- shrd ecx, eax, 16
- mov cx, ax
-endif
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- add edi, edx
-
- sub edi, nfpk_back_right
- add esi, 8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf14: ; 8x8x0 (2 bytes)
- Trans16 cx, esi
- add esi, 2
- shrd ebx, ecx, 16
- mov bx, cx
-
-nf_solid:
- mov edx, nf_width
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
-
- sub edi, nfpk_back_right ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf15: ; unused
- retn
-
-nfHPkDecomp ENDP
-
-endif ; PKDATA
-
-;---------------------------------------------------------------------
-; ShowFrame
-;------------
-
-EXTERN sf_LineWidth: DWORD ;unsigned sf_LineWidth; // Distance between lines in memory
-
-; Banked screen parameters
-EXTERN sf_SetBank: PTRPROC ;unsigned long sf_SetBank;
-EXTERN sf_WinGran: DWORD ;unsigned sf_WinGran;
-EXTERN sf_WinSize: DWORD ;unsigned long sf_WinSize;
-EXTERN sf_WinGranPerSize: DWORD ;unsigned sf_WinGranPerSize;
-;{sf_WriteWinPtr and sf_WriteWinLimit replace sf_WriteWinSeg, see mveliba.asm}
-EXTERN sf_WriteWinPtr: PTRBYTE ;unsigned char *sf_WriteWinPtr;
-EXTERN sf_WriteWinLimit: PTRBYTE ;unsigned char *WriteWinLimit;
-EXTERN sf_WriteWin: DWORD ;unsigned sf_WriteWin;
-
-if SCALING
-EXTERN opt_hscale_step: DWORD
-EXTERN opt_hscale_adj: DWORD
-endif
-
-;void mve_ShowFrameField(
-; unsigned char *buf, unsigned bufw, unsigned bufh,
-; unsigned sx, unsigned sy, unsigned w, unsigned h,
-; unsigned dstx, unsigned dsty, unsigned field)
-
-mve_ShowFrameField PROC USES ESI EDI EBX, \
- buf:PTRBYTE, bufw:DWORD, bufh:DWORD, \
- sx:DWORD, sy:DWORD, w:DWORD, h:DWORD, \
- dstx:DWORD, dsty:DWORD, field:DWORD
- LOCAL bank:DWORD
- LOCAL w4:DWORD
- LOCAL new_src_line:DWORD
- LOCAL linestep:DWORD
- LOCAL new_dst_line:DWORD
-
- mov ax, ds ; Insure es==ds for symantec flat mode
- mov es, ax
-
- mov eax, w ; w4 = w>>2
- shr eax, 2
- mov w4, eax
-
-;;;
-;;; In stretched width mode, we either keep 4/5 (a) of the source pixels,
-;;; or duplicate every fourth pixel to magnify by 5/4 (b).
-;;; In these cases, new_src_line is either bufw-w*5/4 (a) or bufw-w*4/5 (b).
-;;; Let ScaleStep be 5 (a) or 3 (b) instead of 4. This is the amount to advance
-;;; the source after copying 32-bits from source to destination.
-;;; The coordinate system used for the source will be a simulated scaled system.
-;;; Rather than scale height, I plan to use alternate vertical resolutions. However,
-;;; it might be a good idea to also provide for scaled height in case we want a
-;;; higher resolution border.
-;;; Question: Do we still need to support transferring subrectangles?
-
-if SCALING
- .if opt_hscale_step==4
-endif
- mov eax, bufw ; new_src_line = bufw - w
- sub eax, w
- mov new_src_line, eax
-if SCALING
- .else
- mov eax, opt_hscale_adj
- mov new_src_line, eax
- .endif
-endif
-
- mov eax, sf_LineWidth ; linestep = sf_LineWidth<<1;
- .if field ; if (field)
- add eax, eax ; linestep <<= 1;
- .endif
- mov linestep, eax
-
- sub eax, w ; new_dst_line = linestep - w;
- mov new_dst_line, eax
-
- mov eax, sy ; buf += sy*bufw + sx
- mul bufw
- add eax, sx
- add buf, eax
-
- mov eax, sx ; dstx += sx
- add dstx, eax
-
- ; This is a hack. We should pass in src x,y of origin
- ; or make dstx/dsty absolute.
- ;
- mov eax, bufw ; if (field && sx >= (bufw>>1)
- shr eax, 1
- .if field && sx >= eax
- sub dstx, eax ; dstx -= bufw>>1
- .endif
-
- mov eax, sy ; dsty += sy
- add dsty, eax
-
- .if sf_SetBank==0 ;------------------
-
-
- ; dst = WriteWinPtr + (dsty*linestep+dstx)
- mov edi, sf_WriteWinPtr
- mov eax, dsty
- mul linestep
- add eax, dstx
- add edi, eax
-
- .if field & 1
- add edi, sf_LineWidth;
- .endif
-
- mov eax, new_src_line
- mov edx, new_dst_line
- mov esi, buf
- mov ebx, h
-if SCALING
- .if opt_hscale_step==3
- sub edi, 8
-sf_lp2a:mov ecx, w4
- shr ecx, 2
- ALIGN 4
-sf_lp2b:mov eax, [esi]
- mov [edi+8], eax
- mov eax, [esi+3]
- mov [edi+12], eax
- add edi, 16
- mov eax, [esi+6]
- mov [edi], eax
- mov eax, [esi+9]
- mov [edi+4], eax
- add esi, 12
- dec ecx
- jnz sf_lp2b
- ; To avoid problem of last pixel coming from next line
- ; with arrange for w%16==12, so here is where we copy
- ; last 12 pixels.
- mov eax, [esi]
- mov [edi+8], eax
- mov eax, [esi+3]
- mov [edi+12], eax
- add edi, 12
- mov eax, [esi+6]
- mov [edi+4], eax
- add esi, 9
- add esi, new_src_line
- add edi, edx
- dec ebx
- jnz sf_lp2a
- add edi, 8
- .else
-endif
-sf_lp: mov ecx, w4 ;width/4
- rep movsd
- add esi, eax
- add edi, edx
- dec ebx
- jnz sf_lp
-if SCALING
- .endif
-endif
-
- .else ; sf_SetBank ;------------------
-
-
- mov esi, buf
-
- ; start = dsty * linestep + dstx
-
- mov eax, linestep
- mul dsty
- .if field & 1
- add eax, sf_LineWidth
- .endif
- add eax, dstx
- ; bank = start / WinGran
- ; dst = (start % WinGran) + sf_WriteWinPtr
- mov edx, 0
- div sf_WinGran
- mov bank, eax
- mov edi, edx
- add edi, sf_WriteWinPtr
-
- ; Select new bank
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by sf_SetBank
-
-sf_0: ; rem = sf_WriteWinLimit - dst
- mov eax, sf_WriteWinLimit
- sub eax, edi
- ; h2 = (rem+(LineWidth-w))/LineWidth
- add eax, linestep
- sub eax, w
- mov edx, 0
- div linestep
- ; if (h>1
- shr eax, 1
- mov w4, eax ; Number of dst words to transfer
-
- mov eax, bufw ; new_src_line = bufw - w
- sub eax, w
- mov new_src_line, eax
-
- mov eax, sf_LineWidth ; linestep = sf_LineWidth<<1;
- .if field ; if (field)
- add eax, eax ; linestep <<= 1;
- .endif
- mov linestep, eax
-
- sub eax, w ; new_dst_line = linestep - w*2;
- sub eax, w
- mov new_dst_line, eax
-
- mov eax, sy ; buf += sy*bufw + sx
- mul bufw
- add eax, sx
- add buf, eax
-
- mov eax, sx ; dstx += sx
- add dstx, eax
-
- ; This is a hack. We should pass in src x,y of origin
- ; or make dstx/dsty absolute.
- ;
- mov eax, bufw ; if (field && sx >= (bufw>>1)
- shr eax, 1
- .if field && sx >= eax
- sub dstx, eax ; dstx -= bufw>>1
- .endif
-
- mov eax, sy ; dsty += sy
- add dsty, eax
-
- .if sf_SetBank==0 ;------------------
-
-
- ; dst = WriteWinPtr + (dsty*linestep+dstx*2)
- mov edi, sf_WriteWinPtr
- mov eax, dsty
- mul linestep
- add eax, dstx
- add eax, dstx
- add edi, eax
-
- .if field & 1
- add edi, sf_LineWidth;
- .endif
-
- mov esi, buf
- mov ebx, h
-sf_lp: mov ecx, w4 ;width/4
-
- push ebx
- lea ebx, pal15_tbl
- xor eax, eax
-sf_movsd1:
- mov al, [esi]
- add esi, 2
- mov dx, [ebx+eax*2]
- mov al, [esi-1]
- shl edx, 16
- mov dx, [ebx+eax*2]
- rol edx, 16
- mov [edi], edx
- add edi, 4
- dec ecx
- jnz sf_movsd1
- pop ebx
-
-; rep movsd ;;;;;-----;;;;;
-
- add esi, new_src_line
- add edi, new_dst_line
- dec ebx
- jnz sf_lp
-
- .else ; sf_SetBank ;------------------
-
-
- mov esi, buf
-
- ; start = dsty * linestep + dstx*2
-
- mov eax, linestep
- mul dsty
- .if field & 1
- add eax, sf_LineWidth
- .endif
- add eax, dstx
- add eax, dstx
- ; bank = start / WinGran
- ; dst = (start % WinGran) + sf_WriteWinPtr
- mov edx, 0
- div sf_WinGran
- mov bank, eax
- mov edi, edx
- add edi, sf_WriteWinPtr
-
- ; Select new bank
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by sf_SetBank
-
-sf_0: ; rem = sf_WriteWinLimit - dst
- mov eax, sf_WriteWinLimit
- sub eax, edi
- ; h2 = (rem+(LineWidth-w*2))/LineWidth
- add eax, new_dst_line
- mov edx, 0
- div linestep
- ; if (h=WinSize, we're done with squares (but need to correctly
- ; adjust si and di!)
- ; if di+4*cx>WinSize, we need to clip and then we're done
- ; (but need to correctly adjust si and di!)
- ; Reduce cx to (WinSize-di)/4.
-
- ; limit=WriteWinLimit-4*ax
-
-Split: push ebx
- push edx
- push esi
- push edi
-
- mov ecx, w
- mov eax, 0
- jmp aTest1
-
-aNext1: mov dx, word ptr [ebx]
- add ebx, 2
-aTest1: add dx, dx
- jz aNext1
- jb aChgd2
- add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- loop aTest1
- jmp aDone
-
-aNext2: mov dx, [ebx]
- add ebx, 2
-aTest2: add dx, dx
- ja aCopy3
- jz aNext2
-aChgd2: add eax, SWIDTH*HI_COLOR_SCALE/4
- loop aTest2
- call aCopy
- jmp aDone
-
-
-aCopy3: call aCopy
- add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- mov eax, 0
- loop aTest1
- jmp aDone
-
-aCopy: push ebx
- push ecx
- push edx
- push esi
- push edi
-
- mov ecx, eax
- shl ecx, 2
- mov ebx, SrcWidth
- sub ebx, ecx
- mov edx, DstWidth
- sub edx, ecx
- sub ecx, sf_WriteWinLimit
- neg ecx
- mov limit, ecx
-
- REPEAT 7
- cmp edi, limit
- jns aFinal
- mov ecx, eax
- rep movsd
- add esi, ebx
- add edi, edx
- ENDM
- cmp edi, limit
- jns aFinal
- mov ecx, eax
- jmp aLast
-
-aFinal: mov ecx, sf_WriteWinLimit
- sub ecx, edi
- js aCpyDn
- shr ecx, 2
-aLast: rep movsd
-
-aCpyDn: pop edi
- pop esi
- mov ecx, eax
- shl ecx, 2
- add esi, ecx
- add edi, ecx
- pop edx
- pop ecx
- pop ebx
- retn
-
-aDone: pop edi
- pop esi
-
- ; Advance bank
- mov eax, sf_WinGranPerSize
- add bank, eax
- sub edi, sf_WinSize
-
- ; Select new bank
- cmp sf_SetBank, 0
- jz nobank2
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by SetBank
-nobank2:
- pop edx
- pop ebx
-
- ; For start of next bank...
- ; While di+4*cx<=0, advance si & di by src/dst line step instead of
- ; doing rep mov
- ; If di<0, cx += di/4, si-=di, di=0
- ; Do remaining rep mov's (first with modified args, remainder with
- ; with full args).
-
- ; Init bx/dx to src/dst line steps.
- ; limit=-4*ax
-
- mov ecx, w
- mov eax, 0
- jmp bTest1
-
-bNext1: mov dx, [ebx]
- add ebx, 2
-bTest1: add dx, dx
- jz bNext1
- jb bChgd2
- add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- loop bTest1
- jmp LineDone
-
-bNext2: mov dx, [ebx]
- add ebx, 2
-bTest2: add dx, dx
- ja bCopy3
- jz bNext2
-bChgd2: add eax, SWIDTH*HI_COLOR_SCALE/4
- loop bTest2
- call bCopy
- jmp LineDone
-
-
-bCopy3: call bCopy
- add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- mov eax, 0
- loop bTest1
- jmp LineDone
-
-bCopy: push ebx
- push ecx
- push edx
-
- mov ecx, eax
- shl ecx, 2
- neg ecx
- mov limit, ecx
- mov ebx, SrcWidth
- mov edx, DstWidth
-
- sub edi, sf_WriteWinPtr
-
- FOR bMovN,
- mov ecx, offset bMovN
- jns bFull
- cmp limit, edi
- js bPart
- add esi, ebx
- add edi, edx
- ENDM
-
- mov ecx, offset bMov8
- jns bFull
- cmp limit, edi
- js bPart
-
- add edi, sf_WriteWinPtr
-
- shl eax, 2
- add esi, eax
- add edi, eax
-
- jmp bCpyDn
-
-
-bFull: push ecx
- mov ecx, eax
- add ebx, limit
- add edx, limit
- add edi, sf_WriteWinPtr
- retn
-
-bPart: push ecx
- mov ecx, eax
- sub esi, edi
- sar edi, 2
- add ecx, edi
- mov edi, sf_WriteWinPtr
- add ebx, limit
- add edx, limit
- retn
-
-
- FOR bMovN,
-bMovN: rep movsd
- mov ecx, eax
- add esi, ebx
- add edi, edx
- ENDM
-bMov8: rep movsd
-
-bCpyDn: sub esi, SrcWidth7
- sub edi, DstWidth7
-
- pop edx
- pop ecx
- pop ebx
- retn
-
-Finished:
- ret
-
- ENDM ; SHOW_FRAME_CHG_BODY
-
-;void
-;mve_sfShowFrameChg(
-; bool prvbuf,
-; unsigned x, unsigned y, unsigned w, unsigned h,
-; unsigned short *chgs,
-; unsigned dstx, unsigned dsty)
-;
-mve_sfShowFrameChg PROC USES ESI EDI EBX, \
- prvbuf:DWORD, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD, \
- chgs:PTRWORD, \
- dstx:DWORD, dsty:DWORD
- LOCAL _width:DWORD
- LOCAL SrcWidth:DWORD
- LOCAL DstWidth:DWORD
- LOCAL SrcWidth7:DWORD
- LOCAL DstWidth7:DWORD
- LOCAL SrcLineStep:DWORD
- LOCAL DstLineStep1:DWORD
- LOCAL DstLineStep2:DWORD
- LOCAL LineEnd:DWORD
- LOCAL bank:DWORD
- LOCAL limit:DWORD
-
- SHOW_FRAME_CHG_BODY 0 ; Not HiColor
-
-mve_sfShowFrameChg ENDP
-
-
-if HICOLOR
-
-;void
-;mve_sfHiColorShowFrameChg(
-; bool prvbuf,
-; unsigned x, unsigned y, unsigned w, unsigned h,
-; unsigned short *chgs,
-; unsigned dstx, unsigned dsty)
-;
-mve_sfHiColorShowFrameChg PROC USES ESI EDI EBX, \
- prvbuf:DWORD, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD, \
- chgs:PTRWORD, \
- dstx:DWORD, dsty:DWORD
- LOCAL _width:DWORD
- LOCAL SrcWidth:DWORD
- LOCAL DstWidth:DWORD
- LOCAL SrcWidth7:DWORD
- LOCAL DstWidth7:DWORD
- LOCAL SrcLineStep:DWORD
- LOCAL DstLineStep1:DWORD
- LOCAL DstLineStep2:DWORD
- LOCAL LineEnd:DWORD
- LOCAL bank:DWORD
- LOCAL limit:DWORD
-
- SHOW_FRAME_CHG_BODY 1 ; HiColor
-
-mve_sfHiColorShowFrameChg ENDP
-
-
-endif ;HICOLOR
-
-endif ;PARTIAL
-
-
-;----------------------------------------------------------------------
-
-if 0 ; No supported
-if PKDATA
-
-PK_SHOW_FRAME_CHG_BODY MACRO HI_COLOR_FLAG:REQ
-
- LOCAL HI_COLOR_SCALE
-HI_COLOR_SCALE equ HI_COLOR_FLAG+1
-
- mov eax, w ; _width = w*SWIDTH*HI_COLOR_SCALE;
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- mov _width, eax
-
- xor ebx, ebx ; ebx = nf_fqty (converted to 32-bits)
- mov bl, nf_fqty
-
- mov eax, nf_width ; SrcWidth = nf_width*nf_fqty;
- mul ebx ;nf_fqty
- mov SrcWidth, eax
- imul eax, (SHEIGHT-1) ; SrcWidth7 = SrcWidth * (SHEIGHT-1)
- mov SrcWidth7, eax
- add eax, SrcWidth ; SrcLineStep = SrcWidth*SHEIGHT-_width
- sub eax, _width
- mov SrcLineStep, eax
-
- mov eax, sf_LineWidth ; DstWidth = sf_LineWidth*nf_fqty;
- mul ebx ;nf_fqty
- mov DstWidth, eax
- imul eax, (SHEIGHT-1) ; DstWidth7 = DstWidth * (SHEIGHT-1)
- mov DstWidth7, eax
- ;Note: DstLineStep1+2 = DstWidth*SHEIGHT - _width = ????Not True!!!
- dec eax ; DstLineStep1 = DstWidth*(SHEIGHT-1)-1
- mov DstLineStep1, eax
-
- mov eax, DstWidth ; DstLineStep2 = DstWidth-_width+1
- sub eax, _width
- inc eax
- mov DstLineStep2, eax
-
- mov eax, DstLineStep1 ; LineEnd = DstWidth*(SHEIGHT-1)+_width-1
- add eax, _width
- mov LineEnd, eax
-
- ; esi = buf (pointer into buf)
- ; ebx = pointer into ops
- ; dx = temp for current op. dl xor dh keeps just upper nibble op.
- ; edi = pointer into screen
- ; ecx = remaining square lines to copy
-
- .if prvbuf ; buf = prvbuf ? nf_buf_prv : nf_buf_cur
- mov esi, nf_buf_prv
- .else
- mov esi, nf_buf_cur
- .endif
- mov eax, y ; + y*SHEIGHT*nf_WIDTH
- shl eax, LOG2_SHEIGHT
- mul nf_width
- add esi, eax
- mov eax, x ; + x*SWIDTH*HI_COLOR_SCALE
- shl eax, LOG2_SWIDTH+HI_COLOR_FLAG
- add esi, eax
-
- ; dstx must be a multiple of 4 because everything is done on 32-bit words
- ; and bank crossing checks don't check for a crossing within a word.
- and dstx, NOT 3 ; dstx &= ~3
-
- mov ebx, ops
-
- mov cl, nf_fqty
-nxtfld: push ecx
- push esi
-
- mov ecx, h
-
- push ebx
-
- mov eax, sf_LineWidth
- mul dsty
- add eax, dstx
- ; bank = start / WinGran
- ; dst = (start % WinGran) + sf_WriteWinPtr
- mov edx, 0
- div sf_WinGran
- mov bank, eax
- mov edi, edx
- add edi, sf_WriteWinPtr
-
- ; Select new bank
- cmp sf_SetBank, 0
- jz nobank
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by sf_SetBank
-nobank: pop ebx
-
-NextLine:
- push ecx
-
- mov eax, edi
- add eax, LineEnd ; (SHEIGHT-1)*DstWidth+_width-1
- sub eax, sf_WriteWinLimit
- jb NoSplit
- jmp Split
-
-LineDone:
- pop ecx
- add esi, SrcLineStep ; Move back to start column, down SHEIGHT
- add edi, DstLineStep1 ; First advance to last byte
- add edi, DstLineStep2 ; Then advance to new start
- loop NextLine
- pop esi
- pop ecx
- add esi, nf_width
- inc dsty
- dec cl
- jnz nxtfld
- jmp Finished
-
- ; --- Copy full squares ---
-
- ; Scan over contiguous unchanged squares up to max per line
- ; For each unchanged square, add 8 (SWIDTH) to esi and edi.
-
- ; count # of contiguous changed squares up to max per line
- ; Init eax to 0, ebx and edx to line steps for source and dest.
- ; For each square, add 2 (SWIDTH/4) to eax and subtract 8 (SWIDTH)
- ; from ebx and edx.
-
-NoSplit:
- mov ecx, w
- shr ecx, 1
- mov eax, 0
-fNext1: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jnz fChgd2a
-fTest1a:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- xor dl, dh
- jnz fChgd2b
-fTest1b:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- dec ecx
- jnz fNext1
- jmp LineDone
-
-fNext2: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jz fCopy3a
-fChgd2a:add eax, SWIDTH*HI_COLOR_SCALE/4
- xor dl, dh
- jz fCopy3b
-fChgd2b:add eax, SWIDTH*HI_COLOR_SCALE/4
- dec ecx
- jnz fNext2
- call fCopy
- jmp LineDone
-
-fCopy3a:call fCopy
- xor eax, eax
- jmp fTest1a
-
-fCopy3b:call fCopy
- xor eax, eax
- jmp fTest1b
-
-fCopy: push ebx
- push ecx
- push edx
-
- mov ecx, eax
- shl ecx, 2
- mov ebx, SrcWidth
- sub ebx, ecx
- mov edx, DstWidth
- sub edx, ecx
-
- REPEAT 7
- mov ecx, eax
- rep movsd
- add esi, ebx
- add edi, edx
- ENDM
- mov ecx, eax
- rep movsd
-
- sub esi, SrcWidth7
- sub edi, DstWidth7
-
- pop edx
- pop ecx
- pop ebx
- retn
-
-
- ; --- Copy squares across bank boundary ---
- ; (occurs infrequently, but should be streamlined as much as possible
- ; because it could potentially be much more expensive than normal
- ; operation).
- ; HMMM... 16*640 = 10240 = approx 1/6 64K, so for 640x480,
- ; roughly 1 in 6 square lines will need special processing
- ; (actually, 2 in 12 due to interlacing, but that's the same ratio).
-
- ; Repeat above twice, once for end of cur bank, once for start
- ; of next bank, with following modifications:
-
- ; For end of cur bank...
- ; if di>=WinSize, we're done with squares (but need to correctly
- ; adjust si and di!)
- ; if di+4*cx>WinSize, we need to clip and then we're done
- ; (but need to correctly adjust si and di!)
- ; Reduce cx to (WinSize-di)/4.
-
- ; limit=WriteWinLimit-4*ax
-
-Split: push ebx
- push esi
- push edi
-
- mov ecx, w
- shr ecx, 1
- mov eax, 0
-aNext1: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jnz aChgd2a
-aTest1a:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- xor dl, dh
- jnz aChgd2b
-aTest1b:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- dec ecx
- jnz aNext1
- jmp LineDone
-
-aNext2: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jz aCopy3a
-aChgd2a:add eax, SWIDTH*HI_COLOR_SCALE/4
- xor dl, dh
- jz aCopy3b
-aChgd2b:add eax, SWIDTH*HI_COLOR_SCALE/4
- dec ecx
- jnz aNext2
- call aCopy
- jmp LineDone
-
-aCopy3a:call aCopy
- xor eax, eax
- jmp aTest1a
-
-aCopy3b:call aCopy
- xor eax, eax
- jmp aTest1b
-
-aCopy: push ebx
- push ecx
- push edx
- push esi
- push edi
-
- mov ecx, eax
- shl ecx, 2
- mov ebx, SrcWidth
- sub ebx, ecx
- mov edx, DstWidth
- sub edx, ecx
- sub ecx, sf_WriteWinLimit
- neg ecx
- mov limit, ecx
-
- REPEAT 7
- cmp edi, limit
- jns aFinal
- mov ecx, eax
- rep movsd
- add esi, ebx
- add edi, edx
- ENDM
- cmp edi, limit
- jns aFinal
- mov ecx, eax
- jmp aLast
-
-aFinal: mov ecx, sf_WriteWinLimit
- sub ecx, edi
- js aCpyDn
- shr ecx, 2
-aLast: rep movsd
-
-aCpyDn: pop edi
- pop esi
- mov ecx, eax
- shl ecx, 2
- add esi, ecx
- add edi, ecx
- pop edx
- pop ecx
- pop ebx
- retn
-
-aDone: pop edi
- pop esi
-
- ; Advance bank
- mov eax, sf_WinGranPerSize
- add bank, eax
- sub edi, sf_WinSize
-
- ; Select new bank
- cmp sf_SetBank, 0
- jz nobank2
- mov bh, 0
- mov bl, byte ptr sf_WriteWin
- mov edx, bank
- call sf_SetBank
- ; eax/edx destroyed by SetBank
-nobank2:
- pop ebx
-
- ; For start of next bank...
- ; While di+4*cx<=0, advance si & di by src/dst line step instead of
- ; doing rep mov
- ; If di<0, cx += di/4, si-=di, di=0
- ; Do remaining rep mov's (first with modified args, remainder with
- ; with full args).
-
- ; Init bx/dx to src/dst line steps.
- ; limit=-4*ax
-
- mov ecx, w
- shr ecx, 1
- mov eax, 0
-bNext1: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jnz bChgd2a
-bTest1a:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- xor dl, dh
- jnz bChgd2b
-bTest1b:add esi, SWIDTH*HI_COLOR_SCALE
- add edi, SWIDTH*HI_COLOR_SCALE
- dec ecx
- jnz bNext1
- jmp LineDone
-
-bNext2: mov dl, [ebx]
- inc ebx
- mov dh, dl
- and dh, 0Fh
- jz bCopy3a
-bChgd2a:add eax, SWIDTH*HI_COLOR_SCALE/4
- xor dl, dh
- jz bCopy3b
-bChgd2b:add eax, SWIDTH*HI_COLOR_SCALE/4
- dec ecx
- jnz bNext2
- call bCopy
- jmp LineDone
-
-bCopy3a:call bCopy
- xor eax, eax
- jmp bTest1a
-
-bCopy3b:call bCopy
- xor eax, eax
- jmp bTest1b
-
-bCopy: push ebx
- push ecx
- push edx
-
- mov ecx, eax
- shl ecx, 2
- neg ecx
- mov limit, ecx
- mov ebx, SrcWidth
- mov edx, DstWidth
-
- sub edi, sf_WriteWinPtr
-
- FOR bMovN,
- mov ecx, offset bMovN
- jns bFull
- cmp limit, edi
- js bPart
- add esi, ebx
- add edi, edx
- ENDM
-
- mov ecx, offset bMov8
- jns bFull
- cmp limit, edi
- js bPart
-
- add edi, sf_WriteWinPtr
-
- shl eax, 2
- add esi, eax
- add edi, eax
-
- jmp bCpyDn
-
-
-bFull: push ecx
- mov ecx, eax
- add ebx, limit
- add edx, limit
- add edi, sf_WriteWinPtr
- retn
-
-bPart: push ecx
- mov ecx, eax
- sub esi, edi
- sar edi, 2
- add ecx, edi
- mov edi, sf_WriteWinPtr
- add ebx, limit
- add edx, limit
- retn
-
-
- FOR bMovN,
-bMovN: rep movsd
- mov ecx, eax
- add esi, ebx
- add edi, edx
- ENDM
-bMov8: rep movsd
-
-bCpyDn: sub esi, SrcWidth7
- sub edi, DstWidth7
-
- pop edx
- pop ecx
- pop ebx
- retn
-
-Finished:
- ret
-
- ENDM ; PK_SHOW_FRAME_CHG_BODY
-
-;void
-;mve_sfPkShowFrameChg(
-; bool prvbuf,
-; unsigned x, unsigned y, unsigned w, unsigned h,
-; unsigned char *ops,
-; unsigned dstx, unsigned dsty)
-;
-mve_sfPkShowFrameChg PROC USES ESI EDI EBX, \
- prvbuf:DWORD, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD, \
- ops:PTRBYTE, \
- dstx:DWORD, dsty:DWORD
- LOCAL _width:DWORD
- LOCAL SrcWidth:DWORD
- LOCAL DstWidth:DWORD
- LOCAL SrcWidth7:DWORD
- LOCAL DstWidth7:DWORD
- LOCAL SrcLineStep:DWORD
- LOCAL DstLineStep1:DWORD
- LOCAL DstLineStep2:DWORD
- LOCAL LineEnd:DWORD
- LOCAL bank:DWORD
- LOCAL limit:DWORD
-
- PK_SHOW_FRAME_CHG_BODY 0 ; Not HiColor
-
-mve_sfPkShowFrameChg ENDP
-
-
-if HICOLOR
-
-;void
-;mve_sfPkHiColorShowFrameChg(
-; bool prvbuf,
-; unsigned x, unsigned y, unsigned w, unsigned h,
-; unsigned char *ops,
-; unsigned dstx, unsigned dsty)
-;
-mve_sfPkHiColorShowFrameChg PROC USES ESI EDI EBX, \
- prvbuf:DWORD, \
- x:DWORD, y:DWORD, w:DWORD, h:DWORD, \
- ops:PTRBYTE, \
- dstx:DWORD, dsty:DWORD
- LOCAL _width:DWORD
- LOCAL SrcWidth:DWORD
- LOCAL DstWidth:DWORD
- LOCAL SrcWidth7:DWORD
- LOCAL DstWidth7:DWORD
- LOCAL SrcLineStep:DWORD
- LOCAL DstLineStep1:DWORD
- LOCAL DstLineStep2:DWORD
- LOCAL LineEnd:DWORD
- LOCAL bank:DWORD
- LOCAL limit:DWORD
-
- PK_SHOW_FRAME_CHG_BODY 1 ; HiColor
-
-mve_sfPkHiColorShowFrameChg ENDP
-
-
-endif ;HICOLOR
-
-endif ;PKDATA
-
-endif
-
-;---------------------------------------------------------------------
-; Palette Management
-;---------------------
-
-;void __cdecl
-;MVE_SetPalette(unsigned char *p, unsigned start, unsigned count)
-;
-MVE_SetPalette PROC USES ESI EBX, \
- p:PTRBYTE, start:DWORD, count:DWORD
- mov eax, start
- mov ecx, count
- mov esi, p
- .if eax>=256 ; if (start>=256) return;
- ret
- .endif
- lea ebx, [eax+ecx] ; if (start+count>256)
- .if ebx>256
- mov ecx, 256 ; count = 256-start
- sub ecx, eax
- .endif
- add esi, eax ; p += start*3
- add esi, eax
- add esi, eax
- lea ecx, [ecx+2*ecx] ; count *= 3
-
- mov edx, 03c8h ; DAC Write Index Register
- out dx, al ; Init write index to start
- inc edx ; DAC Data Register
- rep outsb
- ret
-MVE_SetPalette ENDP
-
-
-; If at least 11 palette entries aren't changed, this is more compact
-; than uncompressed 256 entry palette.
-;
-;static void palLoadCompPalette(unsigned char *buf)
-;
-palLoadCompPalette PROC USES ESI EDI, \
- buf: PTRBYTE
- mov ax, ds ; Insure es==ds for symantec flat mode
- mov es, ax
-
- mov cx, 32
- mov esi, buf
- mov edi, offset pal_tbl
-next: lodsb
- or al, al
- jnz chk0
- add edi, 24
- loop next
- jmp done
-
-chk0: test al, 1
- jz not0
- movsw
- movsb
- test al, 2
- jz not1
-cpy1: movsw
- movsb
- test al, 4
- jz not2
-cpy2: movsw
- movsb
- test al, 8
- jz not3
-cpy3: movsw
- movsb
- test al, 16
- jz not4
-cpy4: movsw
- movsb
- test al, 32
- jz not5
-cpy5: movsw
- movsb
- test al, 64
- jz not6
-cpy6: movsw
- movsb
- or al, al
- jns not7
-cpy7: movsw
- movsb
- loop next
- jmp done
-
-not0: add edi, 3
- test al, 2
- jnz cpy1
-not1: add edi, 3
- test al, 4
- jnz cpy2
-not2: add edi, 3
- test al, 8
- jnz cpy3
-not3: add edi, 3
- test al, 16
- jnz cpy4
-not4: add edi, 3
- test al, 32
- jnz cpy5
-not5: add edi, 3
- test al, 64
- jnz cpy6
-not6: add edi, 3
- or al, al
- js cpy7
-not7: add edi, 3
- loop next
-
-done: ret
-
-palLoadCompPalette ENDP
-
-;-----------------------------------------------------------------------
-; Graphics
-;----------
-
-gfxMode proc USES EBP ESI EDI EBX, mode:DWORD
- mov eax, mode
- int 10h
- ret
-gfxMode endp
-
-gfxLoadCrtc proc USES ESI EDI EBX, crtc:PTRBYTE, chain4:BYTE, res:BYTE
-
- mov edx, 03c4h ; alter sequence registers
- mov al, 04h ; disable or enable chain 4 in memory mode
- mov ah, chain4
- out dx, ax
-
- mov dx, 03dah ; General Input State #1 register
-
-l1: in al, dx ; Loop until vertical retrace is off
- test al, 8
- jnz l1
-l2: in al, dx ; Now loop until it's back on
- test al, 8
- jz l2
-
- cli ; turn off all interrupts
- mov edx, 03c4h ; Sequencer Synchronous reset
- mov eax, 0100h ; Set sequencer reset
- out dx, ax
- mov edx, 03c2h ; Misc Output Register
- mov al, res ; 25/28-mHz, 350/400/480 lines
- out dx, al
- mov edx, 03c4h ; Sequencer Synchronous reset
- mov eax, 0300h ; Clear sequencer reset
- out dx, ax
-
- mov edx, 03d4h ; 6845 CRTC
- mov esi, crtc ; tweaked values for CRTC registers
- mov al, 011h ; deprotect CRTC registers 0-7
- mov ah, [esi+011h]
- and ah, 07Fh
- out dx, ax
-
- mov ecx, 018h ; Update CRTC registers with tweaked values
- mov ebx, 0
-l3: mov al, bl
- mov ah, [esi+ebx]
- out dx, ax
- inc bl
- loop l3
-
- sti ; restore interrupts
-
- ret
-gfxLoadCrtc endp
-
-; void __cdecl gfxGetCrtc(unsigned char *crtc);
-;
-gfxGetCrtc proc USES ESI EBX, crtc:PTRBYTE
- mov edx, 03d4h ; 6845 CRTC
- mov esi, crtc
- mov ecx, 018h
- mov ebx, 0
-l3: mov al, bl
- out dx, al
- inc dx
- in al, dx
- dec dx
- mov [esi+ebx], al
- inc bl
- loop l3
- ret
-gfxGetCrtc endp
-
-; void __cdecl gfxVres(unsigned char misc, unsigned char *crtc);
-; misc is one of the following:
-; 350: 0x23 | 0x80 (2)
-; 400: 0x23 | 0x40 (1)
-; 480: 0x23 | 0xc0 (3)
-
-; Get crtc register specified by crtc_addr into ah.
-; To update register, do out dx,ax
-GetCrtc MACRO crtc_addr
- mov al, crtc_addr
- out dx, al
- inc dx
- in al, dx
- dec dx
- mov ah, al
- mov al, crtc_addr
- ENDM
-
-gfxVres PROC USES EBX, misc:BYTE, crtc:PTRBYTE
-
- mov edx, 03dah ; General Input State #1 register
-
-l1: in al, dx ; Loop until vertical retrace is off
- test al, 8
- jnz l1
-l2: in al, dx ; Now loop until it's back on
- test al, 8
- jz l2
-
- cli ; turn off all interrupts
-
- mov edx, 03c4h ; Sequencer Synchronous reset
- mov eax, 0100h ; Set sequencer reset
- out dx, ax
- mov edx, 03cch ; Misc Output Register (read port)
- in al, dx
- and al, 03fh ; Keep all but lines field
- mov edx, 03c2h ; Misc Output Register (write port)
- and misc, 0c0h ; Only keep lines field
- or al, misc ; 350/400/480 lines
- out dx, al
- mov edx, 03c4h ; Sequencer Synchronous reset
- mov eax, 0300h ; Clear sequencer reset
- out dx, ax
-
- mov edx, 03d4h ; CRTC address port
- mov ebx, crtc ; Desired CRTC image
-
- GetCrtc 011h ; Vertical Retrace End register
- and ah, 07Fh ; Deprotect CRTC registers 0-7
- out dx, ax
-
- GetCrtc 03h ; End Horizontal Blanking register
- or ah, 080h ; Enable CRTC registers 10-11
- out dx, ax
-
- mov al, 06h ; Vertical Total register
- mov ah, byte ptr 06h[ebx]
- out dx, ax
-
- GetCrtc 07h ; Overflow register
- and ah, 010h ; (Preserve LC)
- or ah, byte ptr 07h[ebx]
- out dx, ax
-
- GetCrtc 09h ; Maximum Scan Line register
- and ah, 040h ; (Preserve LC)
- or ah, byte ptr 09h[ebx]
- out dx, ax
-
- mov al, 010h ; Vertical Retrace Start register
- mov ah, byte ptr 010h[ebx]
- out dx, ax
-
- GetCrtc 11h ; Vertical Retrace End register
- and ah, 070h ; (Preserve BW,DVI,CVI)
- or ah, byte ptr 011h[ebx]
- or ah, 080h ; Reprotect 0-7
- out dx, ax
-
- mov al, 012h ; Vertical Display End register
- mov ah, byte ptr 012h[ebx]
- out dx, ax
-
- mov al, 015h ; Start Vertical Blank register
- mov ah, byte ptr 015h[ebx]
- out dx, ax
-
-; Some SVGA's use 7-bit vbe, others 8-bit vbe!
-if 0
- GetCrtc 16h ; End Vertical Blank register
- and ah, 080h ; (Preserve reserved field)
- or ah, byte ptr 016h[ebx]
- out dx, ax
-else
- mov al, 16h ; End Vertical Blank register
- mov ah, byte ptr 016h[ebx]
- out dx, ax
-endif
-
- sti ; restore interrupts
-
- ret
-gfxVres ENDP
-
-; void __cdecl MVE_gfxWaitRetrace(unsigned state);
-;
-MVE_gfxWaitRetrace proc state:DWORD
- mov edx, 03dah ; Input Status #1 register
- mov eax, state
- or eax, eax
- jnz wt1
-wt0: in al, dx ; Wait for retrace off
- and al, 8
- jnz wt0
- ret
-
-wt1: in al, dx ; Wait for retrace on
- and al, 8
- jz wt1
- ret
-
-MVE_gfxWaitRetrace endp
-
-; void __cdecl MVE_gfxSetSplit(unsigned line)
-;
-MVE_gfxSetSplit proc line:DWORD
- mov edx, 03dah ; Input State #1 register
-wt0: in al, dx ; Wait for retrace off
- and al, 8
- jnz wt0
-wt1: in al, dx ; Wait for retrace on
- and al, 8
- jz wt1
-
- mov edx, 03d4h ; CRTC address port
-
- mov ecx, line
- shr ecx, 4
- and cl, 010h
- GetCrtc 07h ; Overflow Register
- and ah, 0EFh ; LC8 (mask=10h)
- or ah, cl
- out dx, ax
-
- mov ecx, line
- shr ecx, 3
- and cl, 040h
- GetCrtc 09h ; Maximum Scan Line Register
- and ah, 0BFh ; LC9 (mask=40h)
- or ah, cl
- out dx, ax
-
- mov al, 18h ; Line Compare Register
- mov ah, byte ptr line
- out dx, ax
-
- ret
-
-MVE_gfxSetSplit endp
-
-;----------------------------------------------------------------------
-
-mveliba_end:
-
-
- END
diff --git a/libmve/mveplay.cpp b/libmve/mveplay.cpp
index f22323f9..23307068 100644
--- a/libmve/mveplay.cpp
+++ b/libmve/mveplay.cpp
@@ -476,12 +476,6 @@ void MVE_rmEndMovie(MVESTREAM *mve) {
void MVE_rmHoldMovie() { timer_started = 0; }
-void MVE_sndInit(ISoundDevice *lpDS) {
-#ifdef AUDIO
- // snd_ds = lpDS;
-#endif
-}
-
void MVE_sndInit(int x) {
#ifdef AUDIO
if (x == -1)
diff --git a/libmve/platform.cpp b/libmve/platform.cpp
deleted file mode 100644
index 0b19bbd9..00000000
--- a/libmve/platform.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-
-#if _WIN32
-#include
-#include
-
-uint32_t platform_timeGetTime(void) { return timeGetTime(); }
-
-#else
-#include
-#include
-
-uint32_t platform_timeGetTime(void) {
- struct timeval t;
- gettimeofday(&t, NULL);
-
- return (t.tv_sec * 1000 + t.tv_usec / 1000);
-}
-
-#endif
diff --git a/libmve/platform.h b/libmve/platform.h
deleted file mode 100644
index 79d87e0e..00000000
--- a/libmve/platform.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifndef MVEPLATFORM_H_
-#define MVEPLATFORM_H_
-
-#include
-
-uint32_t platform_timeGetTime(void);
-
-#endif
diff --git a/libmve/snd8to16.h b/libmve/snd8to16.h
deleted file mode 100644
index 52e70307..00000000
--- a/libmve/snd8to16.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-
---- HISTORICAL COMMENTS FOLLOW ---
-
-** #include
-** void init_snd_8to16(void)
-** {
-** int i;
-** for (i=0; i<44; ++i)
-** snd_8to16[i] = i;
-** for (i=44; i<128; ++i)
-** snd_8to16[i] = (unsigned)floor(pow(65535,i/127.0)+.5);
-** for (i=1; i<128; ++i)
-** snd_8to16[256-i] = -snd_8to16[i];
-** snd_8to16[128] = snd_8to16[129];
-** }
-*/
-
-#define S int16_t
-int16_t snd_8to16[256] = {
- (S)0, (S)1, (S)2, (S)3, (S)4, (S)5,
- (S)6, (S)7, (S)(S)8, (S)9, (S)10, (S)11,
- (S)12, (S)13, (S)14, (S)15, (S)(S)16, (S)17,
- (S)18, (S)19, (S)20, (S)21, (S)22, (S)23,
- (S)(S)24, (S)25, (S)26, (S)27, (S)28, (S)29,
- (S)30, (S)31, (S)(S)32, (S)33, (S)34, (S)35,
- (S)36, (S)37, (S)38, (S)39, (S)(S)40, (S)41,
- (S)42, (S)43, (S)47, (S)51, (S)56, (S)61,
- (S)(S)66, (S)72, (S)79, (S)86, (S)94, (S)102,
- (S)112, (S)122, (S)(S)133, (S)145, (S)158, (S)173,
- (S)189, (S)206, (S)225, (S)245, (S)(S)267, (S)292,
- (S)318, (S)348, (S)379, (S)414, (S)452, (S)493,
- (S)(S)538, (S)587, (S)640, (S)699, (S)763, (S)832,
- (S)908, (S)991, (S)(S)1081, (S)1180, (S)1288, (S)1405,
- (S)1534, (S)1673, (S)1826, (S)1993, (S)(S)2175, (S)2373,
- (S)2590, (S)2826, (S)3084, (S)3365, (S)3672, (S)4008,
- (S)(S)4373, (S)4772, (S)5208, (S)5683, (S)6202, (S)6767,
- (S)7385, (S)8059, (S)(S)8794, (S)9597, (S)10472, (S)11428,
- (S)12471, (S)13609, (S)14851, (S)16206, (S)(S)17685, (S)19298,
- (S)21060, (S)22981, (S)25078, (S)27367, (S)29864, (S)32589,
- (S)(S)35563, (S)38808, (S)42350, (S)46214, (S)50431, (S)55033,
- (S)60055, (S)65535, (S)(S)-65535, (S)-65535, (S)-60055, (S)-55033,
- (S)-50431, (S)-46214, (S)-42350, (S)-38808, (S)(S)-35563, (S)-32589,
- (S)-29864, (S)-27367, (S)-25078, (S)-22981, (S)-21060, (S)-19298,
- (S)(S)-17685, (S)-16206, (S)-14851, (S)-13609, (S)-12471, (S)-11428,
- (S)-10472, (S)-9597, (S)(S)-8794, (S)-8059, (S)-7385, (S)-6767,
- (S)-6202, (S)-5683, (S)-5208, (S)-4772, (S)(S)-4373, (S)-4008,
- (S)-3672, (S)-3365, (S)-3084, (S)-2826, (S)-2590, (S)-2373,
- (S)(S)-2175, (S)-1993, (S)-1826, (S)-1673, (S)-1534, (S)-1405,
- (S)-1288, (S)-1180, (S)(S)-1081, (S)-991, (S)-908, (S)-832,
- (S)-763, (S)-699, (S)-640, (S)-587, (S)(S)-538, (S)-493,
- (S)-452, (S)-414, (S)-379, (S)-348, (S)-318, (S)-292,
- (S)(S)-267, (S)-245, (S)-225, (S)-206, (S)-189, (S)-173,
- (S)-158, (S)-145, (S)(S)-133, (S)-122, (S)-112, (S)-102,
- (S)-94, (S)-86, (S)-79, (S)-72, (S)(S)-66, (S)-61,
- (S)-56, (S)-51, (S)-47, (S)-43, (S)-42, (S)-41,
- (S)(S)-40, (S)-39, (S)-38, (S)-37, (S)-36, (S)-35,
- (S)-34, (S)-33, (S)(S)-32, (S)-31, (S)-30, (S)-29,
- (S)-28, (S)-27, (S)-26, (S)-25, (S)(S)-24, (S)-23,
- (S)-22, (S)-21, (S)-20, (S)-19, (S)-18, (S)-17,
- (S)(S)-16, (S)-15, (S)-14, (S)-13, (S)-12, (S)-11,
- (S)-10, (S)-9, (S)(S)-8, (S)-7, (S)-6, (S)-5,
- (S)-4, (S)-3, (S)-2, (S)-1
-};
-#undef S
-
diff --git a/libmve/win_sound.cpp b/libmve/win_sound.cpp
deleted file mode 100644
index 014d6cc4..00000000
--- a/libmve/win_sound.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Descent 3
- * Copyright (C) 2024 Descent Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "win_sound.h"
-
-namespace D3 {
-
-MovieSoundDevice::MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, uint32_t buf_size,
- bool is_compressed) {
- m_is_compressed = is_compressed;
-
- m_lpDS = nullptr;
- m_lpDSB = nullptr;
-
- m_WFE.wFormatTag = WAVE_FORMAT_PCM;
- m_WFE.nChannels = channels;
- m_WFE.nSamplesPerSec = sample_rate;
- m_WFE.nAvgBytesPerSec = sample_rate * channels * sample_size;
- m_WFE.nBlockAlign = channels * sample_size;
- m_WFE.wBitsPerSample = sample_size * 8;
-
- // Initialize DSound
- if (FAILED(DirectSoundCreate(nullptr, &m_lpDS, nullptr))) {
- return;
- }
- // Set Cooperative Level
- HWND hWnd = GetForegroundWindow();
- if (hWnd == nullptr) {
- hWnd = GetDesktopWindow();
- }
- if (FAILED(m_lpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE))) {
- return;
- }
-
- // Create Primary Buffer
- DSBUFFERDESC dsbd;
- ZeroMemory(&dsbd, sizeof(dsbd));
- dsbd.dwSize = sizeof(DSBUFFERDESC);
- dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
- dsbd.dwBufferBytes = 0;
- dsbd.lpwfxFormat = nullptr;
-
- LPDIRECTSOUNDBUFFER lpDSB = nullptr;
- if (FAILED(m_lpDS->CreateSoundBuffer(&dsbd, &lpDSB, nullptr))) {
- return;
- }
-
- // Set Primary Buffer Format
- if (FAILED(lpDSB->SetFormat(&m_WFE))) {
- return;
- }
-
- // Create Second Sound Buffer
- dsbd.dwFlags = DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
- dsbd.dwBufferBytes = (buf_size + (buf_size >> 1)) & ~3;
- dsbd.lpwfxFormat = &m_WFE;
-
- if (FAILED(m_lpDS->CreateSoundBuffer(&dsbd, &m_lpDSB, nullptr))) {
- return;
- }
-}
-
-MovieSoundDevice::~MovieSoundDevice() {
- if (m_lpDSB != nullptr) {
- m_lpDSB->Stop();
- m_lpDSB->Release();
- }
- m_sound_buffer.reset();
-}
-
-void MovieSoundDevice::Play() {
- if (!m_lpDSB)
- return;
-
- // Check if the DirectSound was created successfully
- if (m_lpDS == nullptr) {
- return;
- }
-
- LPBYTE lpvAudio1 = nullptr, lpvAudio2 = nullptr;
- DWORD dwBytesAudio1 = 0, dwBytesAudio2 = 0;
-
- if (FAILED(m_lpDSB->Lock(0, (DWORD)GetBuffer()->size() * 2, reinterpret_cast(&lpvAudio1), &dwBytesAudio1,
- reinterpret_cast(&lpvAudio2), &dwBytesAudio2, DSBLOCK_FROMWRITECURSOR)))
- return;
-
- if (dwBytesAudio1 > 0) {
- memset(lpvAudio1, 0, dwBytesAudio1);
- auto limit = std::min(dwBytesAudio1 / 2, (DWORD)GetBuffer()->size());
- for (int i = 0; i < limit; i += 2) {
- int16_t sample = GetBuffer()->front();
- GetBuffer()->pop_front();
- lpvAudio1[i] = sample & 0xff;
- lpvAudio1[i + 1] = sample >> 8;
- }
- }
-
- if (dwBytesAudio2 > 0) {
- memset(lpvAudio2, 0, dwBytesAudio2);
- auto limit = std::min(dwBytesAudio2 / 2, (DWORD)GetBuffer()->size());
- for (int i = 0; i < limit; i += 2) {
- int16_t sample = GetBuffer()->front();
- GetBuffer()->pop_front();
- lpvAudio2[i] = sample & 0xff;
- lpvAudio2[i + 1] = sample >> 8;
- }
- }
-
- m_lpDSB->Unlock(lpvAudio1, dwBytesAudio1, lpvAudio2, dwBytesAudio2);
-
- // Begin Play
- m_lpDSB->Play(0, 0, DSBPLAY_LOOPING);
-
-}
-
-void MovieSoundDevice::Stop() {
- if (m_lpDSB != nullptr) {
-
- m_lpDSB->Stop();
-
- // Empty the buffer
- LPVOID lpvAudio1 = nullptr;
- DWORD dwBytesAudio1 = 0;
- HRESULT hr = m_lpDSB->Lock(0, 0, &lpvAudio1, &dwBytesAudio1, nullptr, nullptr, DSBLOCK_ENTIREBUFFER);
- if (FAILED(hr)) {
- return;
- }
- memset(lpvAudio1, 0, dwBytesAudio1);
- m_lpDSB->Unlock(lpvAudio1, dwBytesAudio1, nullptr, 0);
-
- // Move the current play position to begin
- m_lpDSB->SetCurrentPosition(0);
- }
-}
-
-void MovieSoundDevice::Lock(){}
-
-void MovieSoundDevice::Unlock(){}
-
-} // namespace D3
diff --git a/libmve/win_sound.h b/libmve/win_sound.h
deleted file mode 100644
index 5b06792c..00000000
--- a/libmve/win_sound.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Descent 3
- * Copyright (C) 2024 Descent Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef WIN_SOUND_H
-#define WIN_SOUND_H
-
-#include
-#include
-
-#include "win/DirectX/dsound.h"
-
-#include "sound_interface.h"
-
-namespace D3 {
-
-class MovieSoundDevice : ISoundDevice {
-public:
- MovieSoundDevice(int sample_rate, uint16_t sample_size, uint8_t channels, uint32_t buf_size, bool is_compressed);
- ~MovieSoundDevice();
-
- [[nodiscard]] bool IsInitialized() const { return m_lpDS != nullptr; }
-
- void Play() override;
- void Stop() override;
- void Lock() override;
- void Unlock() override;
-
- using ISoundDevice::GetBuffer;
- using ISoundDevice::IsCompressed;
-
-private:
- WAVEFORMATEX m_WFE{};
- LPDIRECTSOUND m_lpDS;
- LPDIRECTSOUNDBUFFER m_lpDSB;
-
-};
-
-} // namespace D3
-
-#endif // WIN_SOUND_H
diff --git a/lnxmvelib/CMakeLists.txt b/lnxmvelib/CMakeLists.txt
deleted file mode 100644
index 396c0535..00000000
--- a/lnxmvelib/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-set(HEADERS
- dyna_pthread.h
- lnxdsound.h
- mvegfx.h
- mvelibi.h
- mvelibl.h
- snd8to16.h)
-
-set(CPPS
- lnxdraw.cpp
- lnxdsound.cpp
- mveasm.cpp
- mvelibl.cpp)
-
-# asmstub.c
-
-add_library(lnxmvelib STATIC ${HEADERS} ${CPPS})
diff --git a/lnxmvelib/asmstub.c b/lnxmvelib/asmstub.c
deleted file mode 100644
index c50c0055..00000000
--- a/lnxmvelib/asmstub.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-#include
-
-/* These are our global variables for passing values - AH */
-/* For _asm_sndDecompM16 */
-uint16_t *sndDecompM16_dst;
-uint8_t *sndDecompM16_src;
-uint32_t sndDecompM16_len;
-uint32_t sndDecompM16_prev;
-uint32_t sndDecompM16_return;
-/* For _asm_sndDecompM16 */
-uint16_t *sndDecompS16_dst;
-uint8_t *sndDecompS16_src;
-uint32_t sndDecompS16_len;
-uint32_t sndDecompS16_prev;
-uint32_t sndDecompS16_return;
-/* For _asm_nfHPkDecomp */
-uint8_t *nfHPkDecomp_ops;
-uint8_t *nfHPkDecomp_comp;
-uint32_t nfHPkDecomp_x;
-uint32_t nfHPkDecomp_y;
-uint32_t nfHPkDecomp_w;
-uint32_t nfHPkDecomp_h;
-
-#ifdef __cplusplus /* Avoid C++ name mangling - AH */
-extern "C" {
-#endif
-void _asm_sndDecompM16(void);
-void _asm_sndDecompS16(void);
-void _asm_nfPkConfig(void);
-void _asm_nfHPkDecomp(void);
-void _asm_selfModify(void);
-#ifdef __cplusplus
-}
-#endif
-
-#define MAX_MEM_UNLOCK_POINTS 20
-int global_unlock_memory_pointers[MAX_MEM_UNLOCK_POINTS]; // _asm_selfModify() sets these
-
-int allow_self_modification(void) {
- int i;
- uint32_t page_start;
-
- for (i = 0; i < MAX_MEM_UNLOCK_POINTS; i++)
- global_unlock_memory_pointers[i] = 0;
-
- _asm_selfModify();
-
- for (i = 0; i < MAX_MEM_UNLOCK_POINTS; i++)
- if (global_unlock_memory_pointers[i] != 0) {
- page_start = global_unlock_memory_pointers[i] - (global_unlock_memory_pointers[i] % getpagesize());
- mprotect((void *)page_start, getpagesize() * 2, PROT_READ | PROT_WRITE | PROT_EXEC);
- // fprintf(stderr, "Unlocked memory location %x for location %x.\n",page_start, global_unlock_memory_pointers[i]);
- }
- return (1);
-}
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- sndDecompM16_dst = dst;
- sndDecompM16_src = src;
- sndDecompM16_len = len;
- sndDecompM16_prev = prev;
- __asm__(" call _asm_sndDecompM16" : : : "%esi", "%edi", "%ebx", "cc", "memory");
- return (sndDecompM16_return);
-}
-
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- sndDecompS16_dst = dst;
- sndDecompS16_src = src;
- sndDecompS16_len = len;
- sndDecompS16_prev = prev;
- __asm__("call _asm_sndDecompS16" : : : "%esi", "%edi", "%ebx", "cc", "memory");
- return (sndDecompS16_return);
-}
-
-void nfPkConfig(void) {
- __asm__("call _asm_nfPkConfig" : : : "%esi", "%edi", "%ebx", "cc", "memory");
- return;
-}
-
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, uint32_t x, uint32_t y, uint32_t w,
- uint32_t h) {
- nfHPkDecomp_ops = ops;
- nfHPkDecomp_comp = comp;
- nfHPkDecomp_x = x;
- nfHPkDecomp_y = y;
- nfHPkDecomp_w = w;
- nfHPkDecomp_h = h;
- __asm__("call _asm_nfHPkDecomp" : : : "%esi", "%edi", "%ebx", "cc", "memory");
- return;
-}
-
-/***********************************************************/
-/* Non-Implemented functions (from inside mveasm.cpp - AH) */
-/***********************************************************/
-
-void nfHiColorDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfHiColorDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y,
- unsigned w, unsigned h);
-void nfDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y, unsigned w,
- unsigned h);
-void nfPkPal(void);
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-void palLoadCompPalette(uint8_t *buf);
-void gfxMode(unsigned mode);
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res);
-void gfxGetCrtc(uint8_t *crtc);
-void gfxVres(uint8_t misc, uint8_t *crtc);
-void MVE_gfxWaitRetrace(int state);
-void MVE_gfxSetSplit(unsigned line);
-
-// rcg07272000
-// need this on non-Intel platforms. Intel uses int $3.
-#if (defined __i386__) || defined(__x86_64__)
-#define int3 __asm__ __volatile__("int $3");
-#else
-#define int3 raise(SIGTRAP);
-#endif
-
-void nfHiColorDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3 }
-void nfHiColorDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y,
- unsigned w, unsigned h) {
- int3
-}
-void nfDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3 }
-void nfDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y, unsigned w,
- unsigned h) {
- int3
-}
-void nfPkPal(void) { int3 }
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3 }
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3 }
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3 }
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- int3
-}
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- int3
-}
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- int3
-}
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- int3
-}
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- int3
-}
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- int3
-}
-/* Avoid name mangling issues by moving this into mvelibl.cpp - AH
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count)
-{
- int3
-} */
-void palLoadCompPalette(uint8_t *buf) { int3 }
-void gfxMode(unsigned mode) { int3 }
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res) { int3 }
-void gfxGetCrtc(uint8_t *crtc) { int3 }
-void gfxVres(uint8_t misc, uint8_t *crtc) { int3 }
-void MVE_gfxWaitRetrace(int state) { int3 }
-void MVE_gfxSetSplit(unsigned line) { int3 }
diff --git a/lnxmvelib/dyna_pthread.h b/lnxmvelib/dyna_pthread.h
deleted file mode 100644
index d952dc00..00000000
--- a/lnxmvelib/dyna_pthread.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifdef DECLARE_POINTERS
-#define FEXTERN
-#else
-#define FEXTERN extern
-#endif
-#include
-
-#define pthread_create sopthread_create
-#define pthread_exit sopthread_exit
-#define pthread_detach sopthread_detach
-#define pthread_self sopthread_self
-
-typedef int (*pthread_create_fp)(pthread_t *__thread, __const pthread_attr_t *__attr, void *(*__start_routine)(void *),
- void *__arg);
-FEXTERN pthread_create_fp sopthread_create;
-
-typedef void (*pthread_exit_fp)(void *__retval);
-FEXTERN pthread_exit_fp sopthread_exit;
-
-typedef int (*pthread_detach_fp)(pthread_t __th);
-FEXTERN pthread_detach_fp sopthread_detach;
-
-typedef pthread_t (*pthread_self_fp)(void);
-FEXTERN pthread_self_fp sopthread_self;
-
-#ifndef DECLARE_POINTERS
-bool LoadPThreadLib(bool load = true);
-#else
-#include
-#include
-#include
-void LoadPThreadLibSetNULL(void) {
- sopthread_create = NULL;
- sopthread_exit = NULL;
- sopthread_detach = NULL;
- sopthread_self = NULL;
-}
-
-bool LoadPThreadLib(bool load) {
-#define PTHREADLIB "libpthread.so"
- static void *handle = NULL;
-
- if (!load) {
- LoadPThreadLibSetNULL();
- if (handle) {
- dlclose(handle);
- handle = NULL;
- return true;
- }
- fprintf(stderr, "Library Unload Failed: %s\n", PTHREADLIB);
- return false;
- }
-
- if (handle)
- return true;
-
- // Load the library
- handle = dlopen(PTHREADLIB, RTLD_LAZY | RTLD_GLOBAL);
- if (!handle) {
- fprintf(stderr, "Library Load Failed: %s\n", PTHREADLIB);
- return false;
- }
-
- sopthread_create = (pthread_create_fp)dlsym(handle, "pthread_create");
- if (!sopthread_create)
- goto load_error;
-
- sopthread_exit = (pthread_exit_fp)dlsym(handle, "pthread_exit");
- if (!sopthread_exit)
- goto load_error;
-
- sopthread_detach = (pthread_detach_fp)dlsym(handle, "pthread_detach");
- if (!sopthread_detach)
- goto load_error;
-
- sopthread_self = (pthread_self_fp)dlsym(handle, "pthread_self");
- if (!sopthread_self)
- goto load_error;
-
- return true;
-
-load_error:
- LoadPThreadLibSetNULL();
- fprintf(stderr, "Library Symbol Resolve Error: %s\n", PTHREADLIB);
- dlclose(handle);
- handle = NULL;
- return false;
-}
-#endif
diff --git a/lnxmvelib/lnxdraw.cpp b/lnxmvelib/lnxdraw.cpp
deleted file mode 100644
index 538af858..00000000
--- a/lnxmvelib/lnxdraw.cpp
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "linux/lnxdraw.h"
-#include "lnxscreenmode.h"
-
-// static Display *lpDisplay = NULL;
-static int nDefaultScreen = -1;
-static uint32_t dwOriginalWidth, dwOriginalHeight;
-static LnxWindow **WindowList;
-static int NumWindows = 0;
-// static int GetXSharedMemory(int size);
-inline void BltBuffer16ToPixMap24(uint8_t *pixmap, uint8_t *buffer, int width, int height);
-inline void BltBuffer32ToPixMap24(uint8_t *pixmap, uint8_t *buffer, int width, int height);
-inline void BltBuffer16ToPixMap16(uint8_t *pixmap, uint8_t *buffer, int width, int height);
-inline void BltBuffer32ToPixMap16(uint8_t *pixmap, uint8_t *buffer, int width, int height);
-
-static SDL_Rect dispSize;
-
-//////////////////////
-// LnxDraw_InitVideo
-//////////////////////
-// Initializes the Linux video system (for X-Windows)
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameter
-// -2 : already initialized
-int LnxDraw_InitVideo(LnxVideoDesc *ldesc) {
- return -1;
- if (!ldesc)
- return -1;
- // if(lpDisplay)
- // return -2;
-
- // lpDisplay = ldesc->dDisplay;
- // nDefaultScreen = ldesc->nScreen;
-
- // dwOriginalWidth = DisplayWidth(lpDisplay,nDefaultScreen);
- // dwOriginalHeight = DisplayHeight(lpDisplay,nDefaultScreen);
-
- memset(&dispSize, '\0', sizeof(dispSize));
- return 0;
-}
-
-int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event);
-
-/////////////////////////
-// LnxDraw_CreateWindow
-/////////////////////////
-// Creates and displays a window
-//
-// Returns:
-// 0 : no error (handle in lphandle)
-// -1 : invalid parameter
-// -2 : Display not opened
-// -3 : Out of memory
-int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle) {
-#if 1
- SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
- return -1;
-#else
- if (!ldesc || !lphandle)
- return -1;
- *lphandle = NULL;
-
- // rcg09182000 don't need to quitsubsystem anymore...
- // SDL_QuitSubSystem(SDL_INIT_VIDEO); // here goes nothing...
- SDL_ClearError();
- int rc = SDL_Init(SDL_INIT_VIDEO);
- if (rc != 0) {
- fprintf(stderr, "SDL: SDL_Init() failed! rc == (%d).\n", rc);
- fprintf(stderr, "SDL_GetError() reports \"%s\".\n", SDL_GetError());
- return (-2);
- } // if
- SDL_SetEventFilter(d3SDLEventFilter, NULL);
-
- SDL_Rect **modes = LinuxVideoMode.getModes();
- Uint32 sdlflags = LinuxVideoMode.getSDLFlags();
-
- // if(!lpDisplay)
- // return -2;
-
- // determine what we have to work with (currently)
- // uint32_t display_width,display_height;
- // display_width = DisplayWidth(lpDisplay,nDefaultScreen);
- // display_height = DisplayHeight(lpDisplay,nDefaultScreen);
-
- // allocate a window for use
- LnxWindow *wnd;
- wnd = (LnxWindow *)malloc(sizeof(*wnd));
- if (!wnd) {
- return -3;
- }
-
- int i = 0;
-
- dispSize.x = dispSize.y = 0;
- dispSize.w = ldesc->dwWidth;
- dispSize.h = ldesc->dwHeight;
-
- // need these two lines for a Voodoo3 bug.
- SDL_ShowCursor(0);
- SDL_WM_GrabInput(SDL_GRAB_ON);
-
- wnd->surface = SDL_SetVideoMode(ldesc->dwWidth, ldesc->dwHeight, ldesc->bpp, sdlflags);
-
- // failed? Try a window.
- if ((wnd->surface == NULL) && (sdlflags & SDL_FULLSCREEN)) {
- sdlflags &= ~SDL_FULLSCREEN;
- wnd->surface = SDL_SetVideoMode(ldesc->dwWidth, ldesc->dwHeight, ldesc->bpp, sdlflags);
- } // if
-
- SDL_WM_GrabInput(SDL_GRAB_OFF);
- if (!(sdlflags & SDL_FULLSCREEN))
- SDL_ShowCursor(1);
-
- if (wnd->surface == NULL) {
- fprintf(stderr, "ERROR: SDL could not set the video mode!\n");
- return -3;
- } // if
-
- wnd->fullScreen = (sdlflags & SDL_FULLSCREEN) ? true : false;
-
- SDL_WM_SetCaption("Descent 3", NULL);
-
- /*
- wnd->WindowPreCreated = (ldesc->dwFlags&LNXDRAWF_USEPRECREATEDWIN)?true:false;
-
- if(!wnd->WindowPreCreated)
- {
- // allocate what the hints, etc.
- wnd->lpSizeHints = XAllocSizeHints();
- if(!wnd->lpSizeHints)
- {
- // TODO: Free above allocated hints
- free(wnd);
- return -3;
- }
-
- wnd->lpWmHints = XAllocWMHints();
- if(!wnd->lpWmHints)
- {
- // TODO: Free above allocated hints
- free(wnd);
- return -3;
- }
-
- wnd->lpClassHints = XAllocClassHint();
- if(!wnd->lpClassHints)
- {
- // TODO: Free above allocated hints
- free(wnd);
- return -3;
- }
- }
-
- // try to match a visual
- if (!XMatchVisualInfo(lpDisplay,nDefaultScreen,16,TrueColor,&wnd->viVisualInfo))
- {
- fprintf(stderr,"Error: Unable to get 16bit TrueColor Visual\n");
-
- // TODO: Free above allocated hints
- free(wnd);
- return -3;
- }
-
- // see if we have shared memory available
- wnd->bHaveSharedMemory = (bool)(XShmQueryExtension(lpDisplay)!=0);
- wnd->shmInfo.shmaddr = NULL;
-
- // even if the display says it has shared memory, it still might not be
- // available (if we are not running on a local connection)
- if(wnd->bHaveSharedMemory)
- {
- char *ptr;
- char *displayname = (char *)getenv("DISPLAY");
- if (displayname)
- {
- ptr = displayname;
- while (*ptr && (*ptr != ':')) ptr++;
- if (*ptr) *ptr = '\0';
- if (!(!strcasecmp(displayname, "unix") || !*displayname))
- wnd->bHaveSharedMemory = false;
- }else
- wnd->bHaveSharedMemory = false;
- }
- //fprintf(stdout,"Shared Memory: %savailable\n",wnd->bHaveSharedMemory?"":"Not ");
-
- if(!wnd->WindowPreCreated)
- {
- wnd->lpXvisual = wnd->viVisualInfo.visual;
- wnd->cmColorMap = DefaultColormapOfScreen(DefaultScreenOfDisplay(lpDisplay));
-
- uint32_t attrib_mask;
- XSetWindowAttributes attrib;
-
- // setup some attribute and hints for actual window creation
- attrib_mask = CWEventMask | CWColormap | CWBorderPixel;
- attrib.event_mask = KeyPressMask | KeyReleaseMask | PointerMotionMask |
- ButtonPressMask | ButtonReleaseMask | ExposureMask;
- attrib.colormap = wnd->cmColorMap;
- attrib.border_pixel = 0;
-
- wnd->lpSizeHints->width = ldesc->dwWidth;
- wnd->lpSizeHints->height = ldesc->dwHeight;
- wnd->lpSizeHints->min_width = ldesc->dwWidth;
- wnd->lpSizeHints->max_width = ldesc->dwWidth;
- wnd->lpSizeHints->min_height = ldesc->dwHeight;
- wnd->lpSizeHints->max_height = ldesc->dwHeight;
- wnd->lpSizeHints->x = ldesc->dwXPos;
- wnd->lpSizeHints->y = ldesc->dwYPos;
- wnd->lpSizeHints->flags |= USSize | PMinSize | PMaxSize | USPosition;
-
- wnd->wWindow = XCreateWindow(lpDisplay,RootWindow(lpDisplay,nDefaultScreen),
- ldesc->dwXPos,ldesc->dwYPos,
- ldesc->dwWidth,ldesc->dwHeight,
- 0,
- wnd->viVisualInfo.depth,
- InputOutput,
- wnd->lpXvisual,
- attrib_mask,
- &attrib);
-
- XStoreName(lpDisplay,wnd->wWindow,ldesc->lpszName);
- XSetIconName(lpDisplay,wnd->wWindow,ldesc->lpszName);
- XSetWMNormalHints(lpDisplay,wnd->wWindow,wnd->lpSizeHints);
-
- // Display the window!
- XMapWindow(lpDisplay,wnd->wWindow);
-
- // Wait until it is actually visible
- bool wait_for_draw = false;
- XEvent event;
- while (!wait_for_draw)
- {
- XNextEvent(lpDisplay, &event);
- if (event.type == Expose && !event.xexpose.count) wait_for_draw = true;
- }
- }else
- {
- wnd->wWindow = *ldesc->pre_created_window;
-
- // resize window and stuff here
- wnd->viVisualInfo = ldesc->pre_created_visinfo;
- wnd->lpXvisual = wnd->viVisualInfo.visual;
- wnd->cmColorMap = DefaultColormapOfScreen(DefaultScreenOfDisplay(lpDisplay));
- }
- */
-
- // We're done, add it to our Window list
- WindowList = (LnxWindow **)realloc(WindowList, sizeof(LnxWindow *) * (NumWindows + 1));
- if (!WindowList) {
- return -3;
- }
-
- WindowList[NumWindows] = wnd;
- *lphandle = wnd;
- NumWindows++;
-
- // Setup window for blitting
- wnd->bLocked = false;
- wnd->dwWidth = ldesc->dwWidth;
- wnd->dwHeight = ldesc->dwHeight;
-
- // Create the Graphics Context
- // int valuemask;
- // XGCValues xgcvalues;
- // xgcvalues.graphics_exposures = False;
- // valuemask = GCGraphicsExposures;
-
- // wnd->m_GC = XCreateGC(lpDisplay,wnd->wWindow,valuemask,&xgcvalues);
- // wnd->lock_ptr = (uint8_t *)malloc(wnd->dwWidth*wnd->dwHeight<<1);
-
- // int id = GetXSharedMemory(wnd->dwWidth*wnd->dwHeight<<1);
- // if(id<0)
- // {
- // wnd->bHaveSharedMemory = false;
- // wnd->shmInfo.shmaddr = NULL;
- // }else
- // {
- // // attach
- // wnd->shmInfo.shmid = id;
- // wnd->shmInfo.shmaddr = (char *)shmat(id, 0, 0);
- // }
-
- // fprintf(stdout,"Draw: %s shared memory\n",(wnd->bHaveSharedMemory)?"Using":"Not Using");
-
- // Initial clear
- uint8_t *lock_ptr;
- int lock_pitch;
- if (LnxDraw_LockSurface(wnd, 0, 0, wnd->dwWidth - 1, wnd->dwHeight - 1, &lock_ptr, &lock_pitch)) {
- memset(lock_ptr, 0, wnd->dwWidth * wnd->dwHeight << 1);
- LnxDraw_UnlockSurface(wnd, lock_ptr);
- }
-
- return 0;
-#endif
-}
-
-//////////////////////////
-// LnxDraw_DestroyWindow
-//////////////////////////
-// Closes and deletes a window
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameter
-int LnxDraw_DestroyWindow(LnxWindow *handle) {
-#if 1
- SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
- return -1;
-#else
- int i;
- LnxWindow *wnd = NULL;
-
- for (i = 0; i < NumWindows; i++) {
- if (WindowList[i] == handle) {
- wnd = handle;
- break;
- }
- }
-
- if (!wnd)
- return -1;
-
- WindowList[i] = WindowList[NumWindows - 1];
- WindowList = (LnxWindow **)realloc(WindowList, sizeof(LnxWindow *) * (NumWindows - 1));
- NumWindows--;
-
- /*
- if(wnd->shmInfo.shmaddr)
- {
- // Release shared memory.
- shmdt(wnd->shmInfo.shmaddr);
- shmctl(wnd->shmInfo.shmid, IPC_RMID, 0);
- }
-
- if(!wnd->WindowPreCreated)
- {
- // Do what we need to do to close the window
- XDestroyWindow(lpDisplay,wnd->wWindow);
-
- XFree(wnd->lpSizeHints);
- XFree(wnd->lpWmHints);
- XFree(wnd->lpClassHints);
- }
-
- free(wnd->lock_ptr);
- */
-
- if (wnd->fullScreen) {
- SDL_WM_ToggleFullScreen(wnd->surface);
- SDL_ShowCursor(1);
- } // if
-
- free(wnd);
-
- return 0;
-#endif
-}
-
-////////////////////////
-// LnxDraw_LockSurface
-////////////////////////
-// Locks the window surface, giving you a pointer to write data to
-//
-// Returns:
-// true : success
-// false : error
-bool LnxDraw_LockSurface(LnxWindow *wnd, unsigned x1, unsigned y1, unsigned x2, unsigned y2, uint8_t **ptr,
- int *pitch) {
-#if 1
- SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
- return false;
-#else
- return -1;
- if (!wnd || !ptr || !pitch)
- return false;
- if (wnd->bLocked)
- return false;
- wnd->bLocked = true;
-
- *pitch = wnd->dwWidth << 1;
-
- /*
- int w,h;
- if(x2bHaveSharedMemory)
- {
- wnd->lpImage =
- XShmCreateImage(lpDisplay,wnd->lpXvisual,wnd->viVisualInfo.depth,ZPixmap,0,&wnd->shmInfo,wnd->dwWidth,h);
- wnd->lpImage->bitmap_bit_order = LSBFirst;
- wnd->lpImage->byte_order = LSBFirst;
- wnd->lpImage->bits_per_pixel = 16;
- wnd->lpImage->bytes_per_line = wnd->dwWidth<<1;
- wnd->lpImage->red_mask = wnd->lpXvisual->red_mask;
- wnd->lpImage->green_mask = wnd->lpXvisual->green_mask;
- wnd->lpImage->blue_mask = wnd->lpXvisual->blue_mask;
- wnd->lpImage->data = wnd->shmInfo.shmaddr;
-
- if(!wnd->lpImage->data)
- {
- wnd->bHaveSharedMemory = false;
- //fprintf(stderr,"Shared Memory: Invalid Memory\n");
- goto try_no_shared;
- }
-
- // attach the X server to it
- wnd->shmInfo.readOnly = False;
- if(!XShmAttach(lpDisplay,&wnd->shmInfo))
- {
- wnd->bHaveSharedMemory = false;
- //fprintf(stderr,"Shared Memory: Unable to attach to server\n");
- goto try_no_shared;
- }
- }else
- {
- wnd->lpImage = XCreateImage(lpDisplay,wnd->lpXvisual,wnd->viVisualInfo.depth,ZPixmap,0,(char
- *)wnd->lock_ptr,wnd->dwWidth,h,16,0); wnd->lpImage->bitmap_bit_order = LSBFirst; wnd->lpImage->byte_order = LSBFirst;
- wnd->lpImage->bits_per_pixel = 16;
- wnd->lpImage->bytes_per_line = wnd->dwWidth<<1;
- wnd->lpImage->red_mask = wnd->lpXvisual->red_mask;
- wnd->lpImage->green_mask = wnd->lpXvisual->green_mask;
- wnd->lpImage->blue_mask = wnd->lpXvisual->blue_mask;
- wnd->lpImage->data = (char *)wnd->lock_ptr;
- }
-
- *ptr = (uint8_t *)wnd->lpImage->data;
- wnd->lock_x = x1;
- wnd->lock_y = y1;
- wnd->lock_w = w;
- wnd->lock_h = h;
- */
-
- if (SDL_MUSTLOCK(wnd->surface)) {
- if (SDL_LockSurface(wnd->surface) < 0)
- return (false);
- } // if
-
- int imgHeight = y2 - y1;
- int linesDown = (wnd->dwHeight - imgHeight) / 2;
-
- *ptr = ((uint8_t *)wnd->surface->pixels) + ((wnd->surface->format->BytesPerPixel * wnd->dwWidth) * linesDown);
- return true;
-#endif
-}
-
-//////////////////////////
-// LnxDraw_UnlockSurface
-//////////////////////////
-// Unlocks the window surface, blitting the buffer
-//
-void LnxDraw_UnlockSurface(LnxWindow *wnd, uint8_t *ptr) {
-#if 1
- SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
-#else
- if (!wnd->bLocked)
- return;
- bool still_have_shared = true;
- wnd->bLocked = false;
-
- /*
- // blit the region
- if(wnd->bHaveSharedMemory)
- {
- if(!XShmPutImage(lpDisplay,wnd->wWindow,wnd->m_GC,wnd->lpImage,0,0,wnd->lock_x,wnd->lock_y,wnd->lock_w,wnd->lock_h,True))
- {
- //fprintf(stderr,"XShmPutImage: blit failed\n");
- wnd->bHaveSharedMemory = false;
- }
- // Detach from X server
- XShmDetach(lpDisplay,&wnd->shmInfo);
- }else
- {
- // draw the image
- if(XPutImage(lpDisplay,wnd->wWindow,wnd->m_GC,wnd->lpImage,0,0,wnd->lock_x,wnd->lock_y,wnd->lock_w,wnd->lock_h))
- {
- //fprintf(stderr,"XPutImage: blit failed\n");
- }
- }
-
- // sync up with server
- XSync(lpDisplay, False);
-
- // Kill the memory
- wnd->lpImage->data = NULL;//make sure we don't delete our memory here
- XDestroyImage(wnd->lpImage);
- */
-
- if (SDL_MUSTLOCK(wnd->surface))
- SDL_UnlockSurface(wnd->surface);
-
- SDL_UpdateRect(wnd->surface, 0, 0, wnd->dwWidth, wnd->dwHeight);
-
-#ifdef __DUMP_MVE_TO_DISK
- static uint32_t framenum = 0;
- char filename[100];
- snprintf(filename, sizeof(filename), "./mve/frame%lu.bmp", framenum);
- SDL_SaveBMP(wnd->surface, filename);
- framenum++;
-#endif
-#endif
-}
-
-////////////////////////////
-/// LnxDraw_Blit
-////////////////////////////
-// Blits a buffer to the window
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameter
-// -2 : unknown error
-int LnxDraw_Blit(LnxWindow *wnd, uint8_t *ptr, uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
- return 0;
- /*
- if(!wnd || !ptr)
- return -1;
-
- //blt to pixmap
- if(wnd->viVisualInfo.depth==16)
- {
- //check for best case
- if(x==0 && y==0 && w==wnd->dwWidth && h==wnd->dwHeight)
- {
- BltBuffer16ToPixMap16((uint8_t *)wnd->lpImage->data,ptr,wnd->dwWidth,wnd->dwHeight);
- }else
- {
- int num_rows_to_blit;
- int start_row,pitch;
- uint8_t *curr_dest,*curr_src;
-
- pitch = wnd->dwWidth<<1;
- curr_dest = (uint8_t *)wnd->lpImage->data + (y*pitch) + (x<<1);
- curr_src = ptr;
- num_rows_to_blit = h;
-
- // blit away
- while(num_rows_to_blit>0)
- {
- BltBuffer16ToPixMap16(curr_dest,curr_src,w,1);
-
- num_rows_to_blit--;
- curr_dest += pitch;
- curr_src += pitch;
- }
- }
- }else
- {
- return -2;
- }
-
- //Update window
- if(wnd->bHaveSharedMemory)
- {
- if(!XShmPutImage(lpDisplay,wnd->wWindow,wnd->m_GC,wnd->lpImage,0, 0, 0,
- 0,wnd->dwWidth,wnd->dwHeight,True))
- {
- return -2;
- }
- }else
- {
- // draw the image
- XPutImage(lpDisplay,wnd->wWindow,wnd->m_GC,wnd->lpImage,0, 0,0,0,wnd->dwWidth,wnd->dwHeight);
- }
-
- // sync up with server
- XSync(lpDisplay, False);
-
- return 0;
- */
-}
-
-////////////////////////
-// LnxDraw_GetRGBMasks
-////////////////////////
-// Returns the RGB masks for the display
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxDraw_GetRGBMasks(LnxWindow *wnd, uint32_t *r, uint32_t *g, uint32_t *b) {
- return -1;
- if (!wnd || !r || !g || !b)
- return -1;
- /*
- *r = wnd->lpImage->red_mask;
- *g = wnd->lpImage->green_mask;
- *b = wnd->lpImage->blue_mask;
- */
-
- SDL_PixelFormat *pixelFmt = wnd->surface->format;
-
- *r = pixelFmt->Rmask;
- *g = pixelFmt->Gmask;
- *b = pixelFmt->Bmask;
- return (0);
-}
-
-static int GetXSharedMemory(int size) {
- /*
- int key = (14<<24)|(70<<16)|(81<<8)|49;
- struct shmid_ds shminfo;
- int minsize = 640*480;
- int id;
- int rc;
- int num_try=5;
-
- do
- {
- //try to get the id
- id = shmget((key_t) key, minsize,0x1FF);
-
- if(id!=-1)
- {
- rc = shmctl(id, IPC_STAT, &shminfo);
- if(!rc)
- {
- if(shminfo.shm_nattch)
- {
- key++;
- }else
- {
- if(getuid()==shminfo.shm_perm.cuid)
- {
- rc = shmctl(id,IPC_RMID,0);
- if(!rc)
- {
- //fprintf(stderr,"Shared Memory: Stale memory killed\n");
- }
- else
- {
- //fprintf(stderr,"Shared Memory: Unable to kill stale
- memory\n"); return -2;
- }
-
- id = shmget((key_t)key,size,IPC_CREAT|0x1FF);
- if(id==-1)
- {
- //fprintf(stderr,"Shared Memory: Unable to create shared
- memory block (size=%d)\n",size); return -2;
- }
-
- rc=shmctl(id,IPC_STAT,&shminfo);
- break;
- }
-
- if(size>=shminfo.shm_segsz)
- {
- //fprintf(stderr,"Shared Memory: Using User %d's shared
- memory\n",shminfo.shm_cpid); break; }else
- {
- //fprintf(stderr,"Shared Memory: Stale memory (User %d, Key=0x%x) is
- too small\n",shminfo.shm_cpid,key); key++;
- }
- }
- }else
- {
- //fprintf(stderr,"Shared Memory: Unable to read stats on 0x%x\n",key);
- return -2;
- }
- }else
- {
- id = shmget((key_t)key,size,IPC_CREAT|0x1FF);
- if(id==-1)
- {
- //fprintf(stderr,"Shared Memory: Unable to get shared memory (error = %d)\n",errno);
- return -2;
- }
- break;
- }
- }while (--num_try);
-
- if(num_try == 0)
- {
- //fprintf(stderr,"Shared Memory: Unable to get shared memory (too many stale shared memory
- segments)\n");
- }
-
- return id;
- */
- return (0);
-}
-
-inline void BltBuffer32ToPixMap16(uint8_t *pixmap, uint8_t *buffer, int width, int height) {
- uint8_t *data;
- uint16_t int l;
- int r, g, b, a;
- uint32_t c;
-
- data = (uint8_t *)pixmap;
- for (l = height * width; l > 0; l--) {
- c = *(uint32_t *)buffer;
- a = ((c & 0xff000000) >> 24);
- r = ((c & 0x00ff0000) >> 16);
- g = ((c & 0x0000ff00) >> 8);
- b = (c & 0x000000ff);
-
- if (a)
- *(uint32_t *)data = (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3));
- data += 2;
- buffer += 4;
- }
-}
-
-inline void BltBuffer16ToPixMap16(uint8_t *pixmap, uint8_t *buffer, int width, int height) {
- uint8_t *data;
- data = (uint8_t *)pixmap;
- memcpy(data, buffer, (width * height) << 1);
-}
-
-inline void BltBuffer32ToPixMap24(uint8_t *pixmap, uint8_t *buffer, int width, int height) {
- uint8_t *data;
- uint16_t int l;
- int r, g, b, a;
- uint32_t c;
-
- data = (uint8_t *)pixmap;
- for (l = height * width; l > 0; l--) {
- c = *(uint32_t *)buffer;
- a = ((c & 0xff000000) >> 24);
- r = ((c & 0x00ff0000) >> 16);
- g = ((c & 0x0000ff00) >> 8);
- b = (c & 0x000000ff);
-
- if (a)
- *(uint32_t *)data = ((r << 16) + (g << 8) + b);
- data += 4;
- buffer += 4;
- }
-}
-
-inline void BltBuffer16ToPixMap24(uint8_t *pixmap, uint8_t *buffer, int width, int height) {
- uint8_t *data;
- uint16_t int l;
- int r, g, b, a;
- uint16_t c;
-
- data = (uint8_t *)pixmap;
- for (l = height * width; l > 0; l--) {
- c = *(uint16_t *)buffer;
- a = ((c & 0x8000) >> 15);
- r = ((c & 0x7C00) >> 10);
- g = ((c & 0x03E0) >> 5);
- b = (c & 0x001F);
-
- if (a)
- *(uint32_t *)data = ((r << 19) + (g << 11) + (b << 3));
- data += 4;
- buffer += 2;
- }
-}
diff --git a/lnxmvelib/lnxdsound.cpp b/lnxmvelib/lnxdsound.cpp
deleted file mode 100644
index d6f39f30..00000000
--- a/lnxmvelib/lnxdsound.cpp
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-// #include "dyna_pthread.h"//threads
-#include "linux/lnxdsound.h"
-
-#include "SDL.h"
-#include "SDL_audio.h"
-
-#include
-
-#define FRAGMENT_LENGTH (LnxBuffers[0]->bps >> 4)
-#define FREQUENCY_SHIFT (14)
-
-/*
- * TODO:
- * * Might be wise to use mutex's for the enter/exit critical functions
- */
-static int LnxNumBuffers = 0;
-static LnxSoundBuffer **LnxBuffers = NULL;
-static LnxSoundDevice LinuxSoundDevice;
-
-static bool StartupSoundSystem(LnxSoundDevice *dev);
-static void ShutdownSoundSystem(void);
-static void LinuxSoundMixWithVolume(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len);
-static uint32_t LinuxSoundMixNormalize(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len);
-static uint32_t LinuxSoundMixInMainBuffer(LnxSoundBuffer *dsb, int len);
-static void LinuxSoundMixBuffersIntoMain(int len);
-static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len);
-
-static inline void enter_critical(void) { SDL_LockAudio(); }
-
-static inline void exit_critical(void) { SDL_UnlockAudio(); }
-
-///////////////////////////////
-// LnxSound_CreateSoundBuffer
-///////////////////////////////
-// Creates a sound buffer to be used with mixing and output.
-//
-// Returns:
-// -1 : Invalid Parameter
-// -2 : Out of memory
-// 0 : Ok!
-int LnxSound_CreateSoundBuffer(LnxSoundDevice *dev, LnxBufferDesc *lbdesc, LnxSoundBuffer **lsndb) {
- WAVEFORMATEX *wfex;
-
- if (!lbdesc || !lsndb || !dev)
- return -1;
-
- wfex = lbdesc->lpwfxFormat;
- if (!wfex)
- return -1;
-
- // Check to see if we have a primary buffer yet, if not, create it
- // now
- if (lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- if (LnxNumBuffers != 0)
- return -1;
- } else {
- if (LnxNumBuffers == 0) {
- // we need to create a primary buffer
- LnxSoundBuffer *primary;
- LnxBufferDesc primdesc;
- WAVEFORMATEX wf;
-
- memset(&primdesc, 0, sizeof(LnxBufferDesc));
- memset(&wf, 0, sizeof(wf));
-
- primdesc.dwBufferBytes = 0;
- primdesc.dwFlags = LNXSND_CAPS_PRIMARYBUFFER;
- primdesc.lpwfxFormat = &wf;
-
- int ret = LnxSound_CreateSoundBuffer(dev, &primdesc, &primary);
- if (ret != 0)
- return ret;
- }
- }
-
- *lsndb = (LnxSoundBuffer *)malloc(sizeof(LnxSoundBuffer));
- if (!(*lsndb))
- return -2;
- memset(*lsndb, 0, sizeof(LnxSoundBuffer));
-
- if (lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- (*lsndb)->buffer_len = dev->bps;
- (*lsndb)->freq = dev->freq;
- (*lsndb)->bps = dev->bps;
- (*lsndb)->buffer = NULL;
- } else {
- (*lsndb)->buffer_len = lbdesc->dwBufferBytes;
- (*lsndb)->freq = lbdesc->lpwfxFormat->nSamplesPerSec;
-
- (*lsndb)->buffer = (uint8_t *)malloc((*lsndb)->buffer_len);
- if (!(*lsndb)->buffer) {
- free(*lsndb);
- *lsndb = NULL;
- return -2;
- }
- memset((*lsndb)->buffer, 0, (*lsndb)->buffer_len);
- }
-
- (*lsndb)->play_cursor = 0;
- (*lsndb)->write_cursor = 0;
- (*lsndb)->playing = 0;
- (*lsndb)->left_vol = (1 << 15);
- (*lsndb)->right_vol = (1 << 15);
-
- if (!(lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- (*lsndb)->freq_adjustment = ((*lsndb)->freq << FREQUENCY_SHIFT) / LnxBuffers[0]->freq;
- (*lsndb)->bps = (*lsndb)->freq * lbdesc->lpwfxFormat->nBlockAlign;
- }
-
- memcpy(&((*lsndb)->lbdesc), lbdesc, sizeof(LnxBufferDesc));
-
- if (!(lbdesc->dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- memcpy(&((*lsndb)->wfx), lbdesc->lpwfxFormat, sizeof(WAVEFORMATEX));
- } else {
- // set up the wave format based on the device settings (primary)
- (*lsndb)->wfx.wFormatTag = WAVE_FORMAT_PCM;
- (*lsndb)->wfx.nChannels = dev->channels;
- (*lsndb)->wfx.nSamplesPerSec = dev->freq;
- (*lsndb)->wfx.nBlockAlign = dev->channels * (dev->bit_depth / 8);
- (*lsndb)->wfx.nAvgBytesPerSec = dev->freq * (*lsndb)->wfx.nBlockAlign;
- (*lsndb)->wfx.wBitsPerSample = dev->bit_depth;
- (*lsndb)->wfx.cbSize = 0;
- }
-
- if (LnxBuffers) {
- enter_critical();
- LnxBuffers = (LnxSoundBuffer **)realloc(LnxBuffers, sizeof(LnxSoundBuffer *) * (LnxNumBuffers + 1));
- LnxBuffers[LnxNumBuffers] = *lsndb;
- LnxNumBuffers++;
- exit_critical();
- } else {
- LnxBuffers = (LnxSoundBuffer **)malloc(sizeof(LnxSoundBuffer *));
- LnxBuffers[0] = *lsndb;
- LnxNumBuffers++;
-
- // Initialize the Sound system and thread
- StartupSoundSystem(dev);
- }
-
- return 0;
-}
-
-////////////////////////////
-// LnxSoundBuffer_Release
-////////////////////////////
-// Releases the memory associated with a sound buffer. This pointer is
-// no longer valid after return.
-//
-// Returns:
-// -1 : Invalid Parameter
-// 0 : Ok!
-int LnxSoundBuffer_Release(LnxSoundBuffer *buff) {
- int i;
-
- if (!buff)
- return -1;
-
- for (i = 0; i < LnxNumBuffers; i++) {
- if (LnxBuffers[i] == buff)
- break;
- }
-
- if (i < LnxNumBuffers) {
- if (LnxNumBuffers == 1) {
- // stop the thread! primary going down
- ShutdownSoundSystem();
-
- LnxNumBuffers = 0;
- LnxBuffers = NULL;
- } else {
- // wait until it is ok (our thread is in a good position)
- enter_critical();
-
- if (i == 0) {
- // can't delete the primary! whats going on here?
- return -1;
- }
-
- LnxBuffers[i] = LnxBuffers[LnxNumBuffers - 1];
- LnxBuffers = (LnxSoundBuffer **)realloc(LnxBuffers, sizeof(LnxSoundBuffer *) * (LnxNumBuffers - 1));
- LnxNumBuffers--;
-
- exit_critical();
- }
-
- if (buff->buffer)
- free(buff->buffer);
- free(buff);
- } else
- return -1;
-
- if (LnxNumBuffers == 1) {
- // we freed the last non-primary buffer
- // so remove the primary buffer that is remaining
- return LnxSoundBuffer_Release(LnxBuffers[0]);
- }
-
- return 0;
-}
-
-//////////////////////////////
-// LnxSoundBuffer_SetVolume
-//////////////////////////////
-// Sets the volume of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set volume
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetVolume(LnxSoundBuffer *buff, int32_t vol) {
- if (!buff)
- return -1;
-
- if (!(buff->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME))
- return -1;
-
- if ((vol > LNXSND_VOLUME_MAX) || (vol < LNXSND_VOLUME_MIN))
- return -2;
-
- if (buff->lbdesc.dwFlags & LNXSND_CAPS_PRIMARYBUFFER) {
- // not supported
- enter_critical();
- buff->volume = vol;
- exit_critical();
- return 0;
- }
-
- enter_critical();
-
- buff->volume = vol;
-
- double vt;
- vt = (double)(buff->volume - (buff->pan > 0 ? buff->pan : 0));
- buff->left_vol = (uint32_t)(pow(2.0, vt / 600.0) * 32768.0);
- vt = (double)(buff->volume + (buff->pan < 0 ? buff->pan : 0));
- buff->right_vol = (uint32_t)(pow(2.0, vt / 600.0) * 32768.0);
-
- exit_critical();
-
- return 0;
-}
-
-///////////////////////////
-// LnxSoundBuffer_SetPan
-///////////////////////////
-// Sets the pan of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set pan
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetPan(LnxSoundBuffer *buff, int32_t pan) {
- if (!buff)
- return -1;
-
- if ((pan > LNXSND_PAN_RIGHT) || (pan < LNXSND_PAN_LEFT))
- return -2;
-
- if (!(buff->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (buff->lbdesc.dwFlags & LNXSND_CAPS_PRIMARYBUFFER)) {
- return -1;
- }
-
- enter_critical();
-
- buff->pan = pan;
-
- double pt;
- pt = (double)(buff->volume - (buff->pan > 0 ? buff->pan : 0));
- buff->left_vol = (uint32_t)(pow(2.0, pt / 600.0) * 32768.0);
- pt = (double)(buff->volume + (buff->pan < 0 ? buff->pan : 0));
- buff->right_vol = (uint32_t)(pow(2.0, pt / 600.0) * 32768.0);
-
- exit_critical();
-
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Stop
-/////////////////////////
-// Stops a buffer from playing
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Stop(LnxSoundBuffer *buff) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->playing = 0;
- exit_critical();
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Play
-/////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Play(LnxSoundBuffer *buff, uint32_t flags) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->flags = flags;
- buff->playing = 1;
- exit_critical();
- return 0;
-}
-
-////////////////////////////
-// LnxSoundBuffer_GetCaps
-////////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCaps(LnxSoundBuffer *buff, LinuxSoundCaps *caps) {
- if (!caps || !buff)
- return -1;
-
- caps->dwFlags = buff->lbdesc.dwFlags | LNXSND_CAPS_LOCSOFTWARE;
- caps->dwBufferBytes = buff->lbdesc.dwBufferBytes;
-
- return 0;
-}
-
-//////////////////////////////
-// LnxSoundBuffer_GetStatus
-//////////////////////////////
-// Returns the status of a buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetStatus(LnxSoundBuffer *buff, uint32_t *status) {
- if (!status || !buff)
- return -1;
-
- *status = 0;
- if (buff->playing)
- *status |= LNXSND_PLAYING;
- if (buff->flags & LNXSND_LOOPING)
- *status |= LNXSND_LOOPING;
-
- return 0;
-}
-
-///////////////////////////////////////
-// LnxSoundBuffer_GetCurrentPosition
-///////////////////////////////////////
-// Returns the current play and write positions of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCurrentPosition(LnxSoundBuffer *buff, uint32_t *ppos, uint32_t *wpos) {
- if (!buff)
- return -1;
-
- if (ppos)
- *ppos = buff->play_cursor;
- if (wpos)
- *wpos = buff->write_cursor;
-
- return 0;
-}
-
-///////////////////////////////////////
-// LnxSoundBuffer_SetCurrentPosition
-///////////////////////////////////////
-// Sets the current play position of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_SetCurrentPosition(LnxSoundBuffer *buff, uint32_t pos) {
- if (!buff)
- return -1;
-
- enter_critical();
- buff->play_cursor = pos;
- exit_critical();
- return 0;
-}
-
-/////////////////////////
-// LnxSoundBuffer_Lock
-/////////////////////////
-// Locks the given buffer, returning pointer(s) to the buffer(s) along with
-// available the size of the buffer(s) for writing.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Lock(LnxSoundBuffer *buff, uint32_t pos, uint32_t numbytes, void **ptr1,
- uint32_t *numbytes1, void **ptr2, uint32_t *numbytes2, uint32_t flags) {
- if (!buff)
- return -1;
-
- if (flags & LNXSND_LOCK_FROMWRITECURSOR)
- pos += buff->write_cursor;
- if (flags & LNXSND_LOCK_ENTIREBUFFER)
- numbytes = buff->buffer_len;
- if (numbytes > buff->buffer_len)
- numbytes = buff->buffer_len;
-
- assert(numbytes1 != numbytes2);
- assert(ptr1 != ptr2);
-
- if (pos + numbytes <= buff->buffer_len) {
- *(uint8_t **)ptr1 = buff->buffer + pos;
- *numbytes1 = numbytes;
- if (ptr2)
- *(uint8_t **)ptr2 = NULL;
- if (numbytes2)
- *numbytes2 = 0;
- } else {
- *(uint8_t **)ptr1 = buff->buffer + pos;
- *numbytes1 = buff->buffer_len - pos;
- if (ptr2)
- *(uint8_t **)ptr2 = buff->buffer;
- if (numbytes2)
- *numbytes2 = numbytes - (buff->buffer_len - pos);
- }
- return 0;
-}
-
-///////////////////////////
-// LnxSoundBuffer_Unlock
-///////////////////////////
-// Unlocks a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Unlock(LnxSoundBuffer *buff, void *ptr1, uint32_t num1, void *ptr2, uint32_t num2) {
- if (!buff)
- return -1;
-
- return 0;
-}
-
-///////////////////////////////////////////
-// Internal Sound System routines
-//////////////////////////////////////////////////////////////
-
-// Starts up the sound processing thread
-static bool StartupSoundSystem(LnxSoundDevice *dev) {
- SDL_AudioSpec spec;
-
- if (LnxNumBuffers < 1)
- return false;
-
- memcpy(&LinuxSoundDevice, dev, sizeof(LnxSoundDevice));
- spec.freq = dev->freq;
- spec.format = dev->bit_depth == 8 ? AUDIO_U8 : AUDIO_S16SYS;
- spec.channels = dev->channels;
- spec.samples = 1024;
- spec.callback = LinuxSoundThreadHandler;
-
- if (SDL_OpenAudio(&spec, NULL) < 0) {
- return false;
- }
- SDL_PauseAudio(0);
- return true;
-}
-
-// Shutsdown the sound processing thread
-static void ShutdownSoundSystem(void) { SDL_CloseAudio(); }
-
-static inline void GetValues(const LnxSoundBuffer *dsb, uint8_t *buf, uint32_t *fl, uint32_t *fr) {
- int16_t *bufs = (int16_t *)buf;
-
- // 8 bit stereo
- if ((dsb->wfx.wBitsPerSample == 8) && dsb->wfx.nChannels == 2) {
- *fl = (*buf - 128) << 8;
- *fr = (*(buf + 1) - 128) << 8;
- return;
- }
-
- // 16 bit stereo
- if ((dsb->wfx.wBitsPerSample == 16) && dsb->wfx.nChannels == 2) {
- *fl = *bufs;
- *fr = *(bufs + 1);
- return;
- }
-
- // 8 bit mono
- if ((dsb->wfx.wBitsPerSample == 8) && dsb->wfx.nChannels == 1) {
- *fl = (*buf - 128) << 8;
- *fr = *fl;
- return;
- }
-
- // 16 bit mono
- if ((dsb->wfx.wBitsPerSample == 16) && dsb->wfx.nChannels == 1) {
- *fl = *bufs;
- *fr = *bufs;
- return;
- }
- return;
-}
-
-static inline void SetValues(uint8_t *buf, uint32_t fl, uint32_t fr) {
- int16_t *bufs = (int16_t *)buf;
-
- // 8 bit stereo
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 8) && (LnxBuffers[0]->wfx.nChannels == 2)) {
- *buf = (fl + 32768) >> 8;
- *(buf + 1) = (fr + 32768) >> 8;
- return;
- }
-
- // 16 bit stereo
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 16) && (LnxBuffers[0]->wfx.nChannels == 2)) {
- *bufs = fl;
- *(bufs + 1) = fr;
- return;
- }
-
- // 8 bit mono
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 8) && (LnxBuffers[0]->wfx.nChannels == 1)) {
- *buf = (((fl + fr) >> 1) + 32768) >> 8;
- return;
- }
-
- // 16 bit mono
- if ((LnxBuffers[0]->wfx.wBitsPerSample == 16) && (LnxBuffers[0]->wfx.nChannels == 1)) {
- *bufs = (fl + fr) >> 1;
- return;
- }
- return;
-}
-
-static void LinuxSoundMixWithVolume(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len) {
- uint32_t i, inc = (LnxBuffers[0]->wfx.wBitsPerSample >> 3);
- uint8_t *bpc = buf;
- int16_t *bps = (int16_t *)buf;
-
- if ((!(dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (dsb->pan == 0)) &&
- (!(dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME) || (dsb->volume == 0)))
- return;
-
- for (i = 0; i < len; i += inc) {
- uint32_t val;
- switch (inc) {
- case 1: {
- val = *bpc - 128;
- val = ((val * (i & inc ? dsb->right_vol : dsb->left_vol)) >> 15);
- *bpc = val + 128;
- bpc++;
- } break;
- case 2: {
- val = *bps;
- val = ((val * ((i & inc) ? dsb->right_vol : dsb->left_vol)) >> 15);
- *bps = val;
- bps++;
- } break;
- }
- }
-}
-
-static uint32_t LinuxSoundMixNormalize(LnxSoundBuffer *dsb, uint8_t *buf, uint32_t len) {
- uint32_t i, size, ipos, ilen, fieldL, fieldR;
- uint8_t *ibp, *obp;
- uint32_t iAdvance = dsb->wfx.nBlockAlign;
- uint32_t oAdvance = LnxBuffers[0]->wfx.nBlockAlign;
-
- ibp = dsb->buffer + dsb->play_cursor;
- obp = buf;
-
- if ((dsb->freq == LnxBuffers[0]->wfx.nSamplesPerSec) &&
- (dsb->wfx.wBitsPerSample == LnxBuffers[0]->wfx.wBitsPerSample) &&
- (dsb->wfx.nChannels == LnxBuffers[0]->wfx.nChannels)) {
- if ((ibp + len) < (uint8_t *)(dsb->buffer + dsb->buffer_len))
- memcpy(obp, ibp, len);
- else {
- memcpy(obp, ibp, dsb->buffer_len - dsb->play_cursor);
- memcpy(obp + (dsb->buffer_len - dsb->play_cursor), dsb->buffer, len - (dsb->buffer_len - dsb->play_cursor));
- }
- return len;
- }
-
- if (dsb->freq == LnxBuffers[0]->wfx.nSamplesPerSec) {
- ilen = 0;
- for (i = 0; i < len; i += oAdvance) {
- GetValues(dsb, ibp, &fieldL, &fieldR);
- ibp += iAdvance;
- ilen += iAdvance;
- SetValues(obp, fieldL, fieldR);
- obp += oAdvance;
- if (ibp >= (uint8_t *)(dsb->buffer + dsb->buffer_len))
- ibp = dsb->buffer;
- }
- return (ilen);
- }
-
- size = len / oAdvance;
- ilen = ((size * dsb->freq_adjustment) >> FREQUENCY_SHIFT) * iAdvance;
- for (i = 0; i < size; i++) {
- ipos = (((i * dsb->freq_adjustment) >> FREQUENCY_SHIFT) * iAdvance) + dsb->play_cursor;
-
- if (ipos >= dsb->buffer_len)
- ipos %= dsb->buffer_len;
-
- GetValues(dsb, (dsb->buffer + ipos), &fieldL, &fieldR);
- SetValues(obp, fieldL, fieldR);
- obp += oAdvance;
- }
- return ilen;
-}
-
-int DoMulDiv(int nNumber, int nNumerator, int nDenominator) {
- if (!nDenominator)
- return -1;
- int64_t ret;
- ret = (((int64_t)nNumber * nNumerator) + (nDenominator / 2)) / nDenominator;
-
- if ((ret > 0x7FFFFFFF) || (ret < 0xFFFFFFFF))
- return -1;
- return ret;
-}
-
-static void *TempSoundBuffer = NULL;
-static int TempSoundBufferLen = 0;
-static uint32_t LinuxSoundMixInMainBuffer(LnxSoundBuffer *dsb, int len) {
- uint32_t i, ilen, advance = (LnxBuffers[0]->wfx.wBitsPerSample >> 3);
- uint8_t *buf, *ibuf, *obuf;
- int32_t temp, field;
- int16_t *ibufs, *obufs;
-
- if (!(dsb->flags & LNXSND_LOOPING)) {
- temp = DoMulDiv(LnxBuffers[0]->wfx.nAvgBytesPerSec, dsb->buffer_len, dsb->bps) -
- DoMulDiv(LnxBuffers[0]->wfx.nAvgBytesPerSec, dsb->play_cursor, dsb->bps);
- len = (len > temp) ? temp : len;
- }
- len &= ~3; // align to 4 byte boundary
-
- if (!len) {
- dsb->playing = 0;
- dsb->write_cursor = 0;
- dsb->play_cursor = 0;
- return 0;
- }
-
- if (len > TempSoundBufferLen) {
- void *nb = realloc(TempSoundBuffer, len);
- if (nb) {
- TempSoundBuffer = nb;
- TempSoundBufferLen = len;
- buf = ibuf = (uint8_t *)nb;
- } else {
- return 0;
- }
- } else {
- buf = ibuf = (uint8_t *)TempSoundBuffer;
- }
-
- ilen = LinuxSoundMixNormalize(dsb, ibuf, len);
- if ((dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLPAN) || (dsb->lbdesc.dwFlags & LNXSND_CAPS_CTRLVOLUME)) {
- LinuxSoundMixWithVolume(dsb, ibuf, len);
- }
-
- obuf = LnxBuffers[0]->buffer + LnxBuffers[0]->play_cursor;
- for (i = 0; i < len; i += advance) {
- obufs = (int16_t *)obuf;
- ibufs = (int16_t *)ibuf;
- if (LnxBuffers[0]->wfx.wBitsPerSample == 16) {
- field = *ibufs;
- field += *obufs;
- field = (field > 32767) ? (32767) : field;
- field = (field < -32768) ? (-32768) : field;
- *obufs = field;
- } else {
- field = (*ibuf - 128);
- field += (*obuf - 128);
- field = (field > 127) ? (127) : field;
- field = (field < -128) ? (-128) : field;
- *obuf = field + 128;
- }
- ibuf += advance;
- obuf += advance;
- if (obuf >= (uint8_t *)(LnxBuffers[0]->buffer + LnxBuffers[0]->buffer_len))
- obuf = LnxBuffers[0]->buffer;
- }
-
- // adjust positions of the cursors in the buffer
- dsb->play_cursor += ilen;
- dsb->write_cursor = dsb->play_cursor + ilen;
-
- if (dsb->play_cursor >= dsb->buffer_len) {
- if (!(dsb->flags & LNXSND_LOOPING)) {
- // we're not looping, this buffer is done, reset it
- dsb->playing = 0;
- dsb->write_cursor = 0;
- dsb->play_cursor = 0;
- } else {
- // loop back around
- dsb->play_cursor = dsb->play_cursor % dsb->buffer_len;
- }
- }
-
- if (dsb->write_cursor >= dsb->buffer_len) {
- dsb->write_cursor = dsb->write_cursor % dsb->buffer_len;
- }
-
- return len;
-}
-
-static void LinuxSoundMixBuffersIntoMain(int len) {
- LnxSoundBuffer *dsb;
-
- // only go to 1 since 0 is the main buffer
- for (int i = LnxNumBuffers - 1; i > 0; i--) {
- if (!(dsb = LnxBuffers[i]))
- continue;
-
- if (dsb->buffer_len && dsb->playing) {
- LinuxSoundMixInMainBuffer(dsb, len);
- }
- }
-}
-
-static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len) {
- LnxBuffers[0]->buffer = stream;
- LnxBuffers[0]->buffer_len = len;
- LnxBuffers[0]->play_cursor = 0;
- LnxBuffers[0]->write_cursor = 0;
-
- LinuxSoundMixBuffersIntoMain(len);
-
- LnxBuffers[0]->buffer = NULL;
-}
diff --git a/lnxmvelib/lnxdsound.h b/lnxmvelib/lnxdsound.h
deleted file mode 100644
index b64feedf..00000000
--- a/lnxmvelib/lnxdsound.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifndef __LNX_DSOUND_H_
-#define __LNX_DSOUND_H_
-
-// Max&Min values for settings
-#define LNXSND_VOLUME_MAX 0
-#define LNXSND_VOLUME_MIN -10000
-#define LNXSND_PAN_LEFT -10000
-#define LNXSND_PAN_RIGHT 10000
-
-// Status/Buffer flags
-#define LNXSND_PLAYING 0x0001
-#define LNXSND_LOOPING 0x0002
-
-// Buffer lock flags
-#define LNXSND_LOCK_FROMWRITECURSOR 0x0001
-#define LNXSND_LOCK_ENTIREBUFFER 0x0002
-
-// Capability flags
-#define LNXSND_CAPS_PRIMARYBUFFER 0x0001
-#define LNXSND_CAPS_CTRLVOLUME 0x0002
-#define LNXSND_CAPS_CTRLPAN 0x0004
-#define LNXSND_CAPS_CTRLFREQUENCY 0x0008
-#define LNXSND_CAPS_CTRLDEFAULT 0x000E
-#define LNXSND_CAPS_LOCSOFTWARE 0x0010
-
-struct LnxSoundDevice {
- int sound_device; // file device handle for sound
- uint32_t bps; // (bytes per second) channels*freq*bit_depth/8
- uint32_t freq; // frequency (22050, etc.)
- uint32_t bit_depth; // 8 or 16
- uint32_t channels; // 1 or 2 (mono or stereo)
-};
-
-struct WAVEFORMATEX {
- uint16_t wFormatTag;
- uint16_t nChannels;
- uint32_t nSamplesPerSec;
- uint32_t nAvgBytesPerSec;
- uint16_t nBlockAlign;
- uint16_t wBitsPerSample;
- uint16_t cbSize;
-}; // Taken from Windows for porting
-#define WAVE_FORMAT_PCM 0x01
-
-struct LinuxSoundCaps {
- uint32_t dwFlags;
- uint32_t dwBufferBytes;
-};
-
-struct LnxBufferDesc {
- WAVEFORMATEX *lpwfxFormat;
- uint32_t dwBufferBytes;
- uint32_t dwFlags;
-};
-
-struct LnxSoundBuffer
- int freq_adjustment;
- int bps;
- uint32_t buffer_len;
- uint32_t play_cursor;
- uint32_t write_cursor;
- uint32_t flags;
- uint32_t left_vol, right_vol;
-
- uint8_t *buffer;
-
- int32_t volume;
- int32_t pan;
-
- WAVEFORMATEX wfx;
-
- LnxBufferDesc lbdesc;
-
- uint16_t freq;
- char playing;
- char __pad;
-};
-
-///////////////////////////////
-// LnxSound_CreateSoundBuffer
-///////////////////////////////
-// Creates a sound buffer to be used with mixing and output.
-//
-// Returns:
-// -1 : Invalid Parameter
-// -2 : Out of memory
-// 0 : Ok!
-int LnxSound_CreateSoundBuffer(LnxSoundDevice *dev, LnxBufferDesc *lbdesc, LnxSoundBuffer **lsndb);
-
-////////////////////////////
-// LnxSoundBuffer_Release
-////////////////////////////
-// Releases the memory associated with a sound buffer. This pointer is
-// no longer valid after return.
-//
-// Returns:
-// -1 : Invalid Parameter
-// 0 : Ok!
-int LnxSoundBuffer_Release(LnxSoundBuffer *buff);
-
-//////////////////////////////
-// LnxSoundBuffer_SetVolume
-//////////////////////////////
-// Sets the volume of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set volume
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetVolume(LnxSoundBuffer *buff, int32_t vol);
-
-///////////////////////////
-// LnxSoundBuffer_SetPan
-///////////////////////////
-// Sets the pan of a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : Cannot set pan
-// -2 : Invalid parameters
-int LnxSoundBuffer_SetPan(LnxSoundBuffer *buff, int32_t pan);
-
-/////////////////////////
-// LnxSoundBuffer_Stop
-/////////////////////////
-// Stops a buffer from playing
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Stop(LnxSoundBuffer *buff);
-
-/////////////////////////
-// LnxSoundBuffer_Play
-/////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Play(LnxSoundBuffer *buff, uint32_t flags);
-
-////////////////////////////
-// LnxSoundBuffer_GetCaps
-////////////////////////////
-// Starts a buffer playing (or changes the flags for a buffer currently
-// playing).
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCaps(LnxSoundBuffer *buff, LinuxSoundCaps *caps);
-
-//////////////////////////////
-// LnxSoundBuffer_GetStatus
-//////////////////////////////
-// Returns the status of a buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetStatus(LnxSoundBuffer *buff, uint32_t *status);
-
-///////////////////////////////////////
-// LnxSoundBuffer_GetCurrentPosition
-///////////////////////////////////////
-// Returns the current play and write positions of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_GetCurrentPosition(LnxSoundBuffer *buff, uint32_t *ppos, uint32_t *wpos);
-
-///////////////////////////////////////
-// LnxSoundBuffer_SetCurrentPosition
-///////////////////////////////////////
-// Sets the current play position of the buffer
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_SetCurrentPosition(LnxSoundBuffer *buff, uint32_t pos);
-
-/////////////////////////
-// LnxSoundBuffer_Lock
-/////////////////////////
-// Locks the given buffer, returning pointer(s) to the buffer(s) along with
-// available the size of the buffer(s) for writing.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Lock(LnxSoundBuffer *buff, uint32_t pos, uint32_t numbytes, void **ptr1,
- uint32_t *numbytes1, void **ptr2, uint32_t *numbytes2, uint32_t flags);
-
-///////////////////////////
-// LnxSoundBuffer_Unlock
-///////////////////////////
-// Unlocks a buffer.
-//
-// Returns:
-// 0 : no error
-// -1 : invalid parameters
-int LnxSoundBuffer_Unlock(LnxSoundBuffer *buff, void *ptr1, uint32_t num1, void *ptr2, uint32_t num2);
-
-#endif
diff --git a/lnxmvelib/mveasm.cpp b/lnxmvelib/mveasm.cpp
deleted file mode 100644
index fcb2a085..00000000
--- a/lnxmvelib/mveasm.cpp
+++ /dev/null
@@ -1,1630 +0,0 @@
-
-/*
-** mveasm.cpp
-**
-** Interplay Movie File (MVE) Player Library (32-Bit Linux Version)
-** Written by Paul Allen Edelstein. Partial Linux port by Jeff Slutter.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-**
-*/
-#include "mvelibl.h"
-#include "mvelibi.h"
-#include "byteswap.h"
-
-// rcg07272000
-// need this for SIGTRAP on non-Intel platforms. Intel uses int $3.
-#if (!defined __i386__)
-#include
-#endif
-
-extern uint8_t *nf_buf_cur;
-extern uint8_t *nf_buf_prv;
-extern unsigned nf_new_x;
-extern unsigned nf_new_y;
-extern unsigned nf_new_w;
-extern unsigned nf_new_h;
-extern uint8_t nf_fqty; // Number of fields
-extern unsigned nf_new_row0; // SHEIGHT*width*2-width
-extern unsigned nf_width; // wqty * SWIDTH
-extern unsigned nf_new_line; // width - SWIDTH
-extern unsigned nf_back_right; // (SHEIGHT-1)*width
-
-extern int16_t snd_8to16[256];
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, int x, int y, int w, int h);
-void nfPkConfig(void);
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev);
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev);
-
-void Trans16Blk(uint8_t *edi, uint8_t *idx);
-void call_hnfxycshift(uint32_t eax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right);
-void call_hnfxypshift(uint32_t eax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right,
- int DiffBufPtrs);
-void call_hnfshift(uint32_t meax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right);
-
-//--------------------------------------------------------------------
-// Sound Management
-//--------------------
-
-// Decompresses a mono stream containing len samples
-// (src is len bytes, dst is len*2 bytes)
-// prev is the previous decompression state or zero.
-// Returns new decompression state.
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- uint32_t i, eax, ebx;
- if (len == 0)
- return prev;
- eax = prev;
- ebx = 0;
-
- for (i = 0; i < len; i++) {
- ebx = *src;
- src++;
-
- eax += snd_8to16[ebx];
- *dst = eax & 0xFFFF;
- dst++;
- }
-
- return eax;
-}
-
-// Decompresses a stereo stream containing len samples
-// (src is len*2 bytes, dst is len*4 bytes)
-// prev is the previous decompression state or zero
-// (It encodes the 16-bit states of the two stereo channels
-// in its low and high order 16-bit halves.)
-// Returns new decompression state.
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned prev) {
- unsigned re = 0;
- uint32_t eax, edx, ebx, i;
-
- if (len == 0) {
- return prev;
- }
-
- eax = (prev & 0xFFFF);
- edx = ((prev & 0xFFFF0000) >> 16);
- ebx = 0;
-
- for (i = 0; i < len; i++) {
- ebx = *src;
- src++;
-
- eax += snd_8to16[ebx];
- *dst = (eax & 0xFFFF);
- dst++;
-
- ebx = *src;
- src++;
-
- edx += snd_8to16[ebx];
- *dst = (edx & 0xFFFF);
- dst++;
- }
-
- return (eax & 0xFFFF) | ((edx & 0xFFFF) << 16);
-}
-
-struct tNextFrame {
- uint8_t *comp;
- uint8_t *tbuf;
- int new_row, DiffBufPtrs, parms_sz;
- unsigned x, y, w, h;
-};
-
-// NOTE: On exit ebx is nf_fqty
-void NF_DECOMP_INIT(bool HI_COLOR_FLAG, tNextFrame *nf) {
- nf->DiffBufPtrs = nf_buf_prv - nf_buf_cur;
-
- if (HI_COLOR_FLAG) {
- nf_new_x = nf->x << (LOG2_SWIDTH + 1);
- nf_new_w = nf->w << (LOG2_SWIDTH + 1);
- } else {
- nf_new_x = nf->x << LOG2_SWIDTH;
- nf_new_w = nf->w << LOG2_SWIDTH;
- }
- nf_new_y = (nf->y << LOG2_SHEIGHT) * nf_fqty;
- nf_new_h = (nf->h << LOG2_SHEIGHT) * nf_fqty;
-
- nf->new_row = nf_new_row0 - nf_new_w;
-
- // Move to correct place in current buffer
- nf->tbuf = nf_buf_cur;
- if (nf->x || nf->y) {
- nf->tbuf += nf_new_y * nf_width + nf_new_x;
- }
-}
-
-//----------------------------------------------------------------------
-
-// signed 8-bit y * nf_width
-int32_t nfpk_ShiftY[256];
-
-// Constant tables
-
-// 8-bit -8:7 x nf_width + -8:7
-int16_t nfpk_ShiftP1[256];
-int16_t nfpk_ShiftP2[256];
-
-// Constant tables
-// mov eax, ebx/ecx
-// EBX = 0
-// ECX = 1
-uint8_t nfhpk_mov4l[64];
-
-// mov ds:[edi+0/4/8/12], ebx/edx/ecx/ebp
-// EBX = 0
-// EDX = 1
-// ECX = 2
-// EBP = 3
-uint8_t nfhpk_mov8[1024];
-
-// mov eax, ebx/edx/ecx/ebp
-// EBX = 0
-// EDX = 1
-// ECX = 2
-// EBP = 3
-uint8_t nfhpk_mov4[1024];
-
-class initme {
-public:
- initme() {
- int x, y;
- int m4, m3, m2, m1;
- int8_t *ptr;
- uint8_t *uptr;
-
- // Do nfhpk_mov4l
- uptr = nfhpk_mov4l;
- for (m4 = 0; m4 < 2; m4++)
- for (m3 = 0; m3 < 2; m3++)
- for (m2 = 0; m2 < 2; m2++)
- for (m1 = 0; m1 < 2; m1++) {
- *uptr = m1;
- uptr++;
- *uptr = m2;
- uptr++;
- *uptr = m3;
- uptr++;
- *uptr = m4;
- uptr++;
- }
-
- // Do nfhpk_mov8
- uptr = nfhpk_mov8;
- for (m4 = 0; m4 < 4; m4++)
- for (m3 = 0; m3 < 4; m3++)
- for (m2 = 0; m2 < 4; m2++)
- for (m1 = 0; m1 < 4; m1++) {
- *uptr = m1;
- uptr++;
- *uptr = m2;
- uptr++;
- *uptr = m3;
- uptr++;
- *uptr = m4;
- uptr++;
- }
-
- // Do nfhpk_mov4
- uptr = nfhpk_mov4;
- for (m4 = 0; m4 < 4; m4++)
- for (m3 = 0; m3 < 4; m3++)
- for (m2 = 0; m2 < 4; m2++)
- for (m1 = 0; m1 < 4; m1++) {
- *uptr = m1;
- uptr++;
- *uptr = m2;
- uptr++;
- *uptr = m3;
- uptr++;
- *uptr = m4;
- uptr++;
- }
- // do nfpk_ShiftP1
- ptr = (int8_t *)nfpk_ShiftP1;
-
- for (y = -8; y != 8; y++) {
- for (x = -8; x != 8; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(ptr) = y;
- *(ptr + 1) = x;
-#else
- *(ptr) = x;
- *(ptr + 1) = y;
-#endif
- ptr += 2;
- }
- }
-
- // do nfpk_ShiftP2[]
- ptr = (int8_t *)nfpk_ShiftP2;
-
- for (y = 0; y != 8; y++) {
- for (x = 8; x != 15; x++) {
-#ifdef OUTRAGE_BIG_ENDIAN
- *(ptr) = y;
- *(ptr + 1) = x;
-#else
- *(ptr) = x;
- *(ptr + 1) = y;
-#endif
- ptr += 2;
- }
- }
-
- for (y = 8; y != 14; y++) {
- for (x = -14; x != 0; x++) {
- *(ptr) = x;
- *(ptr + 1) = y;
- ptr += 2;
- }
-
- for (x = 0; x != 15; x++) {
- *(ptr) = x;
- *(ptr + 1) = y;
- ptr += 2;
- }
- }
- for (x = -14; x != 0; x++) {
- *(ptr) = x;
- *(ptr + 1) = 14;
- ptr += 2;
- }
- for (x = 0; x != 12; x++) {
- *(ptr) = x;
- *(ptr + 1) = 14;
- ptr += 2;
- }
- }
-};
-
-initme _initme;
-
-// nfPkConfig initializes tables used by nfPkDecomp
-// which are dependent on screen size.
-void nfPkConfig(void) {
- // Build ShiftY table
- int i, val, index;
-
- val = 0;
- index = 0;
-
- for (i = 0; i < 128; i++) {
- nfpk_ShiftY[index] = val;
- index++;
- val += nf_width;
- }
-
- val = nf_width;
- val = val << 7;
- val = -val;
-
- for (i = 0; i < 128; i++) {
- nfpk_ShiftY[index] = val;
- index++;
- val += nf_width;
- }
-}
-
-extern uint16_t nf_trans16_lo[256];
-extern uint16_t nf_trans16_hi[256];
-
-// NOTE: EAX is destroyed after this call (actually the value of
-// nf_trans16_hi[idx+1]
-void Trans16(uint16_t *dst, uint16_t *idx, bool mask) {
- *dst = nf_trans16_lo[*idx];
- *dst |= nf_trans16_hi[*(idx + 1)];
-}
-
-// HiColor version
-//
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) {
- tNextFrame nf;
- nf.w = w;
- nf.h = h;
- nf.x = x;
- nf.y = y;
-
- int nfpk_back_right, wcnt;
- uint8_t *bcomp;
- uint8_t *esi, *edi;
- uint8_t opcode;
-
- NF_DECOMP_INIT(1, &nf);
-
- nfpk_back_right = nf_back_right - SWIDTH * 2;
-
- esi = comp;
- edi = nf.tbuf;
-
- uint16_t swapped = (*(uint16_t *)esi);
- swapped = INTEL_SHORT(swapped);
- bcomp = swapped + esi;
- esi = esi + 2;
-
- wcnt = w >> 1;
-
- do {
- wcnt--;
- if (wcnt >= 0) {
- opcode = *ops; // al == opcode
- ops++;
-
- bool first_opcode = true;
- int opcode_to_use = opcode & 0xF;
-
- do_next_opcode:
-
- switch (opcode_to_use) {
- case 0: {
- // No change from previous buffer
- call_hnfshift(nf.DiffBufPtrs, &edi, &esi, nfpk_back_right);
- } break;
- case 1: {
- // No change (and copied to screen) (0)
- edi += SWIDTH * 2;
- } break;
- case 2: {
- uint32_t eax;
- eax = *bcomp;
- bcomp++;
- eax = nfpk_ShiftP2[eax];
-
- call_hnfxycshift(eax, &edi, &esi, nfpk_back_right);
-
- } break;
- case 3: {
- // Near shift from newer part of current buffer
-#ifdef OUTRAGE_BIG_ENDIAN
- struct reg_word {
- uint16_t hax, ax;
- };
- struct reg_byte {
- int8_t hah, hal, ah, al;
- };
-#else
- struct reg_word {
- uint16_t ax, hax;
- };
- struct reg_byte {
- int8_t al, ah, hal, hah;
- };
-#endif
- union {
- uint32_t eax;
- reg_word word;
- reg_byte byte;
- } myeax;
-
- myeax.eax = *bcomp;
- bcomp++;
-
- myeax.word.ax = nfpk_ShiftP2[myeax.eax];
- myeax.byte.al = -myeax.byte.al;
- myeax.byte.ah = -myeax.byte.ah;
-
- call_hnfxycshift(myeax.eax, &edi, &esi, nfpk_back_right);
-
- } break;
- case 4: {
- // Near shift from previous buffer
-#ifdef OUTRAGE_BIG_ENDIAN
- struct reg_word {
- uint16_t hax, ax;
- };
- struct reg_byte {
- int8_t hah, hal, ah, al;
- };
-#else
- struct reg_word {
- uint16_t ax, hax;
- };
- struct reg_byte {
- int8_t al, ah, hal, hah;
- };
-#endif
- union {
- uint32_t eax;
- reg_word word;
- reg_byte byte;
- } myeax;
-
- myeax.eax = 0;
- myeax.byte.al = *bcomp;
- bcomp++;
-
- myeax.word.ax = nfpk_ShiftP1[myeax.eax];
- call_hnfxypshift(myeax.eax, &edi, &esi, nfpk_back_right, nf.DiffBufPtrs);
-
- } break;
- case 5: {
- uint16_t swapper = *(uint16_t *)(esi);
- uint32_t eax = INTEL_SHORT(swapper);
- esi += 2;
- call_hnfxypshift(eax, &edi, &esi, nfpk_back_right, nf.DiffBufPtrs);
- } break;
- case 6: {
- // Far shift from current buffer
- uint32_t val1, val2;
-
- uint16_t swapper = *(uint16_t *)(esi);
- val1 = INTEL_SHORT(swapper);
- esi += 2;
-
- val2 = ((val1 & 0xFF00) >> 8);
-
- // sign extend al into eax, and multiply by two
- if (val1 & 0x80) {
- val1 = ((val1 & 0x7F) << 1);
- val1 = (val1 & 0xFF) | 0xFFFFFF00;
- } else {
- val1 = ((val1 & 0x7F) << 1);
- }
-
- val1 += nfpk_ShiftY[val2];
-
- call_hnfshift(val1, &edi, &esi, nfpk_back_right);
-
- } break;
- case 7: {
- bool donf23 = false;
- uint16_t val;
- int rep_count, max_repcount;
-
- val = *(uint16_t *)esi;
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- donf23 = true;
- }
-
- if (!donf23) {
- uint32_t colors[4];
- max_repcount = 8;
-
- uint32_t temp_color;
- temp_color = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- temp_color = (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]) | (temp_color << 16);
-
- colors[2] = temp_color;
- temp_color = ((temp_color & 0xFFFF0000) >> 16) | ((temp_color & 0xFFFF) << 16);
- colors[0] = (temp_color & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = temp_color;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- idx = rep_count + 4;
- color_idx = *(uint32_t *)(nfhpk_mov8 + ((*(esi + idx)) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
- }
-
- esi += 12;
- edi -= nfpk_back_right;
- } else {
- uint32_t colors[2];
- max_repcount = 4;
-
- uint32_t temp;
- temp = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = (temp << 16) | temp;
- temp = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = (temp << 16) | temp;
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- // 4l,4h,5l,5h (nibbles)
- switch (rep_count) {
- case 0:
- idx = (*(esi + 4)) & 0xF;
- break;
- case 1:
- idx = ((*(esi + 4)) >> 4);
- break;
- case 2:
- idx = (*(esi + 5)) & 0xF;
- break;
- case 3:
- idx = ((*(esi + 5)) >> 4);
- break;
- }
-
- color_idx = *(uint32_t *)(nfhpk_mov4l + (idx * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + nf_width) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + nf_width + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + nf_width + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- *(uint32_t *)(edi + nf_width + 12) = w4;
- if (rep_count != (max_repcount - 1))
- edi = edi + nf_width * 2;
- }
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += 6;
- }
- } break;
- case 8: {
- bool donf24 = false;
- bool donf40 = false;
- uint16_t val;
- int rep_count, max_repcount;
-
- val = *(uint16_t *)esi;
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- val = *(uint16_t *)(esi + 8);
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- donf40 = true;
- } else {
- donf24 = true;
- }
- }
-
- if (!donf24 && !donf40) {
- uint32_t colors[4];
- max_repcount = 8;
-
- uint32_t tempcolor;
- tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- switch (rep_count) {
- case 0:
- idx = 4;
- break;
- case 1:
- idx = 5;
- break;
- case 2:
- idx = 10;
- break;
- case 3:
- idx = 11;
- break;
- case 4:
- idx = 16;
- break;
- case 5:
- idx = 17;
- break;
- case 6:
- idx = 22;
- break;
- case 7:
- idx = 23;
- break;
- }
-
- color_idx = *(uint32_t *)(nfhpk_mov8 + (*(esi + idx) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- edi += nf_width;
- *(uint32_t *)(edi + 0) = w3;
- *(uint32_t *)(edi + 4) = w4;
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
-
- if (rep_count == 1) {
- tempcolor = nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- }
-
- if (rep_count == 3) {
- edi -= nf_width * 8 - 8;
-
- tempcolor = nf_trans16_lo[*(esi + 14)] | nf_trans16_hi[*(esi + 15)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 12)] | nf_trans16_hi[*(esi + 13)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- }
-
- if (rep_count == 5) {
- tempcolor = nf_trans16_lo[*(esi + 20)] | nf_trans16_hi[*(esi + 21)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- }
- }
-
- esi += 24;
- edi -= (8 + nfpk_back_right);
- }
-
- if (donf24) {
- uint32_t colors[4];
- max_repcount = 8;
-
- uint32_t tempcolor;
- tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- switch (rep_count) {
- case 0:
- idx = 4;
- break;
- case 1:
- idx = 5;
- break;
- case 2:
- idx = 6;
- break;
- case 3:
- idx = 7;
- break;
- case 4:
- idx = 12;
- break;
- case 5:
- idx = 13;
- break;
- case 6:
- idx = 14;
- break;
- case 7:
- idx = 15;
- break;
- }
-
- color_idx = *(uint32_t *)(nfhpk_mov8 + (*(esi + idx) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- edi += nf_width;
- *(uint32_t *)(edi + 0) = w3;
- *(uint32_t *)(edi + 4) = w4;
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
-
- if (rep_count == 3) {
- edi -= nf_width * 8 - 8;
-
- tempcolor = nf_trans16_lo[*(esi + 10)] | nf_trans16_hi[*(esi + 11)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- }
- }
-
- esi += 16;
- edi -= (8 + nfpk_back_right);
- }
-
- if (donf40) {
- uint32_t colors[4];
- max_repcount = 8;
-
- uint32_t tempcolor;
- tempcolor = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 0)] | nf_trans16_hi[*(esi + 1)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- switch (rep_count) {
- case 0:
- idx = 4;
- break;
- case 1:
- idx = 5;
- break;
- case 2:
- idx = 6;
- break;
- case 3:
- idx = 7;
- break;
- case 4:
- idx = 12;
- break;
- case 5:
- idx = 13;
- break;
- case 6:
- idx = 14;
- break;
- case 7:
- idx = 15;
- break;
- }
-
- color_idx = *(uint32_t *)(nfhpk_mov8 + (*(esi + idx) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
-
- if (rep_count == 3) {
- tempcolor = nf_trans16_lo[*(esi + 10)] | nf_trans16_hi[*(esi + 11)];
- tempcolor = (tempcolor << 16) | (nf_trans16_lo[*(esi + 8)] | nf_trans16_hi[*(esi + 9)]);
- colors[2] = tempcolor;
- tempcolor = ((tempcolor & 0xFFFF0000) >> 16) | ((tempcolor & 0xFFFF) << 16);
- colors[0] = (tempcolor & 0xFFFF0000) | (colors[2] & 0xFFFF);
- colors[1] = tempcolor;
- colors[3] = (colors[2] & 0xFFFF0000) | (colors[1] & 0xFFFF);
- }
- }
-
- esi += 16;
- edi -= nfpk_back_right;
- }
- } break;
- case 9: {
- bool donf41 = false;
- bool donf25 = false;
- bool donf57 = false;
- uint16_t val;
- int rep_count, max_repcount;
-
- val = *(uint16_t *)esi;
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- val = *(uint16_t *)(esi + 4);
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- donf57 = true;
- } else {
- donf41 = true;
- }
-
- } else {
- val = *(uint16_t *)(esi + 4);
- val = INTEL_SHORT(val);
- if (val & 0x8000) {
- donf25 = true;
- }
- }
-
- if (donf57) {
- uint16_t colors[4];
- max_repcount = 8;
-
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- idx = rep_count + 8;
- color_idx = *(uint32_t *)(nfhpk_mov4 + ((*(esi + idx)) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- if (rep_count % 2) {
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-
- if (rep_count != (max_repcount - 1))
- edi = edi + nf_width * 2;
- } else {
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
-
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- *(uint32_t *)(edi + nf_width + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- }
- }
-
- edi += nf_width;
- esi += 16;
- edi -= nfpk_back_right;
- }
-
- if (donf41) {
- uint32_t colors[4];
- max_repcount = 8;
-
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = ((colors[0]) << 16) | colors[0];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = ((colors[1]) << 16) | colors[1];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[2] = ((colors[2]) << 16) | colors[2];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- colors[3] = ((colors[3]) << 16) | colors[3];
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- idx = rep_count + 8;
- color_idx = *(uint32_t *)(nfhpk_mov8 + (*(esi + idx) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
-
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
- }
-
- esi += 16;
- edi -= nfpk_back_right;
- }
-
- if (donf25) {
- uint32_t colors[4];
- max_repcount = 4;
-
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[0] = ((colors[0]) << 16) | colors[0];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[1] = ((colors[1]) << 16) | colors[1];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[2] = ((colors[2]) << 16) | colors[2];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
- colors[3] = ((colors[3]) << 16) | colors[3];
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- idx = rep_count + 8;
-
- color_idx = *(uint32_t *)(nfhpk_mov4 + ((*(esi + idx)) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- *(uint32_t *)(edi + 0) = w1;
- *(uint32_t *)(edi + nf_width) = w1;
- *(uint32_t *)(edi + 4) = w2;
- *(uint32_t *)(edi + nf_width + 4) = w2;
- *(uint32_t *)(edi + 8) = w3;
- *(uint32_t *)(edi + nf_width + 8) = w3;
- *(uint32_t *)(edi + 12) = w4;
- *(uint32_t *)(edi + nf_width + 12) = w4;
-
- if (rep_count != (max_repcount - 1))
- edi = edi + nf_width * 2;
- }
-
- edi += nf_width;
- esi += 12;
- edi -= nfpk_back_right;
- }
-
- if (!donf25 && !donf41 && !donf57) {
- uint16_t colors[4];
- max_repcount = 16;
-
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
-
- for (rep_count = 0; rep_count < max_repcount; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- idx = rep_count + 8;
-
- color_idx = *(uint32_t *)(nfhpk_mov4 + ((*(esi + idx)) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- if (rep_count % 2) {
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-
- if (rep_count != (max_repcount - 1))
- edi += nf_width;
- } else {
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- }
- }
-
- esi += 24;
- edi -= nfpk_back_right;
- }
- } break;
- case 10: {
- // 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- int val1;
- int rep_count;
- uint16_t colors[4];
- bool do26 = false;
- bool do42 = false;
-
- uint16_t swapper = *(uint16_t *)esi;
- val1 = INTEL_SHORT(swapper);
- if (val1 & 0x8000) {
- swapper = *(uint16_t *)(esi + 16);
- val1 = INTEL_SHORT(swapper);
- if (val1 & 0x8000) {
- do42 = true;
- } else {
- do26 = true;
- }
- }
-
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- colors[1] = nf_trans16_lo[*(esi + 2)] | nf_trans16_hi[*(esi + 3)];
- colors[2] = nf_trans16_lo[*(esi + 4)] | nf_trans16_hi[*(esi + 5)];
- colors[3] = nf_trans16_lo[*(esi + 6)] | nf_trans16_hi[*(esi + 7)];
-
- for (rep_count = 0; rep_count < 16; rep_count++) {
- uint32_t w1, w2, w3, w4;
- uint32_t color_idx;
- int idx;
-
- if (!do26 && !do42) {
- switch (rep_count) {
- case 0:
- idx = 8;
- break;
- case 1:
- idx = 9;
- break;
- case 2:
- idx = 10;
- break;
- case 3:
- idx = 11;
- break;
- case 4:
- idx = 20;
- break;
- case 5:
- idx = 21;
- break;
- case 6:
- idx = 22;
- break;
- case 7:
- idx = 23;
- break;
- case 8:
- idx = 32;
- break;
- case 9:
- idx = 33;
- break;
- case 10:
- idx = 34;
- break;
- case 11:
- idx = 35;
- break;
- case 12:
- idx = 44;
- break;
- case 13:
- idx = 45;
- break;
- case 14:
- idx = 46;
- break;
- case 15:
- idx = 47;
- break;
- }
- } else {
- switch (rep_count) {
- case 0:
- idx = 8;
- break;
- case 1:
- idx = 9;
- break;
- case 2:
- idx = 10;
- break;
- case 3:
- idx = 11;
- break;
- case 4:
- idx = 12;
- break;
- case 5:
- idx = 13;
- break;
- case 6:
- idx = 14;
- break;
- case 7:
- idx = 15;
- break;
- case 8:
- idx = 24;
- break;
- case 9:
- idx = 25;
- break;
- case 10:
- idx = 26;
- break;
- case 11:
- idx = 27;
- break;
- case 12:
- idx = 28;
- break;
- case 13:
- idx = 29;
- break;
- case 14:
- idx = 30;
- break;
- case 15:
- idx = 31;
- break;
- }
- }
- color_idx = *(uint32_t *)(nfhpk_mov4 + (*(esi + idx) * 4));
- w1 = colors[color_idx & 0x000000FF];
- w2 = colors[(color_idx & 0x0000FF00) >> 8];
- w3 = colors[(color_idx & 0x00FF0000) >> 16];
- w4 = colors[(color_idx & 0xFF000000) >> 24];
-
- if (!do42) {
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-
- if (rep_count != 15)
- edi += nf_width;
- } else {
- if (rep_count % 2) {
- *(uint32_t *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
-
- if (rep_count != 15)
- edi += nf_width;
- } else {
- *(uint32_t *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16);
- *(uint32_t *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16);
- }
- }
-
- if (rep_count == 3 && !do42 && !do26) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 12)] | nf_trans16_hi[*(esi + 13)];
- colors[1] = nf_trans16_lo[*(esi + 14)] | nf_trans16_hi[*(esi + 15)];
- colors[2] = nf_trans16_lo[*(esi + 16)] | nf_trans16_hi[*(esi + 17)];
- colors[3] = nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)];
- }
-
- if (rep_count == 7) {
- if (!do42 && !do26) {
- edi -= nf_width * 8 - 8;
-
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 24)] | nf_trans16_hi[*(esi + 25)];
- colors[1] = nf_trans16_lo[*(esi + 26)] | nf_trans16_hi[*(esi + 27)];
- colors[2] = nf_trans16_lo[*(esi + 28)] | nf_trans16_hi[*(esi + 29)];
- colors[3] = nf_trans16_lo[*(esi + 30)] | nf_trans16_hi[*(esi + 31)];
- }
-
- if (do26) {
- edi -= nf_width * 8 - 8;
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 16)] | nf_trans16_hi[*(esi + 17)];
- colors[1] = nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)];
- colors[2] = nf_trans16_lo[*(esi + 20)] | nf_trans16_hi[*(esi + 21)];
- colors[3] = nf_trans16_lo[*(esi + 22)] | nf_trans16_hi[*(esi + 23)];
- }
-
- if (do42) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 16)] | nf_trans16_hi[*(esi + 17)];
- colors[1] = nf_trans16_lo[*(esi + 18)] | nf_trans16_hi[*(esi + 19)];
- colors[2] = nf_trans16_lo[*(esi + 20)] | nf_trans16_hi[*(esi + 21)];
- colors[3] = nf_trans16_lo[*(esi + 22)] | nf_trans16_hi[*(esi + 23)];
- }
- }
-
- if (rep_count == 11 && !do42 && !do26) {
- // Load bx,dx,cx,bp with four colors
- colors[0] = nf_trans16_lo[*(esi + 36)] | nf_trans16_hi[*(esi + 37)];
- colors[1] = nf_trans16_lo[*(esi + 38)] | nf_trans16_hi[*(esi + 39)];
- colors[2] = nf_trans16_lo[*(esi + 40)] | nf_trans16_hi[*(esi + 41)];
- colors[3] = nf_trans16_lo[*(esi + 42)] | nf_trans16_hi[*(esi + 43)];
- }
- }
-
- if (!do42 && !do26) {
- esi += 48;
- } else {
- esi += 32;
- }
-
- if (!do42) {
- edi -= (8 + nfpk_back_right);
- } else {
- edi -= nfpk_back_right;
- }
-
- } break;
-
- case 11: {
- // 8x8x16 (128 bytes)
- Trans16Blk(edi, esi);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 16);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 32);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 48);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 64);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 80);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 96);
- edi += nf_width;
-
- Trans16Blk(edi, esi + 112);
-
- esi += 128;
- edi -= nfpk_back_right;
- } break;
- case 12: {
- // low 4x4x16 (32 bytes)
- int i;
- uint32_t eax, ebx;
-
- for (i = 0; i < 4; i++) {
- eax = *(uint8_t *)(esi + i * 8 + 0);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 1);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 0) = eax;
- *(uint32_t *)(edi + nf_width) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 2);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 3);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 4) = eax;
- *(uint32_t *)(edi + nf_width + 4) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 4);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 5);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 8) = eax;
- *(uint32_t *)(edi + nf_width + 8) = eax;
-
- eax = *(uint8_t *)(esi + i * 8 + 6);
- ebx = nf_trans16_lo[eax];
- eax = *(uint8_t *)(esi + i * 8 + 7);
- ebx |= nf_trans16_hi[eax];
- eax = ((ebx & 0xFFFF) << 16) | (ebx & 0xFFFF);
- *(uint32_t *)(edi + 12) = eax;
- *(uint32_t *)(edi + nf_width + 12) = eax;
-
- if (i != 3)
- edi = edi + nf_width * 2;
- }
-
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += 32;
- } break;
- case 13: {
- // 2x2 4x4x0 (8 bytes)
- uint32_t temp, ebx, ecx;
-
- temp = nf_trans16_lo[(*esi)] | nf_trans16_hi[(*(esi + 1))];
- ebx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- temp = nf_trans16_lo[(*(esi + 2))] | nf_trans16_hi[(*(esi + 3))];
- ecx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi = edi + nf_width * 2;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi = edi + nf_width * 2;
-
- temp = nf_trans16_lo[(*(esi + 4))] | nf_trans16_hi[(*(esi + 5))];
- ebx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- temp = nf_trans16_lo[(*(esi + 6))] | nf_trans16_hi[(*(esi + 7))];
- ecx = ((temp & 0xFFFF) << 16) | (temp & 0xFFFF);
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi = edi + nf_width * 2;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ecx;
- *(uint32_t *)(edi + 12) = ecx;
- *(uint32_t *)(edi + nf_width) = ebx;
- *(uint32_t *)(edi + nf_width + 4) = ebx;
- *(uint32_t *)(edi + nf_width + 8) = ecx;
- *(uint32_t *)(edi + nf_width + 12) = ecx;
-
- edi += nf_width;
- edi -= nfpk_back_right;
- esi += 8;
- } break;
- case 14: {
- // 8x8x0 (2 bytes)
- uint32_t ecx, ebx;
- ecx = nf_trans16_lo[*(esi)] | nf_trans16_hi[*(esi + 1)];
- esi += 2;
- ebx = ((ecx & 0xFFFF) << 16) | (ecx & 0xFFFF);
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
- edi += nf_width;
-
- *(uint32_t *)(edi + 0) = ebx;
- *(uint32_t *)(edi + 4) = ebx;
- *(uint32_t *)(edi + 8) = ebx;
- *(uint32_t *)(edi + 12) = ebx;
-
- edi -= nfpk_back_right;
- } break;
- case 15: {
- int i;
- i = 0;
- } break;
- }
-
- if (first_opcode) {
- first_opcode = false;
- opcode_to_use = (opcode >> 4);
- goto do_next_opcode;
- }
-
- // go back up
- continue;
- } else {
- edi += nf.new_row;
- h--;
- wcnt = w >> 1;
- }
- } while (h != 0);
-}
-
-void Trans16Blk(uint8_t *edi, uint8_t *idx) {
- *((uint16_t *)(edi + 0)) = nf_trans16_lo[*(idx + 0)] | nf_trans16_hi[*(idx + 1)];
- *((uint16_t *)(edi + 2)) = nf_trans16_lo[*(idx + 2)] | nf_trans16_hi[*(idx + 3)];
- *((uint16_t *)(edi + 4)) = nf_trans16_lo[*(idx + 4)] | nf_trans16_hi[*(idx + 5)];
- *((uint16_t *)(edi + 6)) = nf_trans16_lo[*(idx + 6)] | nf_trans16_hi[*(idx + 7)];
- *((uint16_t *)(edi + 8)) = nf_trans16_lo[*(idx + 8)] | nf_trans16_hi[*(idx + 9)];
- *((uint16_t *)(edi + 10)) = nf_trans16_lo[*(idx + 10)] | nf_trans16_hi[*(idx + 11)];
- *((uint16_t *)(edi + 12)) = nf_trans16_lo[*(idx + 12)] | nf_trans16_hi[*(idx + 13)];
- *((uint16_t *)(edi + 14)) = nf_trans16_lo[*(idx + 14)] | nf_trans16_hi[*(idx + 15)];
-}
-
-void call_hnfxycshift(uint32_t eax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right) {
- uint32_t ebx;
- ebx = ((eax & 0xFF00) >> 8);
-
- if (eax & 0x80) {
- // we have to sign extend also
- eax = ((eax & 0x7F) << 1);
- eax = (eax & 0xFF) | 0xFFFFFF00;
- } else {
- eax = ((eax & 0x7F) << 1);
- }
- eax += nfpk_ShiftY[ebx];
-
- call_hnfshift(eax, medi, mesi, nfpk_back_right);
-}
-
-void call_hnfxypshift(uint32_t eax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right,
- int DiffBufPtrs) {
- uint32_t ebx;
- ebx = ((eax & 0xFF00) >> 8);
-
- if (eax & 0x80) {
- // we have to sign extend also
- eax = ((eax & 0x7F) << 1);
- eax = (eax & 0xFF) | 0xFFFFFF00;
- } else {
- eax = ((eax & 0x7F) << 1);
- }
- eax += nfpk_ShiftY[ebx];
- eax += DiffBufPtrs;
-
- call_hnfshift(eax, medi, mesi, nfpk_back_right);
-}
-
-void call_hnfshift(uint32_t meax, uint8_t **medi, uint8_t **mesi, int nfpk_back_right) {
- uint8_t *esi, *edi, *saved_esi;
- int i;
-
- edi = *medi;
- saved_esi = esi = *mesi;
- esi = edi + meax;
-
- for (i = 0; i < 8; i++) {
-#define HNFSHIFT_WRITEOUT(x) *(uint32_t *)(edi + x) = *(uint32_t *)(esi + x);
-
- HNFSHIFT_WRITEOUT(0);
- HNFSHIFT_WRITEOUT(4);
- HNFSHIFT_WRITEOUT(8);
- HNFSHIFT_WRITEOUT(12);
-
-#undef HNFSHIFT_WRITEOUT
-
- if (i != 7) {
- esi += nf_width;
- edi += nf_width;
- }
- }
-
- edi -= nfpk_back_right;
- esi = saved_esi;
-
- *medi = edi;
- *mesi = esi;
-}
-
-////////////////////////////////////////////////
-// Non-Implemented Functions
-////////////////////////////////////////////////
-void nfHiColorDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfHiColorDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y,
- unsigned w, unsigned h);
-void nfDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y, unsigned w,
- unsigned h);
-void nfPkPal(void);
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty);
-
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-void palLoadCompPalette(uint8_t *buf);
-void gfxMode(unsigned mode);
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res);
-void gfxGetCrtc(uint8_t *crtc);
-void gfxVres(uint8_t misc, uint8_t *crtc);
-void MVE_gfxWaitRetrace(int state);
-void MVE_gfxSetSplit(unsigned line);
-
-// rcg07272000
-// need this on non-Intel platforms. Intel uses int $3.
-#if (defined __i386__) || defined(__x86_64__)
-#error
-#define int3() __asm__ __volatile__("int $3")
-#else
-#define int3() raise(SIGTRAP)
-#endif
-
-void nfHiColorDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3(); }
-void nfHiColorDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y,
- unsigned w, unsigned h) {
- int3();
-}
-void nfDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3(); }
-void nfDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y, unsigned w,
- unsigned h) {
- int3();
-}
-void nfPkPal(void) { int3(); }
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3(); }
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3(); }
-void nfPkDecompD(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h) { int3(); }
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- int3();
-}
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field) {
- int3();
-}
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- int3();
-}
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty) {
- int3();
-}
-void mve_sfPkShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- int3();
-}
-void mve_sfPkHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint8_t *ops,
- unsigned dstx, unsigned dsty) {
- int3();
-}
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count) { int3(); }
-void palLoadCompPalette(uint8_t *buf) { int3(); }
-void gfxMode(unsigned mode) { int3(); }
-void gfxLoadCrtc(uint8_t *crtc, uint8_t chain4, uint8_t res) { int3(); }
-void gfxGetCrtc(uint8_t *crtc) { int3(); }
-void gfxVres(uint8_t misc, uint8_t *crtc) { int3(); }
-void MVE_gfxWaitRetrace(int state) { int3(); }
-void MVE_gfxSetSplit(unsigned line) { int3(); }
diff --git a/lnxmvelib/mvegfx.h b/lnxmvelib/mvegfx.h
deleted file mode 100644
index 3d1e21e3..00000000
--- a/lnxmvelib/mvegfx.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#define MVE_GFX_VESA_640_400 0x100
-#define MVE_GFX_VESA_640_200 0x8100
-#define MVE_GFX_VESA_640_480 0x101
-#define MVE_GFX_VESA_640_240 0x8101
-#define MVE_GFX_VESA_800_600 0x103
-#define MVE_GFX_VESA_800_300 0x8103
-#define MVE_GFX_VESA_1024_768 0x105
-#define MVE_GFX_VESA_1024_384 0x8105
-#define MVE_GFX_VESA_1280_1024 0x107
-#define MVE_GFX_VESA_1280_512 0x8107
-
-#define MVE_GFX_VESA_320_200_HI 0x10d /* 1:5:5:5 Hi Color modes */
-#define MVE_GFX_VESA_640_480_HI 0x110
-#define MVE_GFX_VESA_800_600_HI 0x113
-#define MVE_GFX_VESA_1024_768_HI 0x116
-#define MVE_GFX_VESA_1280_1024_HI 0x119
-
-/* Some hacked vesa modes */
-#define MVE_GFX_VESA_640_350 0x0F00 /* 640x350 */
-#define MVE_GFX_VESA_640_175 0x8F00 /* 640x175 */
-#define MVE_GFX_VESA_640_160 0x0F01 /* 640x160 */
-
-#define MVE_GFX_VESA_CURRENT 0 /* Use current VESA mode */
-
-#define MVE_GFX_AUTO (-1) /* Choose mode based on movie's preference */
-#define MVE_GFX_VGA 0x13 /* 320x200 */
-#define MVE_GFX_VGA_CURRENT (-2) /* 320x200 (mode already set) */
-#define MVE_GFX_VGA_MEDRES (-3) /* 248x264 out of 320x350 */
-#define MVE_GFX_VGA_HIRES (-4) /* 224x288 out of 360x480 */
-#define MVE_GFX_VGA_LORES (-5) /* 288x224 out of 320x240 */
-#define MVE_GFX_VESA_320_480 (-6) /* 320x480 */
diff --git a/lnxmvelib/mvelibi.h b/lnxmvelib/mvelibi.h
deleted file mode 100644
index 480eb4bb..00000000
--- a/lnxmvelib/mvelibi.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#if __SC__
-#pragma SC align 1
-#elif __WATCOMC__
-#pragma pack(1);
-#elif _MSC_VER
-#pragma pack(1)
-#else
-//???
-#pragma pack(push, 1)
-#endif
-
-#include "byteswap.h"
-
-//--------------------------------
-// Useful type definitions
-//--------------------------------
-
-#ifndef __cplusplus
-typedef unsigned bool;
-#endif
-#define FALSE 0
-#define TRUE 1
-
-//--------------------------------
-// 386 Assembler Support
-//--------------------------------
-
-#define OPERAND32 __asm _emit 0x66
-#define SEG_ES __asm _emit 0x26
-#define SEG_FS __asm _emit 0x64
-#define SEG_GS __asm _emit 0x65
-#define MOVZX_BP_IND_BX __asm _emit 0x0F __asm _emit 0xB6 __asm _emit 0x2F
-#define MOV_FS_AX __asm _emit 0x8e __asm _emit 0xE0
-#define MOV_GS_AX __asm _emit 0x8e __asm _emit 0xE8
-
-//--------------------------------
-// Compressed Video Constants
-//--------------------------------
-
-// Width and height of sections in pixels.
-#define SWIDTH 8
-#define SHEIGHT 8
-
-#define LOG2_SWIDTH 3
-#define LOG2_SHEIGHT 3
-
-//------------------------------
-// Movie File Header
-//------------------------------
-
-#define MVE_FILE_TYPE "Interplay MVE File\x1A\0"
-#define MVE_FILE_VERSION 0x0100
-
-struct mve_hdr {
- char FileType[20]; // MVE_FILE_TYPE
- uint16_t HdrSize; // sizeof(mve_hdr)
- uint16_t version; // MVE_FILE_VERSION
- uint16_t id; // ~MVE_FILE_VERSION+0x1234
-};
-
-//------------------------------
-// Movie File Records
-//------------------------------
-
-struct ioHdrRec {
- uint16_t len; // Length of record data (pad to even)
- uint16_t kind; // See IO_REC_xxx
- // uint8_t data[0]; // Record data
-};
-
-// This record classifications simplify utilities which must operate on
-// records. They are not used by this library when running a movie.
-//
-#define IO_REC_SND_INIT 0 // Sound setup
-#define IO_REC_SND_PRELOAD 1 // Sound preload
-#define IO_REC_FRAME_INIT 2 // Frame (video) setup
-#define IO_REC_FRAME 3 // Movie frames
-#define IO_REC_END 4 // Last Record (End of Movie)
-#define IO_REC_EOF 5 // Empty eof record at end of file.
-
-//------------------------------
-// Movie File Major Opcodes
-//------------------------------
-//
-
-#define MCMD_DATA(arg) ((uint8_t *)((arg) + 1))
-
-struct mcmd_hdr {
- uint16_t len; // Length of data (pad to even)
- uint8_t major; // Major opcode
- uint8_t minor; // Minor opcode
- // uint8_t data[0]; // Opcode data
-};
-
-#define mcmd_end 0 // End processing of movie
-
-#define mcmd_next 1 // Advance to next movie record
-
-#define mcmd_syncInit 2
-struct marg_syncInit {
- uint32_t period; // period of quanta
- uint16_t wait_quanta; // # of quanta per frame
-};
-
-#define mcmd_sndConfigure 3
-struct marg_sndConfigure {
- uint16_t rate; // 65536-(256E6/(frequency*(stereo+1)))
- // comp16 is a minor opcode 1 field
- // It indicates that 16-bit data has been compressed to 8-bits.
- // When it is set, bits16 will also be set.
- // Each record will contain initial 16-bit sample followed
- // by remaining compressed 8-bit samples.
- // For stereo, there will be two initial 16-bit samples.
- // and compressed streams will be interleaved.
- // uint16_t stereo:1, bits16:1, comp16:1;
-#ifdef OUTRAGE_BIG_ENDIAN
- uint8_t bitpadder : 5;
-#endif
- uint8_t stereo : 1, bits16 : 1, comp16 : 1;
- uint8_t dummy1;
- uint16_t frequency;
- // Minor opcode 1 extends buflen to be a long
- uint32_t buflen;
-};
-
-#define mcmd_sndSync 4
-
-#define mcmd_nfConfig 5
-struct marg_nfConfig {
- uint16_t wqty;
- uint16_t hqty;
- // Minor opcode 1 fields:
- uint16_t fqty;
- // Minor opcode 2 fields:
- uint16_t hicolor; /*0=256-color, 1=HiColor, 2=HiColorSwapped*/
-};
-
-#define mcmd_nfDecomp 6
-#define mcmd_nfDecompChg 16
-#define mcmd_nfPkDecomp 17
-struct marg_nfDecomp {
- uint16_t prev; // info:Prev frames+1 needed for full picture
- uint16_t iframe; // info:Current internal frame #
- uint16_t x;
- uint16_t y;
- uint16_t w;
- uint16_t h;
- // uint16_t advance:1;
-#ifdef OUTRAGE_BIG_ENDIAN
- uint8_t bitpadder : 7;
-#endif
- uint8_t advance : 1;
- uint8_t dummy1;
- // uint8_t comp[0];
-};
-
-#define mcmd_sfShowFrame 7
-#if 0 // Not supported
-#define mcmd_sfPkShowFrameChg 18
-#endif
-struct marg_sfShowFrame {
- uint16_t pal_start;
- uint16_t pal_count;
- // Minor opcode 1 fields:
- uint16_t field; // 0:none, 2:send to even, 3:send to odd
-};
-
-#define mcmd_sndAdd 8
-#define mcmd_sndSilence 9
-struct marg_sndAdd {
- uint16_t iframe; // info: iframe # of sound
- uint16_t TrackMask;
- uint16_t qty; // Uncompressed audio size in bytes
- // uint8_t data[0];
-};
-
-#define mcmd_gfxMode 10
-struct marg_gfxMode {
- uint16_t minw;
- uint16_t minh;
- uint16_t mode;
-};
-
-#define mcmd_palMakeSynthPalette 11
-struct marg_palLoadPalette {
- uint8_t base_r;
- uint8_t range_r;
- uint8_t range_rb;
- uint8_t base_g;
- uint8_t range_g;
- uint8_t range_gb;
-};
-
-#define mcmd_palLoadPalette 12
-struct marg_palLoadPalette {
- uint16_t start;
- uint16_t count;
- // uint8_t data[0];
-};
-
-#define mcmd_palLoadCompPalette 13
-
-#define mcmd_nfChanges 14
-#define mcmd_nfParms 15
-// 16 is used for mcmd_nfDecompChg, see above.
-// 17 is used for mcmd_nfPkDecomp, see above.
-// 18 is used for mcmd_nfPkShowFrameChg, see above
-
-#define mcmd_nfPkInfo 19
-#define mcmd_nfHPkInfo 20
-struct marg_nfPkInfo {
- uint32_t error; // scaled by 10000
- uint16_t usage[64];
-};
-
-#define mcmd_idcode 21
-struct marg_idcode {
- uint32_t idcode; // Code identifying version mcomp used to create
-};
-
-#if __SC__
-#pragma SC align
-#elif __WATCOMC__
-#pragma pack();
-#elif _MSC_VER
-#pragma pack()
-#else
-//???
-#pragma pack(pop)
-#endif
diff --git a/lnxmvelib/mvelibl.cpp b/lnxmvelib/mvelibl.cpp
deleted file mode 100644
index 09089829..00000000
--- a/lnxmvelib/mvelibl.cpp
+++ /dev/null
@@ -1,1852 +0,0 @@
-/*
-** mvelibl.cpp
-**
-** Interplay Movie File (MVE) Player Library (32-Bit Linux Version)
-** Written by Paul Allen Edelstein. Partial Linux port by Jeff Slutter.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-**
-
---- HISTORICAL COMMENTS FOLLOW ---
-
-** Linux Specific Notes:
-** It uses SDL. We love it. Woohoo. None of this low-level X11 shit. --ryan.
-*/
-static char notice1[] = "(c) 1997 Interplay Productions. All Rights Reserved.\n"
- "This file is confidential and consists of proprietary information\n"
- "of Interplay Productions. This file and associated libraries\n"
- "may not, in whole or in part, be disclosed to third parties,\n"
- "incorporated into any software product which is not being created\n"
- "for Interplay Productions, copied or duplicated in any form,\n"
- "without the prior written permission of Interplay Productions.\n"
- "Further, you may not reverse engineer, decompile or otherwise\n"
- "attempt to derive source code of this material.\n";
-
-#include
-#include
-#include
-#include
-#include
-
-#include "mvelibi.h"
-#include "mvegfx.h"
-#include "mvelibl.h"
-
-#include "byteswap.h"
-
-static unsigned opt_fastmode = 0; // 0:normal, 1:even lines only, 2:dither between even/odd lines |4 to spread lines
-
-unsigned opt_hscale_step = 4; // 3: 4/3, 4:4/4, 5:4/5 (not fully implemented)
-unsigned opt_hscale_adj;
-
-#define logLabel(x)
-
-#include "snd8to16.h"
-// len always specifies length of destination in bytes.
-unsigned sndDecompM16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned state);
-unsigned sndDecompS16(uint16_t *dst, const uint8_t *src, unsigned len, unsigned state);
-
-static LnxWindow *mve_lpWin = NULL;
-
-uint32_t timeGetTime(void) {
- struct timeval t;
- gettimeofday(&t, NULL);
-
- return (t.tv_sec * 1000 + t.tv_usec / 1000);
-}
-
-//----------------------------------------------------------------------
-// Memory Management
-//--------------------
-
-static void *(*mem_alloc)(unsigned size);
-static void (*mem_free)(void *p);
-
-struct _mem {
- void *ptr;
- unsigned size;
- bool dynamic;
-} MemRec, *MemRec*;
-
-static void MemInit(MemRec* m, unsigned size, void *p);
-static void *MemAlloc(MemRec* m, unsigned size);
-static void MemFree(MemRec* m);
-
-void MVE_memCallbacks(void *(*fn_alloc)(unsigned size), void (*fn_free)(void *p)) {
- mem_alloc = fn_alloc;
- mem_free = fn_free;
-}
-
-static void MemFree(MemRec* m) {
- if (m->dynamic && mem_free) {
- (*mem_free)(m->ptr);
- m->dynamic = FALSE; // prevent from being freed again!
- }
- m->size = 0;
-}
-
-static void MemInit(MemRec* m, unsigned size, void *p) {
- if (!p)
- return;
- MemFree(m);
- m->ptr = p;
- m->size = size;
- m->dynamic = FALSE;
-}
-
-static void *MemAlloc(MemRec* m, unsigned size) {
- if (size <= m->size)
- return m->ptr;
- if (mem_alloc) {
- void *p;
- MemFree(m);
- size += 100; // Add some pad to reduce chance of another realloc.
- p = (*mem_alloc)(size);
- if (!p)
- return (void *)NULL;
- MemInit(m, size, p);
- m->dynamic = TRUE;
- return m->ptr;
- }
- return (void *)NULL;
-}
-
-//----------------------------------------------------------------------
-// Synchronization Management
-//-----------------------------
-
-static bool sync_active = FALSE;
-static int sync_time;
-static int sync_wait_quanta;
-
-static bool sync_late = FALSE;
-static bool sync_FrameDropped = FALSE;
-
-static void syncReset(uint32_t wait_quanta);
-static void syncRelease(void);
-static bool syncInit(uint32_t period, unsigned wait_quanta);
-static bool syncWait(void);
-static void syncSync(void);
-
-static void syncReset(uint32_t wait_quanta) {
- sync_time = wait_quanta - timeGetTime() * 1000;
- sync_active = TRUE;
-}
-
-static void syncRelease(void) { sync_active = FALSE; }
-
-static bool syncInit(uint32_t period, unsigned wait_quanta) {
- int new_wait_quanta = -(int32_t)(period * wait_quanta + (wait_quanta >> 1));
- // If timer is still running and has same timing
- // characteristics, assume we are trying to continue smoothly
- // with another movie and ignore new syncInit() call.
- if (sync_active && sync_wait_quanta == new_wait_quanta)
- return TRUE;
-
- syncWait();
- sync_wait_quanta = new_wait_quanta;
- syncReset(sync_wait_quanta);
- return TRUE;
-}
-
-// Returns true if actually waited, false if called too late to wait.
-static bool syncWait(void) {
- bool waited = FALSE;
- if (!sync_active)
- return FALSE;
- while ((int)(sync_time + timeGetTime() * 1000) < 0)
- waited = TRUE;
- sync_time += sync_wait_quanta;
- return waited;
-}
-
-// Returns true if actually waited, false if called too late to wait.
-static int syncWaitLevel(int level) {
- int waited;
- if (!sync_active)
- return 0;
- level += sync_time;
- for (;;) {
- waited = level + timeGetTime() * 1000;
- if (waited >= 0)
- break;
- }
- sync_time += sync_wait_quanta;
- return waited;
-}
-
-static void syncSync(void) {
- if (sync_active) {
- while ((int)(sync_time + timeGetTime() * 1000) < 0)
- ;
- }
-}
-
-int MVE_syncTime(void) {
- if (sync_active)
- return sync_time + timeGetTime() * 1000;
- else
- return 0;
-}
-
-void MVE_logDumpStats(void) {}
-
-//----------------------------------------------------------------------
-// I/O Management
-//-----------------
-
-static unsigned (*io_read)(int handle, void *buf, unsigned count);
-
-static MemRec io_mem_buf;
-
-static int io_handle;
-static ioHdrRec io_next_hdr;
-
-static bool ioReset(int h);
-static uint8_t *ioRead(unsigned qty);
-static uint8_t *ioNextRecord(void);
-static void ioRelease(void);
-
-void MVE_ioCallbacks(unsigned (*fn_read)(int handle, void *buf, unsigned count)) { io_read = fn_read; }
-
-static bool ioReset(int h) {
- mve_hdr *hdr;
-
- io_handle = h;
- hdr = (mve_hdr *)ioRead(sizeof(mve_hdr) + sizeof(ioHdrRec));
- if (!hdr)
- return FALSE;
-
- hdr->HdrSize = INTEL_SHORT(hdr->HdrSize);
- hdr->version = INTEL_SHORT(hdr->version);
- hdr->id = INTEL_SHORT(hdr->id);
-
- if (strcmp(hdr->FileType, MVE_FILE_TYPE) != 0 || hdr->id != ~hdr->version + 0x1234 ||
- // The following two checks may eventually be weakened.
- hdr->version != MVE_FILE_VERSION || hdr->HdrSize != sizeof(mve_hdr))
- return FALSE;
-
- io_next_hdr = *(ioHdrRec *)(hdr + 1);
- io_next_hdr.len = INTEL_SHORT(io_next_hdr.len);
- io_next_hdr.kind = INTEL_SHORT(io_next_hdr.kind);
- return TRUE;
-}
-
-void MVE_memIO(void *p, unsigned size) { MemInit(&io_mem_buf, size, p); }
-
-static uint8_t *ioRead(unsigned len) {
- uint8_t *buf;
-
- buf = (uint8_t *)MemAlloc(&io_mem_buf, len);
- if (!buf)
- return (uint8_t *)NULL;
- if (!(*io_read)(io_handle, buf, len))
- return (uint8_t *)NULL;
- return buf;
-}
-
-static uint8_t *ioNextRecord(void) {
- uint8_t *buf;
- logLabel("StartRead");
- buf = ioRead(io_next_hdr.len + sizeof(ioHdrRec));
- logLabel("EndRead");
- if (!buf)
- return (uint8_t *)NULL;
- io_next_hdr = *(ioHdrRec *)(buf + io_next_hdr.len);
- io_next_hdr.len = INTEL_SHORT(io_next_hdr.len);
- io_next_hdr.kind = INTEL_SHORT(io_next_hdr.kind);
- return buf;
-}
-
-static void ioRelease(void) { MemFree(&io_mem_buf); }
-
-//----------------------------------------------------------------------
-// Sound Management
-//-----------------------
-
-#define SOUND_SUPPORT 1
-
-#if SOUND_SUPPORT
-
-static LnxSoundDevice *snd_ds = NULL;
-static LnxSoundBuffer *snd_buffer = NULL;
-static LinuxSoundCaps snd_buffer_caps;
-static uint32_t snd_write_cursor;
-
-enum { snd_queue_max = 60 };
-
-static struct _snd_queue {
- unsigned ptr;
-} snd_queue[snd_queue_max];
-static unsigned snd_fill, snd_empty;
-static int snd_pad;
-
-static unsigned snd_stereo;
-static unsigned snd_comp16;
-static unsigned snd_bits16;
-
-static int32_t snd_volume = 0;
-static int32_t snd_pan = 0;
-
-#endif
-
-void MVE_sndInit(LnxSoundDevice *lpDS) {
-#if SOUND_SUPPORT
- snd_ds = lpDS;
-#endif
-}
-
-void MVE_dsbSetVolume(int32_t lVolume) {
-#if SOUND_SUPPORT
- snd_volume = lVolume;
- if (snd_buffer)
- LnxSoundBuffer_SetVolume(snd_buffer, snd_volume);
-#endif
-}
-
-void MVE_dsbSetPan(int32_t lPan) {
-#if SOUND_SUPPORT
- snd_pan = lPan;
- if (snd_buffer)
- LnxSoundBuffer_SetPan(snd_buffer, snd_pan);
-#endif
-}
-
-static void sndReset(void) {
-#if SOUND_SUPPORT
- if (snd_buffer) {
- LnxSoundBuffer_Stop(snd_buffer);
- LnxSoundBuffer_Release(snd_buffer);
- snd_buffer = NULL;
- }
-#endif
-}
-
-static bool sndConfigure(unsigned rate, unsigned buflen, unsigned stereo, unsigned frequency, unsigned bits16,
- unsigned comp16) {
-#if SOUND_SUPPORT
-
- LnxBufferDesc snd_bufferdesc;
- WAVEFORMATEX snd_wfx;
- int dsrval;
-
- if (!snd_ds)
- return TRUE;
- syncSync();
- sndReset();
-
- snd_stereo = stereo;
- snd_bits16 = bits16;
- snd_comp16 = comp16;
-
- snd_bufferdesc.dwFlags = LNXSND_CAPS_CTRLDEFAULT;
- snd_bufferdesc.dwBufferBytes = (buflen + (buflen >> 1)) & ~3;
- snd_bufferdesc.lpwfxFormat = &snd_wfx;
- snd_wfx.wFormatTag = WAVE_FORMAT_PCM;
- snd_wfx.nChannels = stereo ? 2 : 1;
- snd_wfx.nSamplesPerSec = frequency;
- snd_wfx.nBlockAlign = (stereo ? 2 : 1) * (bits16 ? 2 : 1);
- snd_wfx.nAvgBytesPerSec = frequency * snd_wfx.nBlockAlign;
- snd_wfx.wBitsPerSample = bits16 ? 16 : 8;
- snd_fill = 0;
- snd_empty = 0;
-
- dsrval = LnxSound_CreateSoundBuffer(snd_ds, &snd_bufferdesc, &snd_buffer);
- if (dsrval != 0)
- return FALSE;
-
- LnxSoundBuffer_SetVolume(snd_buffer, snd_volume);
- LnxSoundBuffer_SetPan(snd_buffer, snd_pan);
-
- snd_write_cursor = 0;
-
- dsrval = LnxSoundBuffer_GetCaps(snd_buffer, &snd_buffer_caps);
- if (dsrval != 0)
- return FALSE;
-
-#endif
-
- return TRUE;
-}
-
-static void sndSync(void) {
-
-#ifdef __DUMP_MVE_TO_DISK
- return;
-#else
-
-#if SOUND_SUPPORT
-
- int dsrval;
- uint32_t dsbstatus;
- uint32_t play_cursor, write_cursor, target;
-
- bool need_resync;
-#endif
-
- // Better frame dropping using more flexible synchronization
- sync_late = syncWaitLevel(sync_wait_quanta >> 2) > (-sync_wait_quanta >> 1) && !sync_FrameDropped;
- sync_FrameDropped = FALSE;
-
-#if SOUND_SUPPORT
- if (!snd_ds || !snd_buffer)
- return;
-
- need_resync = FALSE;
- for (;;) {
- dsrval = LnxSoundBuffer_GetStatus(snd_buffer, &dsbstatus);
- if (dsrval != 0)
- return;
- dsrval = LnxSoundBuffer_GetCurrentPosition(snd_buffer, &play_cursor, &write_cursor);
- if (dsrval != 0)
- return;
- write_cursor = snd_write_cursor;
-
-#define set_target(t) \
- (target = (snd_queue[snd_empty].ptr + (t) + snd_buffer_caps.dwBufferBytes) % snd_buffer_caps.dwBufferBytes)
-#define target_pending() \
- ((play_cursor <= write_cursor) ? (play_cursor <= target && target < write_cursor) \
- : (play_cursor <= target || target < write_cursor))
-
- // Don't get too far ahead of sound (target-pad not yet played)
- set_target(-snd_pad);
- if (target_pending() && (dsbstatus & LNXSND_PLAYING))
- need_resync = TRUE;
- else
- break;
- }
- if (need_resync) {
- syncReset(sync_wait_quanta + (sync_wait_quanta >> 2));
- }
-
- if (!(dsbstatus & LNXSND_PLAYING)) // If currently not playing
- {
- // Don't restart too soon (restart when target hasn't been played)
- set_target(0);
- if (target_pending()) {
- dsrval = LnxSoundBuffer_SetCurrentPosition(snd_buffer, target);
- if (dsrval != 0)
- return;
- dsrval = LnxSoundBuffer_Play(snd_buffer, LNXSND_LOOPING);
- if (dsrval != 0)
- return;
-
- syncReset(sync_wait_quanta);
- }
- }
- // Because DirectSound can consume an unpredictable amount into primary, this won't always be invoked when it should
- else {
- // Don't get too far behind sound (has target+pad already been played?)
- set_target(snd_pad);
- {
- int amt = write_cursor - play_cursor;
- if (amt < 0)
- amt += snd_buffer_caps.dwBufferBytes;
- amt = snd_buffer_caps.dwBufferBytes - amt - 1;
- if (amt > (int)snd_buffer_caps.dwBufferBytes / 2)
- amt = snd_buffer_caps.dwBufferBytes / 2;
- play_cursor = (play_cursor - amt + snd_buffer_caps.dwBufferBytes) % snd_buffer_caps.dwBufferBytes;
- }
- if (!target_pending()) {
- LnxSoundBuffer_Stop(snd_buffer);
- // dsrval = LnxSoundBuffer_GetCurrentPosition(snd_buffer, &snd_write_cursor, &write_cursor);
- }
- }
-
- if (snd_empty != snd_fill) {
- if (snd_empty == snd_queue_max - 1)
- snd_empty = 0;
- else
- ++snd_empty;
- }
-#endif
-
-#endif // dump mve to disk
-}
-
-// For compressed streams, assumes len (which is in bytes) will be in multiples
-// of 2 for mono and 4 for stereo.
-static unsigned sndAddHelper(uint8_t *dst, uint8_t **pSrc, unsigned len, unsigned state, bool init) {
-#if SOUND_SUPPORT
- uint8_t *src;
- src = *pSrc;
- if (!src)
- memset(dst, (snd_bits16 ? 0 : 0x80), len);
- else if (snd_comp16)
- if (!snd_stereo) {
- if (init) {
- uint16_t swapper = *(uint16_t *)src;
- state = INTEL_SHORT(swapper);
- *(uint16_t *)dst = state;
- src += 2;
- dst += 2;
- len -= 2;
- }
-
- state = sndDecompM16((uint16_t *)dst, src, len >> 1, state);
-
- src += len >> 1;
- } else {
- if (init) {
- state = *(uint32_t *)src;
- state = INTEL_INT(state);
- *(uint32_t *)dst = state;
- src += 4;
- dst += 4;
- len -= 4;
- }
- state = sndDecompS16((uint16_t *)dst, src, len >> 2, state);
- src += len >> 1;
- }
- else {
- memcpy(dst, src, len);
- src += len;
- }
- *pSrc = src;
- return state;
-#else
- return 0;
-#endif
-}
-
-static void sndAdd(const uint8_t *buf, unsigned len) {
-#if SOUND_SUPPORT
-
- int dsrval;
- uint32_t play_cursor, write_cursor;
- uint32_t len1, len2;
-
- unsigned state = 0;
- bool init = TRUE;
- uint8_t *ptr1, *ptr2;
-
- snd_pad = len;
-
- if (!snd_buffer || snd_fill + 1 == (snd_empty ? snd_empty : snd_queue_max))
- return;
-
- dsrval = LnxSoundBuffer_GetCurrentPosition(snd_buffer, &play_cursor, &write_cursor);
- if (dsrval != 0)
- return;
- write_cursor = snd_write_cursor;
-
- dsrval = LnxSoundBuffer_Lock(snd_buffer, write_cursor, len, (void **)&ptr1, &len1, (void **)&ptr2, &len2,
- 0 /*LNXSND_LOCK_FROMWRITECURSOR*/ /*flags*/);
- if (dsrval != 0)
- return;
- if (len1) {
- state = sndAddHelper(ptr1, &buf, len1, state, init);
- init = FALSE;
- snd_write_cursor += len1;
- }
- if (len2) {
- sndAddHelper(ptr2, &buf, len2, state, init);
- snd_write_cursor = len2;
- }
-
- if (snd_write_cursor == snd_buffer_caps.dwBufferBytes)
- snd_write_cursor = 0;
-
- LnxSoundBuffer_Unlock(snd_buffer, ptr1, len1, ptr2, len2);
-
- snd_queue[snd_fill].ptr = write_cursor;
- if (snd_fill == snd_queue_max - 1)
- snd_fill = 0;
- else
- ++snd_fill;
-#endif
-}
-
-static void sndRelease(void) {
-#if SOUND_SUPPORT
- // Nothing to free
-#endif
-}
-
-static void sndPause(void) {
-#if SOUND_SUPPORT
- if (snd_buffer)
- LnxSoundBuffer_Stop(snd_buffer);
-#endif
-}
-
-static void sndResume(void) {
- // Nothing need be done here to resume sound
- // The next call to sndSync will automatically resume the sound.
-}
-
-//--------------------------------------------------------------------
-// NextFrame (Video Decompression)
-//----------------------------------
-
-// static removed from most nf_ vars to support mveliba.asm
-
-static bool nf_memory_mode = FALSE;
-
-// NextFrame working storage
-static uint8_t *nf_dds_cur = NULL;
-static uint8_t *nf_dds_prv = NULL;
-static MemRec nf_mem_buf1;
-static MemRec nf_mem_buf2;
-uint8_t *nf_buf_cur;
-uint8_t *nf_buf_prv;
-
-// NextFrame parameters
-uint8_t nf_wqty; // (width/SWIDTH)
-uint8_t nf_hqty; // (height/SHEIGHT)
-uint8_t nf_fqty; // Number of fields
-unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
-//
-unsigned nf_width; // wqty * SWIDTH
-unsigned nf_height; // hqty * SHEIGHT;
-unsigned nf_new_line; // width - SWIDTH
-unsigned nf_new_row0; // SHEIGHT*width*2-width
-unsigned nf_back_right; // (SHEIGHT-1)*width
-
-// Frame parameters
-// Portion of current frame which has been updated
-// and needs to be sent to screen.
-//
-unsigned nf_new_x;
-unsigned nf_new_y;
-unsigned nf_new_w;
-unsigned nf_new_h;
-
-// Hicolor format translation tables
-uint16_t nf_trans16_lo[256];
-uint16_t nf_trans16_hi[256];
-
-void MVE_memVID(void *p1, void *p2, unsigned size) {
- MemInit(&nf_mem_buf1, size, p1);
- MemInit(&nf_mem_buf2, size, p2);
-}
-
-void nfPkConfig(void);
-
-// ffs()
-// Returns position of most significant bit set (0 to 31).
-// Assumes bits is nonzero.
-static int ffs(unsigned bits) {
- int pos;
- unsigned t;
- t = bits & 0xFFFF0000;
- if (t)
- bits = t, pos = 16;
- else
- pos = 0;
- t = bits & 0xFF00FF00;
- if (t)
- bits = t, pos |= 8;
- t = bits & 0xF0F0F0F0;
- if (t)
- bits = t, pos |= 4;
- t = bits & 0xCCCCCCCC;
- if (t)
- bits = t, pos |= 2;
- if (bits & 0xAAAAAAAA)
- pos |= 1;
- return pos;
-}
-
-static bool nfConfig(int wqty, int hqty, int fqty, int hicolor) {
- unsigned size;
-
- if (!nf_memory_mode) {
- if (nf_dds_cur) {
- free(nf_dds_cur);
- nf_dds_cur = NULL;
- }
- if (nf_dds_prv) {
- free(nf_dds_prv);
- nf_dds_prv = NULL;
- }
- }
-
- nf_wqty = (uint8_t)wqty;
- nf_hqty = (uint8_t)hqty;
- nf_fqty = (uint8_t)fqty;
- nf_width = wqty * SWIDTH;
- nf_height = hqty * fqty * SHEIGHT;
- if (opt_fastmode)
- nf_height >>= 1;
- {
- if (hicolor) {
- int pal_rshift, pal_gshift, pal_bshift;
- unsigned pal_rmask, pal_bmask, pal_gmask;
- unsigned i, r, g, b;
- LnxDraw_GetRGBMasks(mve_lpWin, &pal_rmask, &pal_gmask, &pal_bmask);
-
- pal_rshift = ffs(pal_rmask) - 4;
- pal_gshift = ffs(pal_gmask) - 4;
- pal_bshift = ffs(pal_bmask) - 4;
- for (i = 0, r = 0, g = 0; g < 8; ++g)
- for (b = 0; b < 32; ++b, ++i)
- nf_trans16_lo[i] = (((pal_rshift > 0 ? r << pal_rshift : r >> -pal_rshift) & pal_rmask) |
- ((pal_gshift > 0 ? g << pal_gshift : g >> -pal_gshift) & pal_gmask) |
- ((pal_bshift > 0 ? b << pal_bshift : b >> -pal_bshift) & pal_bmask));
-
- for (i = 0, r = 0, b = 0; r < 32; ++r)
- for (g = 0; g < 32; g += 8, ++i)
- nf_trans16_hi[i + 128] = nf_trans16_hi[i] =
- (((pal_rshift > 0 ? r << pal_rshift : r >> -pal_rshift) & pal_rmask) |
- ((pal_gshift > 0 ? g << pal_gshift : g >> -pal_gshift) & pal_gmask) |
- ((pal_bshift > 0 ? b << pal_bshift : b >> -pal_bshift) & pal_bmask));
- }
- int size = nf_width * nf_height << 1;
-
- nf_dds_cur = (uint8_t *)malloc(size);
- nf_dds_prv = (uint8_t *)malloc(size);
- }
-
- nf_new_line = nf_width * fqty - SWIDTH;
- nf_hicolor = hicolor;
- if (hicolor) {
- nf_width <<= 1;
- nf_new_line <<= 1;
- }
-
- nf_new_row0 = fqty * SHEIGHT * nf_width;
- nf_back_right = fqty * (SHEIGHT - 1) * nf_width;
- size = nf_width * nf_height;
- nfPkConfig();
-
- return TRUE;
-}
-
-static bool nfLock(void) {
- // nf_buf_cur = (uint8_t *)nf_dds_cur;
- int pitch;
- int x1, y1, x2, y2, mw;
- extern unsigned sf_ScreenHeight; // Height of modifiable screen
- extern unsigned sf_ScreenWidth; // Width of modifiable screen
-
- // center it
- mw = (nf_hicolor) ? nf_width >> 1 : nf_width;
- x1 = (sf_ScreenWidth >> 1) - (mw >> 1);
- if (x1 < 0)
- x1 = 0;
- y1 = (sf_ScreenHeight >> 1) - (nf_height >> 1);
- if (y1 < 0)
- y1 = 0;
- x2 = x1 + mw - 1;
- y2 = y1 + nf_height - 1;
-
- LnxDraw_LockSurface(mve_lpWin, x1, y1, x2, y2, &nf_buf_cur, &pitch);
- memcpy(nf_buf_cur, nf_dds_cur, nf_width * nf_height);
- nf_buf_prv = (uint8_t *)nf_dds_prv;
- if (!nf_buf_cur || !nf_buf_prv)
- return FALSE;
- return TRUE;
-}
-
-static void nfUnlock(void) {
- memcpy(nf_dds_cur, nf_buf_cur, nf_width * nf_height);
- LnxDraw_UnlockSurface(mve_lpWin, nf_buf_cur);
-}
-
-static void nfRelease(void) {
- free(nf_dds_cur);
- free(nf_dds_prv);
- nf_dds_cur = NULL;
- nf_dds_prv = NULL;
-}
-
-static void nfAdvance(void) {
- /*
- int ret;
- int x,y;
- extern unsigned sf_ScreenHeight; // Height of modifiable screen
- extern unsigned sf_ScreenWidth; // Width of modifiable screen
-
- // center it
- int mw;
- mw = (nf_hicolor)?nf_width>>1:nf_width;
- x = (sf_ScreenWidth>>1) - (mw>>1);
- if(x<0) x = 0;
- y = (sf_ScreenHeight>>1) - (nf_height>>1);
- if(y<0) y = 0;
-
- ret = LnxDraw_Blit(mve_lpWin,nf_dds_cur,(uint32_t)x,(uint32_t)y,mw,nf_height);
- */
- uint8_t *tmp;
- tmp = nf_dds_prv;
- nf_dds_prv = nf_dds_cur;
- nf_dds_cur = tmp;
-}
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-//
-void nfHiColorDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-//
-void nfHiColorDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y,
- unsigned w, unsigned h);
-
-// Non-HiColor versions
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-//
-void nfDecomp(uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-void nfPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-void nfPkDecompH(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-void nfHPkDecomp(uint8_t *ops, uint8_t *comp, unsigned x, unsigned y, unsigned w, unsigned h);
-
-// Decompress into subsection of current buffer specified
-// by x,y,w,h in units of SWIDTHxSHEIGHT (8x8).
-// Chgs specifies which squares to update.
-// Parms are motion parms for squares to update.
-//
-void nfDecompChg(uint16_t *chgs, uint16_t *parms, uint8_t *comp, unsigned x, unsigned y, unsigned w,
- unsigned h);
-
-//---------------------------------------------------------------------
-// ShowFrame
-//------------
-
-// TODO:
-// Support for software cursor.
-// Issues & Considerations:
-// 1. Current code only deals with writing to screen, not reading it.
-// 2. To prevent flicker, cursor should be drawn into current buffer
-// before it is sent to screen, first saving area overwritten.
-// After current before is sent to screen, the area modified
-// by the cursor in the current buffer should be restored.
-// 3. Screen must also be updated in outside areas if cursor
-// appears there. This requires read/modify/write to screen,
-// because current buffer may not exist or be valid for area
-// of screen. Also, contents of screen must be saved so that
-// if next frame doesn't modify that area of screen, it can be
-// restored when mouse moves away.
-// In other words:
-// (a):
-// Save area on screen where mouse will go.
-// Draw mouse onto screen.
-// When mouse moves, restore previous contents of screen and
-// loop back to (a).
-// When screen is to be redrawn with video, draw mouse clipped
-// into buffer, saving previous contents. Draw video, then restore
-// buffer. Note that saving previous contents saves into same
-// area that was used when area under mouse was originally saved,
-// but it may only be a subrectangle.
-// Question: Should I implement VESA read from screen code?
-// Or work with caller to implement?
-// With caller:
-// Caller provides pointer to mouse image and save area buffers,
-// and screen location. Caller informs us when mouse changes
-// (position or contents). We deal with drawing mouse into internal
-// buffer and updating save area. Caller deals with drawing
-// mouse on screen and saving areas from screen. Color zero will
-// be assumed transparent. If old and new locations are within
-// area we are about to draw, caller need do nothing other than
-// call us (we can return a bool to let him know that). We can
-// call him to draw cursor just before showframe (whereas
-// call back from pausing would be just after showframe).
-// Without special support?
-// Everytime frame is shown, redraw mouse on screen, saving previous
-// contents. If mouse moves, restore previous contents and redraw.
-// Result will be a flickering mouse (mostly on, briefly off).
-
-static void (*sf_ShowFrame)(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned nf_hicolor) = NULL;
-
-unsigned sf_ResolutionHeight; // Height of screen
-unsigned sf_ResolutionWidth; // Width of screen
-unsigned sf_ScreenHeight; // Height of modifiable screen
-unsigned sf_ScreenWidth; // Width of modifiable screen
-// Private, see mveliba.asm :
-unsigned sf_LineWidth; // Distance between lines in memory
-unsigned sf_hicolor; // Hicolor mode (0:none,1:normal,2:swapped)
-
-// Banked screen parameters, Private, see mveliba.asm
-void *sf_SetBank;
-unsigned sf_WinGran;
-uint32_t sf_WinSize;
-unsigned sf_WinGranPerSize;
-//{sf_WriteWinPtr and sf_WriteWinLimit replace sf_WriteWinSeg, see mveliba.asm}
-uint8_t *sf_WriteWinPtr;
-uint8_t *sf_WriteWinLimit;
-unsigned sf_WriteWin;
-
-//
-static bool sf_auto = TRUE; // True if mode can be set from movie
- // (mode not specified by caller).
-static int sf_auto_mode = 0; // Current sf_auto mode.
-
-static void sfVGA(unsigned w, unsigned h, unsigned resw, unsigned resh);
-static void sfShowFrame(int dx, int dy, unsigned field);
-
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-void mve_ShowFrameField(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-
-void mve_ShowFrameFieldHi(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned field);
-
-// Restrictions/Assumptions:
-// 64K >= WinSize >= WinGran
-// WinSize % WinGran == 0
-// WinGran of 64K is represented by 0
-// SetBank is address of function with following protocol:
-// bh: 0=Set window, 1=Get Window
-// bl: Window number (0 or 1)
-// dx: Window position in video memory in units of WinGran.
-// on return, registers AX and DX are destroyed.
-void MVE_sfSVGA(unsigned w, unsigned h, unsigned LineWidth, unsigned WriteWin, uint8_t *WriteWinPtr,
- uint32_t WinSize, unsigned WinGran, void *SetBank, unsigned hicolor) {
- sf_ScreenWidth = w;
- sf_ScreenHeight = h;
- sf_ResolutionWidth = w;
- sf_ResolutionHeight = h;
- sf_LineWidth = LineWidth;
- if (opt_fastmode & 4)
- sf_LineWidth <<= 1;
- sf_WriteWin = WriteWin;
- sf_WinSize = WinSize;
- sf_WriteWinPtr = WriteWinPtr;
- sf_WriteWinLimit = sf_WriteWinPtr + sf_WinSize;
- sf_WinGran = WinGran;
- sf_SetBank = SetBank;
- if (WinGran)
- // Assumes WinGran divides evenly into WinSize.
- sf_WinGranPerSize = (unsigned)WinSize / WinGran;
- else
- // Assumes WinSize is also 64K.
- sf_WinGranPerSize = 1;
- sf_auto = FALSE;
- sf_hicolor = hicolor;
-}
-
-// QUESTION: Should sfShowFrame also take x,y,w,h as command args?
-// The issue is, will it always be true that area to update on
-// screen matches area updated in memory, since previous contents
-// of memory will be from two frames back, not one!
-// Answer: By having compressor compare previous screen to desired screen,
-// areas that are identical can be located. Only areas that change
-// need to be built in memory. Remaining areas will not be correct,
-// but can still be used for source data for next screen.
-// Therefore, additional x,y,w,h args are not needed.
-// However, should this prove to be wrong, a minor opcode variant
-// can always be added which supplies the additional arguments.
-
-static void sfShowFrame(int dx, int dy, unsigned field) {
- unsigned scaled_width = nf_width * 4 / opt_hscale_step;
- scaled_width = ((scaled_width - 12) & ~0xf) + 12; // Round down to a multiple of 16 + 12.
- opt_hscale_adj = nf_width - (scaled_width / 4 * opt_hscale_step);
-
- logLabel("StartShow");
- if (dx < 0)
- if (nf_hicolor)
- dx = (sf_ScreenWidth - (scaled_width >> 1)) >> 1;
- else
- dx = (sf_ScreenWidth - scaled_width) >> 1;
-
- if (nf_hicolor)
- dx <<= 1;
-
- if (dy < 0)
- if (opt_fastmode & 4) // HACK
- dy = (sf_ScreenHeight - nf_height * 2) >> 1;
- else
- dy = (sf_ScreenHeight - nf_height) >> 1;
-
- dx &= ~3; // Force to a multiple of 4 boundary for performance!
-
- if (opt_fastmode & 4) // HACK
- dy >>= 1;
-
- if (field)
- mve_ShowFrameField(nf_buf_cur, nf_width, nf_height, nf_new_x, nf_new_y, nf_new_w, nf_new_h, dx, dy, field);
- else if (opt_hscale_step != 4) {
- (*sf_ShowFrame)(nf_dds_cur, nf_width, nf_height, 0, nf_new_y, scaled_width, nf_new_h, dx, dy, nf_hicolor);
- } else
- (*sf_ShowFrame)(nf_dds_cur, nf_width, nf_height, nf_new_x, nf_new_y, nf_new_w, nf_new_h, dx, dy, nf_hicolor);
-
- logLabel("EndShow");
-}
-
-void MVE_sfCallbacks(void (*fn_ShowFrame)(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy,
- unsigned w, unsigned h, unsigned dstx, unsigned dsty, unsigned hicolor)) {
- sf_ShowFrame = fn_ShowFrame;
-}
-
-// Restriction: w must be a multiple of 4.
-// Strong Recommendation: sx and dstx should be multiples of 4.
-// dstx & dsty are deltas relative to sx & sy.
-// Field is a hack and should be removed. Instead, nfConfig
-// should specify interlace mode and cause linestep to be twice
-// sf_LineWidth. dstx/dsty should be made absolute to allow interlace
-// field to be determined by dst.
-// ON THE OTHER HAND -- All this makes user clipping quite complex...
-// A caller would probably like to deal in ordinary coordinates,
-// but then we still need 'field'.
-// Also note that when field is on, the actual height of the image
-// on the screen is 2*h alternate lines.
-//
-
-void mve_sfHiColorShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-
-void mve_sfShowFrameChg(bool prvbuf, unsigned x, unsigned y, unsigned w, unsigned h, uint16_t *chgs,
- unsigned dstx, unsigned dsty);
-
-static void sfShowFrameChg(int dx, int dy, uint16_t *chgs) { logLabel("StartShowChg"); }
-
-//---------------------------------------------------------------------
-// Palette Management
-//---------------------
-#ifdef __USE_X86_ASM__ // AH
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count) { __asm__("int $3"); }
-#else
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-#endif
-
-static void (*pal_SetPalette)(uint8_t *p, unsigned start, unsigned count) = MVE_SetPalette;
-
-uint8_t pal_tbl[3 * 256]; // Private, see mveliba.asm
-#if DBL_DBG
-uint8_t pal_tbl_old[3 * 256];
-#endif
-uint16_t pal15_tbl[256]; // Private, see mveliba.asm
-
-void MVE_palCallbacks(void (*fn_SetPalette)(uint8_t *p, unsigned start, unsigned count)) {
- pal_SetPalette = fn_SetPalette;
-}
-
-static void palSetPalette(unsigned start, unsigned count) {
- if (!nf_hicolor)
- (*pal_SetPalette)((uint8_t *)pal_tbl, start, count);
-}
-
-static void palClrPalette(unsigned start, unsigned count) {
- static uint8_t clr_pal_tbl[256 * 3];
- if (!nf_hicolor)
- (*pal_SetPalette)((uint8_t *)clr_pal_tbl, start, count);
-}
-
-// Old Synth: 0,21,6
-// 128,32,4
-//
-// New Synth: 129,21,6
-// 17,28,4
-//
-static void palMakeSynthPalette(int base_r, int range_r, int range_rb, int base_g, int range_g, int range_gb) {
- uint8_t(*SynthPal)[3] = (uint8_t(*)[3])pal_tbl;
- int i, j;
-
- for (i = 0; i < range_r; ++i)
- for (j = 0; j < range_rb; ++j) {
- int idx = base_r + i * range_rb + j;
- SynthPal[idx][0] = (char)(i * 63 / (range_r - 1));
- SynthPal[idx][1] = 0;
- SynthPal[idx][2] = (char)((j * 63 / (range_rb - 1)) * 5 / 8);
- }
-
- for (i = 0; i < range_g; ++i)
- for (j = 0; j < range_gb; ++j) {
- int idx = base_g + i * range_gb + j;
- SynthPal[idx][0] = 0;
- SynthPal[idx][1] = (char)(i * 63 / (range_g - 1));
- SynthPal[idx][2] = (char)((j * 63 / (range_gb - 1)) * 5 / 8);
- }
-}
-
-static void palLoadPalette(uint8_t *buf, unsigned start, unsigned count) {
-#if DBL_DBG
- memcpy(pal_tbl_old, pal_tbl, 256 * 3);
-#endif
- memcpy(&pal_tbl[start * 3], buf, count * 3);
-}
-
-// If at least 11 palette entries aren't changed, this is more compact
-// than uncompressed 256 entry palette.
-//
-void palLoadCompPalette(uint8_t *buf);
-
-//-----------------------------------------------------------------------
-// Graphics
-//----------
-
-void gfxVres(uint8_t misc, uint8_t *crtc);
-
-static void ForceVres2(uint8_t misc, unsigned vt, unsigned height, unsigned vrs /*vpos*/, unsigned _2t4,
- unsigned msl, unsigned bdr_b, unsigned bdr_t) {}
-
-void MVE_ForceVres350(void) {}
-
-void MVE_ForceVresHalf(void) {}
-
-// If auto is set, and this function is being called to change mode
-// for movie, be sure to turn auto back on after call!
-//
-unsigned MVE_gfxMode(int16_t mode) { return FALSE; }
-
-// Restore a text mode
-void MVE_gfxReset(void) {
- sf_auto = TRUE;
- sf_auto_mode = 0;
-}
-
-//----------------------------------------------------------------------
-// Movie Interpreter
-//--------------------
-
-static int (*rm_ctl)(void);
-
-static int rm_dx;
-static int rm_dy;
-static unsigned rm_track_bit;
-static uint8_t *rm_p;
-static unsigned rm_len;
-static bool rm_hold = FALSE;
-static bool rm_active = FALSE;
-static unsigned rm_FrameCount;
-static unsigned rm_FrameDropCount;
-
-void MVE_rmWindow(LnxWindow *wnd) { mve_lpWin = wnd; }
-
-void MVE_rmCallbacks(int (*fn_ctl)(void)) { rm_ctl = fn_ctl; }
-
-void MVE_rmFastMode(int mode) { opt_fastmode = mode; }
-
-void MVE_rmHScale(int hscale) {
- if (hscale == 3)
- opt_hscale_step = 3;
- else
- opt_hscale_step = 4;
-}
-
-void MVE_rmFrameCounts(unsigned *FrameCount, unsigned *FrameDropCount) {
- *FrameCount = rm_FrameCount;
- *FrameDropCount = rm_FrameDropCount;
-}
-
-int MVE_rmPrepMovie(int hFile, int dx, int dy, unsigned track) {
- if (!mve_lpWin)
- return MVE_ERR_LD;
-
- rm_dx = dx;
- rm_dy = dy;
-
- rm_track_bit = 1 << track;
- if (!rm_track_bit)
- rm_track_bit = 1;
-
- if (!ioReset(hFile)) {
- MVE_rmEndMovie();
- return MVE_ERR_BADFMT;
- }
-
- rm_p = ioNextRecord();
- rm_len = 0;
- if (!rm_p) {
- MVE_rmEndMovie();
- return MVE_ERR_IO;
- }
-
- rm_active = TRUE;
- rm_hold = FALSE;
- rm_FrameCount = 0;
- rm_FrameDropCount = 0;
- return 0;
-}
-
-int MVE_rmHoldMovie(void) {
- if (!rm_hold) {
- sndPause();
- rm_hold = TRUE;
- }
- syncWait();
- return 0;
-}
-
-int MVE_rmStepMovie(void) {
- unsigned len = rm_len;
- uint8_t *p = rm_p;
-
- int result;
-
- if (!rm_active)
- return MVE_ERR_PREP;
- if (rm_hold) {
- sndResume();
- rm_hold = FALSE;
- }
-
- for (;; p = ioNextRecord(), len = 0) {
- uint16_t *DecompChg_chgs = (uint16_t *)NULL;
- uint16_t *DecompChg_parms = (uint16_t *)NULL;
-
- if (!p) {
- result = MVE_ERR_IO;
-
- goto done;
- }
- for (;;) {
- mcmd_hdr hdr;
- p += len; // Advance past data of previous command
- hdr = *(mcmd_hdr *)p;
- hdr.len = INTEL_SHORT(hdr.len);
- p += sizeof(hdr);
- len = hdr.len;
- switch (hdr.major) {
- default:
- continue;
-
- case mcmd_end:
- result = MVE_ERR_EOF;
- goto movie_eof;
- case mcmd_next:
- break;
- case mcmd_syncInit: {
- marg_syncInit *arg = (marg_syncInit *)p;
- arg->period = INTEL_INT(arg->period);
- arg->wait_quanta = INTEL_SHORT(arg->wait_quanta);
- if (!syncInit(arg->period, arg->wait_quanta)) {
- result = MVE_ERR_SYNC;
- goto done;
- }
- continue;
- }
-
- case mcmd_sndConfigure: {
- marg_sndConfigure *arg = (marg_sndConfigure *)p;
- arg->rate = INTEL_SHORT(arg->rate);
- arg->frequency = INTEL_SHORT(arg->frequency);
- arg->buflen = INTEL_INT(arg->buflen);
- unsigned comp16 = hdr.minor >= 1 ? arg->comp16 : 0;
- // linux has a problem with bit fields in the middle of the struct
- unsigned buflen = *(unsigned *)(p + 6);
- if (hdr.minor == 0)
- buflen &= 0xFFFF;
- if (!sndConfigure(arg->rate, buflen, arg->stereo, arg->frequency, arg->bits16, comp16)) {
- result = MVE_ERR_SND;
- goto done;
- }
- continue;
- }
-
- case mcmd_sndSync: {
- sndSync();
- continue;
- }
-
- case mcmd_nfConfig: {
- marg_nfConfig *arg = (marg_nfConfig *)p;
- arg->wqty = INTEL_SHORT(arg->wqty);
- arg->hqty = INTEL_SHORT(arg->hqty);
- arg->fqty = INTEL_SHORT(arg->fqty);
- arg->hicolor = INTEL_SHORT(arg->hicolor);
- unsigned hicolor = hdr.minor >= 2 ? arg->hicolor : 0;
- if (!nfConfig(arg->wqty, arg->hqty, (hdr.minor >= 1 ? arg->fqty : 1), hicolor)) {
- result = MVE_ERR_NF;
- goto done;
- }
- // To handle interlace mode, we need the following:
- // A window width/height in addition to nf_width/height.
- // Window width/height should be used here and in centering
- // code in sfShowFrame.
- {
- unsigned scaled_width = nf_width * 4 / opt_hscale_step;
- scaled_width &= ~0xf; // Round down to a multiple of 16.
- if (nf_hicolor)
- scaled_width >>= 1; /*HACK*/
- if (scaled_width + (rm_dx < 0 ? 0 : rm_dx) > sf_ScreenWidth ||
- nf_height + (rm_dy < 0 ? 0 : rm_dy) > sf_ScreenHeight) {
- result = MVE_ERR_GFX_FIT;
- goto done;
- }
- }
- // NOTE: Eventually, change this to allow sf_hicolor when !nf_hicolor and
- // have show function convert from 256-color to hicolor format.
- // HiColor will also need to disable hardware palette changes and
- // maintain 15-bit software palette along with 24-bit palette.
- if (nf_hicolor && !sf_hicolor) {
- result = MVE_ERR_GFX_FIT;
- goto done;
- }
- continue;
- }
-
- case mcmd_nfDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->prev = INTEL_SHORT(arg->prev);
- arg->iframe = INTEL_SHORT(arg->iframe);
- arg->x = INTEL_SHORT(arg->x);
- arg->y = INTEL_SHORT(arg->y);
- arg->w = INTEL_SHORT(arg->w);
- arg->h = INTEL_SHORT(arg->h);
- if (arg->advance)
- nfAdvance();
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
- nfDecomp(MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- nfUnlock();
- continue;
- }
-
- case mcmd_sfShowFrame: {
- unsigned field = 0;
- marg_sfShowFrame *arg = (marg_sfShowFrame *)p;
- arg->pal_start = INTEL_SHORT(arg->pal_start);
- arg->pal_count = INTEL_SHORT(arg->pal_count);
- arg->field = INTEL_SHORT(arg->field);
-
- ++rm_FrameCount;
-
- if (hdr.minor >= 1)
- field = arg->field;
-
- if (arg->pal_count && !DecompChg_chgs && !sf_hicolor)
- palClrPalette(arg->pal_start, arg->pal_count);
- else {
- palSetPalette(arg->pal_start, arg->pal_count);
- }
-
- if (DecompChg_chgs)
- sfShowFrameChg(rm_dx, rm_dy, DecompChg_chgs);
- else if (sync_late && arg->pal_count == 0) {
- sync_FrameDropped = TRUE;
- ++rm_FrameDropCount;
- } else {
- sfShowFrame(rm_dx, rm_dy, field);
- }
-
- if (arg->pal_count && !DecompChg_chgs && !sf_hicolor) {
- palSetPalette(arg->pal_start, arg->pal_count);
- }
-
- goto FrameDone;
- }
-
- case mcmd_sndAdd:
- case mcmd_sndSilence: {
- marg_sndAdd *arg = (marg_sndAdd *)p;
- arg->iframe = INTEL_SHORT(arg->iframe);
- arg->TrackMask = INTEL_SHORT(arg->TrackMask);
- arg->qty = INTEL_SHORT(arg->qty);
- if (arg->TrackMask & rm_track_bit)
- sndAdd((hdr.major == mcmd_sndAdd ? MCMD_DATA(arg) : (uint8_t *)NULL), arg->qty);
- continue;
- }
-
- case mcmd_gfxMode: {
- marg_gfxMode *arg = (marg_gfxMode *)p;
- arg->minw = INTEL_SHORT(arg->minw);
- arg->minh = INTEL_SHORT(arg->minh);
- arg->mode = INTEL_SHORT(arg->mode);
- if (sf_auto) {
- int16_t mode = arg->mode;
- if (opt_fastmode && (opt_fastmode & 4) == 0)
- mode |= 0x8000;
- if (sf_auto_mode != mode)
- if (!MVE_gfxMode(mode)) {
- result = MVE_ERR_GFX_FAIL;
- goto done;
- }
- sf_auto = TRUE;
- sf_auto_mode = mode;
- }
- continue;
- }
-
- case mcmd_palMakeSynthPalette: {
- marg_palMakeSynthPalette *arg = (marg_palMakeSynthPalette *)p;
- palMakeSynthPalette(arg->base_r, arg->range_r, arg->range_rb, arg->base_g, arg->range_g, arg->range_gb);
- continue;
- }
-
- case mcmd_palLoadPalette: {
- marg_palLoadPalette *arg = (marg_palLoadPalette *)p;
- arg->start = INTEL_SHORT(arg->start);
- arg->count = INTEL_SHORT(arg->count);
- palLoadPalette(MCMD_DATA(arg), arg->start, arg->count);
- continue;
- }
-
- case mcmd_palLoadCompPalette: {
- palLoadCompPalette(p);
- continue;
- }
-
- case mcmd_nfChanges: {
- DecompChg_chgs = (uint16_t *)p;
- continue;
- }
- case mcmd_nfParms: {
- DecompChg_parms = (uint16_t *)p;
- continue;
- }
- case mcmd_nfDecompChg: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->prev = INTEL_SHORT(arg->prev);
- arg->iframe = INTEL_SHORT(arg->iframe);
- arg->x = INTEL_SHORT(arg->x);
- arg->y = INTEL_SHORT(arg->y);
- arg->w = INTEL_SHORT(arg->w);
- arg->h = INTEL_SHORT(arg->h);
- if (arg->advance)
- nfAdvance();
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
- nfDecompChg(DecompChg_chgs, DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- nfUnlock();
- continue;
- }
- case mcmd_nfPkDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->prev = INTEL_SHORT(arg->prev);
- arg->iframe = INTEL_SHORT(arg->iframe);
- arg->x = INTEL_SHORT(arg->x);
- arg->y = INTEL_SHORT(arg->y);
- arg->w = INTEL_SHORT(arg->w);
- arg->h = INTEL_SHORT(arg->h);
- if (hdr.minor < 3) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
-
- if (arg->advance)
- nfAdvance();
-
- if (nf_hicolor) {
- if (opt_fastmode) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
-
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
-
- nfHPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
-
- nfUnlock();
- } else if ((opt_fastmode & 3) == 1) {
- // Half mode (half height, even lines only)
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
-
- nfPkDecompH((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
-
- nfUnlock();
- } else if ((opt_fastmode & 3) == 2) {
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
- // Support for dithered mode disabled...
- // so just use half mode instead
- nfPkDecompH((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- nfUnlock();
- } else // opt_fastmode==0
- {
- // Normal mode
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
-
- nfPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
-
- nfUnlock();
- }
- continue;
- }
- }
- break;
- }
- }
-done: // Error
- MVE_rmEndMovie();
-
-movie_eof: // End of movie
- return result;
-
-FrameDone: // Done with frame, return to caller for between frame processing
- rm_p = p;
- rm_len = len;
- return 0;
-}
-
-void MVE_rmEndMovie(void) {
- if (rm_active) {
- syncWait();
- syncRelease();
- sndReset();
- rm_active = FALSE;
- }
-}
-
-int MVE_RunMovie(int hFile, int dx, int dy, unsigned track) {
- int result;
- result = MVE_rmPrepMovie(hFile, dx, dy, track);
- while (!result) {
- result = MVE_rmStepMovie();
- logLabel("StartUser");
- while (!result) {
- result = (*rm_ctl)();
- if (result != MVE_CTL_HOLD)
- break;
- result = MVE_rmHoldMovie();
- }
- logLabel("EndUser");
- }
- MVE_rmEndMovie();
- return (result == MVE_ERR_EOF) ? 0 : result;
-}
-
-int MVE_RunMovieContinue(int hFile, int dx, int dy, unsigned track) {
- int result;
- result = MVE_rmPrepMovie(hFile, dx, dy, track);
- while (!result) {
- result = MVE_rmStepMovie();
- logLabel("StartUser");
- while (!result) {
- result = (*rm_ctl)();
- if (result != MVE_CTL_HOLD)
- break;
- result = MVE_rmHoldMovie();
- }
- logLabel("EndUser");
- }
- // Continue version doesn't call MVE_rmEndMovie;
- return (result == MVE_ERR_EOF) ? 0 : result;
-}
-
-void MVE_ReleaseMem(void) {
- MVE_rmEndMovie();
- ioRelease();
- sndRelease();
- nfRelease();
-}
-
-//----------------------------------------------------------------------
-
-const char *MVE_strerror(int code) {
- char *errors[] = {"Movie aborted with special code",
- "Movie aborted",
- "Movie completed normally", // 0
- "Movie completed normally", //-1
- "File I/O error or Unable to allocate I/O buffers",
- "Unable to create timer",
- "Unable to allocate sound buffers",
- "Unable to allocate video buffers",
- "Insufficient screen resolution for movie",
- "Unable to setup graphics mode used by movie",
- "Invalid movie file",
- "Incorrect screen color mode",
- "StepMovie() without PrepMovie()",
- "Unable to initialize Linux Draw System",
- "Unable to lock window surface",
- "Unknown movie error code"};
-
- if (code >= MVE_CTL_EXIT + 1)
- code = MVE_CTL_EXIT + 1;
- if (code <= MVE_ERR_LAST - 1)
- code = MVE_ERR_LAST - 1;
- return errors[MVE_CTL_EXIT + 1 - code];
-}
-
-//----------------------------------------------------------------------
-// Frame Reader
-//--------------
-
-struct MVE_frStreamRec {
- int (*callback)(unsigned op, unsigned subop, void *buf);
-
- // I/O Stream state
- unsigned (*io_read)(int handle, void *buf, unsigned count);
- MemRec io_mem_buf;
- int io_handle;
- ioHdrRec io_next_hdr;
- uint8_t *p;
- unsigned len;
-
- // NextFrame working storage
- bool nf_memory_mode;
- uint8_t *nf_dds_cur;
- uint8_t *nf_dds_prv;
-
- MemRec nf_mem_buf1;
- MemRec nf_mem_buf2;
- uint8_t *nf_buf_cur;
- uint8_t *nf_buf_prv;
- // NextFrame parameters
- uint8_t nf_wqty; // (width/SWIDTH)
- uint8_t nf_hqty; // (height/SHEIGHT)
- uint8_t nf_fqty; // Number of fields
- unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
- // NextFrame derived quantities
- unsigned nf_width; // wqty * SWIDTH
- unsigned nf_height; // hqty * SHEIGHT;
- unsigned nf_new_line; // width - SWIDTH
- unsigned nf_new_row0; // SHEIGHT*width*2-width
- unsigned nf_back_right; // (SHEIGHT-1)*width
- // Palette
- uint8_t pal_tbl[3 * 256];
- unsigned pal_start, pal_count;
-
-};
-
-static void frLoad(MVE_frStream frs) {
- io_read = frs->io_read;
- io_mem_buf = frs->io_mem_buf;
- io_handle = frs->io_handle;
- io_next_hdr = frs->io_next_hdr;
-
- nf_memory_mode = frs->nf_memory_mode;
- nf_dds_cur = frs->nf_dds_cur;
- nf_dds_prv = frs->nf_dds_prv;
- nf_mem_buf1 = frs->nf_mem_buf1;
- nf_mem_buf2 = frs->nf_mem_buf2;
- nf_buf_cur = frs->nf_buf_cur;
- nf_buf_prv = frs->nf_buf_prv;
- nf_wqty = frs->nf_wqty;
- nf_hqty = frs->nf_hqty;
- nf_fqty = frs->nf_fqty;
- nf_hicolor = frs->nf_hicolor;
- nf_width = frs->nf_width;
- nf_height = frs->nf_height;
- nf_new_line = frs->nf_new_line;
- nf_new_row0 = frs->nf_new_row0;
- nf_back_right = frs->nf_back_right;
-}
-
-static void frSave(MVE_frStream frs) {
- frs->io_read = io_read;
- frs->io_mem_buf = io_mem_buf;
- frs->io_handle = io_handle;
- frs->io_next_hdr = io_next_hdr;
-
- frs->nf_memory_mode = nf_memory_mode;
- frs->nf_dds_cur = nf_dds_cur;
- frs->nf_dds_prv = nf_dds_prv;
- frs->nf_mem_buf1 = nf_mem_buf1;
- frs->nf_mem_buf2 = nf_mem_buf2;
- frs->nf_buf_cur = nf_buf_cur;
- frs->nf_buf_prv = nf_buf_prv;
- frs->nf_wqty = nf_wqty;
- frs->nf_hqty = nf_hqty;
- frs->nf_fqty = nf_fqty;
- frs->nf_hicolor = nf_hicolor;
- frs->nf_width = nf_width;
- frs->nf_height = nf_height;
- frs->nf_new_line = nf_new_line;
- frs->nf_new_row0 = nf_new_row0;
- frs->nf_back_right = nf_back_right;
-}
-
-MVE_frStream MVE_frOpen(unsigned (*fn_read)(int handle, void *buf, unsigned count), int handle,
- int (*fr_callback)(unsigned, unsigned, void *buf)) {
- MVE_frStream frs;
- MVE_frStreamRec save;
- bool failed = FALSE;
-
- if (!mve_lpWin || !mem_alloc)
- return (MVE_frStream)NULL;
-
- frs = (struct MVE_frStreamRec *)(*mem_alloc)(sizeof(*frs));
- if (!frs)
- return frs;
- memset(frs, 0, sizeof(*frs));
-
- frSave(&save);
- frLoad(frs);
-
- MVE_ioCallbacks(fn_read);
- failed = !ioReset(handle);
- frs->callback = fr_callback;
-
- if (!failed) {
- frs->p = ioNextRecord();
- frs->len = 0;
- }
-
- frSave(frs);
- frLoad(&save);
-
- if (failed) {
- MVE_frClose(frs);
- return (MVE_frStream)NULL;
- }
-
- return frs;
-}
-
-int MVE_frGet(MVE_frStream frs, uint8_t **pBuf, unsigned *width, unsigned *height) {
- MVE_frStreamRec save;
- uint8_t *p;
- unsigned len;
- int result = 0;
-
- frSave(&save);
- frLoad(frs);
- p = frs->p;
- len = frs->len;
-
- for (;; p = ioNextRecord(), len = 0) {
- uint16_t *DecompChg_parms = (uint16_t *)NULL;
-
- if (!p) {
- result = MVE_ERR_IO;
- goto done;
- }
- for (;;) {
- mcmd_hdr hdr;
- p += len; // Advance past data of previous command
- hdr = *(mcmd_hdr *)p;
- hdr.len = INTEL_SHORT(hdr.len);
- p += sizeof(hdr);
- len = hdr.len;
- switch (hdr.major) {
- default:
- if (frs->callback) {
- result = (*frs->callback)(hdr.major, hdr.minor, p);
- if (result)
- goto done;
- }
- continue;
-
- case mcmd_end:
- result = MVE_ERR_EOF;
- goto done;
-
- case mcmd_next:
- break;
-
- case mcmd_nfConfig: {
- marg_nfConfig *arg = (marg_nfConfig *)p;
- arg->wqty = INTEL_SHORT(arg->wqty);
- arg->hqty = INTEL_SHORT(arg->hqty);
- arg->fqty = INTEL_SHORT(arg->fqty);
- arg->hicolor = INTEL_SHORT(arg->hicolor);
- unsigned hicolor = hdr.minor >= 2 ? arg->hicolor : 0;
- unsigned opt_fastmode_save = opt_fastmode;
- opt_fastmode = 0;
- if (hicolor || (hdr.minor >= 1 && arg->fqty != 1) ||
- !nfConfig(arg->wqty, arg->hqty, (hdr.minor >= 1) ? arg->fqty : 1, hicolor)) {
- opt_fastmode = opt_fastmode_save;
- result = MVE_ERR_NF;
- goto done;
- }
- opt_fastmode = opt_fastmode_save;
- continue;
- }
-
- case mcmd_sfShowFrame: {
- unsigned field = 0;
- marg_sfShowFrame *arg = (marg_sfShowFrame *)p;
- arg->pal_start = INTEL_SHORT(arg->pal_start);
- arg->pal_count = INTEL_SHORT(arg->pal_count);
- if (hdr.minor >= 1)
- field = arg->field;
- if (field) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- *pBuf = nf_dds_cur;
- *width = nf_width;
- *height = nf_height;
- frs->pal_start = arg->pal_start;
- frs->pal_count = arg->pal_count;
- goto done;
- }
-
- case mcmd_nfParms: {
- DecompChg_parms = (uint16_t *)p;
- continue;
- }
-
- case mcmd_nfPkDecomp: {
- marg_nfDecomp *arg = (marg_nfDecomp *)p;
- arg->prev = INTEL_SHORT(arg->prev);
- arg->iframe = INTEL_SHORT(arg->iframe);
- arg->x = INTEL_SHORT(arg->x);
- arg->y = INTEL_SHORT(arg->y);
- arg->w = INTEL_SHORT(arg->w);
- arg->h = INTEL_SHORT(arg->h);
- if (hdr.minor < 3) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- if (arg->advance)
- nfAdvance();
- if (nf_hicolor) {
- result = MVE_ERR_BADFMT;
- goto done;
- }
- nfPkConfig();
- if (!nfLock()) {
- result = MVE_ERR_LOST;
- goto done;
- }
- nfPkDecomp((uint8_t *)DecompChg_parms, MCMD_DATA(arg), arg->x, arg->y, arg->w, arg->h);
- nfUnlock();
- continue;
- }
- case mcmd_palLoadPalette: {
- marg_palLoadPalette *arg = (marg_palLoadPalette *)p;
- arg->start = INTEL_SHORT(arg->start);
- arg->count = INTEL_SHORT(arg->count);
- memcpy(&frs->pal_tbl[arg->start * 3], MCMD_DATA(arg), arg->count * 3);
- continue;
- }
- }
- break;
- }
- }
-
-done:
- frSave(frs);
- frs->p = p;
- frs->len = len;
- frLoad(&save);
- nfPkConfig();
- if (result)
- frs->pal_start = frs->pal_count = 0;
- return result;
-}
-
-void MVE_frPal(MVE_frStream frs, uint8_t **p, unsigned *start, unsigned *count) {
- *p = frs->pal_tbl;
- *start = frs->pal_start;
- *count = frs->pal_count;
-}
-
-void MVE_frClose(MVE_frStream frs) {
- MVE_frStreamRec save;
-
- frSave(&save);
- frLoad(frs);
-
- ioRelease();
- nfRelease();
-
- frLoad(&save);
- if (mem_free)
- (*mem_free)(frs);
-}
diff --git a/lnxmvelib/mvelibl.h b/lnxmvelib/mvelibl.h
deleted file mode 100644
index 7b705a39..00000000
--- a/lnxmvelib/mvelibl.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
-** mvelibl.h
-**
-** Interplay Movie File (MVE) Player
-** Library Definitions (32-Bit Linux Version)
-** Written by Paul Allen Edelstein, Interplay Productions.
-** Partial Linux port by Jeff Slutter, Outrage Entertainment.
-**
-** (c) 1997 Interplay Productions. All Rights Reserved.
-** This file is confidential and consists of proprietary information
-** of Interplay Productions. This file and associated libraries
-** may not, in whole or in part, be disclosed to third parties,
-** incorporated into any software product which is not being created
-** for Interplay Productions, copied or duplicated in any form,
-** without the prior written permission of Interplay Productions.
-** Further, you may not reverse engineer, decompile or otherwise
-** attempt to derive source code of this material.
-*/
-
-#ifndef _MVELIB_H_INCLUDED
-
-#include "linux/lnxdsound.h"
-#include "linux/lnxdraw.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Call this function to provide hooks into your memory management.
- */
-typedef void *(mve_cb_alloc)(unsigned size);
-typedef void(mve_cb_free)(void *p);
-void MVE_memCallbacks(mve_cb_alloc *fn_alloc, mve_cb_free *fn_free);
-
-/* This function remains from the DOS version of mvelib.
-** It allows you to provide a preallocated buffer for file I/O,
-** but under Windows there's no real point to doing this.
-*/
-void MVE_memIO(void *p, unsigned size);
-
-/* Call this function to provide hook into your file io.
- */
-typedef unsigned mve_cb_read(int handle, void *buf, unsigned count);
-void MVE_ioCallbacks(mve_cb_read *fn_read);
-
-/* Call this function to provide hook into your digital sound driver.
-** Call with NULL if no sound support is available (default).
-*/
-void MVE_sndInit(LnxSoundDevice *lpDS);
-
-/* Volume controls.
-** These functions are equivalent to the IDirectSoundBuffer
-** SetVolume and SetPan functions. They take effect immediately
-** and do NOT reset when a new movie starts.
-** Volume ranges from 0 (0 db, no volume change) to -10,000 (-100db, essentially silent).
-** Pan ranges from -10,000 (left full volume, right -100db), thru 0 (both full),
-** thru 10,000 (left -100db, right full volume).
-** The default value for volume and pan is zero.
-*/
-void MVE_dsbSetVolume(int32_t lVolume);
-void MVE_dsbSetPan(int32_t lPan);
-
-/* Only call this function to configure software to work with a Super VGA
-** mode if you do not have VESA support.
-**
-** Restrictions/Assumptions:
-** 64K >= WinSize >= WinGran
-** WinSize % WinGran == 0
-** WinGran of 64K is represented by 0
-** SetBank is address of function with following protocol:
-** bh: 0=Set window, 1=Get Window
-** bl: Window number (0 or 1)
-** dx: Window position in video memory in units of WinGran.
-** on return, registers AX and DX are destroyed.
-**
-** Hicolor is 0 for 8-bit color, 1 for 15-bit rgb color, 2
-** for byte swapped 15-bit rgb color.
-*/
-
-/* Note: 16-bit WriteWinSeg replaced with 32-bit WriteWinPtr */
-
-/* The functionality of the following function is reduced in the Windows
-** version of the player. Call it as follows:
-** MVE_sfSVGA(w,h,w,0,NULL,0,0,NULL,hicolor)
-** where w and h are the width and height of your window,
-** and hicolor is a boolean which indicates if the screen
-** is operating in hi color, rather than 8-bit paletted color.
-** Under windows, the information provided by this function
-** is just used for window centering and for determining
-** how and when to do palette callbacks.
-*/
-void MVE_sfSVGA(unsigned w, unsigned h, unsigned LineWidth, unsigned WriteWin, uint8_t *WriteWinPtr,
- uint32_t WinSize, unsigned WinGran, void *SetBank, unsigned hicolor);
-
-/* This function alters the display from 640x480 or 640x400 to 640x350 resolution.
- */
-void MVE_ForceVres350(void);
-
-/* This function alters the display from 640x480/400/350 to
-** 640x240/200/175.
-*/
-void MVE_ForceVresHalf(void);
-
-/* **NOTE** There still need to be calls to restore original screen resolution
-** after using MVE_ForceVres350() or MVE_ForceVresHalf()!
-*/
-
-/* Only call this function to either
-** 1. Replace method of copying frame to screen (perhaps for a nonstandard
-** screen format).
-** 2. Wrap your own code around the transfer of frame to screen
-** or modify which portions of the screen are updated.
-** This function replaces calls to the default MVE_ShowFrame function
-** with calls to your function, which can itself call MVE_ShowFrame.
-*/
-typedef void mve_cb_ShowFrame(uint8_t *buf, unsigned bufw, unsigned bufh, unsigned sx, unsigned sy, unsigned w,
- unsigned h, unsigned dstx, unsigned dsty, unsigned hicolor);
-void MVE_sfCallbacks(mve_cb_ShowFrame *fn_ShowFrame);
-
-typedef void mve_cb_SetPalette(uint8_t *p, unsigned start, unsigned count);
-void MVE_palCallbacks(mve_cb_SetPalette *fn_SetPalette);
-
-/* I'm pulling this, since it removes a C/C++ name mangling conflict - AH
-void MVE_SetPalette(uint8_t *p, unsigned start, unsigned count);
-*/
-
-/* Configure the software for a graphics mode, optionally setting the
-** display to that mode (see the MVE_GFX_xxx constants defined below).
-*/
-unsigned MVE_gfxMode(int16_t mode);
-
-/* Reset the screen to text mode (usually done before exiting a program).
- */
-void MVE_gfxReset(void);
-
-/* Set line for split screen graphics */
-/* {Use vbe_SetDisplayStart(x,y) to set vid buf for upper screen} */
-void MVE_gfxSetSplit(unsigned line);
-
-/* Setup double buffering */
-void MVE_gfxSetDoubleBuffer(unsigned y1, unsigned y2, unsigned vis);
-
-/* Get double buffering state */
-void MVE_gfxGetDoubleBuffer(unsigned *vis_y, unsigned *hid_y);
-
-/* Enable double buffering for auto screen modes */
-void MVE_sfAutoDoubleBuffer(unsigned on);
-
-/* Wait for video retrace off (0) or on (1) */
-void MVE_gfxWaitRetrace(unsigned state);
-
-/*---------------------------------------------*/
-/* Establish link to a graphics window
- */
-void MVE_rmWindow(LnxWindow *wnd);
-
-/*---------------------------------------------*/
-
-/* Establish callback for user control of movie playback.
- */
-typedef int mve_cb_ctl(void);
-void MVE_rmCallbacks(mve_cb_ctl *fn_ctl);
-
-/* Specify playback fastmode option (default is MVE_RM_NORMAL).
- */
-#define MVE_RM_NORMAL 0 /* Normal playback */
-#define MVE_RM_HALF 1 /* Half height (even lines only) */
-#define MVE_RM_DITHERED 2 /* Half height (dither between lines) */
-#define MVE_RM_HALF_2 5 /* Full height, even lines only */
-#define MVE_RM_DITHERED_2 6 /* Full height, dither, even lines only */
-
-void MVE_rmFastMode(int mode);
-
-/* Specifying horizontal magnification:
-** 3: 4/3 horizontal magnification
-** 4: normal
-*/
-void MVE_rmHScale(int hscale);
-
-/* Get frame count and number of dropped frames from last movie played.
- */
-void MVE_rmFrameCounts(unsigned *FrameCount, unsigned *FrameDropCount);
-
-/* Dump timing statistics (if enabled).
- */
-void MVE_logDumpStats(void);
-
-/* Run a compressed movie by reading data starting at the current
-** position in the file specified by handle hFile.
-** The movie window is displaced by dx,dy from the upper left hand corner
-** or is centered if dx,dy is -1,-1.
-** track specifies which audio track to play (usually 0 for a single
-** audio track).
-**
-** Returns an error/result code.
-**
-** Memory may be dynamically allocated while movie runs.
-*/
-int MVE_RunMovie(int hFile, int dx, int dy, unsigned track);
-
-/* MVE_RunMovieContinue is the same as MVE_RunMovie except that it does not
-** automatically call MVE_rmEndMovie(). This may improve the smoothness
-** of immediately playing another movie afterwards.
-*/
-int MVE_RunMovieContinue(int hFile, int dx, int dy, unsigned track);
-
-/*
-** Alternative to using MVE_RunMovie() and MVE_rmCallbacks().
-** Call MVE_rmPrepMovie() to prepare movie for playing.
-** Call MVE_rmStepMovie() to display next frame of movie until nonzero
-** result is returned (MVE_ERR_EOF for no next frame or some other error).
-** Call MVE_rmHoldMovie() to hold on current frame (and pause audio).
-** Call MVE_rmEndMovie() to abort movie.
-** All functions except MVE_rmEndMovie() return an error code.
-*/
-int MVE_rmPrepMovie(int hFile, int dx, int dy, unsigned track);
-int MVE_rmStepMovie(void);
-int MVE_rmHoldMovie(void);
-void MVE_rmEndMovie(void);
-
-/* Frame Reader Streams
-** This is a special interface to the movie system which
-** allows a movie file to be opened as a stream from which
-** its frames may be retrieved. Audio and timing information
-** are ignored. For 256-color screen applications, palette
-** information is also typically ignored, and movies with a common
-** predefined palette are used. However, for hi-color screen
-** applications, an interface to obtain palette information has
-** been provided. This system is intended for use by video sprites
-** played off of the hard drive or out of memory.
-*/
-struct _MVE_frstream *MVE_frStream;
-
-/* MVE_frOpen
-** Before calling this function, be sure to call MVE_memCallbacks()
-** and MVE_rmDirectDraw().
-**
-** fn_read specifies a file reader similar to the one
-** used by MVE_ioCallbacks().
-** handle specifies a file handle for an already opened
-** movie file. It is used by the file reader and is similar
-** to hFile argument used by MVE_RunMovie() and MVE_rmPrepMovie().
-** fr_callback is normally NULL, but can be used to supply
-** a handler for user data which has been interleaved into
-** the movie stream.
-**
-** If the movie file is invalid or the call otherwise fails,
-** NULL is returned.
-*/
-MVE_frStream MVE_frOpen(unsigned (*fn_read)(int handle, void *buf, unsigned count), int handle,
- int (*fr_callback)(unsigned op, unsigned subop, void *buf));
-
-/* MVE_frGet
-** Returns the next frame from the specified frame reader stream
-** a nonzero error code {the same codes as returned by MVE_RunMovie()
-** and MVE_rmStepMovie()}.
-** If successful, MVE_frGet(frs, &buf, &w, &h) returns a pointer
-** to a direct draw surface containing the frame in buf,
-** and its width and height in w and h.
-*/
-int MVE_frGet(MVE_frStream frs, uint8_t **pBuf, unsigned *width, unsigned *height);
-
-/* MVE_frPal
-** After each successful call to MVE_frGet(), this call may be used to
-** obtain corresponding palette information. It returns a pointer to the
-** entire current palette for the frame, and the subportion of the palette
-** which has changed this frame is identified by start and count (they will
-** both be zero on frames for which the palette has not changed).
-**
-** Paltbl points to 256*3 bytes of 6-bit r,g,b triples.
-** Start ranges from 0 to 255. Count from 0 to 256.
-**
-** These conventions are similar to those used by the palette callback arguments
-** with the standard player interface, except that this interface requires
-** polling each frame instead, and must be passed pointers to the variables where
-** the values will be returned.
-**
-*/
-void MVE_frPal(MVE_frStream frs, uint8_t **pPaltbl, unsigned *pStart, unsigned *pCount);
-
-/* MVE_frClose
-** Closes the specified Frame Reader Stream frs.
-** Frees all storage associated with the stream.
-** The specified frs must not be used after this call.
-** Note that the open file handle specified in MVE_frOpen() is
-** not closed by this call...that is the caller's responsibility.
-*/
-void MVE_frClose(MVE_frStream frs);
-
-/* Release any memory dynamically allocated by MVE_RunMovie.
- */
-void MVE_ReleaseMem(void);
-
-/* Return string corresponding to MVE_RunMovie result code.
- */
-const char *MVE_strerror(int code);
-
-/* RunMovie callback control code and result codes.
-** Codes > 1 are user defined.
-*/
-
-#define MVE_CTL_HOLD -1 /* Returned by rmCtl() to hold current frame */
-#define MVE_CTL_EXIT 1 /* Returned by rmCtl() to end movie */
-
-#define MVE_ERR_EOF -1 /* Returned by StepMovie() for end of movie */
-#define MVE_ERR_IO -2 /* File I/O error or unable to alloc memory. */
-#define MVE_ERR_SYNC -3 /* Timer error. */
-#define MVE_ERR_SND -4 /* Unable to allocate memory for sound */
-#define MVE_ERR_NF -5 /* Unable to allocate memory for video */
-#define MVE_ERR_GFX_FIT -6 /* Screen size too small for movie */
-#define MVE_ERR_GFX_FAIL -7 /* Failed to set desired graphics mode */
-#define MVE_ERR_BADFMT -8 /* Not a MVE file or unacceptable version */
-#define MVE_ERR_GFX_CLR -9 /* Incorrect screen color mode */
-#define MVE_ERR_PREP -10 /* StepMovie() without PrepMovie() */
-#define MVE_ERR_LD -11 /* Unable to initialize LinuxDraw */
-#define MVE_ERR_LOST -12 /* Direct Draw Surface Lost */
-
-#define MVE_ERR_LAST -12
-
-#define _MVELIB_H_INCLUDED
-#ifdef __cplusplus
-};
-#endif
-#endif
diff --git a/lnxmvelib/mvelibla.asm b/lnxmvelib/mvelibla.asm
deleted file mode 100644
index d43fb1ab..00000000
--- a/lnxmvelib/mvelibla.asm
+++ /dev/null
@@ -1,3632 +0,0 @@
-; mvelibwa.c
-;
-; Interplay Movie (MVE) File Player Library (32-Bit Win95 Version)
-; Assembly Language Components
-; Written by Paul Allen Edelstein
-;
-; (c) 1997 Interplay Productions. All Rights Reserved.
-; This file is confidential and consists of proprietary information
-; of Interplay Productions. This file and associated libraries
-; may not, in whole or in part, be disclosed to third parties,
-; incorporated into any software product which is not being created
-; for Interplay Productions, copied or duplicated in any form,
-; without the prior written permission of Interplay Productions.
-; Further, you may not reverse engineer, decompile or otherwise
-; attempt to derive source code of this material.
-;
-
-;;--- Options ---
-
-ONLYNEW equ 0 ; For debug, disables motion comp
-LOGGING equ 0 ; Log timing statistics
-PARTIAL equ 1 ; Support for partial updates
-PKDATA equ 1 ; Support for packed data
-HICOLOR equ 1 ; Support for HiColor
-INTERP equ 0 ; Interpolated squares
- ; 0:none (4x4x8), 1:generic dither,
- ; 2:direction dither, 3:blend
-COMPOPS equ 1 ; Compressed opcode table
-SCALING equ 1 ; Scaling support
-DECOMPD equ 0 ; Support for dithered half vert res
-TRANS16 equ 1 ; Support for translating 16-bit rgb format
-
-;;--- Constants ---
-
-; Width and height of sections in pixels.
-SWIDTH equ 8
-SHEIGHT equ 8
-
-LOG2_SWIDTH equ 3
-LOG2_SHEIGHT equ 3
-
-;;---
-
-EXTERN pal_tbl ;:BYTE ; unsigned char pal_tbl[3*256];
-EXTERN pal15_tbl ;:WORD ; unsigned short pal15_tbl[256];
-EXTERN nf_trans16_lo
-EXTERN nf_trans16_hi
-EXTERN snd_8to16 ;: WORD ; short snd_8to16[256];
-
-EXTERN nf_buf_cur ;: PTRBYTE ; unsigned char* nf_buf_cur;
-EXTERN nf_buf_prv ;: PTRBYTE ; unsigned char* nf_buf_prv;
-
-;; NextFrame parameters
-EXTERN nf_wqty ;: BYTE ;unsigned char nf_wqty; // (width/SWIDTH)
-EXTERN nf_hqty ;: BYTE ;unsigned char nf_hqty; // (height/SHEIGHT)
-EXTERN nf_fqty ;: BYTE ;unsigned char nf_fqty; // Number of fields
-EXTERN nf_hicolor ;: DWORD ;unsigned nf_hicolor; // HiColor (0:none,1:normal,2:swapped)
-
-;;
-EXTERN nf_width ;: DWORD ;unsigned nf_width; // wqty * SWIDTH
-EXTERN nf_height ;: DWORD ;unsigned nf_height; // hqty * SHEIGHT;
-EXTERN nf_new_line ;: DWORD ;unsigned nf_new_line; // width - SWIDTH
-EXTERN nf_new_row0 ;: DWORD ;unsigned nf_new_row0; // SHEIGHT*width*2-width
-EXTERN nf_back_right ;: DWORD ;unsigned nf_back_right; // (SHEIGHT-1)*width
-
-;; Frame parameters
-;; Portion of current frame which has been updated
-;; and needs to be sent to screen.
-;;
-EXTERN nf_new_x ;: DWORD ;unsigned nf_new_x;
-EXTERN nf_new_y ;: DWORD ;unsigned nf_new_y;
-EXTERN nf_new_w ;: DWORD ;unsigned nf_new_w;
-EXTERN nf_new_h ;: DWORD ;unsigned nf_new_h;
-
-; These are all of our global parameter-passing variables - AH
-extern sndDecompM16_dst
-extern sndDecompM16_src
-extern sndDecompM16_len
-extern sndDecompM16_prev
-extern sndDecompM16_return
-extern sndDecompS16_dst
-extern sndDecompS16_src
-extern sndDecompS16_len
-extern sndDecompS16_prev
-extern sndDecompS16_return
-extern nfHPkDecomp_ops
-extern nfHPkDecomp_comp
-extern nfHPkDecomp_x
-extern nfHPkDecomp_y
-extern nfHPkDecomp_w
-extern nfHPkDecomp_h
-
-; This is the global array of pointers to memory locations that
-; need to be self-modified - AH
-extern global_unlock_memory_pointers
-
-; These are our functions that the C stubs call - AH
-global _asm_sndDecompM16
-global _asm_sndDecompS16
-global _asm_nfPkConfig
-global _asm_nfHPkDecomp
-
-; This is our memory "unlock" function for the self-mofiying asm - AH
-global _asm_selfModify
-
-SECTION .data
-
- db "(c) 1997 Interplay Productions. All Rights Reserved.\n"
- db "This file is confidential and consists of proprietary information\n"
- db "of Interplay Productions. This file and associated libraries\n"
- db "may not, in whole or in part, be disclosed to third parties,\n"
- db "incorporated into any software product which is not being created\n"
- db "for Interplay Productions, copied or duplicated in any form,\n"
- db "without the prior written permission of Interplay Productions.\n"
- db "Further, you may not reverse engineer, decompile or otherwise\n"
- db "attempt to derive source code of this material.\n",0
-
- tbuf dd 0 ;LOCAL tbuf : PTRBYTE
- new_row dd 0 ;LOCAL new_row :DWORD
- DiffBufPtrs dd 0 ;LOCAL DiffBufPtrs :DWORD
-
- nfpk_back_right dd 0 ;LOCAL nfpk_back_right : DWORD
- wcnt dd 0 ;LOCAL wcnt :DWORD
- bcomp dd 0 ;LOCAL bcomp :PTRBYTE
-
-nfhpk_OpTbl: ;label dword
- dd nf0 ;dword offset nf0 ; Prev Same (0)
- dd nf1 ;dword offset nf1 ; No change (and copied to screen) (0)
- dd nf2 ;dword offset nf2 ; Near shift from older part of current buf (1)
- dd nf3 ;dword offset nf3 ; Near shift from newer part of current buf (1)
- dd nf4 ;dword offset nf4 ; Near shift from previous buffer (1)
- dd nf5 ;dword offset nf5 ; Far shift from previous buffer (2)
- dd nf6 ;dword offset nf6 ; Far shift from current buffer (2)
- ; [Or if COMPOPS, run of no changes (0)]
- dd nf7 ;dword offset nf7 ; 8x8x1 (10 bytes) or low 4x4x1 (4 bytes)
- dd nf8 ;dword offset nf8 ; 2x2 4x4x1 (16 bytes) or 2x1 4x8x1 (12 bytes) or 1x2 8x4x1 (12 bytes)
- dd nf9 ;dword offset nf9 ; 8x8x2 (20 bytes) or low 4x4x2 (8 bytes) or
- ; low 4x8x2 (12 bytes) or low 8x4x2 (12 bytes)
- dd nf10 ;dword offset nf10 ; 2x2 4x4x2 (32 bytes) or 2x1 4x8x2 (24 bytes) or 1x2 4x8x2 (24 bytes)
- dd nf11 ;dword offset nf11 ; 8x8x8 (64 bytes)
- dd nf12 ;dword offset nf12 ; low 4x4x8 (16 bytes)
- dd nf13 ;dword offset nf13 ; 2x2 4x4x0 (ie 2x2x8) (4 bytes)
- dd nf14 ;dword offset nf14 ; 8x8x0 (1 byte)
- dd nf15 ;dword offset nf15 ; mix 8x8x0 (2 bytes)
-
-; signed 8-bit y * nf_width
-nfpk_ShiftY times 256 dd 0
-
-; Constant tables
-
-; 8-bit -8:7 x nf_width + -8:7
-nfpk_ShiftP1
-
-%assign y -8
-%rep 16 ;16
- %assign x -8
- %rep 16 ;16
- db x,y
- %assign x x+1
- %endrep
-%assign y y+1
-%endrep
-
-; 8-bit to right and below in roughly 0:14*nf_width + -14:14 (-3 cases)
-; negative is
-; 8-bit to left and above in roughly -14:0*nf_width + -14:14 (-3 cases)
-nfpk_ShiftP2
-
-%assign y 0
-%rep 8 ;8
- %assign x 8
- %rep 7 ;7
- db x,y
- %assign x x+1
- %endrep
-%assign y y+1
-%endrep
-
-%assign y 8
-%rep 6 ;6
-
- %assign x -14
- %rep 14 ;14
- db x,y
- %assign x x+1
- %endrep
-
- %assign x 0
- %rep 15 ;15
- db x,y
- %assign x x+1
- %endrep
-
-%assign y y+1
-%endrep
-
-%assign x -14
-%rep 14 ;14
- db x,14
-%assign x x+1
-%endrep
-
-%assign x 0
-%rep 12 ;12
- db x,14
-%assign x x+1
-%endrep
-
-; Constant tables
-nfhpk_mov4l ;LABEL DWORD
-; low 4x1 in 8x1 (patch +1)
-; mov eax, ebx/ecx
-db 0c0h+3, 0c0h+3, 0c0h+3, 0c0h+3
-db 0c0h+1, 0c0h+3, 0c0h+3, 0c0h+3
-db 0c0h+3, 0c0h+1, 0c0h+3, 0c0h+3
-db 0c0h+1, 0c0h+1, 0c0h+3, 0c0h+3
-db 0c0h+3, 0c0h+3, 0c0h+1, 0c0h+3
-db 0c0h+1, 0c0h+3, 0c0h+1, 0c0h+3
-db 0c0h+3, 0c0h+1, 0c0h+1, 0c0h+3
-db 0c0h+1, 0c0h+1, 0c0h+1, 0c0h+3
-db 0c0h+3, 0c0h+3, 0c0h+3, 0c0h+1
-db 0c0h+1, 0c0h+3, 0c0h+3, 0c0h+1
-db 0c0h+3, 0c0h+1, 0c0h+3, 0c0h+1
-db 0c0h+1, 0c0h+1, 0c0h+3, 0c0h+1
-db 0c0h+3, 0c0h+3, 0c0h+1, 0c0h+1
-db 0c0h+1, 0c0h+3, 0c0h+1, 0c0h+1
-db 0c0h+3, 0c0h+1, 0c0h+1, 0c0h+1
-db 0c0h+1, 0c0h+1, 0c0h+1, 0c0h+1
-
-nfhpk_mov8 ;LABEL DWORD
-; 8x1 (each two bits select a pair of colors in a reg)
-; low 4x2 in 8x2 (each two bits select a duplicated color in reg)
-; (patch +1)
-; mov ds:[edi+0/4/8/12], ebx/edx/ecx/ebp
-; Note: Patched code specifies mov [ebp+0]... instead
-; of mov [edi+0]... to insure that 8-bit offsets are
-; used by the assembler even for offset of zero.
-
-%assign m4 24
-%rep 4
- %assign m3 24
- %rep 4
- %assign m2 24
- %rep 4
- %assign m1 24
- %rep 4
- db m1+047h,m2+047h,m3+047h,m4+047h
- %if (m1 == 24)
- %assign m1 16
- %elif (m1 == 16)
- %assign m1 8
- %elif (m1 == 8)
- %assign m1 40
- %endif
- %endrep
- %if (m2 == 24)
- %assign m2 16
- %elif (m2 == 16)
- %assign m2 8
- %elif (m2 == 8)
- %assign m2 40
- %endif
- %endrep
- %if (m3 == 24)
- %assign m3 16
- %elif (m3 == 16)
- %assign m3 8
- %elif (m3 == 8)
- %assign m3 40
- %endif
- %endrep
- %if (m4 == 24)
- %assign m4 16
- %elif (m4 == 16)
- %assign m4 8
- %elif (m4 == 8)
- %assign m4 40
- %endif
-%endrep
-
-nfhpk_mov4
-
-; 4x2 (patch +2)
-; mov ax, bx/dx/cx/bp
-; low 4x2 in 8x2 (patch +1)
-; mov eax, ebx/edx/ecx/ebp
-%assign m4 0c3h
-%rep 4
- %assign m3 0c3h
- %rep 4
- %assign m2 0c3h
- %rep 4
- %assign m1 0c3h
- %rep 4
- db m1,m2,m3,m4
- %if (m1 == 0c3h)
- %assign m1 0c2h
- %elif (m1 == 0c2h)
- %assign m1 0c1h
- %elif (m1 == 0c1h)
- %assign m1 0c5h
- %endif
- %endrep
- %if (m2 == 0c3h)
- %assign m2 0c2h
- %elif (m2 == 0c2h)
- %assign m2 0c1h
- %elif (m2 == 0c1h)
- %assign m2 0c5h
- %endif
- %endrep
- %if (m3 == 0c3h)
- %assign m3 0c2h
- %elif (m3 == 0c2h)
- %assign m3 0c1h
- %elif (m3 == 0c1h)
- %assign m3 0c5h
- %endif
- %endrep
- %if (m4 == 0c3h)
- %assign m4 0c2h
- %elif (m4 == 0c2h)
- %assign m4 0c1h
- %elif (m4 == 0c1h)
- %assign m4 0c5h
- %endif
-%endrep
-
-
-SEGMENT .text
-
-_asm_selfModify:
- pushf
- ; Move the pointer to the start of the pointer array into eax
- mov eax, global_unlock_memory_pointers
-
- ; Load unlock addresses from _asm_nfHPkDecomp
- mov dword [eax], nf7_0
- mov dword [eax + 4], nf8_0
- mov dword [eax + 8], nf9_0
- mov dword [eax + 12], nf10_0
- mov dword [eax + 16], nf23_0
- mov dword [eax + 20], nf24_0
- mov dword [eax + 24], nf25_0
- mov dword [eax + 28], nf26_0
- mov dword [eax + 32], nf42_0
-
- popf
- ret
-
-;--------------------------------------------------------------------
-; Sound Management
-;--------------------
-
-;unsigned sndDecompM16(unsigned short *dst, const unsigned char *src,
-; unsigned len, unsigned prev);
-;
-;Decompresses a mono stream containing len samples
-;(src is len bytes, dst is len*2 bytes)
-;prev is the previous decompression state or zero.
-;Returns new decompression state.
-;
-_asm_sndDecompM16: ; PROC USES ESI EDI EBX, \
-; dst:PTRWORD, src:PTRBYTE, len:DWORD, prev:DWORD
- mov eax, [sndDecompM16_prev]
-
- mov ecx, [sndDecompM16_len]
- jecxz done
-
- mov esi, [sndDecompM16_src]
- mov edi, [sndDecompM16_dst]
-
- xor ebx, ebx
-
-lp: mov bl, byte [esi]
- add esi, 1
- add ax, word [snd_8to16 + ebx*2]
- mov word [edi], ax
- add edi, 2
- dec ecx
- jnz lp
-
-done:
- ; Store our return value - AH
- mov dword [sndDecompM16_return], eax
-
- ret
-;sndDecompM16 ENDP
-
-;unsigned sndDecompS16(unsigned short *dst, const unsigned char *src,
-; unsigned len, unsigned prev);
-;
-;Decompresses a stereo stream containing len samples
-;(src is len*2 bytes, dst is len*4 bytes)
-;prev is the previous decompression state or zero
-; (It encodes the 16-bit states of the two stereo channels
-; in its low and high order 16-bit halves.)
-;Returns new decompression state.
-;
-_asm_sndDecompS16: ; PROC USES ESI EDI EBX, \
-; dst:PTRWORD, src:PTRBYTE, len:DWORD, prev:DWORD
- movzx eax, word [sndDecompS16_prev]
- movzx edx, word [sndDecompS16_prev+2]
-
- mov ecx, [sndDecompS16_len]
- jecxz Sdone
-
- mov esi, [sndDecompS16_src]
- mov edi, [sndDecompS16_dst]
-
- xor ebx, ebx
-
-Slp: mov bl, byte [esi]
- add esi, 1
- add ax, word [snd_8to16 + ebx*2]
- mov word [edi], ax
- add edi, 2
-
- mov bl, byte [esi]
- add esi, 1
- add dx, word [snd_8to16 + ebx*2]
- mov word [edi], dx
- add edi, 2
-
- dec ecx
- jnz Slp
-
-Sdone: shl edx, 16
- or eax, edx
-
- ; Store our return value - AH
- mov dword [sndDecompS16_return], eax
- ret
-
-;sndDecompS16 ENDP
-
-;--------------------------------------------------------------------
-; NextFrame (Video Decompression)
-;----------------------------------
-
-%macro NF_DECOMP_INIT 1 ;HI_COLOR_FLAG: REQ
-
- mov eax, [nf_buf_prv] ;br ; DiffBufPtrs = nf_buf_prv - nf_buf_cur
- sub eax, [nf_buf_cur] ;br
- mov [DiffBufPtrs], eax
-
- xor ebx, ebx ; ebx = nf_fqty (convert to 32-bits)
- mov bl, [nf_fqty]
-
- mov eax, [nfHPkDecomp_x] ;br ; nf_new_x = x*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+%1 ;HI_COLOR_FLAG
- mov [nf_new_x], eax
-
- mov eax, [nfHPkDecomp_w] ;br ; nf_new_w = w*SWIDTH*2^HI_COLOR_FLAG;
- shl eax, LOG2_SWIDTH+%1 ;HI_COLOR_FLAG
- mov [nf_new_w], eax
-
- mov eax, [nfHPkDecomp_y] ;br ; nf_new_y = y*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov [nf_new_y], eax
-
- mov eax, [nfHPkDecomp_h] ;br ; nf_new_h = h*nf_fqty*SHEIGHT;
- shl eax, LOG2_SHEIGHT
- mul ebx ;nf_fqty
- mov [nf_new_h], eax
-
- mov eax, [nf_new_row0] ;br ; new_row = nf_new_row0 - nf_new_w;
- sub eax, [nf_new_w] ;br
- mov [new_row], eax
-
- ;; Move to correct place in current buffer
- mov eax, [nf_buf_cur] ;br ; tbuf = nf_buf_cur
- mov [tbuf], eax
-; %if (nfHPkDecomp_x || nfHPkDecomp_y) ; if (x||y)
- ; cmp, jnz, jz and labels are mine - AH
- cmp dword [nfHPkDecomp_x], 0
- jne before
- cmp dword [nfHPkDecomp_y], 0
- je after
-before:
- mov eax, [nf_new_y] ;br ; tbuf += nf_new_y*nf_width + nf_new_x;
- mul dword [nf_width] ; Added dword - AH
- add eax, [nf_new_x] ;br
- add [tbuf], eax
-after:
-; %endif
-
-%endmacro ; DECOMP_INIT
-
-;----------------------------------------------------------------------
-
-; nfPkConfig initializes tables used by nfPkDecomp
-; which are dependent on screen size.
-_asm_nfPkConfig: ; PROC USES ESI EDI EBX
-
- ; Build ShiftY table
- ;
- lea edi, [nfpk_ShiftY]
- mov ebx, [nf_width]
-
- mov eax, 0
- mov ecx, 128
-lp1: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp1
-
- mov eax, ebx
- shl eax, 7
- neg eax
- mov ecx, 128
-lp2: mov [edi], eax
- add edi,4
- add eax,ebx
- dec ecx
- jne lp2
-
- ret
-;nfPkConfig ENDP
-
-%macro Trans16_3 3 ; dst:req, idx:req, mask
- xor eax, eax
- mov al, [%2]
- mov %1, [nf_trans16_lo + eax*2]
- xor eax, eax
- mov al, [%2+1]
- or %1, [nf_trans16_hi + eax*2]
-%endmacro
-
-%macro Trans16 2 ; dst:req, idx:req
- xor eax, eax
- mov al, [%2]
- mov %1, [nf_trans16_lo + eax*2]
- xor eax, eax
- mov al, [%2+1]
- or %1, [nf_trans16_hi + eax*2]
-%endmacro
-
-_asm_nfHPkDecomp: ; PROC USES ESI EDI EBX, \
-; ops:PTRBYTE, comp:PTRBYTE, \
-; x:DWORD, y:DWORD, w:DWORD, h:DWORD
-
- NF_DECOMP_INIT 1
-
- mov eax, [nf_back_right] ;br
- sub eax, SWIDTH*2
- mov [nfpk_back_right], eax
-
- mov esi, [nfHPkDecomp_comp] ;br
- mov edi, [tbuf]
-
- xor eax, eax
- mov ax, [esi]
- add eax, esi
- mov [bcomp], eax
- add esi, 2
-
-nf_StartRow:
- mov eax, [nfHPkDecomp_w] ;br
- shr eax, 1
- mov [wcnt],eax
- ALIGN 4
-nf_NextPair:
- dec dword [wcnt] ; Added dword - AH
- js nf_NextRow
- mov ebx, [nfHPkDecomp_ops] ; br
- mov al, [ebx]
- inc ebx
- mov [nfHPkDecomp_ops], ebx
-
- xor ebx, ebx
- mov bl, al
- shr bl, 4
- and eax, 0Fh
- push dword nf_NextPair ; Added dword on these two - AH
- push dword [nfhpk_OpTbl + ebx*4]
- jmp [nfhpk_OpTbl + eax*4]
-
-nf_NextRow:
- add edi, [new_row] ;br
- dec dword [nfHPkDecomp_h] ; Added dword - AH
- jnz nf_StartRow
-
- ret
-
-;----------------------------------------
- ALIGN 4
-nf0: ; No change from previous buffer
- mov eax, [DiffBufPtrs] ; br
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf1: ; No change (and copied to screen)
-
- add edi, SWIDTH*2
- retn
-
-;----------------------------------------
- ALIGN 4
-nf2: ; Near shift from older part of current buffer
- xor eax, eax
- mov ebx, [bcomp] ; br
- inc dword [bcomp] ; Added dword - AH
- mov al, [ebx]
- mov ax, [nfpk_ShiftP2 + eax*2]
-nf_xyc_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24-1
- add eax, [nfpk_ShiftY + ebx*4]
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-nf3: ; Near shift from newer part of current buffer
- xor eax, eax
- mov ebx, [bcomp] ; br
- inc dword [bcomp] ; Added dword - AH
- mov al, [ebx]
- mov ax, [nfpk_ShiftP2 + eax*2]
- neg al
- neg ah
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf4: ; Near shift from previous buffer
- xor eax, eax
- mov ebx, [bcomp] ; br
- inc dword [bcomp] ; Added dword - AH
- mov al, [ebx]
- mov ax, [nfpk_ShiftP1 + eax*2]
- jmp nf_xyp_shift
-
-;----------------------------------------
- ALIGN 4
-nf5: ; Far shift from previous buffer
- mov ax, [esi]
- add esi, 2
-nf_xyp_shift:
- xor ebx, ebx
- mov bl, ah
- shl eax, 24
- sar eax, 24-1
- add eax, [nfpk_ShiftY + ebx*4]
- add eax, [DiffBufPtrs] ; br
- jmp nf_shift
-
-;----------------------------------------
- ALIGN 4
-
-nf6: ; Far shift from current buffer
- mov ax, [esi]
- add esi, 2
- jmp nf_xyc_shift
-
-;----------------------------------------
- ALIGN 4
-nf_shift:
-
- mov ebx, esi ; save esi
- lea esi, [edi+eax]
- mov edx, [nf_width]
-
- %rep 7
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- mov eax, [esi+8]
- mov [edi+8], eax
- mov eax, [esi+12]
- mov [edi+12], eax
- add esi, edx
- add edi, edx
- %endrep
- mov eax, [esi]
- mov [edi], eax
- mov eax, [esi+4]
- mov [edi+4], eax
- mov eax, [esi+8]
- mov [edi+8], eax
- mov eax, [esi+12]
- mov [edi+12], eax
-
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
- mov esi, ebx ; restore esi
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf7: ; 8x8x1 (12 bytes)
- test word [esi], 08000h
- jnz near nf23
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov8]
- lea edx, [nf7_11+1] ; Removed byte ds:- AH
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_11-nf7_11)], bl
- mov [edx+(nf7_12-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_13-nf7_11)], bl
- mov [edx+(nf7_14-nf7_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_21-nf7_11)], bl
- mov [edx+(nf7_22-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_23-nf7_11)], bl
- mov [edx+(nf7_24-nf7_11)], bh
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_31-nf7_11)], bl
- mov [edx+(nf7_32-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_33-nf7_11)], bl
- mov [edx+(nf7_34-nf7_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_41-nf7_11)], bl
- mov [edx+(nf7_42-nf7_11)], bh
- shr ebx, 16
- mov [edx+(nf7_43-nf7_11)], bl
- mov [edx+(nf7_44-nf7_11)], bh
-
- lea edx, [edx+(nf7_51-nf7_11)]
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_51-nf7_51)], bl
- mov [edx+(nf7_52-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_53-nf7_51)], bl
- mov [edx+(nf7_54-nf7_51)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_61-nf7_51)], bl
- mov [edx+(nf7_62-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_63-nf7_51)], bl
- mov [edx+(nf7_64-nf7_51)], bh
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_71-nf7_51)], bl
- mov [edx+(nf7_72-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_73-nf7_51)], bl
- mov [edx+(nf7_74-nf7_51)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf7_81-nf7_51)], bl
- mov [edx+(nf7_82-nf7_51)], bh
- shr ebx, 16
- mov [edx+(nf7_83-nf7_51)], bl
- mov [edx+(nf7_84-nf7_51)], bh
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi
-
- mov esi,[nf_width]
- mov edx, ecx
-
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf7_0 ; flush prefetch
- ALIGN 4
-nf7_0:
-nf7_11: mov [ebp+0], ebx
-nf7_12: mov [ebp+4], ebx
-nf7_13: mov [ebp+8], ebx
-nf7_14: mov [ebp+12], ebx
- add edi, esi
-
-nf7_21: mov [ebp+0], ebx
-nf7_22: mov [ebp+4], ebx
-nf7_23: mov [ebp+8], ebx
-nf7_24: mov [ebp+12], ebx
- add edi, esi
-
-nf7_31: mov [ebp+0], ebx
-nf7_32: mov [ebp+4], ebx
-nf7_33: mov [ebp+8], ebx
-nf7_34: mov [ebp+12], ebx
- add edi, esi
-
-nf7_41: mov [ebp+0], ebx
-nf7_42: mov [ebp+4], ebx
-nf7_43: mov [ebp+8], ebx
-nf7_44: mov [ebp+12], ebx
- add edi, esi
-
-nf7_51: mov [ebp+0], ebx
-nf7_52: mov [ebp+4], ebx
-nf7_53: mov [ebp+8], ebx
-nf7_54: mov [ebp+12], ebx
- add edi, esi
-
-nf7_61: mov [ebp+0], ebx
-nf7_62: mov [ebp+4], ebx
-nf7_63: mov [ebp+8], ebx
-nf7_64: mov [ebp+12], ebx
- add edi, esi
-
-nf7_71: mov [ebp+0], ebx
-nf7_72: mov [ebp+4], ebx
-nf7_73: mov [ebp+8], ebx
-nf7_74: mov [ebp+12], ebx
- add edi, esi
-
-nf7_81: mov [ebp+0], ebx
-nf7_82: mov [ebp+4], ebx
-nf7_83: mov [ebp+8], ebx
-nf7_84: mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf7+16
-nf23: ; low 4x4x1 (6 bytes)
-
- xor eax, eax
- lea ecx, [nfhpk_mov4l]
- lea edx, [nf23_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+4]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_11-nf23_11)], bl
- mov [edx+(nf23_12-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_13-nf23_11)], bl
- mov [edx+(nf23_14-nf23_11)], bh
-
- mov al, [esi+4]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_31-nf23_11)], bl
- mov [edx+(nf23_32-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_33-nf23_11)], bl
- mov [edx+(nf23_34-nf23_11)], bh
-
-
- mov al, [esi+5]
- and al, 0fH
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_51-nf23_11)], bl
- mov [edx+(nf23_52-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_53-nf23_11)], bl
- mov [edx+(nf23_54-nf23_11)], bh
-
- mov al, [esi+5]
- shr al, 4
- mov ebx, [ecx+eax*4]
- mov [edx+(nf23_71-nf23_11)], bl
- mov [edx+(nf23_72-nf23_11)], bh
- shr ebx, 16
- mov [edx+(nf23_73-nf23_11)], bl
- mov [edx+(nf23_74-nf23_11)], bh
-
- mov edx, [nf_width]
-
- ; load ebx,ecx with 00,11 color combinations
-
- Trans16_3 cx, esi, 1
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-
- jmp nf23_0 ; flush prefetch
- ALIGN 4
-nf23_0:
-
-nf23_11:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_12:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_13:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_14:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_31:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_32:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_33:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_34:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_51:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_52:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_53:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_54:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- lea edi, [edi+edx*2]
-
-nf23_71:mov eax, ebx
- mov [edi], eax
- mov [edi+edx], eax
-nf23_72:mov eax, ebx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-nf23_73:mov eax, ebx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-nf23_74:mov eax, ebx
- mov [edi+12], eax
- mov [edi+edx+12], eax
- add edi, edx
-
- sub edi, [nfpk_back_right]
- add esi, 6
- retn
-
-;----------------------------------------
- ALIGN 4
-nf8: ; 2x2 4x4x1 (24 bytes)
- test word [esi], 08000h
- jnz near nf24
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov8]
- lea edx, [nf8_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_11-nf8_11)], bl
- mov [edx+(nf8_12-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_13-nf8_11)], bl
- mov [edx+(nf8_14-nf8_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_21-nf8_11)], bl
- mov [edx+(nf8_22-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_23-nf8_11)], bl
- mov [edx+(nf8_24-nf8_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_31-nf8_11)], bl
- mov [edx+(nf8_32-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_33-nf8_11)], bl
- mov [edx+(nf8_34-nf8_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_41-nf8_11)], bl
- mov [edx+(nf8_42-nf8_11)], bh
- shr ebx, 16
- mov [edx+(nf8_43-nf8_11)], bl
- mov [edx+(nf8_44-nf8_11)], bh
-
- add edx, nf8_51-nf8_11
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_51-nf8_51)], bl
- mov [edx+(nf8_52-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_53-nf8_51)], bl
- mov [edx+(nf8_54-nf8_51)], bh
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_61-nf8_51)], bl
- mov [edx+(nf8_62-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_63-nf8_51)], bl
- mov [edx+(nf8_64-nf8_51)], bh
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_71-nf8_51)], bl
- mov [edx+(nf8_72-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_73-nf8_51)], bl
- mov [edx+(nf8_74-nf8_51)], bh
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf8_81-nf8_51)], bl
- mov [edx+(nf8_82-nf8_51)], bh
- shr ebx, 16
- mov [edx+(nf8_83-nf8_51)], bl
- mov [edx+(nf8_84-nf8_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-
- Trans16 cx, esi+18+2
- shl ecx, 16
- Trans16 cx, esi+18
- push ecx
-
- Trans16 cx, esi+12+2
- shl ecx, 16
- Trans16 cx, esi+12
- push ecx
-
- Trans16 cx, esi+6+2
- shl ecx, 16
- Trans16 cx, esi+6
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16 cx, esi
-
- mov esi,[nf_width]
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf8_0 ; flush prefetch
- ALIGN 4
-nf8_0:
-nf8_11: mov [ebp+0], ebx
-nf8_12: mov [ebp+4], ebx
- add edi, esi
-nf8_13: mov [ebp+0], ebx
-nf8_14: mov [ebp+4], ebx
- add edi, esi
-
-nf8_21: mov [ebp+0], ebx
-nf8_22: mov [ebp+4], ebx
- add edi, esi
-nf8_23: mov [ebp+0], ebx
-nf8_24: mov [ebp+4], ebx
- add edi, esi
-
- pop ecx
-
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-
-nf8_31: mov [ebp+0], ebx
-nf8_32: mov [ebp+4], ebx
- add edi, esi
-nf8_33: mov [ebp+0], ebx
-nf8_34: mov [ebp+4], ebx
- add edi, esi
-
-nf8_41: mov [ebp+0], ebx
-nf8_42: mov [ebp+4], ebx
- add edi, esi
-nf8_43: mov [ebp+0], ebx
-nf8_44: mov [ebp+4], ebx
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- pop ecx
-
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf8_51: mov [ebp+0], ebx
-nf8_52: mov [ebp+4], ebx
- add edi, esi
-nf8_53: mov [ebp+0], ebx
-nf8_54: mov [ebp+4], ebx
- add edi, esi
-
-nf8_61: mov [ebp+0], ebx
-nf8_62: mov [ebp+4], ebx
- add edi, esi
-nf8_63: mov [ebp+0], ebx
-nf8_64: mov [ebp+4], ebx
- add edi, esi
-
- pop ecx
-
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf8_71: mov [ebp+0], ebx
-nf8_72: mov [ebp+4], ebx
- add edi, esi
-nf8_73: mov [ebp+0], ebx
-nf8_74: mov [ebp+4], ebx
- add edi, esi
-
-nf8_81: mov [ebp+0], ebx
-nf8_82: mov [ebp+4], ebx
- add edi, esi
-nf8_83: mov [ebp+0], ebx
-nf8_84: mov [ebp+4], ebx
-
- pop esi
- pop ebp
- add esi, 24
- sub edi, 8
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+16
-nf24: ; 2x1 4x8x1 (16 bytes)
-
- test word [esi+8], 08000h
- jnz near nf40
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov8]
- lea edx, [nf24_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_11-nf24_11)], bl
- mov [edx+(nf24_12-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_13-nf24_11)], bl
- mov [edx+(nf24_14-nf24_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_21-nf24_11)], bl
- mov [edx+(nf24_22-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_23-nf24_11)], bl
- mov [edx+(nf24_24-nf24_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_31-nf24_11)], bl
- mov [edx+(nf24_32-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_33-nf24_11)], bl
- mov [edx+(nf24_34-nf24_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_41-nf24_11)], bl
- mov [edx+(nf24_42-nf24_11)], bh
- shr ebx, 16
- mov [edx+(nf24_43-nf24_11)], bl
- mov [edx+(nf24_44-nf24_11)], bh
-
- add edx, nf24_51-nf24_11
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_51-nf24_51)], bl
- mov [edx+(nf24_52-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_53-nf24_51)], bl
- mov [edx+(nf24_54-nf24_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_61-nf24_51)], bl
- mov [edx+(nf24_62-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_63-nf24_51)], bl
- mov [edx+(nf24_64-nf24_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_71-nf24_51)], bl
- mov [edx+(nf24_72-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_73-nf24_51)], bl
- mov [edx+(nf24_74-nf24_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf24_81-nf24_51)], bl
- mov [edx+(nf24_82-nf24_51)], bh
- shr ebx, 16
- mov [edx+(nf24_83-nf24_51)], bl
- mov [edx+(nf24_84-nf24_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-
- Trans16 cx, esi+8+2
- shl ecx, 16
- Trans16 cx, esi+8
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16_3 cx, esi, 1
-
- mov esi,[nf_width]
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf24_0 ; flush prefetch
- ALIGN 4
-nf24_0:
-
-nf24_11:mov [ebp+0], ebx
-nf24_12:mov [ebp+4], ebx
- add edi, esi
-nf24_13:mov [ebp+0], ebx
-nf24_14:mov [ebp+4], ebx
- add edi, esi
-
-nf24_21:mov [ebp+0], ebx
-nf24_22:mov [ebp+4], ebx
- add edi, esi
-nf24_23:mov [ebp+0], ebx
-nf24_24:mov [ebp+4], ebx
- add edi, esi
-
-nf24_31:mov [ebp+0], ebx
-nf24_32:mov [ebp+4], ebx
- add edi, esi
-nf24_33:mov [ebp+0], ebx
-nf24_34:mov [ebp+4], ebx
- add edi, esi
-
-nf24_41:mov [ebp+0], ebx
-nf24_42:mov [ebp+4], ebx
- add edi, esi
-nf24_43:mov [ebp+0], ebx
-nf24_44:mov [ebp+4], ebx
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- pop ecx
-
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf24_51:mov [ebp+0], ebx
-nf24_52:mov [ebp+4], ebx
- add edi, esi
-nf24_53:mov [ebp+0], ebx
-nf24_54:mov [ebp+4], ebx
- add edi, esi
-
-nf24_61:mov [ebp+0], ebx
-nf24_62:mov [ebp+4], ebx
- add edi, esi
-nf24_63:mov [ebp+0], ebx
-nf24_64:mov [ebp+4], ebx
- add edi, esi
-
-nf24_71:mov [ebp+0], ebx
-nf24_72:mov [ebp+4], ebx
- add edi, esi
-nf24_73:mov [ebp+0], ebx
-nf24_74:mov [ebp+4], ebx
- add edi, esi
-
-nf24_81:mov [ebp+0], ebx
-nf24_82:mov [ebp+4], ebx
- add edi, esi
-nf24_83:mov [ebp+0], ebx
-nf24_84:mov [ebp+4], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, 8
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf8+32
-nf40: ; 1x2 8x4x1 (16 bytes)
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov8]
- lea edx, [nf40_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+4]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_11-nf40_11)], bl
- mov [edx+(nf40_12-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_13-nf40_11)], bl
- mov [edx+(nf40_14-nf40_11)], bh
-
- mov al, [esi+5]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_21-nf40_11)], bl
- mov [edx+(nf40_22-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_23-nf40_11)], bl
- mov [edx+(nf40_24-nf40_11)], bh
-
-
- mov al, [esi+6]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_31-nf40_11)], bl
- mov [edx+(nf40_32-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_33-nf40_11)], bl
- mov [edx+(nf40_34-nf40_11)], bh
-
- mov al, [esi+7]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_41-nf40_11)], bl
- mov [edx+(nf40_42-nf40_11)], bh
- shr ebx, 16
- mov [edx+(nf40_43-nf40_11)], bl
- mov [edx+(nf40_44-nf40_11)], bh
-
- add edx, nf40_51-nf40_11
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_51-nf40_51)], bl
- mov [edx+(nf40_52-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_53-nf40_51)], bl
- mov [edx+(nf40_54-nf40_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_61-nf40_51)], bl
- mov [edx+(nf40_62-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_63-nf40_51)], bl
- mov [edx+(nf40_64-nf40_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_71-nf40_51)], bl
- mov [edx+(nf40_72-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_73-nf40_51)], bl
- mov [edx+(nf40_74-nf40_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf40_81-nf40_51)], bl
- mov [edx+(nf40_82-nf40_51)], bh
- shr ebx, 16
- mov [edx+(nf40_83-nf40_51)], bl
- mov [edx+(nf40_84-nf40_51)], bh
-
-
- push ebp
- push esi
- ; load ebx,edx,ecx,ebp with 00,01,10,11 color combinations
- ; (note that bits are read least significant first).
-
- Trans16 cx, esi+8+2
- shl ecx, 16
- Trans16_3 cx, esi+8, 1
- push ecx
-
- Trans16 cx, esi+2
- shl ecx, 16
- Trans16_3 cx, esi, 1
-
- mov esi,[nf_width]
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
- jmp nf40_0 ; flush prefetch
- ALIGN 4
-nf40_0:
-
-nf40_11:mov [ebp+0], ebx
-nf40_12:mov [ebp+4], ebx
-nf40_13:mov [ebp+8], ebx
-nf40_14:mov [ebp+12], ebx
- add edi, esi
-
-nf40_21:mov [ebp+0], ebx
-nf40_22:mov [ebp+4], ebx
-nf40_23:mov [ebp+8], ebx
-nf40_24:mov [ebp+12], ebx
- add edi, esi
-
-nf40_31:mov [ebp+0], ebx
-nf40_32:mov [ebp+4], ebx
-nf40_33:mov [ebp+8], ebx
-nf40_34:mov [ebp+12], ebx
- add edi, esi
-
-nf40_41:mov [ebp+0], ebx
-nf40_42:mov [ebp+4], ebx
-nf40_43:mov [ebp+8], ebx
-nf40_44:mov [ebp+12], ebx
- add edi, esi
-
- pop ecx
-
- mov edx, ecx
- ror edx, 16
- mov ebx, edx
- mov bx, cx
- mov ebp, ecx
- mov bp, dx
-
-nf40_51:mov [ebp+0], ebx
-nf40_52:mov [ebp+4], ebx
-nf40_53:mov [ebp+8], ebx
-nf40_54:mov [ebp+12], ebx
- add edi, esi
-
-nf40_61:mov [ebp+0], ebx
-nf40_62:mov [ebp+4], ebx
-nf40_63:mov [ebp+8], ebx
-nf40_64:mov [ebp+12], ebx
- add edi, esi
-
-nf40_71:mov [ebp+0], ebx
-nf40_72:mov [ebp+4], ebx
-nf40_73:mov [ebp+8], ebx
-nf40_74:mov [ebp+12], ebx
- add edi, esi
-
-nf40_81:mov [ebp+0], ebx
-nf40_82:mov [ebp+4], ebx
-nf40_83:mov [ebp+8], ebx
-nf40_84:mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf9: ; 8x8x2 (24 bytes)
-
- test word [esi], 08000h
- jnz near nf41
-
- test word [esi+4], 08000h
- jnz near nf25
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf9_11+2] ; Removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_11-nf9_11)], bh
- mov [edx+(nf9_12-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_13-nf9_11)], bh
- mov [edx+(nf9_14-nf9_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_15-nf9_11)], bh
- mov [edx+(nf9_16-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_17-nf9_11)], bh
- mov [edx+(nf9_18-nf9_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_21-nf9_11)], bh
- mov [edx+(nf9_22-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_23-nf9_11)], bh
- mov [edx+(nf9_24-nf9_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_25-nf9_11)], bh
- mov [edx+(nf9_26-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_27-nf9_11)], bh
- mov [edx+(nf9_28-nf9_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_31-nf9_11)], bh
- mov [edx+(nf9_32-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_33-nf9_11)], bh
- mov [edx+(nf9_34-nf9_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_35-nf9_11)], bh
- mov [edx+(nf9_36-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_37-nf9_11)], bh
- mov [edx+(nf9_38-nf9_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_41-nf9_11)], bh
- mov [edx+(nf9_42-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_43-nf9_11)], bh
- mov [edx+(nf9_44-nf9_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_45-nf9_11)], bh
- mov [edx+(nf9_46-nf9_11)], bl
- shr ebx, 16
- mov [edx+(nf9_47-nf9_11)], bh
- mov [edx+(nf9_48-nf9_11)], bl
-
-
- lea edx, [edx+(nf9_51-nf9_11)]
-
- mov al, [esi+16]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_51-nf9_51)], bh
- mov [edx+(nf9_52-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_53-nf9_51)], bh
- mov [edx+(nf9_54-nf9_51)], bl
-
- mov al, [esi+17]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_55-nf9_51)], bh
- mov [edx+(nf9_56-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_57-nf9_51)], bh
- mov [edx+(nf9_58-nf9_51)], bl
-
-
- mov al, [esi+18]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_61-nf9_51)], bh
- mov [edx+(nf9_62-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_63-nf9_51)], bh
- mov [edx+(nf9_64-nf9_51)], bl
-
- mov al, [esi+19]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_65-nf9_51)], bh
- mov [edx+(nf9_66-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_67-nf9_51)], bh
- mov [edx+(nf9_68-nf9_51)], bl
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_71-nf9_51)], bh
- mov [edx+(nf9_72-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_73-nf9_51)], bh
- mov [edx+(nf9_74-nf9_51)], bl
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_75-nf9_51)], bh
- mov [edx+(nf9_76-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_77-nf9_51)], bh
- mov [edx+(nf9_78-nf9_51)], bl
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_81-nf9_51)], bh
- mov [edx+(nf9_82-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_83-nf9_51)], bh
- mov [edx+(nf9_84-nf9_51)], bl
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf9_85-nf9_51)], bh
- mov [edx+(nf9_86-nf9_51)], bl
- shr ebx, 16
- mov [edx+(nf9_87-nf9_51)], bh
- mov [edx+(nf9_88-nf9_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-
- Trans16 bx, esi
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-
- mov esi, [nf_width]
-
- jmp nf9_0 ; flush prefetch
- ALIGN 4
-nf9_0:
-
-nf9_11: mov ax, bx
- shl eax, 16
-nf9_12: mov ax, bx
- mov [edi], eax
-nf9_13: mov ax, bx
- shl eax, 16
-nf9_14: mov ax, bx
- mov [edi+4], eax
-nf9_15: mov ax, bx
- shl eax, 16
-nf9_16: mov ax, bx
- mov [edi+8], eax
-nf9_17: mov ax, bx
- shl eax, 16
-nf9_18: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_21: mov ax, bx
- shl eax, 16
-nf9_22: mov ax, bx
- mov [edi], eax
-nf9_23: mov ax, bx
- shl eax, 16
-nf9_24: mov ax, bx
- mov [edi+4], eax
-nf9_25: mov ax, bx
- shl eax, 16
-nf9_26: mov ax, bx
- mov [edi+8], eax
-nf9_27: mov ax, bx
- shl eax, 16
-nf9_28: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_31: mov ax, bx
- shl eax, 16
-nf9_32: mov ax, bx
- mov [edi], eax
-nf9_33: mov ax, bx
- shl eax, 16
-nf9_34: mov ax, bx
- mov [edi+4], eax
-nf9_35: mov ax, bx
- shl eax, 16
-nf9_36: mov ax, bx
- mov [edi+8], eax
-nf9_37: mov ax, bx
- shl eax, 16
-nf9_38: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_41: mov ax, bx
- shl eax, 16
-nf9_42: mov ax, bx
- mov [edi], eax
-nf9_43: mov ax, bx
- shl eax, 16
-nf9_44: mov ax, bx
- mov [edi+4], eax
-nf9_45: mov ax, bx
- shl eax, 16
-nf9_46: mov ax, bx
- mov [edi+8], eax
-nf9_47: mov ax, bx
- shl eax, 16
-nf9_48: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_51: mov ax, bx
- shl eax, 16
-nf9_52: mov ax, bx
- mov [edi], eax
-nf9_53: mov ax, bx
- shl eax, 16
-nf9_54: mov ax, bx
- mov [edi+4], eax
-nf9_55: mov ax, bx
- shl eax, 16
-nf9_56: mov ax, bx
- mov [edi+8], eax
-nf9_57: mov ax, bx
- shl eax, 16
-nf9_58: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_61: mov ax, bx
- shl eax, 16
-nf9_62: mov ax, bx
- mov [edi], eax
-nf9_63: mov ax, bx
- shl eax, 16
-nf9_64: mov ax, bx
- mov [edi+4], eax
-nf9_65: mov ax, bx
- shl eax, 16
-nf9_66: mov ax, bx
- mov [edi+8], eax
-nf9_67: mov ax, bx
- shl eax, 16
-nf9_68: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_71: mov ax, bx
- shl eax, 16
-nf9_72: mov ax, bx
- mov [edi], eax
-nf9_73: mov ax, bx
- shl eax, 16
-nf9_74: mov ax, bx
- mov [edi+4], eax
-nf9_75: mov ax, bx
- shl eax, 16
-nf9_76: mov ax, bx
- mov [edi+8], eax
-nf9_77: mov ax, bx
- shl eax, 16
-nf9_78: mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf9_81: mov ax, bx
- shl eax, 16
-nf9_82: mov ax, bx
- mov [edi], eax
-nf9_83: mov ax, bx
- shl eax, 16
-nf9_84: mov ax, bx
- mov [edi+4], eax
-nf9_85: mov ax, bx
- shl eax, 16
-nf9_86: mov ax, bx
- mov [edi+8], eax
-nf9_87: mov ax, bx
- shl eax, 16
-nf9_88: mov ax, bx
- mov [edi+12], eax
-
- pop esi
- pop ebp
- add esi, 24
- sub edi, [nfpk_back_right] ; br
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+16
-nf25: ; low 4x4x2 (12 bytes)
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf25_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_11-nf25_11)], bl
- mov [edx+(nf25_12-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_13-nf25_11)], bl
- mov [edx+(nf25_14-nf25_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_21-nf25_11)], bl
- mov [edx+(nf25_22-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_23-nf25_11)], bl
- mov [edx+(nf25_24-nf25_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_31-nf25_11)], bl
- mov [edx+(nf25_32-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_33-nf25_11)], bl
- mov [edx+(nf25_34-nf25_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf25_41-nf25_11)], bl
- mov [edx+(nf25_42-nf25_11)], bh
- shr ebx, 16
- mov [edx+(nf25_43-nf25_11)], bl
- mov [edx+(nf25_44-nf25_11)], bh
-
- push ebp
- push esi
- ; Load ebx,edx,ecx,ebp with four colors, duplicated in high order.
-
- Trans16 cx, esi
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd edx, ecx, 16
- mov dx, cx
- Trans16_3 cx, esi+4, 1
- shrd eax, ecx, 16
- mov ax, cx
- push eax
- Trans16 cx, esi+6
- shrd ebp, ecx, 16
- mov bp, cx
- pop ecx
-
- mov esi, [nf_width]
-
- jmp nf25_0 ; flush prefetch
- ALIGN 4
-nf25_0:
-
-nf25_11:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_12:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_13:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_14:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_21:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_22:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_23:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_24:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_31:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_32:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_33:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_34:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf25_41:mov eax, ebx
- mov [edi], eax
- mov [edi+esi], eax
-nf25_42:mov eax, ebx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf25_43:mov eax, ebx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf25_44:mov eax, ebx
- mov [edi+12], eax
- mov [edi+esi+12], eax
-
- add edi, esi
-
- pop esi
- pop ebp
- add esi, 12
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+32
-nf41: ; low 4x8x2 (16 bytes)
- test word [esi+4], 08000h
- jnz near nf57
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov8]
- lea edx, [nf41_11+1] ; Removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_11-nf41_11)], bl
- mov [edx+(nf41_12-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_13-nf41_11)], bl
- mov [edx+(nf41_14-nf41_11)], bh
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_21-nf41_11)], bl
- mov [edx+(nf41_22-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_23-nf41_11)], bl
- mov [edx+(nf41_24-nf41_11)], bh
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_31-nf41_11)], bl
- mov [edx+(nf41_32-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_33-nf41_11)], bl
- mov [edx+(nf41_34-nf41_11)], bh
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_41-nf41_11)], bl
- mov [edx+(nf41_42-nf41_11)], bh
- shr ebx, 16
- mov [edx+(nf41_43-nf41_11)], bl
- mov [edx+(nf41_44-nf41_11)], bh
-
- lea edx, [edx+(nf41_51-nf41_11)]
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_51-nf41_51)], bl
- mov [edx+(nf41_52-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_53-nf41_51)], bl
- mov [edx+(nf41_54-nf41_51)], bh
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_61-nf41_51)], bl
- mov [edx+(nf41_62-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_63-nf41_51)], bl
- mov [edx+(nf41_64-nf41_51)], bh
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_71-nf41_51)], bl
- mov [edx+(nf41_72-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_73-nf41_51)], bl
- mov [edx+(nf41_74-nf41_51)], bh
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf41_81-nf41_51)], bl
- mov [edx+(nf41_82-nf41_51)], bh
- shr ebx, 16
- mov [edx+(nf41_83-nf41_51)], bl
- mov [edx+(nf41_84-nf41_51)], bh
-
- push ebp
- push esi
- ; Load ebx,edx,ecx,ebp with four colors, duplicated in high order.
-
- Trans16_3 cx, esi, 1
- shrd ebx, ecx, 16
- mov bx, cx
- Trans16 cx, esi+2
- shrd edx, ecx, 16
- mov dx, cx
- Trans16 cx, esi+4
- shrd eax, ecx, 16
- mov ax, cx
- push eax
- Trans16 cx, esi+6
- shrd ebp, ecx, 16
- mov bp, cx
- pop ecx
-
- mov esi, [nf_width]
-
- jmp nf41_0 ; flush prefetch
- ALIGN 4
-nf41_0:
-
-nf41_11:mov [ebp+0], ebx
-nf41_12:mov [ebp+4], ebx
-nf41_13:mov [ebp+8], ebx
-nf41_14:mov [ebp+12], ebx
- add edi, esi
-
-nf41_21:mov [ebp+0], ebx
-nf41_22:mov [ebp+4], ebx
-nf41_23:mov [ebp+8], ebx
-nf41_24:mov [ebp+12], ebx
- add edi, esi
-
-nf41_31:mov [ebp+0], ebx
-nf41_32:mov [ebp+4], ebx
-nf41_33:mov [ebp+8], ebx
-nf41_34:mov [ebp+12], ebx
- add edi, esi
-
-nf41_41:mov [ebp+0], ebx
-nf41_42:mov [ebp+4], ebx
-nf41_43:mov [ebp+8], ebx
-nf41_44:mov [ebp+12], ebx
- add edi, esi
-
-nf41_51:mov [ebp+0], ebx
-nf41_52:mov [ebp+4], ebx
-nf41_53:mov [ebp+8], ebx
-nf41_54:mov [ebp+12], ebx
- add edi, esi
-
-nf41_61:mov [ebp+0], ebx
-nf41_62:mov [ebp+4], ebx
-nf41_63:mov [ebp+8], ebx
-nf41_64:mov [ebp+12], ebx
- add edi, esi
-
-nf41_71:mov [ebp+0], ebx
-nf41_72:mov [ebp+4], ebx
-nf41_73:mov [ebp+8], ebx
-nf41_74:mov [ebp+12], ebx
- add edi, esi
-
-nf41_81:mov [ebp+0], ebx
-nf41_82:mov [ebp+4], ebx
-nf41_83:mov [ebp+8], ebx
-nf41_84:mov [ebp+12], ebx
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf9+48
-nf57: ; low 8x4x2 (16 bytes)
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf57_11+2] ; Removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_11-nf57_11)], bh
- mov [edx+(nf57_12-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_13-nf57_11)], bh
- mov [edx+(nf57_14-nf57_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_15-nf57_11)], bh
- mov [edx+(nf57_16-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_17-nf57_11)], bh
- mov [edx+(nf57_18-nf57_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_21-nf57_11)], bh
- mov [edx+(nf57_22-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_23-nf57_11)], bh
- mov [edx+(nf57_24-nf57_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_25-nf57_11)], bh
- mov [edx+(nf57_26-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_27-nf57_11)], bh
- mov [edx+(nf57_28-nf57_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_31-nf57_11)], bh
- mov [edx+(nf57_32-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_33-nf57_11)], bh
- mov [edx+(nf57_34-nf57_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_35-nf57_11)], bh
- mov [edx+(nf57_36-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_37-nf57_11)], bh
- mov [edx+(nf57_38-nf57_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_41-nf57_11)], bh
- mov [edx+(nf57_42-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_43-nf57_11)], bh
- mov [edx+(nf57_44-nf57_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf57_45-nf57_11)], bh
- mov [edx+(nf57_46-nf57_11)], bl
- shr ebx, 16
- mov [edx+(nf57_47-nf57_11)], bh
- mov [edx+(nf57_48-nf57_11)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-
- Trans16_3 bx, esi, 1
- Trans16 dx, esi+2
- Trans16_3 cx, esi+4, 1
- Trans16 bp, esi+6
-
- mov esi, [nf_width]
-
- jmp nf57_0 ; flush prefetch
- ALIGN 4
-nf57_0:
-
-nf57_11:mov ax, bx
- shl eax, 16
-nf57_12:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_13:mov ax, bx
- shl eax, 16
-nf57_14:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_15:mov ax, bx
- shl eax, 16
-nf57_16:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_17:mov ax, bx
- shl eax, 16
-nf57_18:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_21:mov ax, bx
- shl eax, 16
-nf57_22:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_23:mov ax, bx
- shl eax, 16
-nf57_24:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_25:mov ax, bx
- shl eax, 16
-nf57_26:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_27:mov ax, bx
- shl eax, 16
-nf57_28:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_31:mov ax, bx
- shl eax, 16
-nf57_32:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_33:mov ax, bx
- shl eax, 16
-nf57_34:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_35:mov ax, bx
- shl eax, 16
-nf57_36:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_37:mov ax, bx
- shl eax, 16
-nf57_38:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- lea edi, [edi+esi*2]
-
-nf57_41:mov ax, bx
- shl eax, 16
-nf57_42:mov ax, bx
- mov [edi], eax
- mov [edi+esi], eax
-nf57_43:mov ax, bx
- shl eax, 16
-nf57_44:mov ax, bx
- mov [edi+4], eax
- mov [edi+esi+4], eax
-nf57_45:mov ax, bx
- shl eax, 16
-nf57_46:mov ax, bx
- mov [edi+8], eax
- mov [edi+esi+8], eax
-nf57_47:mov ax, bx
- shl eax, 16
-nf57_48:mov ax, bx
- mov [edi+12], eax
- mov [edi+esi+12], eax
- add edi, esi
-
- pop esi
- pop ebp
- add esi, 16
- sub edi, [nfpk_back_right] ;br
- retn
-
-;----------------------------------------
- ALIGN 4
-nf10: ; 2x2 4x4x2 (48 bytes)
-
- test word [esi], 08000h
- jnz near nf26
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf10_11+2] ; Remove byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_11-nf10_11)], bh
- mov [edx+(nf10_12-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_13-nf10_11)], bh
- mov [edx+(nf10_14-nf10_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_15-nf10_11)], bh
- mov [edx+(nf10_16-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_17-nf10_11)], bh
- mov [edx+(nf10_18-nf10_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_21-nf10_11)], bh
- mov [edx+(nf10_22-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_23-nf10_11)], bh
- mov [edx+(nf10_24-nf10_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_25-nf10_11)], bh
- mov [edx+(nf10_26-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_27-nf10_11)], bh
- mov [edx+(nf10_28-nf10_11)], bl
-
-
- mov al, [esi+20]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_31-nf10_11)], bh
- mov [edx+(nf10_32-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_33-nf10_11)], bh
- mov [edx+(nf10_34-nf10_11)], bl
-
- mov al, [esi+21]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_35-nf10_11)], bh
- mov [edx+(nf10_36-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_37-nf10_11)], bh
- mov [edx+(nf10_38-nf10_11)], bl
-
-
- mov al, [esi+22]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_41-nf10_11)], bh
- mov [edx+(nf10_42-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_43-nf10_11)], bh
- mov [edx+(nf10_44-nf10_11)], bl
-
- mov al, [esi+23]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_45-nf10_11)], bh
- mov [edx+(nf10_46-nf10_11)], bl
- shr ebx, 16
- mov [edx+(nf10_47-nf10_11)], bh
- mov [edx+(nf10_48-nf10_11)], bl
-
-
- lea edx, [edx+(nf10_51-nf10_11)]
-
- mov al, [esi+32]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_51-nf10_51)], bh
- mov [edx+(nf10_52-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_53-nf10_51)], bh
- mov [edx+(nf10_54-nf10_51)], bl
-
- mov al, [esi+33]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_55-nf10_51)], bh
- mov [edx+(nf10_56-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_57-nf10_51)], bh
- mov [edx+(nf10_58-nf10_51)], bl
-
-
- mov al, [esi+34]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_61-nf10_51)], bh
- mov [edx+(nf10_62-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_63-nf10_51)], bh
- mov [edx+(nf10_64-nf10_51)], bl
-
- mov al, [esi+35]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_65-nf10_51)], bh
- mov [edx+(nf10_66-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_67-nf10_51)], bh
- mov [edx+(nf10_68-nf10_51)], bl
-
-
- mov al, [esi+44]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_71-nf10_51)], bh
- mov [edx+(nf10_72-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_73-nf10_51)], bh
- mov [edx+(nf10_74-nf10_51)], bl
-
- mov al, [esi+45]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_75-nf10_51)], bh
- mov [edx+(nf10_76-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_77-nf10_51)], bh
- mov [edx+(nf10_78-nf10_51)], bl
-
-
- mov al, [esi+46]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_81-nf10_51)], bh
- mov [edx+(nf10_82-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_83-nf10_51)], bh
- mov [edx+(nf10_84-nf10_51)], bl
-
- mov al, [esi+47]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf10_85-nf10_51)], bh
- mov [edx+(nf10_86-nf10_51)], bl
- shr ebx, 16
- mov [edx+(nf10_87-nf10_51)], bh
- mov [edx+(nf10_88-nf10_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-
- Trans16 bx, esi
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-
- mov esi, [nf_width]
-
- jmp nf10_0 ; flush prefetch
- ALIGN 4
-nf10_0:
-
-nf10_11:mov ax, bx
- shl eax, 16
-nf10_12:mov ax, bx
- mov [edi], eax
-nf10_13:mov ax, bx
- shl eax, 16
-nf10_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_15:mov ax, bx
- shl eax, 16
-nf10_16:mov ax, bx
- mov [edi], eax
-nf10_17:mov ax, bx
- shl eax, 16
-nf10_18:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_21:mov ax, bx
- shl eax, 16
-nf10_22:mov ax, bx
- mov [edi], eax
-nf10_23:mov ax, bx
- shl eax, 16
-nf10_24:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_25:mov ax, bx
- shl eax, 16
-nf10_26:mov ax, bx
- mov [edi], eax
-nf10_27:mov ax, bx
- shl eax, 16
-nf10_28:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-
- mov esi, [esp]
- Trans16 bx, esi+12
- Trans16 dx, esi+14
- Trans16 cx, esi+16
- Trans16 bp, esi+18
- mov esi, [nf_width]
-
-nf10_31:mov ax, bx
- shl eax, 16
-nf10_32:mov ax, bx
- mov [edi], eax
-nf10_33:mov ax, bx
- shl eax, 16
-nf10_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_35:mov ax, bx
- shl eax, 16
-nf10_36:mov ax, bx
- mov [edi], eax
-nf10_37:mov ax, bx
- shl eax, 16
-nf10_38:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_41:mov ax, bx
- shl eax, 16
-nf10_42:mov ax, bx
- mov [edi], eax
-nf10_43:mov ax, bx
- shl eax, 16
-nf10_44:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_45:mov ax, bx
- shl eax, 16
-nf10_46:mov ax, bx
- mov [edi], eax
-nf10_47:mov ax, bx
- shl eax, 16
-nf10_48:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- ; Load bx,dx,cx,bp with four colors
-
- mov esi, [esp]
- Trans16 bx, esi+24
- Trans16 dx, esi+26
- Trans16 cx, esi+28
- Trans16 bp, esi+30
- mov esi, [nf_width]
-
-nf10_51:mov ax, bx
- shl eax, 16
-nf10_52:mov ax, bx
- mov [edi], eax
-nf10_53:mov ax, bx
- shl eax, 16
-nf10_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_55:mov ax, bx
- shl eax, 16
-nf10_56:mov ax, bx
- mov [edi], eax
-nf10_57:mov ax, bx
- shl eax, 16
-nf10_58:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_61:mov ax, bx
- shl eax, 16
-nf10_62:mov ax, bx
- mov [edi], eax
-nf10_63:mov ax, bx
- shl eax, 16
-nf10_64:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_65:mov ax, bx
- shl eax, 16
-nf10_66:mov ax, bx
- mov [edi], eax
-nf10_67:mov ax, bx
- shl eax, 16
-nf10_68:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-
- mov esi, [esp]
- Trans16 bx, esi+36
- Trans16 dx, esi+38
- Trans16 cx, esi+40
- Trans16 bp, esi+42
- mov esi, [nf_width]
-
-nf10_71:mov ax, bx
- shl eax, 16
-nf10_72:mov ax, bx
- mov [edi], eax
-nf10_73:mov ax, bx
- shl eax, 16
-nf10_74:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_75:mov ax, bx
- shl eax, 16
-nf10_76:mov ax, bx
- mov [edi], eax
-nf10_77:mov ax, bx
- shl eax, 16
-nf10_78:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_81:mov ax, bx
- shl eax, 16
-nf10_82:mov ax, bx
- mov [edi], eax
-nf10_83:mov ax, bx
- shl eax, 16
-nf10_84:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf10_85:mov ax, bx
- shl eax, 16
-nf10_86:mov ax, bx
- mov [edi], eax
-nf10_87:mov ax, bx
- shl eax, 16
-nf10_88:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 48
- sub edi, 8
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+16
-nf26: ; 2x1 4x8x2 (32 bytes)
-
- test word [esi+16], 08000h
- jnz near nf42
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf26_11+2] ; Removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_11-nf26_11)], bh
- mov [edx+(nf26_12-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_13-nf26_11)], bh
- mov [edx+(nf26_14-nf26_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_15-nf26_11)], bh
- mov [edx+(nf26_16-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_17-nf26_11)], bh
- mov [edx+(nf26_18-nf26_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_21-nf26_11)], bh
- mov [edx+(nf26_22-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_23-nf26_11)], bh
- mov [edx+(nf26_24-nf26_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_25-nf26_11)], bh
- mov [edx+(nf26_26-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_27-nf26_11)], bh
- mov [edx+(nf26_28-nf26_11)], bl
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_31-nf26_11)], bh
- mov [edx+(nf26_32-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_33-nf26_11)], bh
- mov [edx+(nf26_34-nf26_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_35-nf26_11)], bh
- mov [edx+(nf26_36-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_37-nf26_11)], bh
- mov [edx+(nf26_38-nf26_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_41-nf26_11)], bh
- mov [edx+(nf26_42-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_43-nf26_11)], bh
- mov [edx+(nf26_44-nf26_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_45-nf26_11)], bh
- mov [edx+(nf26_46-nf26_11)], bl
- shr ebx, 16
- mov [edx+(nf26_47-nf26_11)], bh
- mov [edx+(nf26_48-nf26_11)], bl
-
-
- lea edx, [edx+(nf26_51-nf26_11)]
-
- mov al, [esi+24]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_51-nf26_51)], bh
- mov [edx+(nf26_52-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_53-nf26_51)], bh
- mov [edx+(nf26_54-nf26_51)], bl
-
- mov al, [esi+25]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_55-nf26_51)], bh
- mov [edx+(nf26_56-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_57-nf26_51)], bh
- mov [edx+(nf26_58-nf26_51)], bl
-
-
- mov al, [esi+26]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_61-nf26_51)], bh
- mov [edx+(nf26_62-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_63-nf26_51)], bh
- mov [edx+(nf26_64-nf26_51)], bl
-
- mov al, [esi+27]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_65-nf26_51)], bh
- mov [edx+(nf26_66-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_67-nf26_51)], bh
- mov [edx+(nf26_68-nf26_51)], bl
-
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_71-nf26_51)], bh
- mov [edx+(nf26_72-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_73-nf26_51)], bh
- mov [edx+(nf26_74-nf26_51)], bl
-
- mov al, [esi+29]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_75-nf26_51)], bh
- mov [edx+(nf26_76-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_77-nf26_51)], bh
- mov [edx+(nf26_78-nf26_51)], bl
-
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_81-nf26_51)], bh
- mov [edx+(nf26_82-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_83-nf26_51)], bh
- mov [edx+(nf26_84-nf26_51)], bl
-
- mov al, [esi+31]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf26_85-nf26_51)], bh
- mov [edx+(nf26_86-nf26_51)], bl
- shr ebx, 16
- mov [edx+(nf26_87-nf26_51)], bh
- mov [edx+(nf26_88-nf26_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-
- Trans16_3 bx, esi, 1
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-
- mov esi, [nf_width]
-
- jmp nf26_0 ; flush prefetch
- ALIGN 4
-nf26_0:
-
-nf26_11:mov ax, bx
- shl eax, 16
-nf26_12:mov ax, bx
- mov [edi], eax
-nf26_13:mov ax, bx
- shl eax, 16
-nf26_14:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_15:mov ax, bx
- shl eax, 16
-nf26_16:mov ax, bx
- mov [edi], eax
-nf26_17:mov ax, bx
- shl eax, 16
-nf26_18:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_21:mov ax, bx
- shl eax, 16
-nf26_22:mov ax, bx
- mov [edi], eax
-nf26_23:mov ax, bx
- shl eax, 16
-nf26_24:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_25:mov ax, bx
- shl eax, 16
-nf26_26:mov ax, bx
- mov [edi], eax
-nf26_27:mov ax, bx
- shl eax, 16
-nf26_28:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_31:mov ax, bx
- shl eax, 16
-nf26_32:mov ax, bx
- mov [edi], eax
-nf26_33:mov ax, bx
- shl eax, 16
-nf26_34:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_35:mov ax, bx
- shl eax, 16
-nf26_36:mov ax, bx
- mov [edi], eax
-nf26_37:mov ax, bx
- shl eax, 16
-nf26_38:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_41:mov ax, bx
- shl eax, 16
-nf26_42:mov ax, bx
- mov [edi], eax
-nf26_43:mov ax, bx
- shl eax, 16
-nf26_44:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_45:mov ax, bx
- shl eax, 16
-nf26_46:mov ax, bx
- mov [edi], eax
-nf26_47:mov ax, bx
- shl eax, 16
-nf26_48:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
- lea eax, [esi*8-8]
- sub edi, eax
-
- ; Load bx,dx,cx,bp with four colors
-
- mov esi, [esp]
- Trans16 bx, esi+16
- Trans16 dx, esi+18
- Trans16 cx, esi+20
- Trans16 bp, esi+22
- mov esi, [nf_width]
-
-nf26_51:mov ax, bx
- shl eax, 16
-nf26_52:mov ax, bx
- mov [edi], eax
-nf26_53:mov ax, bx
- shl eax, 16
-nf26_54:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_55:mov ax, bx
- shl eax, 16
-nf26_56:mov ax, bx
- mov [edi], eax
-nf26_57:mov ax, bx
- shl eax, 16
-nf26_58:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_61:mov ax, bx
- shl eax, 16
-nf26_62:mov ax, bx
- mov [edi], eax
-nf26_63:mov ax, bx
- shl eax, 16
-nf26_64:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_65:mov ax, bx
- shl eax, 16
-nf26_66:mov ax, bx
- mov [edi], eax
-nf26_67:mov ax, bx
- shl eax, 16
-nf26_68:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_71:mov ax, bx
- shl eax, 16
-nf26_72:mov ax, bx
- mov [edi], eax
-nf26_73:mov ax, bx
- shl eax, 16
-nf26_74:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_75:mov ax, bx
- shl eax, 16
-nf26_76:mov ax, bx
- mov [edi], eax
-nf26_77:mov ax, bx
- shl eax, 16
-nf26_78:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_81:mov ax, bx
- shl eax, 16
-nf26_82:mov ax, bx
- mov [edi], eax
-nf26_83:mov ax, bx
- shl eax, 16
-nf26_84:mov ax, bx
- mov [edi+4], eax
- add edi, esi
-
-nf26_85:mov ax, bx
- shl eax, 16
-nf26_86:mov ax, bx
- mov [edi], eax
-nf26_87:mov ax, bx
- shl eax, 16
-nf26_88:mov ax, bx
- mov [edi+4], eax
-
- pop esi
- pop ebp
- add esi, 32
- sub edi, 8
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-;nf10+32
-nf42: ; 1x2 8x4x2 (32 bytes)
-
- xor eax, eax
-
- lea ecx, [nfhpk_mov4]
- lea edx, [nf42_11+2] ; removed byte ds: - AH
-
- mov al, [esi+8]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_11-nf42_11)], bh
- mov [edx+(nf42_12-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_13-nf42_11)], bh
- mov [edx+(nf42_14-nf42_11)], bl
-
- mov al, [esi+9]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_15-nf42_11)], bh
- mov [edx+(nf42_16-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_17-nf42_11)], bh
- mov [edx+(nf42_18-nf42_11)], bl
-
-
- mov al, [esi+10]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_21-nf42_11)], bh
- mov [edx+(nf42_22-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_23-nf42_11)], bh
- mov [edx+(nf42_24-nf42_11)], bl
-
- mov al, [esi+11]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_25-nf42_11)], bh
- mov [edx+(nf42_26-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_27-nf42_11)], bh
- mov [edx+(nf42_28-nf42_11)], bl
-
-
- mov al, [esi+12]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_31-nf42_11)], bh
- mov [edx+(nf42_32-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_33-nf42_11)], bh
- mov [edx+(nf42_34-nf42_11)], bl
-
- mov al, [esi+13]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_35-nf42_11)], bh
- mov [edx+(nf42_36-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_37-nf42_11)], bh
- mov [edx+(nf42_38-nf42_11)], bl
-
-
- mov al, [esi+14]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_41-nf42_11)], bh
- mov [edx+(nf42_42-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_43-nf42_11)], bh
- mov [edx+(nf42_44-nf42_11)], bl
-
- mov al, [esi+15]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_45-nf42_11)], bh
- mov [edx+(nf42_46-nf42_11)], bl
- shr ebx, 16
- mov [edx+(nf42_47-nf42_11)], bh
- mov [edx+(nf42_48-nf42_11)], bl
-
-
- lea edx, [edx+(nf42_51-nf42_11)]
-
- mov al, [esi+24]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_51-nf42_51)], bh
- mov [edx+(nf42_52-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_53-nf42_51)], bh
- mov [edx+(nf42_54-nf42_51)], bl
-
- mov al, [esi+25]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_55-nf42_51)], bh
- mov [edx+(nf42_56-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_57-nf42_51)], bh
- mov [edx+(nf42_58-nf42_51)], bl
-
-
- mov al, [esi+26]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_61-nf42_51)], bh
- mov [edx+(nf42_62-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_63-nf42_51)], bh
- mov [edx+(nf42_64-nf42_51)], bl
-
- mov al, [esi+27]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_65-nf42_51)], bh
- mov [edx+(nf42_66-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_67-nf42_51)], bh
- mov [edx+(nf42_68-nf42_51)], bl
-
-
- mov al, [esi+28]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_71-nf42_51)], bh
- mov [edx+(nf42_72-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_73-nf42_51)], bh
- mov [edx+(nf42_74-nf42_51)], bl
-
- mov al, [esi+29]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_75-nf42_51)], bh
- mov [edx+(nf42_76-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_77-nf42_51)], bh
- mov [edx+(nf42_78-nf42_51)], bl
-
-
- mov al, [esi+30]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_81-nf42_51)], bh
- mov [edx+(nf42_82-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_83-nf42_51)], bh
- mov [edx+(nf42_84-nf42_51)], bl
-
- mov al, [esi+31]
- mov ebx, [ecx+eax*4]
- mov [edx+(nf42_85-nf42_51)], bh
- mov [edx+(nf42_86-nf42_51)], bl
- shr ebx, 16
- mov [edx+(nf42_87-nf42_51)], bh
- mov [edx+(nf42_88-nf42_51)], bl
-
- push ebp
- push esi
- ; Load bx,dx,cx,bp with four colors
-
- Trans16_3 bx, esi, 1
- Trans16 dx, esi+2
- Trans16 cx, esi+4
- Trans16 bp, esi+6
-
- mov esi, [nf_width]
-
- jmp nf42_0 ; flush prefetch
- ALIGN 4
-nf42_0:
-
-nf42_11:mov ax, bx
- shl eax, 16
-nf42_12:mov ax, bx
- mov [edi], eax
-nf42_13:mov ax, bx
- shl eax, 16
-nf42_14:mov ax, bx
- mov [edi+4], eax
-nf42_15:mov ax, bx
- shl eax, 16
-nf42_16:mov ax, bx
- mov [edi+8], eax
-nf42_17:mov ax, bx
- shl eax, 16
-nf42_18:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_21:mov ax, bx
- shl eax, 16
-nf42_22:mov ax, bx
- mov [edi], eax
-nf42_23:mov ax, bx
- shl eax, 16
-nf42_24:mov ax, bx
- mov [edi+4], eax
-nf42_25:mov ax, bx
- shl eax, 16
-nf42_26:mov ax, bx
- mov [edi+8], eax
-nf42_27:mov ax, bx
- shl eax, 16
-nf42_28:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_31:mov ax, bx
- shl eax, 16
-nf42_32:mov ax, bx
- mov [edi], eax
-nf42_33:mov ax, bx
- shl eax, 16
-nf42_34:mov ax, bx
- mov [edi+4], eax
-nf42_35:mov ax, bx
- shl eax, 16
-nf42_36:mov ax, bx
- mov [edi+8], eax
-nf42_37:mov ax, bx
- shl eax, 16
-nf42_38:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_41:mov ax, bx
- shl eax, 16
-nf42_42:mov ax, bx
- mov [edi], eax
-nf42_43:mov ax, bx
- shl eax, 16
-nf42_44:mov ax, bx
- mov [edi+4], eax
-nf42_45:mov ax, bx
- shl eax, 16
-nf42_46:mov ax, bx
- mov [edi+8], eax
-nf42_47:mov ax, bx
- shl eax, 16
-nf42_48:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
- ; Load bx,dx,cx,bp with four colors
-
- mov esi, [esp]
- Trans16_3 bx, esi+16, 1
- Trans16 dx, esi+18
- Trans16 cx, esi+20
- Trans16 bp, esi+22
- mov esi, [nf_width]
-
-nf42_51:mov ax, bx
- shl eax, 16
-nf42_52:mov ax, bx
- mov [edi], eax
-nf42_53:mov ax, bx
- shl eax, 16
-nf42_54:mov ax, bx
- mov [edi+4], eax
-nf42_55:mov ax, bx
- shl eax, 16
-nf42_56:mov ax, bx
- mov [edi+8], eax
-nf42_57:mov ax, bx
- shl eax, 16
-nf42_58:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_61:mov ax, bx
- shl eax, 16
-nf42_62:mov ax, bx
- mov [edi], eax
-nf42_63:mov ax, bx
- shl eax, 16
-nf42_64:mov ax, bx
- mov [edi+4], eax
-nf42_65:mov ax, bx
- shl eax, 16
-nf42_66:mov ax, bx
- mov [edi+8], eax
-nf42_67:mov ax, bx
- shl eax, 16
-nf42_68:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_71:mov ax, bx
- shl eax, 16
-nf42_72:mov ax, bx
- mov [edi], eax
-nf42_73:mov ax, bx
- shl eax, 16
-nf42_74:mov ax, bx
- mov [edi+4], eax
-nf42_75:mov ax, bx
- shl eax, 16
-nf42_76:mov ax, bx
- mov [edi+8], eax
-nf42_77:mov ax, bx
- shl eax, 16
-nf42_78:mov ax, bx
- mov [edi+12], eax
- add edi, esi
-
-nf42_81:mov ax, bx
- shl eax, 16
-nf42_82:mov ax, bx
- mov [edi], eax
-nf42_83:mov ax, bx
- shl eax, 16
-nf42_84:mov ax, bx
- mov [edi+4], eax
-nf42_85:mov ax, bx
- shl eax, 16
-nf42_86:mov ax, bx
- mov [edi+8], eax
-nf42_87:mov ax, bx
- shl eax, 16
-nf42_88:mov ax, bx
- mov [edi+12], eax
-
- pop esi
- pop ebp
- add esi, 32
- sub edi, [nfpk_back_right] ;br
- retn
-
-;----------------------------------------
- ALIGN 4
-nf11: ; 8x8x16 (128 bytes)
- mov edx, [nf_width]
-
-%macro Trans16Blk 1 ; MACRO idx
- Trans16 bx, %1 ;idx
- mov [edi], bx
- Trans16 bx, (%1 + 2) ;idx+2
- mov [edi+2], bx
- Trans16 bx, (%1 + 4) ;idx+4
- mov [edi+4], bx
- Trans16 bx, (%1 + 6) ;idx+6
- mov [edi+6], bx
- Trans16 bx, (%1 + 8) ;idx+8
- mov [edi+8], bx
- Trans16 bx, (%1 + 10) ;idx+10
- mov [edi+10], bx
- Trans16 bx, (%1 + 12) ;idx+12
- mov [edi+12], bx
- Trans16 bx, (%1 + 14) ;idx+14
- mov [edi+14], bx
-%endmacro
-
- Trans16Blk esi ;0
- add edi, edx
- Trans16Blk esi+16 ;1
- add edi, edx
- Trans16Blk esi+32 ;2
- add edi, edx
- Trans16Blk esi+48 ;3
- add edi, edx
- Trans16Blk esi+64 ;4
- add edi, edx
- Trans16Blk esi+80 ;5
- add edi, edx
- Trans16Blk esi+96 ;6
- add edi, edx
- Trans16Blk esi+112 ;7
-
- add esi, 128
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
- retn
-
-;----------------------------------------
- ALIGN 4
-nf12: ; low 4x4x16 (32 bytes)
-
- mov edx, [nf_width]
-
- Trans16 bx, esi
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+2
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+4
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+6
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+8
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+10
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+12
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+14
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+16
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+18
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+20
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+22
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- lea edi, [edi+edx*2]
-
- Trans16 bx, esi+24
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi], eax
- mov [edi+edx], eax
-
- Trans16 bx, esi+26
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+4], eax
- mov [edi+edx+4], eax
-
- Trans16 bx, esi+28
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+8], eax
- mov [edi+edx+8], eax
-
- Trans16 bx, esi+30
- shrd eax, ebx, 16
- mov ax, bx
- mov [edi+12], eax
- mov [edi+edx+12], eax
-
- add edi, edx
-
- sub edi, [nfpk_back_right] ;br
- add esi, 32
- retn
-
-;----------------------------------------
- ALIGN 4
-nf13: ; 2x2 4x4x0 (8 bytes)
- mov edx, [nf_width]
-
- Trans16 cx, esi
- shrd ebx, ecx, 16
- mov bx, cx
-
- Trans16 cx, esi+2
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
-
- Trans16 cx, esi+4
- shrd ebx, ecx, 16
- mov bx, cx
-
- Trans16 cx, esi+6
- shrd eax, ecx, 16
- mov ax, cx
- mov ecx, eax
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- lea edi, [edi+edx*2]
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ecx
- mov [edi+12], ecx
- mov [edi+edx], ebx
- mov [edi+edx+4], ebx
- mov [edi+edx+8], ecx
- mov [edi+edx+12], ecx
- add edi, edx
-
- sub edi, [nfpk_back_right] ; br
- add esi, 8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf14: ; 8x8x0 (2 bytes)
- Trans16 cx, esi
- add esi, 2
- shrd ebx, ecx, 16
- mov bx, cx
-
-nf_solid:
- mov edx, [nf_width]
-
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
- add edi, edx
- mov [edi], ebx
- mov [edi+4], ebx
- mov [edi+8], ebx
- mov [edi+12], ebx
-
- sub edi, [nfpk_back_right] ;br ; (SHEIGHT-1)*width+8
-
- retn
-
-;----------------------------------------
- ALIGN 4
-nf15: ; unused
- retn
-
-;nfHPkDecomp ENDP
-
-
diff --git a/lnxmvelib/snd8to16.h b/lnxmvelib/snd8to16.h
deleted file mode 100644
index b9482c43..00000000
--- a/lnxmvelib/snd8to16.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Descent 3
-* Copyright (C) 2024 Parallax Software
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-
---- HISTORICAL COMMENTS FOLLOW ---
-
-** #include
-** void init_snd_8to16(void)
-** {
-** int i;
-** for (i=0; i<44; ++i)
-** snd_8to16[i] = i;
-** for (i=44; i<128; ++i)
-** snd_8to16[i] = (unsigned)floor(pow(65535,i/127.0)+.5);
-** for (i=1; i<128; ++i)
-** snd_8to16[256-i] = -snd_8to16[i];
-** snd_8to16[128] = snd_8to16[129];
-** }
-*/
-#pragma warning(disable : 4245)
-
-int16_t snd_8to16[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 47, 51, 56, 61, 66, 72, 79, 86, 94, 102, 112, 122,
- 133, 145, 158, 173, 189, 206, 225, 245, 267, 292, 318, 348, 379, 414,
- 452, 493, 538, 587, 640, 699, 763, 832, 908, 991, 1081, 1180, 1288, 1405,
- 1534, 1673, 1826, 1993, 2175, 2373, 2590, 2826, 3084, 3365, 3672, 4008, 4373, 4772,
- 5208, 5683, 6202, 6767, 7385, 8059, 8794, 9597, 10472, 11428, 12471, 13609, 14851, 16206,
- 17685, 19298, 21060, 22981, 25078, 27367, 29864, 32589, 35563, 38808, 42350, 46214, 50431, 55033,
- 60055, 65535, -65535, -65535, -60055, -55033, -50431, -46214, -42350, -38808, -35563, -32589, -29864, -27367,
- -25078, -22981, -21060, -19298, -17685, -16206, -14851, -13609, -12471, -11428, -10472, -9597, -8794, -8059,
- -7385, -6767, -6202, -5683, -5208, -4772, -4373, -4008, -3672, -3365, -3084, -2826, -2590, -2373,
- -2175, -1993, -1826, -1673, -1534, -1405, -1288, -1180, -1081, -991, -908, -832, -763, -699,
- -640, -587, -538, -493, -452, -414, -379, -348, -318, -292, -267, -245, -225, -206,
- -189, -173, -158, -145, -133, -122, -112, -102, -94, -86, -79, -72, -66, -61,
- -56, -51, -47, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33,
- -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19,
- -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5,
- -4, -3, -2, -1};
-#pragma warning(default : 4245)
diff --git a/movie/d3movie.cpp b/movie/d3movie.cpp
index 317f2093..6841dc83 100644
--- a/movie/d3movie.cpp
+++ b/movie/d3movie.cpp
@@ -16,23 +16,9 @@
* along with this program. If not, see .
*/
-#ifdef __LINUX__
-#include
-#include "lnxdsound.h"
-#endif
-
-
-#ifdef WIN32
-#include
-#include
-#include
-#include "dsound.h"
-#endif
-
#include
#include "movie.h"
-//#include "mvelibw.h"
#include "mvelib.h"
#include "pserror.h"
#include "renderer.h"