#include "doomdef.h"
-#if !defined (__APPLE__)
+#ifndef SRB2_HAVE_STRLCPY
// Like the OpenBSD version, but it doesn't check for src not being a valid
// C string.
diff --git a/src/tmap.nas b/src/tmap.nas
deleted file mode 100644
index 85091cbd5..000000000
--- a/src/tmap.nas
+++ /dev/null
@@ -1,957 +0,0 @@
-;; SONIC ROBO BLAST 2
-;;-----------------------------------------------------------------------------
-;; Copyright (C) 1998-2000 by DooM Legacy Team.
-;; Copyright (C) 1999-2023 by Sonic Team Junior.
-;;
-;; This program is free software distributed under the
-;; terms of the GNU General Public License, version 2.
-;; See the 'LICENSE' file for more details.
-;;-----------------------------------------------------------------------------
-;; FILE:
-;; tmap.nas
-;; DESCRIPTION:
-;; Assembler optimised rendering code for software mode.
-;; Draw wall columns.
-
-
-[BITS 32]
-
-%define FRACBITS 16
-%define TRANSPARENTPIXEL 255
-
-%ifdef LINUX
-%macro cextern 1
-[extern %1]
-%endmacro
-
-%macro cglobal 1
-[global %1]
-%endmacro
-
-%else
-%macro cextern 1
-%define %1 _%1
-[extern %1]
-%endmacro
-
-%macro cglobal 1
-%define %1 _%1
-[global %1]
-%endmacro
-
-%endif
-
-
-; The viddef_s structure. We only need the width field.
-struc viddef_s
- resb 12
-.width: resb 4
- resb 44
-endstruc
-
-;; externs
-;; columns
-cextern dc_x
-cextern dc_yl
-cextern dc_yh
-cextern ylookup
-cextern columnofs
-cextern dc_source
-cextern dc_texturemid
-cextern dc_texheight
-cextern dc_iscale
-cextern dc_hires
-cextern centery
-cextern centeryfrac
-cextern dc_colormap
-cextern dc_transmap
-cextern colormaps
-cextern vid
-cextern topleft
-
-; DELME
-cextern R_DrawColumn_8
-
-; polygon edge rasterizer
-cextern prastertab
-
-[SECTION .data]
-
-;;.align 4
-loopcount dd 0
-pixelcount dd 0
-tystep dd 0
-
-[SECTION .text]
-
-;;----------------------------------------------------------------------
-;;
-;; R_DrawColumn : 8bpp column drawer
-;;
-;; New optimised version 10-01-1998 by D.Fabrice and P.Boris
-;; Revised by G. Dick July 2010 to support the intervening twelve years'
-;; worth of changes to the renderer. Since I only vaguely know what I'm
-;; doing, this is probably rather suboptimal. Help appreciated!
-;;
-;;----------------------------------------------------------------------
-;; fracstep, vid.width in memory
-;; eax = accumulator
-;; ebx = colormap
-;; ecx = count
-;; edx = heightmask
-;; esi = source
-;; edi = dest
-;; ebp = frac
-;;----------------------------------------------------------------------
-
-cglobal R_DrawColumn_8_ASM
-; align 16
-R_DrawColumn_8_ASM:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov ebp,[dc_yl]
- mov edi,[ylookup+ebp*4]
- mov ebx,[dc_x]
- add edi,[columnofs+ebx*4] ;; edi = dest
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov ecx,[dc_yh]
- add ecx,1
- sub ecx,ebp ;; pixel count
- jle near .done ;; nothing to scale
-;;
-;; fracstep = dc_iscale; // But we just use [dc_iscale]
-;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
-;;
- mov eax,ebp ;; dc_yl
- shl eax,FRACBITS
- sub eax,[centeryfrac]
- imul dword [dc_iscale]
- shrd eax,edx,FRACBITS
- add eax,[dc_texturemid]
- mov ebp,eax ;; ebp = frac
-
- mov ebx,[dc_colormap]
-
- mov esi,[dc_source]
-;;
-;; if (dc_hires) frac = 0;
-;;
- test byte [dc_hires],0x01
- jz .texheightcheck
- xor ebp,ebp
-
-;;
-;; Check for power of two
-;;
-.texheightcheck:
- mov edx,[dc_texheight]
- sub edx,1 ;; edx = heightmask
- test edx,[dc_texheight]
- jnz .notpowertwo
-
- test ecx,0x01 ;; Test for odd no. pixels
- jnz .odd
-
-;;
-;; Texture height is a power of two, so we get modular arithmetic by
-;; masking
-;;
-.powertwo:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part
- and eax,edx ;; eax &= heightmask
- movzx eax,byte [esi + eax] ;; eax = texel
- add ebp,[dc_iscale] ;; frac += fracstep
- movzx eax,byte [ebx+eax] ;; Map through colormap
- mov [edi],al ;; Write pixel
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
-.odd:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part
- and eax,edx ;; eax &= heightmask
- movzx eax,byte [esi + eax] ;; eax = texel
- add ebp,[dc_iscale] ;; frac += fracstep
- movzx eax,byte [ebx+eax] ;; Map through colormap
- mov [edi],al ;; Write pixel
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
-
- sub ecx,2 ;; count -= 2
- jg .powertwo
-
- jmp .done
-
-.notpowertwo:
- add edx,1
- shl edx,FRACBITS
- test ebp,ebp
- jns .notpowtwoloop
-
-.makefracpos:
- add ebp,edx ;; frac is negative; make it positive
- js .makefracpos
-
-.notpowtwoloop:
- cmp ebp,edx ;; Reduce mod height
- jl .writenonpowtwo
- sub ebp,edx
- jmp .notpowtwoloop
-
-.writenonpowtwo:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part.
- mov bl,[esi + eax] ;; ebx = colormap + texel
- add ebp,[dc_iscale] ;; frac += fracstep
- movzx eax,byte [ebx] ;; Map through colormap
- mov [edi],al ;; Write pixel
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
- sub ecx,1
- jnz .notpowtwoloop
-
-;;
-
-.done:
- pop ebx ;; restore register variables
- pop edi
- pop esi
- pop ebp ;; restore caller's stack frame pointer
- ret
-
-
-;;----------------------------------------------------------------------
-;;
-;; R_Draw2sMultiPatchColumn : Like R_DrawColumn, but omits transparent
-;; pixels.
-;;
-;; New optimised version 10-01-1998 by D.Fabrice and P.Boris
-;; Revised by G. Dick July 2010 to support the intervening twelve years'
-;; worth of changes to the renderer. Since I only vaguely know what I'm
-;; doing, this is probably rather suboptimal. Help appreciated!
-;;
-;;----------------------------------------------------------------------
-;; fracstep, vid.width in memory
-;; eax = accumulator
-;; ebx = colormap
-;; ecx = count
-;; edx = heightmask
-;; esi = source
-;; edi = dest
-;; ebp = frac
-;;----------------------------------------------------------------------
-
-cglobal R_Draw2sMultiPatchColumn_8_ASM
-; align 16
-R_Draw2sMultiPatchColumn_8_ASM:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov ebp,[dc_yl]
- mov edi,[ylookup+ebp*4]
- mov ebx,[dc_x]
- add edi,[columnofs+ebx*4] ;; edi = dest
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov ecx,[dc_yh]
- add ecx,1
- sub ecx,ebp ;; pixel count
- jle near .done ;; nothing to scale
-;;
-;; fracstep = dc_iscale; // But we just use [dc_iscale]
-;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
-;;
- mov eax,ebp ;; dc_yl
- shl eax,FRACBITS
- sub eax,[centeryfrac]
- imul dword [dc_iscale]
- shrd eax,edx,FRACBITS
- add eax,[dc_texturemid]
- mov ebp,eax ;; ebp = frac
-
- mov ebx,[dc_colormap]
-
- mov esi,[dc_source]
-;;
-;; if (dc_hires) frac = 0;
-;;
- test byte [dc_hires],0x01
- jz .texheightcheck
- xor ebp,ebp
-
-;;
-;; Check for power of two
-;;
-.texheightcheck:
- mov edx,[dc_texheight]
- sub edx,1 ;; edx = heightmask
- test edx,[dc_texheight]
- jnz .notpowertwo
-
- test ecx,0x01 ;; Test for odd no. pixels
- jnz .odd
-
-;;
-;; Texture height is a power of two, so we get modular arithmetic by
-;; masking
-;;
-.powertwo:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part
- and eax,edx ;; eax &= heightmask
- movzx eax,byte [esi + eax] ;; eax = texel
- add ebp,[dc_iscale] ;; frac += fracstep
- cmp al,TRANSPARENTPIXEL ;; Is pixel transparent?
- je .nextpowtwoeven ;; If so, advance.
- movzx eax,byte [ebx+eax] ;; Map through colormap
- mov [edi],al ;; Write pixel
-.nextpowtwoeven:
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
-.odd:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part
- and eax,edx ;; eax &= heightmask
- movzx eax,byte [esi + eax] ;; eax = texel
- add ebp,[dc_iscale] ;; frac += fracstep
- cmp al,TRANSPARENTPIXEL ;; Is pixel transparent?
- je .nextpowtwoodd ;; If so, advance.
- movzx eax,byte [ebx+eax] ;; Map through colormap
- mov [edi],al ;; Write pixel
-.nextpowtwoodd:
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
-
- sub ecx,2 ;; count -= 2
- jg .powertwo
-
- jmp .done
-
-.notpowertwo:
- add edx,1
- shl edx,FRACBITS
- test ebp,ebp
- jns .notpowtwoloop
-
-.makefracpos:
- add ebp,edx ;; frac is negative; make it positive
- js .makefracpos
-
-.notpowtwoloop:
- cmp ebp,edx ;; Reduce mod height
- jl .writenonpowtwo
- sub ebp,edx
- jmp .notpowtwoloop
-
-.writenonpowtwo:
- mov eax,ebp ;; eax = frac
- sar eax,FRACBITS ;; Integer part.
- mov bl,[esi + eax] ;; ebx = colormap + texel
- add ebp,[dc_iscale] ;; frac += fracstep
- cmp bl,TRANSPARENTPIXEL ;; Is pixel transparent?
- je .nextnonpowtwo ;; If so, advance.
- movzx eax,byte [ebx] ;; Map through colormap
- mov [edi],al ;; Write pixel
-.nextnonpowtwo:
- ;; dest += vid.width
- add edi,[vid + viddef_s.width]
-
- sub ecx,1
- jnz .notpowtwoloop
-
-;;
-
-.done:
- pop ebx ;; restore register variables
- pop edi
- pop esi
- pop ebp ;; restore caller's stack frame pointer
- ret
-
-;;----------------------------------------------------------------------
-;; R_DrawTranslucentColumnA_8
-;;
-;; Vertical column texture drawer, with transparency. Replaces Doom2's
-;; 'fuzz' effect, which was not so beautiful.
-;; Transparency is always impressive in some way, don't know why...
-;;----------------------------------------------------------------------
-
-cglobal R_DrawTranslucentColumn_8_ASM
-R_DrawTranslucentColumn_8_ASM:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov ebp,[dc_yl]
- mov ebx,ebp
- mov edi,[ylookup+ebx*4]
- mov ebx,[dc_x]
- add edi,[columnofs+ebx*4] ;; edi = dest
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov eax,[dc_yh]
- inc eax
- sub eax,ebp ;; pixel count
- mov [pixelcount],eax ;; save for final pixel
- jle near vtdone ;; nothing to scale
-;;
-;; frac = dc_texturemid - (centery-dc_yl)*fracstep;
-;;
- mov ecx,[dc_iscale] ;; fracstep
- mov eax,[centery]
- sub eax,ebp
- imul eax,ecx
- mov edx,[dc_texturemid]
- sub edx,eax
- mov ebx,edx
-
- shr ebx,16 ;; frac int.
- and ebx,0x7f
- shl edx,16 ;; y frac up
-
- mov ebp,ecx
- shl ebp,16 ;; fracstep f. up
- shr ecx,16 ;; fracstep i. ->cl
- and cl,0x7f
- push cx
- mov ecx,edx
- pop cx
- mov edx,[dc_colormap]
- mov esi,[dc_source]
-;;
-;; lets rock :) !
-;;
- mov eax,[pixelcount]
- shr eax,0x2
- test byte [pixelcount],0x3
- mov ch,al ;; quad count
- mov eax,[dc_transmap]
- je vt4quadloop
-;;
-;; do un-even pixel
-;;
- test byte [pixelcount],0x1
- je trf2
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add ecx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov dl,[edx]
- mov [edi],dl
-pf: add edi,0x12345678
-;;
-;; do two non-quad-aligned pixels
-;;
-trf2: test byte [pixelcount],0x2
- je trf3
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add ecx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov dl,[edx]
- mov [edi],dl
-pg: add edi,0x12345678
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add ecx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov dl,[edx]
- mov [edi],dl
-ph: add edi,0x12345678
-;;
-;; test if there was at least 4 pixels
-;;
-trf3: test ch,0xff ;; test quad count
- je near vtdone
-
-;;
-;; ebp : ystep frac. upper 24 bits
-;; edx : y frac. upper 24 bits
-;; ebx : y i. lower 7 bits, masked for index
-;; ecx : ch = counter, cl = y step i.
-;; eax : colormap aligned 256
-;; esi : source texture column
-;; edi : dest screen
-;;
-vt4quadloop:
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [tystep],ebp
-pi: add edi,0x12345678
- mov al,[edi] ;; fetch dest : index into colormap
-pj: sub edi,0x12345678
- mov ebp,edi
-pk: sub edi,0x12345678
- jmp short inloop
-align 4
-vtquadloop:
- add ecx,[tystep]
- adc bl,cl
-q1: add ebp,0x23456789
- and bl,0x7f
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov dl,[edx]
- mov [edi],dl
- mov al,[ebp] ;; fetch dest : index into colormap
-inloop:
- add ecx,[tystep]
- adc bl,cl
-q2: add edi,0x23456789
- and bl,0x7f
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov dl,[edx]
- mov [ebp+0x0],dl
- mov al,[edi] ;; fetch dest : index into colormap
-
- add ecx,[tystep]
- adc bl,cl
-q3: add ebp,0x23456789
- and bl,0x7f
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov dl,[edx]
- mov [edi],dl
- mov al,[ebp] ;; fetch dest : index into colormap
-
- add ecx,[tystep]
- adc bl,cl
-q4: add edi,0x23456789
- and bl,0x7f
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov dl,[edx]
- mov [ebp],dl
- mov al,[edi] ;; fetch dest : index into colormap
-
- dec ch
- jne vtquadloop
-vtdone:
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
-
-;;----------------------------------------------------------------------
-;; R_DrawShadeColumn
-;;
-;; for smoke..etc.. test.
-;;----------------------------------------------------------------------
-cglobal R_DrawShadeColumn_8_ASM
-R_DrawShadeColumn_8_ASM:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov ebp,[dc_yl]
- mov ebx,ebp
- mov edi,[ylookup+ebx*4]
- mov ebx,[dc_x]
- add edi,[columnofs+ebx*4] ;; edi = dest
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov eax,[dc_yh]
- inc eax
- sub eax,ebp ;; pixel count
- mov [pixelcount],eax ;; save for final pixel
- jle near shdone ;; nothing to scale
-;;
-;; frac = dc_texturemid - (centery-dc_yl)*fracstep;
-;;
- mov ecx,[dc_iscale] ;; fracstep
- mov eax,[centery]
- sub eax,ebp
- imul eax,ecx
- mov edx,[dc_texturemid]
- sub edx,eax
- mov ebx,edx
- shr ebx,16 ;; frac int.
- and ebx,byte +0x7f
- shl edx,16 ;; y frac up
-
- mov ebp,ecx
- shl ebp,16 ;; fracstep f. up
- shr ecx,16 ;; fracstep i. ->cl
- and cl,0x7f
-
- mov esi,[dc_source]
-;;
-;; lets rock :) !
-;;
- mov eax,[pixelcount]
- mov dh,al
- shr eax,2
- mov ch,al ;; quad count
- mov eax,[colormaps]
- test dh,3
- je sh4quadloop
-;;
-;; do un-even pixel
-;;
- test dh,0x1
- je shf2
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add edx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov [edi],dl
-pl: add edi,0x12345678
-;;
-;; do two non-quad-aligned pixels
-;;
-shf2:
- test dh,0x2
- je shf3
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add edx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov [edi],dl
-pm: add edi,0x12345678
-
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- add edx,ebp
- adc bl,cl
- mov al,[edi] ;; fetch dest : index into colormap
- and bl,0x7f
- mov dl,[eax]
- mov [edi],dl
-pn: add edi,0x12345678
-;;
-;; test if there was at least 4 pixels
-;;
-shf3:
- test ch,0xff ;; test quad count
- je near shdone
-
-;;
-;; ebp : ystep frac. upper 24 bits
-;; edx : y frac. upper 24 bits
-;; ebx : y i. lower 7 bits, masked for index
-;; ecx : ch = counter, cl = y step i.
-;; eax : colormap aligned 256
-;; esi : source texture column
-;; edi : dest screen
-;;
-sh4quadloop:
- mov dh,0x7f ;; prep mask
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [tystep],ebp
-po: add edi,0x12345678
- mov al,[edi] ;; fetch dest : index into colormap
-pp: sub edi,0x12345678
- mov ebp,edi
-pq: sub edi,0x12345678
- jmp short shinloop
-
-align 4
-shquadloop:
- add edx,[tystep]
- adc bl,cl
- and bl,dh
-q5: add ebp,0x12345678
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [edi],dl
- mov al,[ebp] ;; fetch dest : index into colormap
-shinloop:
- add edx,[tystep]
- adc bl,cl
- and bl,dh
-q6: add edi,0x12345678
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [ebp],dl
- mov al,[edi] ;; fetch dest : index into colormap
-
- add edx,[tystep]
- adc bl,cl
- and bl,dh
-q7: add ebp,0x12345678
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [edi],dl
- mov al,[ebp] ;; fetch dest : index into colormap
-
- add edx,[tystep]
- adc bl,cl
- and bl,dh
-q8: add edi,0x12345678
- mov dl,[eax]
- mov ah,[esi+ebx] ;; fetch texel : colormap number
- mov [ebp],dl
- mov al,[edi] ;; fetch dest : index into colormap
-
- dec ch
- jne shquadloop
-
-shdone:
- pop ebx ;; restore register variables
- pop edi
- pop esi
- pop ebp ;; restore caller's stack frame pointer
- ret
-
-
-;; ========================================================================
-;; Rasterization of the segments of a LINEAR polygne textur of manire.
-;; It is thus a question of interpolating coordinate them at the edges of texture in
-;; the time that the X-coordinates minx/maxx for each line.
-;; the argument ' dir' indicates which edges of texture are Interpol?:
-;; 0: segments associs at edge TOP? and BOTTOM? (constant TY)
-;; 1: segments associs at the LEFT and RIGHT edge (constant TX)
-;; ========================================================================
-;;
-;; void rasterize_segment_tex( LONG x1, LONG y1, LONG x2, LONG y2, LONG tv1, LONG tv2, LONG tc, LONG dir );
-;; ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7 ARG8
-;;
-;; Pour dir = 0, (tv1,tv2) = (tX1,tX2), tc = tY, en effet TY est constant.
-;;
-;; Pour dir = 1, (tv1,tv2) = (tY1,tY2), tc = tX, en effet TX est constant.
-;;
-;;
-;; Uses: extern struct rastery *_rastertab;
-;;
-
-MINX EQU 0
-MAXX EQU 4
-TX1 EQU 8
-TY1 EQU 12
-TX2 EQU 16
-TY2 EQU 20
-RASTERY_SIZEOF EQU 24
-
-cglobal rasterize_segment_tex_asm
-rasterize_segment_tex_asm:
- push ebp
- mov ebp,esp
-
- sub esp,byte +0x8 ;; allocate the local variables
-
- push ebx
- push esi
- push edi
- o16 mov ax,es
- push eax
-
-;; #define DX [ebp-4]
-;; #define TD [ebp-8]
-
- mov eax,[ebp+0xc] ;; y1
- mov ebx,[ebp+0x14] ;; y2
- cmp ebx,eax
- je near .L_finished ;; special (y1==y2) segment horizontal, exit!
-
- jg near .L_rasterize_right
-
-;;rasterize_left: ;; one rasterize a segment LEFT of the polygne
-
- mov ecx,eax
- sub ecx,ebx
- inc ecx ;; y1-y2+1
-
- mov eax,RASTERY_SIZEOF
- mul ebx ;; * y2
- mov esi,[prastertab]
- add esi,eax ;; point into rastertab[y2]
-
- mov eax,[ebp+0x8] ;; ARG1
- sub eax,[ebp+0x10] ;; ARG3
- shl eax,0x10 ;; ((x1-x2)<cl
- andb $0x7f,%cl
-
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
- movl C(pixelcount),%eax
- movb %al,%dh
- shrl $2,%eax
- movb %al,%ch // quad count
- movl C(dc_colormap),%eax
- testb $3,%dh
- jz v4quadloop
-
-//
-// do un-even pixel
-//
- testb $1,%dh
- jz 2f
-
- movb (%esi,%ebx),%al // prep un-even loops
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- movb %dl,(%edi) // output pixel
- addl C(vidwidth),%edi
-
-//
-// do two non-quad-aligned pixels
-//
-2:
- testb $2,%dh
- jz 3f
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- movb %dl,(%edi) // output pixel
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- addl C(vidwidth),%edi
- movb %dl,(%edi) // output pixel
-
- addl C(vidwidth),%edi
-
-//
-// test if there was at least 4 pixels
-//
-3:
- testb $0xFF,%ch // test quad count
- jz vdone
-
-//
-// ebp : ystep frac. upper 24 bits
-// edx : y frac. upper 24 bits
-// ebx : y i. lower 7 bits, masked for index
-// ecx : ch = counter, cl = y step i.
-// eax : colormap aligned 256
-// esi : source texture column
-// edi : dest screen
-//
-v4quadloop:
- movb $0x7f,%dh // prep mask
-// .align 4
-vquadloop:
- movb (%esi,%ebx),%al // prep loop
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- movb %dl,(%edi) // output pixel
- andb $0x7f,%bl // mask 0-127 texture index
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p1: movb %dl,0x12345678(%edi)
- andb $0x7f,%bl
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p2: movb %dl,2*0x12345678(%edi)
- andb $0x7f,%bl
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p3: movb %dl,3*0x12345678(%edi)
- andb $0x7f,%bl
-
-p4: addl $4*0x12345678,%edi
-
- decb %ch
- jnz vquadloop
-
-vdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-#ifdef HORIZONTALDRAW
-// --------------------------------------------------------------------------
-// Horizontal Column Drawer Optimisation
-// --------------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-.globl C(R_DrawHColumn_8)
-C(R_DrawHColumn_8):
- pushl %ebp
- pushl %esi
- pushl %edi
- pushl %ebx
-
-//
-// dest = yhlookup[dc_x] + hcolumnofs[dc_yl];
-//
- movl C(dc_x),%ebx
- movl C(yhlookup)(,%ebx,4),%edi
- movl C(dc_yl),%ebp
- movl %ebp,%ebx
- addl C(hcolumnofs)(,%ebx,4),%edi // edi = dest
-
-//
-// pixelcount = yh - yl + 1
-//
- movl C(dc_yh),%eax
- incl %eax
- subl %ebp,%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle vhdone // nothing to scale
-
-//
-// frac = dc_texturemid - (centery-dc_yl)*fracstep;
-//
- movl C(dc_iscale),%ecx // fracstep
- movl C(centery),%eax
- subl %ebp,%eax
- imul %ecx,%eax
- movl C(dc_texturemid),%edx
- subl %eax,%edx
- movl %edx,%ebx
- shrl $16,%ebx // frac int.
- andl $0x0000007f,%ebx
- shll $16,%edx // y frac up
-
- movl %ecx,%ebp
- shll $16,%ebp // fracstep f. up
- shrl $16,%ecx // fracstep i. ->cl
- andb $0x7f,%cl
-
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
-
- movl C(pixelcount),%eax
- movb %al,%dh
- shrl $2,%eax
- movb %al,%ch // quad count
-
- testb %ch, %ch
- jz vhnearlydone
-
- movl C(dc_colormap),%eax
- decl %edi //-----
-
-vhloop:
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- andb $0x7f,%bl
- incl %edi //-----
- movb (%eax),%dh
- movb %dh,(%edi) //-----
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- incl %edi //-----
- adcb %cl,%bl
- movb (%eax),%dl
- andb $0x7f,%bl
- movb %dl,(%edi) //-----
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
-// shll $16,%edx
- andb $0x7f,%bl
- incl %edi //-----
- movb (%eax),%dh
- movb %dh,(%edi) //-----
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- incl %edi //-----
- adcb %cl,%bl
- movb (%eax),%dl
- andb $0x7f,%bl
- movb %dl,(%edi)
-// movl %edx,(%edi)
-// addl $4,%edi
-
- decb %ch
- jnz vhloop
-
-vhnearlydone:
-// movl C(pixelcount)
-
-vhdone:
- popl %ebx
- popl %edi
- popl %esi
- popl %ebp
- ret
-
-
-// --------------------------------------------------------------------------
-// Rotate a buffer 90 degree in clockwise order after horiz.col. draws
-// --------------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-.globl C(R_RotateBuffer)
-C(R_RotateBuffer):
- pushl %ebp
- pushl %esi
- pushl %edi
- pushl %ebx
-
-
- movl C(dc_source),%esi
- movl C(dc_colormap),%edi
-
-
- movb (%esi),%ah
- addl $200,%esi
- movb (%ebx),%al
- addl $200,%ebx
- bswap %eax
- movb (%esi),%ah
- addl $200,%esi
- movb (%ebx),%al
- addl $200,%ebx
- movl %eax,(%edi)
- addl $4,%edi
-
-
- popl %ebx
- popl %edi
- popl %esi
- popl %ebp
- ret
-#endif
-
-//----------------------------------------------------------------------
-//13-02-98:
-// R_DrawSkyColumn : same as R_DrawColumn but:
-//
-// - wrap around 256 instead of 127.
-// this is needed because we have a higher texture for mouselook,
-// we need at least 200 lines for the sky.
-//
-// NOTE: the sky should never wrap, so it could use a faster method.
-// for the moment, we'll still use a wrapping method...
-//
-// IT S JUST A QUICK CUT N PASTE, WAS NOT OPTIMISED AS IT SHOULD BE !!!
-//
-//----------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-.globl C(R_DrawSkyColumn_8)
-C(R_DrawSkyColumn_8):
- pushl %ebp
- pushl %esi
- pushl %edi
- pushl %ebx
-
-//
-// dest = ylookup[dc_yl] + columnofs[dc_x];
-//
- movl C(dc_yl),%ebp
- movl %ebp,%ebx
- movl C(ylookup)(,%ebx,4),%edi
- movl C(dc_x),%ebx
- addl C(columnofs)(,%ebx,4),%edi // edi = dest
-
-//
-// pixelcount = yh - yl + 1
-//
- movl C(dc_yh),%eax
- incl %eax
- subl %ebp,%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle vskydone // nothing to scale
-
-//
-// frac = dc_texturemid - (centery-dc_yl)*fracstep;
-//
- movl C(dc_iscale),%ecx // fracstep
- movl C(centery),%eax
- subl %ebp,%eax
- imul %ecx,%eax
- movl C(dc_texturemid),%edx
- subl %eax,%edx
- movl %edx,%ebx
- shrl $16,%ebx // frac int.
- andl $0x000000ff,%ebx
- shll $16,%edx // y frac up
-
- movl %ecx,%ebp
- shll $16,%ebp // fracstep f. up
- shrl $16,%ecx // fracstep i. ->cl
-
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
- movl C(pixelcount),%eax
- movb %al,%dh
- shrl $2,%eax
- movb %al,%ch // quad count
- movl C(dc_colormap),%eax
- testb $3,%dh
- jz v4skyquadloop
-
-//
-// do un-even pixel
-//
- testb $1,%dh
- jz 2f
-
- movb (%esi,%ebx),%al // prep un-even loops
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- movb %dl,(%edi) // output pixel
- addl C(vidwidth),%edi
-
-//
-// do two non-quad-aligned pixels
-//
-2:
- testb $2,%dh
- jz 3f
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- movb %dl,(%edi) // output pixel
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- addl C(vidwidth),%edi
- movb %dl,(%edi) // output pixel
-
- addl C(vidwidth),%edi
-
-//
-// test if there was at least 4 pixels
-//
-3:
- testb $0xFF,%ch // test quad count
- jz vskydone
-
-//
-// ebp : ystep frac. upper 24 bits
-// edx : y frac. upper 24 bits
-// ebx : y i. lower 7 bits, masked for index
-// ecx : ch = counter, cl = y step i.
-// eax : colormap aligned 256
-// esi : source texture column
-// edi : dest screen
-//
-v4skyquadloop:
-// .align 4
-vskyquadloop:
- movb (%esi,%ebx),%al // prep loop
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- movb %dl,(%edi) // output pixel
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p1b: movb %dl,0x12345678(%edi)
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p2b: movb %dl,2*0x12345678(%edi)
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-p3b: movb %dl,3*0x12345678(%edi)
-
-p4b: addl $4*0x12345678,%edi
-
- decb %ch
- jnz vskyquadloop
-
-vskydone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-
-
-//----------------------------------------------------------------------
-//
-// R_DrawSpan
-//
-// Horizontal texture mapping
-//
-//----------------------------------------------------------------------
-
- .data
-
-ystep: .long 0
-xstep: .long 0
-C(texwidth): .long 64 // texture width
-#if !defined( LINUX)
- .text
-#endif
-#ifdef LINUX
- .align 2
-#else
- .align 4
-#endif
-.globl C(R_DrawSpan_8)
-C(R_DrawSpan_8):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
-
-//
-// find loop count
-//
- movl C(ds_x2),%eax
- incl %eax
- subl C(ds_x1),%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- js hdone // nothing to scale
- shrl $1,%eax // double pixel count
- movl %eax,C(loopcount)
-
-//
-// build composite position
-//
- movl C(ds_xfrac),%ebp
- shll $10,%ebp
- andl $0x0ffff0000,%ebp
- movl C(ds_yfrac),%eax
- shrl $6,%eax
- andl $0x0ffff,%eax
- movl C(ds_y),%edi
- orl %eax,%ebp
-
- movl C(ds_source),%esi
-
-//
-// calculate screen dest
-//
-
- movl C(ylookup)(,%edi,4),%edi
- movl C(ds_x1),%eax
- addl C(columnofs)(,%eax,4),%edi
-
-//
-// build composite step
-//
- movl C(ds_xstep),%ebx
- shll $10,%ebx
- andl $0x0ffff0000,%ebx
- movl C(ds_ystep),%eax
- shrl $6,%eax
- andl $0x0ffff,%eax
- orl %eax,%ebx
-
- //movl %eax,OFFSET hpatch1+2 // convice tasm to modify code...
- movl %ebx,hpatch1+2
- //movl %eax,OFFSET hpatch2+2 // convice tasm to modify code...
- movl %ebx,hpatch2+2
- movl %esi,hpatch3+2
- movl %esi,hpatch4+2
-// %eax aligned colormap
-// %ebx aligned colormap
-// %ecx,%edx scratch
-// %esi virtual source
-// %edi moving destination pointer
-// %ebp frac
- movl C(ds_colormap),%eax
-// shld $22,%ebp,%ecx // begin calculating third pixel (y units)
-// shld $6,%ebp,%ecx // begin calculating third pixel (x units)
- movl %ebp,%ecx
- addl %ebx,%ebp // advance frac pointer
- shrw $10,%cx
- roll $6,%ecx
- andl $4095,%ecx // finish calculation for third pixel
-// shld $22,%ebp,%edx // begin calculating fourth pixel (y units)
-// shld $6,%ebp,%edx // begin calculating fourth pixel (x units)
- movl %ebp,%edx
- shrw $10,%dx
- roll $6,%edx
- addl %ebx,%ebp // advance frac pointer
- andl $4095,%edx // finish calculation for fourth pixel
- movl %eax,%ebx
- movb (%esi,%ecx),%al // get first pixel
- movb (%esi,%edx),%bl // get second pixel
- testl $0x0fffffffe,C(pixelcount)
- movb (%eax),%dl // color translate first pixel
-
-// jnz hdoubleloop // at least two pixels to map
-// jmp hchecklast
-
-// movw $0xf0f0,%dx //see visplanes start
-
- jz hchecklast
- movb (%ebx),%dh // color translate second pixel
- movl C(loopcount),%esi
-// .align 4
-hdoubleloop:
-// shld $22,%ebp,%ecx // begin calculating third pixel (y units)
-// shld $6,%ebp,%ecx // begin calculating third pixel (x units)
- movl %ebp,%ecx
- shrw $10,%cx
- roll $6,%ecx
-hpatch1:
- addl $0x012345678,%ebp // advance frac pointer
- movw %dx,(%edi) // write first pixel
- andl $4095,%ecx // finish calculation for third pixel
-// shld $22,%ebp,%edx // begin calculating fourth pixel (y units)
-// shld $6,%ebp,%edx // begin calculating fourth pixel (x units)
- movl %ebp,%edx
- shrw $10,%dx
- roll $6,%edx
-hpatch3:
- movb 0x012345678(%ecx),%al // get third pixel
-// movb %bl,1(%edi) // write second pixel
- andl $4095,%edx // finish calculation for fourth pixel
-hpatch2:
- addl $0x012345678,%ebp // advance frac pointer
-hpatch4:
- movb 0x012345678(%edx),%bl // get fourth pixel
- movb (%eax),%dl // color translate third pixel
- addl $2,%edi // advance to third pixel destination
- decl %esi // done with loop?
- movb (%ebx),%dh // color translate fourth pixel
- jnz hdoubleloop
-
-// check for final pixel
-hchecklast:
- testl $1,C(pixelcount)
- jz hdone
- movb %dl,(%edi) // write final pixel
-
-hdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-
-//.endif
-
-
-//----------------------------------------------------------------------
-// R_DrawTransColumn
-//
-// Vertical column texture drawer, with transparency. Replaces Doom2's
-// 'fuzz' effect, which was not so beautiful.
-// Transparency is always impressive in some way, don't know why...
-//----------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-
-.globl C(R_DrawTranslucentColumn_8)
-C(R_DrawTranslucentColumn_8):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
-//
-// dest = ylookup[dc_yl] + columnofs[dc_x];
-//
- movl C(dc_yl),%ebp
- movl %ebp,%ebx
- movl C(ylookup)(,%ebx,4),%edi
- movl C(dc_x),%ebx
- addl C(columnofs)(,%ebx,4),%edi // edi = dest
-
-//
-// pixelcount = yh - yl + 1
-//
- movl C(dc_yh),%eax
- incl %eax
- subl %ebp,%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle vtdone // nothing to scale
-
-//
-// frac = dc_texturemid - (centery-dc_yl)*fracstep;
-//
- movl C(dc_iscale),%ecx // fracstep
- movl C(centery),%eax
- subl %ebp,%eax
- imul %ecx,%eax
- movl C(dc_texturemid),%edx
- subl %eax,%edx
- movl %edx,%ebx
-
- shrl $16,%ebx // frac int.
- andl $0x0000007f,%ebx
- shll $16,%edx // y frac up
-
- movl %ecx,%ebp
- shll $16,%ebp // fracstep f. up
- shrl $16,%ecx // fracstep i. ->cl
- andb $0x7f,%cl
- pushw %cx
- movl %edx,%ecx
- popw %cx
- movl C(dc_colormap),%edx
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
- movl C(pixelcount),%eax
- shrl $2,%eax
- testb $0x03,C(pixelcount)
- movb %al,%ch // quad count
- movl C(dc_transmap),%eax
- jz vt4quadloop
-//
-// do un-even pixel
-//
- testb $1,C(pixelcount)
- jz 2f
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%ecx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%edx), %dl // use colormap now !
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-//
-// do two non-quad-aligned pixels
-//
-2:
- testb $2,C(pixelcount)
- jz 3f
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%ecx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%edx), %dl // use colormap now !
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%ecx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%edx), %dl // use colormap now !
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-
-//
-// test if there was at least 4 pixels
-//
-3:
- testb $0xFF,%ch // test quad count
- jz vtdone
-
-//
-// tystep : ystep frac. upper 24 bits
-// edx : upper 24 bit : colomap
-// dl : tmp pixel to write
-// ebx : y i. lower 7 bits, masked for index
-// ecx : y frac. upper 16 bits
-// ecx : ch = counter, cl = y step i.
-// eax : transmap aligned 65535 (upper 16 bit)
-// ah : background pixel (from the screen buffer)
-// al : foreground pixel (from the texture)
-// esi : source texture column
-// ebp,edi : dest screen
-//
-vt4quadloop:
- movb (%esi,%ebx),%ah // fetch texel : colormap number
-p5: movb 0x12345678(%edi),%al // fetch dest : index into colormap
-
- movl %ebp,C(tystep)
- movl %edi,%ebp
- subl C(vidwidth),%edi
- jmp inloop
-// .align 4
-vtquadloop:
- addl C(tystep),%ecx
- adcb %cl,%bl
-p6: addl $2*0x12345678,%ebp
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb (%edx), %dl // use colormap now !
- movb %dl,(%edi)
- movb (%ebp),%al // fetch dest : index into colormap
-inloop:
- addl C(tystep),%ecx
- adcb %cl,%bl
-p7: addl $2*0x12345678,%edi
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb (%edx), %dl // use colormap now !
- movb %dl,(%ebp)
- movb (%edi),%al // fetch dest : index into colormap
-
- addl C(tystep),%ecx
- adcb %cl,%bl
-p8: addl $2*0x12345678,%ebp
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb (%edx), %dl // use colormap now !
- movb %dl,(%edi)
- movb (%ebp),%al // fetch dest : index into colormap
-
- addl C(tystep),%ecx
- adcb %cl,%bl
-p9: addl $2*0x12345678,%edi
- andb $0x7f,%bl
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb (%edx), %dl // use colormap now !
- movb %dl,(%ebp)
- movb (%edi),%al // fetch dest : index into colormap
-
- decb %ch
- jnz vtquadloop
-
-vtdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-#endif // ifdef USEASM
-
-
-
-//----------------------------------------------------------------------
-// R_DrawShadeColumn
-//
-// for smoke..etc.. test.
-//----------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-.globl C(R_DrawShadeColumn_8)
-C(R_DrawShadeColumn_8):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
-//
-// dest = ylookup[dc_yl] + columnofs[dc_x];
-//
- movl C(dc_yl),%ebp
- movl %ebp,%ebx
- movl C(ylookup)(,%ebx,4),%edi
- movl C(dc_x),%ebx
- addl C(columnofs)(,%ebx,4),%edi // edi = dest
-
-//
-// pixelcount = yh - yl + 1
-//
- movl C(dc_yh),%eax
- incl %eax
- subl %ebp,%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle shdone // nothing to scale
-
-//
-// frac = dc_texturemid - (centery-dc_yl)*fracstep;
-//
- movl C(dc_iscale),%ecx // fracstep
- movl C(centery),%eax
- subl %ebp,%eax
- imul %ecx,%eax
- movl C(dc_texturemid),%edx
- subl %eax,%edx
- movl %edx,%ebx
- shrl $16,%ebx // frac int.
- andl $0x0000007f,%ebx
- shll $16,%edx // y frac up
-
- movl %ecx,%ebp
- shll $16,%ebp // fracstep f. up
- shrl $16,%ecx // fracstep i. ->cl
- andb $0x7f,%cl
-
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
- movl C(pixelcount),%eax
- movb %al,%dh
- shrl $2,%eax
- movb %al,%ch // quad count
- movl C(colormaps),%eax
- testb $0x03,%dh
- jz sh4quadloop
-
-//
-// do un-even pixel
-//
- testb $1,%dh
- jz 2f
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-
-//
-// do two non-quad-aligned pixels
-//
-2:
- testb $2,%dh
- jz 3f
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%edi),%al // fetch dest : index into colormap
- andb $0x7f,%bl
- movb (%eax),%dl
- movb %dl,(%edi)
- addl C(vidwidth),%edi
-
-//
-// test if there was at least 4 pixels
-//
-3:
- testb $0xFF,%ch // test quad count
- jz shdone
-
-//
-// ebp : ystep frac. upper 24 bits
-// edx : y frac. upper 24 bits
-// ebx : y i. lower 7 bits, masked for index
-// ecx : ch = counter, cl = y step i.
-// eax : colormap aligned 256
-// esi : source texture column
-// edi : dest screen
-//
-sh4quadloop:
- movb $0x7f,%dh // prep mask
-
- movb (%esi,%ebx),%ah // fetch texel : colormap number
-sh5: movb 0x12345678(%edi),%al // fetch dest : index into colormap
-
- movl %ebp,C(tystep)
- movl %edi,%ebp
- subl C(vidwidth),%edi
- jmp shinloop
-// .align 4
-shquadloop:
- addl C(tystep),%edx
- adcb %cl,%bl
- andb %dh,%bl
-sh6: addl $2*0x12345678,%ebp
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb %dl,(%edi)
- movb (%ebp),%al // fetch dest : index into colormap
-shinloop:
- addl C(tystep),%edx
- adcb %cl,%bl
- andb %dh,%bl
-sh7: addl $2*0x12345678,%edi
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb %dl,(%ebp)
- movb (%edi),%al // fetch dest : index into colormap
-
- addl C(tystep),%edx
- adcb %cl,%bl
- andb %dh,%bl
-sh8: addl $2*0x12345678,%ebp
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb %dl,(%edi)
- movb (%ebp),%al // fetch dest : index into colormap
-
- addl C(tystep),%edx
- adcb %cl,%bl
- andb %dh,%bl
-sh9: addl $2*0x12345678,%edi
- movb (%eax),%dl
- movb (%esi,%ebx),%ah // fetch texel : colormap number
- movb %dl,(%ebp)
- movb (%edi),%al // fetch dest : index into colormap
-
- decb %ch
- jnz shquadloop
-
-shdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-
-
-//----------------------------------------------------------------------
-//
-// R_DrawWaterColumn : basically it's just a copy of R_DrawColumn,
-// but it uses dc_colormap from dc_yl to dc_yw-1
-// then it uses dc_wcolormap from dc_yw to dc_yh
-//
-// Thus, the 'underwater' part of the walls is remapped to 'water-like'
-// colors.
-//
-//----------------------------------------------------------------------
-
-#ifdef LINUX
- .align 2
-#else
- .align 5
-#endif
-.globl C(R_DrawWaterColumn)
-C(R_DrawWaterColumn):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
-//
-// dest = ylookup[dc_yl] + columnofs[dc_x];
-//
- movl C(dc_yl),%ebp
- movl %ebp,%ebx
- movl C(ylookup)(,%ebx,4),%edi
- movl C(dc_x),%ebx
- addl C(columnofs)(,%ebx,4),%edi // edi = dest
-
-//
-// pixelcount = yh - yl + 1
-//
- movl C(dc_yh),%eax
- incl %eax
- subl %ebp,%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle wdone // nothing to scale
-
-//
-// frac = dc_texturemid - (centery-dc_yl)*fracstep;
-//
- movl C(dc_iscale),%ecx // fracstep
- movl C(centery),%eax
- subl %ebp,%eax
- imul %ecx,%eax
- movl C(dc_texturemid),%edx
- subl %eax,%edx
- movl %edx,%ebx
- shrl $16,%ebx // frac int.
- andl $0x0000007f,%ebx
- shll $16,%edx // y frac up
-
- movl %ecx,%ebp
- shll $16,%ebp // fracstep f. up
- shrl $16,%ecx // fracstep i. ->cl
- andb $0x7f,%cl
-
- movl C(dc_source),%esi
-
-//
-// lets rock :) !
-//
- movl C(pixelcount),%eax
- movb %al,%dh
- shrl $2,%eax
- movb %al,%ch // quad count
- movl C(dc_wcolormap),%eax
- testb $3,%dh
- jz w4quadloop
-
-//
-// do un-even pixel
-//
- testb $1,%dh
- jz 2f
-
- movb (%esi,%ebx),%al // prep un-even loops
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- movb %dl,(%edi) // output pixel
- addl C(vidwidth),%edi
-
-//
-// do two non-quad-aligned pixels
-//
-2:
- testb $2,%dh
- jz 3f
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- movb %dl,(%edi) // output pixel
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- andb $0x7f,%bl // mask 0-127 texture index
- addl C(vidwidth),%edi
- movb %dl,(%edi) // output pixel
-
- addl C(vidwidth),%edi
-
-//
-// test if there was at least 4 pixels
-//
-3:
- testb $0xFF,%ch // test quad count
- jz wdone
-
-//
-// ebp : ystep frac. upper 24 bits
-// edx : y frac. upper 24 bits
-// ebx : y i. lower 7 bits, masked for index
-// ecx : ch = counter, cl = y step i.
-// eax : colormap aligned 256
-// esi : source texture column
-// edi : dest screen
-//
-w4quadloop:
- movb $0x7f,%dh // prep mask
-// .align 4
-wquadloop:
- movb (%esi,%ebx),%al // prep loop
- addl %ebp,%edx // ypos f += ystep f
- adcb %cl,%bl // ypos i += ystep i
- movb (%eax),%dl // colormap texel
- movb %dl,(%edi) // output pixel
- andb $0x7f,%bl // mask 0-127 texture index
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-w1: movb %dl,0x12345678(%edi)
- andb $0x7f,%bl
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-w2: movb %dl,2*0x12345678(%edi)
- andb $0x7f,%bl
-
- movb (%esi,%ebx),%al // fetch source texel
- addl %ebp,%edx
- adcb %cl,%bl
- movb (%eax),%dl
-w3: movb %dl,3*0x12345678(%edi)
- andb $0x7f,%bl
-
-w4: addl $4*0x12345678,%edi
-
- decb %ch
- jnz wquadloop
-
-wdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-
-
-
-
-
-
-//----------------------------------------------------------------------
-//
-// R_DrawSpanNoWrap
-//
-// Horizontal texture mapping, does not remap colors,
-// neither needs to wrap around the source texture.
-//
-// Thus, a special optimisation can be used...
-//
-//----------------------------------------------------------------------
-
- .data
-
-advancetable: .long 0, 0
-#if !defined( LINUX)
- .text
-#endif
-#ifdef LINUX
- .align 2
-#else
- .align 4
-#endif
-.globl C(R_DrawSpanNoWrap)
-C(R_DrawSpanNoWrap):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
-//
-// find loop count
-//
-
- movl C(ds_x2),%eax
- incl %eax
- subl C(ds_x1),%eax // pixel count
- movl %eax,C(pixelcount) // save for final pixel
- jle htvdone // nothing to scale
-// shrl $1,%eax // double pixel count
-// movl %eax,C(loopcount)
-
-//
-// calculate screen dest
-//
-
- movl C(ds_y),%edi //full destination start address
-
-//
-// set up advancetable
-//
-
- movl C(ds_xstep),%ebp
- movl C(ds_ystep),%ecx
- movl %ecx,%eax
- movl %ebp,%edx
- sarl $16,%edx // xstep >>= 16;
- movl C(vidwidth),%ebx
- sarl $16,%eax // ystep >>= 16;
- jz 0f
- imull %ebx,%eax // (ystep >> 16) * texwidth;
-0:
- addl %edx,%eax // add in xstep
- // (ystep >> 16) * texwidth + (xstep >> 16);
-
- movl %eax,advancetable+4 // advance base in y
- addl %ebx,%eax // ((ystep >> 16) + 1) * texwidth +
- // (xstep >> 16);
- movl %eax,advancetable // advance extra in y
-
- shll $16,%ebp // left-justify xstep fractional part
- movl %ebp,xstep
- shll $16,%ecx // left-justify ystep fractional part
- movl %ecx,ystep
-
-//
-// calculate the texture starting address
-//
- movl C(ds_source),%esi // texture source
-
- movl C(ds_yfrac),%eax
- movl %eax,%edx
- sarl $16,%eax
- movl C(ds_xfrac),%ecx
- imull %ebx,%eax // (yfrac >> 16) * texwidth
- movl %ecx,%ebx
- sarl $16,%ecx
- movl %ecx,%ebp
- addl %eax,%ebp // source = (xfrac >> 16) +
- // ((yfrac >> 16) * texwidth);
-
-//
-// esi : texture source
-// edi : screen dest
-// eax : colormap aligned on 256 boundary, hehehe...
-// ebx : xfrac << 16
-// ecx : used in loop, contains either 0 or -1, *4, offset into advancetable
-// edx : yfrac << 16
-// ebp : offset into texture
-//
-
- shll $16,%edx // yfrac upper word, lower byte will be used
- movl C(ds_colormap),%eax
- shll $16,%ebx // xfrac upper word, lower unused
-
- movl C(pixelcount),%ecx
- shrl $2,%ecx
- movb %cl,%dh // quad pixels count
-
- movl C(pixelcount),%ecx
- andl $3,%ecx
- jz htvquadloop // pixelcount is multiple of 4
- decl %ecx
- jz 1f
- decl %ecx
- jz 2f
-
-//
-// do one to three pixels first
-//
- addl ystep,%edx // yfrac += ystep
- sbbl %ecx,%ecx // turn carry into 0 or -1 if set
- movb (%esi,%ebp),%al // get texture pixel
- addl xstep,%ebx // xfrac += xstep
-// movb (%eax),%dl // pixel goes through colormap
- adcl advancetable+4(,%ecx,4),%ebp // advance source
- movb %al,(%edi) // write pixel dest
-
- incl %edi
-
-2:
- addl ystep,%edx // yfrac += ystep
- sbbl %ecx,%ecx // turn carry into 0 or -1 if set
- movb (%esi,%ebp),%al // get texture pixel
- addl xstep,%ebx // xfrac += xstep
-// movb (%eax),%dl // pixel goes through colormap
- adcl advancetable+4(,%ecx,4),%ebp // advance source
- movb %al,(%edi) // write pixel dest
-
- incl %edi
-
-1:
- addl ystep,%edx // yfrac += ystep
- sbbl %ecx,%ecx // turn carry into 0 or -1 if set
- movb (%esi,%ebp),%al // get texture pixel
- addl xstep,%ebx // xfrac += xstep
-// movb (%eax),%dl // pixel goes through colormap
- adcl advancetable+4(,%ecx,4),%ebp // advance source
- movb %al,(%edi) // write pixel dest
-
- incl %edi
-
-//
-// test if there was at least 4 pixels
-//
- testb $0xFF,%dh
- jz htvdone
-
-//
-// two pixels per loop
-// U
-// V
-htvquadloop:
- addl ystep,%edx // yfrac += ystep
- sbbl %ecx,%ecx // turn carry into 0 or -1 if set
- movb (%esi,%ebp),%al // get texture pixel
- addl xstep,%ebx // xfrac += xstep
-// movb (%eax),%dl // pixel goes through colormap
- adcl advancetable+4(,%ecx,4),%ebp // advance source
- movb %al,(%edi) // write pixel dest
-
- addl ystep,%edx
- sbbl %ecx,%ecx
- movb (%esi,%ebp),%al
- addl xstep,%ebx
-// movb (%eax),%dl
- adcl advancetable+4(,%ecx,4),%ebp
- movb %al,1(%edi)
-
- addl ystep,%edx
- sbbl %ecx,%ecx
- movb (%esi,%ebp),%al
- addl xstep,%ebx
-// movb (%eax),%dl
- adcl advancetable+4(,%ecx,4),%ebp
- movb %al,2(%edi)
-
- addl ystep,%edx
- sbbl %ecx,%ecx
- movb (%esi,%ebp),%al
- addl xstep,%ebx
-// movb (%eax),%dl
- adcl advancetable+4(,%ecx,4),%ebp
- movb %al,3(%edi)
-
- addl $4, %edi
- incl %ecx //dummy
-
- decb %dh
- jnz htvquadloop // paire dans V-pipe
-
-htvdone:
- popl %ebx // restore register variables
- popl %edi
- popl %esi
- popl %ebp // restore caller's stack frame pointer
- ret
-
-
-//.endif
-
-#ifdef HORIZONTALDRAW
-// void R_RotateBuffere (void)
-
-#ifdef LINUX
- .align 2
-#else
- .align 4
-#endif
-.globl C(R_RotateBufferasm)
-C(R_RotateBufferasm):
- pushl %ebp // preserve caller's stack frame pointer
- pushl %esi // preserve register variables
- pushl %edi
- pushl %ebx
-
- movl C(dc_source),%esi
- movl C(dc_colormap),%edi
-
- movl $200,%edx
-ra2:
- movl $40,%ecx
-ra:
- movb -2*200(%esi),%al
- movb -6*200(%esi),%bl
- movb -3*200(%esi),%ah
- movb -7*200(%esi),%bh
- shll $16,%eax
- shll $16,%ebx
- movb (%esi),%al
- movb -4*200(%esi),%bl
- movb -1*200(%esi),%ah
- movb -5*200(%esi),%bh
- movl %eax,(%edi)
- subl $8*200,%esi
- movl %ebx,4(%edi)
- addl $8,%edi
- decl %ecx
- jnz ra
-
- addl $320*200+1,%esi //32*480 passe a la ligne suivante
-// addl 320-32,%edi
-
- decl %edx
- jnz ra2
-
- pop %ebp // preserve caller's stack frame pointer
- pop %esi // preserve register variables
- pop %edi
- pop %ebx
- ret
-#endif
diff --git a/src/tmap_asm.s b/src/tmap_asm.s
deleted file mode 100644
index d8967178c..000000000
--- a/src/tmap_asm.s
+++ /dev/null
@@ -1,322 +0,0 @@
-// SONIC ROBO BLAST 2
-//-----------------------------------------------------------------------------
-// Copyright (C) 1998-2000 by DooM Legacy Team.
-// Copyright (C) 1999-2023 by Sonic Team Junior.
-//
-// This program is free software distributed under the
-// terms of the GNU General Public License, version 2.
-// See the 'LICENSE' file for more details.
-//-----------------------------------------------------------------------------
-/// \file tmap_asm.s
-/// \brief ???
-
-//.comm _dc_colormap,4
-//.comm _dc_x,4
-//.comm _dc_yl,4
-//.comm _dc_yh,4
-//.comm _dc_iscale,4
-//.comm _dc_texturemid,4
-//.comm _dc_source,4
-//.comm _ylookup,4
-//.comm _columnofs,4
-//.comm _loopcount,4
-//.comm _pixelcount,4
-.data
-_pixelcount:
-.long 0x00000000
-_loopcount:
-.long 0x00000000
-.align 8
-_mmxcomm:
-.long 0x00000000
-.text
-
- .align 4
-.globl _R_DrawColumn8_NOMMX
-_R_DrawColumn8_NOMMX:
- pushl %ebp
- pushl %esi
- pushl %edi
- pushl %ebx
- movl _dc_yl,%edx
- movl _dc_yh,%eax
- subl %edx,%eax
- leal 1(%eax),%ebx
- testl %ebx,%ebx
- jle rdc8ndone
- movl _dc_x,%eax
- movl _ylookup, %edi
- movl (%edi,%edx,4),%esi
- movl _columnofs, %edi
- addl (%edi,%eax,4),%esi
- movl _dc_iscale,%edi
- movl %edx,%eax
- imull %edi,%eax
- movl _dc_texturemid,%ecx
- addl %eax,%ecx
-
- movl _dc_source,%ebp
- xorl %edx, %edx
- subl $0x12345678, %esi
-.globl rdc8nwidth1
-rdc8nwidth1:
- .align 4,0x90
-rdc8nloop:
- movl %ecx,%eax
- shrl $16,%eax
- addl %edi,%ecx
- andl $127,%eax
- addl $0x12345678,%esi
-.globl rdc8nwidth2
-rdc8nwidth2:
- movb (%eax,%ebp),%dl
- movl _dc_colormap,%eax
- movb (%eax,%edx),%al
- movb %al,(%esi)
- decl %ebx
- jne rdc8nloop
-rdc8ndone:
- popl %ebx
- popl %edi
- popl %esi
- popl %ebp
- ret
-
-//
-// Optimised specifically for P54C/P55C (aka Pentium with/without MMX)
-// By ES 1998/08/01
-//
-
-.globl _R_DrawColumn_8_Pentium
-_R_DrawColumn_8_Pentium:
- pushl %ebp
- pushl %ebx
- pushl %esi
- pushl %edi
- movl _dc_yl,%eax // Top pixel
- movl _dc_yh,%ebx // Bottom pixel
- movl _ylookup, %edi
- movl (%edi,%ebx,4),%ecx
- subl %eax,%ebx // ebx=number of pixels-1
- jl rdc8pdone // no pixel to draw, done
- jnz rdc8pmany
- movl _dc_x,%edx // Special case: only one pixel
- movl _columnofs, %edi
- addl (%edi,%edx,4),%ecx // dest pixel at (%ecx)
- movl _dc_iscale,%esi
- imull %esi,%eax
- movl _dc_texturemid,%edi
- addl %eax,%edi // texture index in edi
- movl _dc_colormap,%edx
- shrl $16, %edi
- movl _dc_source,%ebp
- andl $127,%edi
- movb (%edi,%ebp),%dl // read texture pixel
- movb (%edx),%al // lookup for light
- movb %al,0(%ecx) // write it
- jmp rdc8pdone // done!
-.align 4, 0x90
-rdc8pmany: // draw >1 pixel
- movl _dc_x,%edx
- movl _columnofs, %edi
- movl (%edi,%edx,4),%edx
- leal 0x12345678(%edx, %ecx), %edi // edi = two pixels above bottom
-.globl rdc8pwidth5
-rdc8pwidth5: // DeadBeef = -2*SCREENWIDTH
- movl _dc_iscale,%edx // edx = fracstep
- imull %edx,%eax
- shll $9, %edx // fixme: Should get 7.25 fix as input
- movl _dc_texturemid,%ecx
- addl %eax,%ecx // ecx = frac
- movl _dc_colormap,%eax // eax = lighting/special effects LUT
- shll $9, %ecx
- movl _dc_source,%esi // esi = source ptr
-
- imull $0x12345678, %ebx // ebx = negative offset to pixel
-.globl rdc8pwidth6
-rdc8pwidth6: // DeadBeef = -SCREENWIDTH
-
-// Begin the calculation of the two first pixels
- leal (%ecx, %edx), %ebp
- shrl $25, %ecx
- movb (%esi, %ecx), %al
- leal (%edx, %ebp), %ecx
- shrl $25, %ebp
- movb (%eax), %dl
-
-// The main loop
-rdc8ploop:
- movb (%esi,%ebp), %al // load 1
- leal (%ecx, %edx), %ebp // calc frac 3
-
- shrl $25, %ecx // shift frac 2
- movb %dl, 0x12345678(%edi, %ebx)// store 0
-.globl rdc8pwidth1
-rdc8pwidth1: // DeadBeef = 2*SCREENWIDTH
-
- movb (%eax), %al // lookup 1
-
- movb %al, 0x12345678(%edi, %ebx)// store 1
-.globl rdc8pwidth2
-rdc8pwidth2: // DeadBeef = 3*SCREENWIDTH
- movb (%esi, %ecx), %al // load 2
-
- leal (%ebp, %edx), %ecx // calc frac 4
-
- shrl $25, %ebp // shift frac 3
- movb (%eax), %dl // lookup 2
-
- addl $0x12345678, %ebx // counter
-.globl rdc8pwidth3
-rdc8pwidth3: // DeadBeef = 2*SCREENWIDTH
- jl rdc8ploop // loop
-
-// End of loop. Write extra pixel or just exit.
- jnz rdc8pdone
- movb %dl, 0x12345678(%edi, %ebx)// Write odd pixel
-.globl rdc8pwidth4
-rdc8pwidth4: // DeadBeef = 2*SCREENWIDTH
-
-rdc8pdone:
-
- popl %edi
- popl %esi
- popl %ebx
- popl %ebp
- ret
-
-//
-// MMX asm version, optimised for K6
-// By ES 1998/07/05
-//
-
-.globl _R_DrawColumn_8_K6_MMX
-_R_DrawColumn_8_K6_MMX:
- pushl %ebp
- pushl %ebx
- pushl %esi
- pushl %edi
-
- movl %esp, %eax // Push 8 or 12, so that (%esp) gets aligned by 8
- andl $7,%eax
- addl $8,%eax
- movl %eax, _mmxcomm // Temp storage in mmxcomm: (%esp) is used instead
- subl %eax,%esp
-
- movl _dc_yl,%edx // Top pixel
- movl _dc_yh,%ebx // Bottom pixel
- movl _ylookup, %edi
- movl (%edi,%ebx,4),%ecx
- subl %edx,%ebx // ebx=number of pixels-1
- jl 0x12345678 // no pixel to draw, done
-.globl rdc8moffs1
-rdc8moffs1:
- jnz rdc8mmany
- movl _dc_x,%eax // Special case: only one pixel
- movl _columnofs, %edi
- addl (%edi,%eax,4),%ecx // dest pixel at (%ecx)
- movl _dc_iscale,%esi
- imull %esi,%edx
- movl _dc_texturemid,%edi
- addl %edx,%edi // texture index in edi
- movl _dc_colormap,%edx
- shrl $16, %edi
- movl _dc_source,%ebp
- andl $127,%edi
- movb (%edi,%ebp),%dl // read texture pixel
- movb (%edx),%al // lookup for light
- movb %al,0(%ecx) // write it
- jmp rdc8mdone // done!
-.globl rdc8moffs2
-rdc8moffs2:
-.align 4, 0x90
-rdc8mmany: // draw >1 pixel
- movl _dc_x,%eax
- movl _columnofs, %edi
- movl (%edi,%eax,4),%eax
- leal 0x12345678(%eax, %ecx), %esi // esi = two pixels above bottom
-.globl rdc8mwidth3
-rdc8mwidth3: // DeadBeef = -2*SCREENWIDTH
- movl _dc_iscale,%ecx // ecx = fracstep
- imull %ecx,%edx
- shll $9, %ecx // fixme: Should get 7.25 fix as input
- movl _dc_texturemid,%eax
- addl %edx,%eax // eax = frac
- movl _dc_colormap,%edx // edx = lighting/special effects LUT
- shll $9, %eax
- leal (%ecx, %ecx), %edi
- movl _dc_source,%ebp // ebp = source ptr
- movl %edi, 0(%esp) // Start moving frac and fracstep to MMX regs
-
- imull $0x12345678, %ebx // ebx = negative offset to pixel
-.globl rdc8mwidth5
-rdc8mwidth5: // DeadBeef = -SCREENWIDTH
-
- movl %edi, 4(%esp)
- leal (%eax, %ecx), %edi
- movq 0(%esp), %mm1 // fracstep:fracstep in mm1
- movl %eax, 0(%esp)
- shrl $25, %eax
- movl %edi, 4(%esp)
- movzbl (%ebp, %eax), %eax
- movq 0(%esp), %mm0 // frac:frac in mm0
-
- paddd %mm1, %mm0
- shrl $25, %edi
- movq %mm0, %mm2
- psrld $25, %mm2 // texture index in mm2
- paddd %mm1, %mm0
- movq %mm2, 0(%esp)
-
-.globl rdc8mloop
-rdc8mloop: // The main loop
- movq %mm0, %mm2 // move 4-5 to temp reg
- movzbl (%ebp, %edi), %edi // read 1
-
- psrld $25, %mm2 // shift 4-5
- movb (%edx,%eax), %cl // lookup 0
-
- movl 0(%esp), %eax // load 2
- addl $0x12345678, %ebx // counter
-.globl rdc8mwidth2
-rdc8mwidth2: // DeadBeef = 2*SCREENWIDTH
-
- movb %cl, (%esi, %ebx) // write 0
- movb (%edx,%edi), %ch // lookup 1
-
- movb %ch, 0x12345678(%esi, %ebx) // write 1
-.globl rdc8mwidth1
-rdc8mwidth1: // DeadBeef = SCREENWIDTH
- movl 4(%esp), %edi // load 3
-
- paddd %mm1, %mm0 // frac 6-7
- movzbl (%ebp, %eax), %eax // lookup 2
-
- movq %mm2, 0(%esp) // store texture index 4-5
- jl rdc8mloop
-
- jnz rdc8mno_odd
- movb (%edx,%eax), %cl // write the last odd pixel
- movb %cl, 0x12345678(%esi)
-.globl rdc8mwidth4
-rdc8mwidth4: // DeadBeef = 2*SCREENWIDTH
-rdc8mno_odd:
-
-.globl rdc8mdone
-rdc8mdone:
- emms
-
- addl _mmxcomm, %esp
- popl %edi
- popl %esi
- popl %ebx
- popl %ebp
- ret
-
-// Need some extra space to align run-time
-.globl R_DrawColumn_8_K6_MMX_end
-R_DrawColumn_8_K6_MMX_end:
-nop;nop;nop;nop;nop;nop;nop;nop;
-nop;nop;nop;nop;nop;nop;nop;nop;
-nop;nop;nop;nop;nop;nop;nop;nop;
-nop;nop;nop;nop;nop;nop;nop;
diff --git a/src/tmap_mmx.nas b/src/tmap_mmx.nas
deleted file mode 100644
index a45667e23..000000000
--- a/src/tmap_mmx.nas
+++ /dev/null
@@ -1,674 +0,0 @@
-;; SONIC ROBO BLAST 2
-;;-----------------------------------------------------------------------------
-;; Copyright (C) 1998-2000 by DOSDOOM.
-;; Copyright (C) 2010-2023 by Sonic Team Junior.
-;;
-;; This program is free software distributed under the
-;; terms of the GNU General Public License, version 2.
-;; See the 'LICENSE' file for more details.
-;;-----------------------------------------------------------------------------
-;; FILE:
-;; tmap_mmx.nas
-;; DESCRIPTION:
-;; Assembler optimised rendering code for software mode, using SIMD
-;; instructions.
-;; Draw wall columns.
-
-
-[BITS 32]
-
-%define FRACBITS 16
-%define TRANSPARENTPIXEL 255
-
-%ifdef LINUX
-%macro cextern 1
-[extern %1]
-%endmacro
-
-%macro cglobal 1
-[global %1]
-%endmacro
-
-%else
-%macro cextern 1
-%define %1 _%1
-[extern %1]
-%endmacro
-
-%macro cglobal 1
-%define %1 _%1
-[global %1]
-%endmacro
-
-%endif
-
-
-; The viddef_s structure. We only need the width field.
-struc viddef_s
- resb 12
-.width: resb 4
- resb 44
-endstruc
-
-
-;; externs
-;; columns
-cextern dc_colormap
-cextern dc_x
-cextern dc_yl
-cextern dc_yh
-cextern dc_iscale
-cextern dc_texturemid
-cextern dc_texheight
-cextern dc_source
-cextern dc_hires
-cextern centery
-cextern centeryfrac
-cextern dc_transmap
-
-cextern R_DrawColumn_8_ASM
-cextern R_Draw2sMultiPatchColumn_8_ASM
-
-;; spans
-cextern nflatshiftup
-cextern nflatxshift
-cextern nflatyshift
-cextern nflatmask
-cextern ds_xfrac
-cextern ds_yfrac
-cextern ds_xstep
-cextern ds_ystep
-cextern ds_x1
-cextern ds_x2
-cextern ds_y
-cextern ds_source
-cextern ds_colormap
-
-cextern ylookup
-cextern columnofs
-cextern vid
-
-[SECTION .data]
-
-nflatmask64 dq 0
-
-
-[SECTION .text]
-
-;;----------------------------------------------------------------------
-;;
-;; R_DrawColumn : 8bpp column drawer
-;;
-;; MMX column drawer.
-;;
-;;----------------------------------------------------------------------
-;; eax = accumulator
-;; ebx = colormap
-;; ecx = count
-;; edx = accumulator
-;; esi = source
-;; edi = dest
-;; ebp = vid.width
-;; mm0 = accumulator
-;; mm1 = heightmask, twice
-;; mm2 = 2 * fracstep, twice
-;; mm3 = pair of consecutive fracs
-;;----------------------------------------------------------------------
-
-
-cglobal R_DrawColumn_8_MMX
-R_DrawColumn_8_MMX:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-
-;;
-;; Our algorithm requires that the texture height be a power of two.
-;; If not, fall back to the non-MMX drawer.
-;;
-.texheightcheck:
- mov edx, [dc_texheight]
- sub edx, 1 ;; edx = heightmask
- test edx, [dc_texheight]
- jnz near .usenonMMX
-
- mov ebp, edx ;; Keep a copy of heightmask in a
- ;; GPR for the time being.
-
-;;
-;; Fill mm1 with heightmask
-;;
- movd mm1, edx ;; low dword = heightmask
- punpckldq mm1, mm1 ;; copy low dword to high dword
-
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov eax, [dc_yl]
- mov edi, [ylookup+eax*4]
- mov ebx, [dc_x]
- add edi, [columnofs+ebx*4] ;; edi = dest
-
-
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov ecx, [dc_yh]
- add ecx, 1
- sub ecx, eax ;; pixel count
- jle near .done ;; nothing to scale
-
-;;
-;; fracstep = dc_iscale;
-;;
- movd mm2, [dc_iscale] ;; fracstep in low dword
- punpckldq mm2, mm2 ;; copy to high dword
-
- mov ebx, [dc_colormap]
- mov esi, [dc_source]
-
-;;
-;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
-;;
- ;; eax == dc_yl already
- shl eax, FRACBITS
- sub eax, [centeryfrac]
- imul dword [dc_iscale]
- shrd eax, edx, FRACBITS
- add eax, [dc_texturemid]
-
-;;
-;; if (dc_hires) frac = 0;
-;;
- test byte [dc_hires], 0x01
- jz .mod2
- xor eax, eax
-
-
-;;
-;; Do mod-2 pixel.
-;;
-.mod2:
- test ecx, 1
- jz .pairprepare
- mov edx, eax ;; edx = frac
- add eax, [dc_iscale] ;; eax += fracstep
- sar edx, FRACBITS
- and edx, ebp ;; edx &= heightmask
- movzx edx, byte [esi + edx]
- movzx edx, byte [ebx + edx]
- mov [edi], dl
-
- add edi, [vid + viddef_s.width]
- sub ecx, 1
- jz .done
-
-.pairprepare:
-;;
-;; Prepare for the main loop.
-;;
- movd mm3, eax ;; Low dword = frac
- movq mm4, mm3 ;; Copy to intermediate register
- paddd mm4, mm2 ;; dwords of mm4 += fracstep
- punpckldq mm3, mm4 ;; Low dword = first frac, high = second
- pslld mm2, 1 ;; fracstep *= 2
-
-;;
-;; ebp = vid.width
-;;
- mov ebp, [vid + viddef_s.width]
-
- align 16
-.pairloop:
- movq mm0, mm3 ;; 3B 1u.
- psrad mm0, FRACBITS ;; 4B 1u.
- pand mm0, mm1 ;; 3B 1u. frac &= heightmask
- paddd mm3, mm2 ;; 3B 1u. frac += fracstep
-
- movd eax, mm0 ;; 3B 1u. Get first frac
-;; IFETCH boundary
- movzx eax, byte [esi + eax] ;; 4B 1u. Texture map
- movzx eax, byte [ebx + eax] ;; 4B 1u. Colormap
-
- punpckhdq mm0, mm0 ;; 3B 1(2)u. low dword = high dword
- movd edx, mm0 ;; 3B 1u. Get second frac
- mov [edi], al ;; 2B 1(2)u. First pixel
-;; IFETCH boundary
-
- movzx edx, byte [esi + edx] ;; 4B 1u. Texture map
- movzx edx, byte [ebx + edx] ;; 4B 1u. Colormap
- mov [edi + 1*ebp], dl ;; 3B 1(2)u. Second pixel
-
- lea edi, [edi + 2*ebp] ;; 3B 1u. edi += 2 * vid.width
-;; IFETCH boundary
- sub ecx, 2 ;; 3B 1u. count -= 2
- jnz .pairloop ;; 2B 1u. if(count != 0) goto .pairloop
-
-
-.done:
-;;
-;; Clear MMX state, or else FPU operations will go badly awry.
-;;
- emms
-
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
-
-.usenonMMX:
- call R_DrawColumn_8_ASM
- jmp .done
-
-
-;;----------------------------------------------------------------------
-;;
-;; R_Draw2sMultiPatchColumn : Like R_DrawColumn, but omits transparent
-;; pixels.
-;;
-;; MMX column drawer.
-;;
-;;----------------------------------------------------------------------
-;; eax = accumulator
-;; ebx = colormap
-;; ecx = count
-;; edx = accumulator
-;; esi = source
-;; edi = dest
-;; ebp = vid.width
-;; mm0 = accumulator
-;; mm1 = heightmask, twice
-;; mm2 = 2 * fracstep, twice
-;; mm3 = pair of consecutive fracs
-;;----------------------------------------------------------------------
-
-
-cglobal R_Draw2sMultiPatchColumn_8_MMX
-R_Draw2sMultiPatchColumn_8_MMX:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-
-;;
-;; Our algorithm requires that the texture height be a power of two.
-;; If not, fall back to the non-MMX drawer.
-;;
-.texheightcheck:
- mov edx, [dc_texheight]
- sub edx, 1 ;; edx = heightmask
- test edx, [dc_texheight]
- jnz near .usenonMMX
-
- mov ebp, edx ;; Keep a copy of heightmask in a
- ;; GPR for the time being.
-
-;;
-;; Fill mm1 with heightmask
-;;
- movd mm1, edx ;; low dword = heightmask
- punpckldq mm1, mm1 ;; copy low dword to high dword
-
-;;
-;; dest = ylookup[dc_yl] + columnofs[dc_x];
-;;
- mov eax, [dc_yl]
- mov edi, [ylookup+eax*4]
- mov ebx, [dc_x]
- add edi, [columnofs+ebx*4] ;; edi = dest
-
-
-;;
-;; pixelcount = yh - yl + 1
-;;
- mov ecx, [dc_yh]
- add ecx, 1
- sub ecx, eax ;; pixel count
- jle near .done ;; nothing to scale
-;;
-;; fracstep = dc_iscale;
-;;
- movd mm2, [dc_iscale] ;; fracstep in low dword
- punpckldq mm2, mm2 ;; copy to high dword
-
- mov ebx, [dc_colormap]
- mov esi, [dc_source]
-
-;;
-;; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep));
-;;
- ;; eax == dc_yl already
- shl eax, FRACBITS
- sub eax, [centeryfrac]
- imul dword [dc_iscale]
- shrd eax, edx, FRACBITS
- add eax, [dc_texturemid]
-
-;;
-;; if (dc_hires) frac = 0;
-;;
- test byte [dc_hires], 0x01
- jz .mod2
- xor eax, eax
-
-
-;;
-;; Do mod-2 pixel.
-;;
-.mod2:
- test ecx, 1
- jz .pairprepare
- mov edx, eax ;; edx = frac
- add eax, [dc_iscale] ;; eax += fracstep
- sar edx, FRACBITS
- and edx, ebp ;; edx &= heightmask
- movzx edx, byte [esi + edx]
- cmp dl, TRANSPARENTPIXEL
- je .nextmod2
- movzx edx, byte [ebx + edx]
- mov [edi], dl
-
-.nextmod2:
- add edi, [vid + viddef_s.width]
- sub ecx, 1
- jz .done
-
-.pairprepare:
-;;
-;; Prepare for the main loop.
-;;
- movd mm3, eax ;; Low dword = frac
- movq mm4, mm3 ;; Copy to intermediate register
- paddd mm4, mm2 ;; dwords of mm4 += fracstep
- punpckldq mm3, mm4 ;; Low dword = first frac, high = second
- pslld mm2, 1 ;; fracstep *= 2
-
-;;
-;; ebp = vid.width
-;;
- mov ebp, [vid + viddef_s.width]
-
- align 16
-.pairloop:
- movq mm0, mm3 ;; 3B 1u.
- psrad mm0, FRACBITS ;; 4B 1u.
- pand mm0, mm1 ;; 3B 1u. frac &= heightmask
- paddd mm3, mm2 ;; 3B 1u. frac += fracstep
-
- movd eax, mm0 ;; 3B 1u. Get first frac
-;; IFETCH boundary
- movzx eax, byte [esi + eax] ;; 4B 1u. Texture map
- punpckhdq mm0, mm0 ;; 3B 1(2)u. low dword = high dword
- movd edx, mm0 ;; 3B 1u. Get second frac
- cmp al, TRANSPARENTPIXEL ;; 2B 1u.
- je .secondinpair ;; 2B 1u.
-;; IFETCH boundary
- movzx eax, byte [ebx + eax] ;; 4B 1u. Colormap
- mov [edi], al ;; 2B 1(2)u. First pixel
-
-.secondinpair:
- movzx edx, byte [esi + edx] ;; 4B 1u. Texture map
- cmp dl, TRANSPARENTPIXEL ;; 2B 1u.
- je .nextpair ;; 2B 1u.
-;; IFETCH boundary
- movzx edx, byte [ebx + edx] ;; 4B 1u. Colormap
- mov [edi + 1*ebp], dl ;; 3B 1(2)u. Second pixel
-
-.nextpair:
- lea edi, [edi + 2*ebp] ;; 3B 1u. edi += 2 * vid.width
- sub ecx, 2 ;; 3B 1u. count -= 2
- jnz .pairloop ;; 2B 1u. if(count != 0) goto .pairloop
-
-
-.done:
-;;
-;; Clear MMX state, or else FPU operations will go badly awry.
-;;
- emms
-
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
-
-.usenonMMX:
- call R_Draw2sMultiPatchColumn_8_ASM
- jmp .done
-
-
-;;----------------------------------------------------------------------
-;;
-;; R_DrawSpan : 8bpp span drawer
-;;
-;; MMX span drawer.
-;;
-;;----------------------------------------------------------------------
-;; eax = accumulator
-;; ebx = colormap
-;; ecx = count
-;; edx = accumulator
-;; esi = source
-;; edi = dest
-;; ebp = two pixels
-;; mm0 = accumulator
-;; mm1 = xposition
-;; mm2 = yposition
-;; mm3 = 2 * xstep
-;; mm4 = 2 * ystep
-;; mm5 = nflatxshift
-;; mm6 = nflatyshift
-;; mm7 = accumulator
-;;----------------------------------------------------------------------
-
-cglobal R_DrawSpan_8_MMX
-R_DrawSpan_8_MMX:
- push ebp ;; preserve caller's stack frame pointer
- push esi ;; preserve register variables
- push edi
- push ebx
-
-;;
-;; esi = ds_source
-;; ebx = ds_colormap
-;;
- mov esi, [ds_source]
- mov ebx, [ds_colormap]
-
-;;
-;; edi = ylookup[ds_y] + columnofs[ds_x1]
-;;
- mov eax, [ds_y]
- mov edi, [ylookup + eax*4]
- mov edx, [ds_x1]
- add edi, [columnofs + edx*4]
-
-;;
-;; ecx = ds_x2 - ds_x1 + 1
-;;
- mov ecx, [ds_x2]
- sub ecx, edx
- add ecx, 1
-
-;;
-;; Needed for fracs and steps
-;;
- movd mm7, [nflatshiftup]
-
-;;
-;; mm3 = xstep
-;;
- movd mm3, [ds_xstep]
- pslld mm3, mm7
- punpckldq mm3, mm3
-
-;;
-;; mm4 = ystep
-;;
- movd mm4, [ds_ystep]
- pslld mm4, mm7
- punpckldq mm4, mm4
-
-;;
-;; mm1 = pair of consecutive xpositions
-;;
- movd mm1, [ds_xfrac]
- pslld mm1, mm7
- movq mm6, mm1
- paddd mm6, mm3
- punpckldq mm1, mm6
-
-;;
-;; mm2 = pair of consecutive ypositions
-;;
- movd mm2, [ds_yfrac]
- pslld mm2, mm7
- movq mm6, mm2
- paddd mm6, mm4
- punpckldq mm2, mm6
-
-;;
-;; mm5 = nflatxshift
-;; mm6 = nflatyshift
-;;
- movd mm5, [nflatxshift]
- movd mm6, [nflatyshift]
-
-;;
-;; Mask is in memory due to lack of registers.
-;;
- mov eax, [nflatmask]
- mov [nflatmask64], eax
- mov [nflatmask64 + 4], eax
-
-
-;;
-;; Go until we reach a dword boundary.
-;;
-.unaligned:
- test edi, 3
- jz .alignedprep
-.stragglers:
- cmp ecx, 0
- je .done ;; If ecx == 0, we're finished.
-
-;;
-;; eax = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)
-;;
- movq mm0, mm1 ;; mm0 = xposition
- movq mm7, mm2 ;; mm7 = yposition
- paddd mm1, mm3 ;; xposition += xstep (once!)
- paddd mm2, mm4 ;; yposition += ystep (once!)
- psrld mm0, mm5 ;; shift
- psrld mm7, mm6 ;; shift
- pand mm7, [nflatmask64] ;; mask
- por mm0, mm7 ;; or x and y together
-
- movd eax, mm0 ;; eax = index of first pixel
- movzx eax, byte [esi + eax] ;; al = source[eax]
- movzx eax, byte [ebx + eax] ;; al = colormap[al]
-
- mov [edi], al
- add edi, 1
-
- sub ecx, 1
- jmp .unaligned
-
-
-.alignedprep:
-;;
-;; We can double the steps now.
-;;
- pslld mm3, 1
- pslld mm4, 1
-
-
-;;
-;; Generate chunks of four pixels.
-;;
-.alignedloop:
-
-;;
-;; Make sure we have at least four pixels.
-;;
- cmp ecx, 4
- jl .prestragglers
-
-;;
-;; First two pixels.
-;;
- movq mm0, mm1 ;; mm0 = xposition
- movq mm7, mm2 ;; mm7 = yposition
- paddd mm1, mm3 ;; xposition += xstep
- paddd mm2, mm4 ;; yposition += ystep
- psrld mm0, mm5 ;; shift
- psrld mm7, mm6 ;; shift
- pand mm7, [nflatmask64] ;; mask
- por mm0, mm7 ;; or x and y together
-
- movd eax, mm0 ;; eax = index of first pixel
- movzx eax, byte [esi + eax] ;; al = source[eax]
- movzx ebp, byte [ebx + eax] ;; ebp = colormap[al]
-
- punpckhdq mm0, mm0 ;; both dwords = high dword
- movd eax, mm0 ;; eax = index of second pixel
- movzx eax, byte [esi + eax] ;; al = source[eax]
- movzx eax, byte [ebx + eax] ;; al = colormap[al]
- shl eax, 8 ;; get pixel in right byte
- or ebp, eax ;; put pixel in ebp
-
-;;
-;; Next two pixels.
-;;
- movq mm0, mm1 ;; mm0 = xposition
- movq mm7, mm2 ;; mm7 = yposition
- paddd mm1, mm3 ;; xposition += xstep
- paddd mm2, mm4 ;; yposition += ystep
- psrld mm0, mm5 ;; shift
- psrld mm7, mm6 ;; shift
- pand mm7, [nflatmask64] ;; mask
- por mm0, mm7 ;; or x and y together
-
- movd eax, mm0 ;; eax = index of third pixel
- movzx eax, byte [esi + eax] ;; al = source[eax]
- movzx eax, byte [ebx + eax] ;; al = colormap[al]
- shl eax, 16 ;; get pixel in right byte
- or ebp, eax ;; put pixel in ebp
-
- punpckhdq mm0, mm0 ;; both dwords = high dword
- movd eax, mm0 ;; eax = index of second pixel
- movzx eax, byte [esi + eax] ;; al = source[eax]
- movzx eax, byte [ebx + eax] ;; al = colormap[al]
- shl eax, 24 ;; get pixel in right byte
- or ebp, eax ;; put pixel in ebp
-
-;;
-;; Write pixels.
-;;
- mov [edi], ebp
- add edi, 4
-
- sub ecx, 4
- jmp .alignedloop
-
-.prestragglers:
-;;
-;; Back to one step at a time.
-;;
- psrad mm3, 1
- psrad mm4, 1
- jmp .stragglers
-
-.done:
-;;
-;; Clear MMX state, or else FPU operations will go badly awry.
-;;
- emms
-
- pop ebx
- pop edi
- pop esi
- pop ebp
- ret
diff --git a/src/tmap_vc.nas b/src/tmap_vc.nas
deleted file mode 100644
index c85cf7003..000000000
--- a/src/tmap_vc.nas
+++ /dev/null
@@ -1,48 +0,0 @@
-;; SONIC ROBO BLAST 2
-;;-----------------------------------------------------------------------------
-;; Copyright (C) 1998-2000 by DooM Legacy Team.
-;; Copyright (C) 1999-2023 by Sonic Team Junior.
-;;
-;; This program is free software distributed under the
-;; terms of the GNU General Public License, version 2.
-;; See the 'LICENSE' file for more details.
-;;-----------------------------------------------------------------------------
-;; FILE:
-;; tmap_vc.nas
-;; DESCRIPTION:
-;; Assembler optimised math code for Visual C++.
-
-
-[BITS 32]
-
-%macro cglobal 1
-%define %1 _%1
-[global %1]
-%endmacro
-
-[SECTION .text write]
-
-;----------------------------------------------------------------------------
-;fixed_t FixedMul (fixed_t a, fixed_t b)
-;----------------------------------------------------------------------------
-cglobal FixedMul
-; align 16
-FixedMul:
- mov eax,[esp+4]
- imul dword [esp+8]
- shrd eax,edx,16
- ret
-
-;----------------------------------------------------------------------------
-;fixed_t FixedDiv2 (fixed_t a, fixed_t b);
-;----------------------------------------------------------------------------
-cglobal FixedDiv2
-; align 16
-FixedDiv2:
- mov eax,[esp+4]
- mov edx,eax ;; these two instructions allow the next
- sar edx,31 ;; two to pair, on the Pentium processor.
- shld edx,eax,16
- sal eax,16
- idiv dword [esp+8]
- ret
diff --git a/src/v_video.c b/src/v_video.c
index 461a5e3bc..3f958b286 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -447,12 +447,6 @@ static void CV_palette_OnChange(void)
V_SetPalette(0);
}
-#if defined (__GNUC__) && defined (__i386__) && !defined (NOASM) && !defined (__APPLE__) && !defined (NORUSEASM)
-void VID_BlitLinearScreen_ASM(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes,
- size_t destrowbytes);
-#define HAVE_VIDCOPY
-#endif
-
static void CV_constextsize_OnChange(void)
{
if (!con_refresh)
@@ -466,9 +460,6 @@ static void CV_constextsize_OnChange(void)
void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes,
size_t destrowbytes)
{
-#ifdef HAVE_VIDCOPY
- VID_BlitLinearScreen_ASM(srcptr,destptr,width,height,srcrowbytes,destrowbytes);
-#else
if (srcrowbytes == destrowbytes)
M_Memcpy(destptr, srcptr, srcrowbytes * height);
else
@@ -481,7 +472,6 @@ void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT3
srcptr += srcrowbytes;
}
}
-#endif
}
static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0};
diff --git a/src/version.h b/src/version.h
index 083c53134..3242cad67 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,4 +1,4 @@
-#define SRB2VERSION "2.2.11"/* this must be the first line, for cmake !! */
+#define SRB2VERSION "2.2.13"/* this must be the first line, for cmake !! */
// The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/members/?key=ms_admin ).
// DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server.
@@ -9,7 +9,7 @@
// it's only for detection of the version the player is using so the MS can alert them of an update.
// Only set it higher, not lower, obviously.
// Note that we use this to help keep internal testing in check; this is why v2.2.0 is not version "1".
-#define MODVERSION 52
+#define MODVERSION 54
// Define this as a prerelease version suffix (pre#, RC#)
//#define BETAVERSION "pre1"
diff --git a/src/vid_copy.s b/src/vid_copy.s
deleted file mode 100644
index 1473a3856..000000000
--- a/src/vid_copy.s
+++ /dev/null
@@ -1,61 +0,0 @@
-// SONIC ROBO BLAST 2
-//-----------------------------------------------------------------------------
-// Copyright (C) 1998-2000 by DooM Legacy Team.
-// Copyright (C) 1999-2023 by Sonic Team Junior.
-//
-// This program is free software distributed under the
-// terms of the GNU General Public License, version 2.
-// See the 'LICENSE' file for more details.
-//-----------------------------------------------------------------------------
-/// \file vid_copy.s
-/// \brief code for updating the linear frame buffer screen.
-
-#include "asm_defs.inc" // structures, must match the C structures!
-
-// DJGPPv2 is as fast as this one, but then someone may compile with a less
-// good version of DJGPP than mine, so this little asm will do the trick!
-
-#define srcptr 4+16
-#define destptr 8+16
-#define width 12+16
-#define height 16+16
-#define srcrowbytes 20+16
-#define destrowbytes 24+16
-
-// VID_BlitLinearScreen( src, dest, width, height, srcwidth, destwidth );
-// width is given as BYTES
-
-#ifdef __i386__
-
-.globl C(VID_BlitLinearScreen_ASM)
-C(VID_BlitLinearScreen_ASM):
- pushl %ebp // preserve caller's stack frame
- pushl %edi
- pushl %esi // preserve register variables
- pushl %ebx
-
- cld
- movl srcptr(%esp),%esi
- movl destptr(%esp),%edi
- movl width(%esp),%ebx
- movl srcrowbytes(%esp),%eax
- subl %ebx,%eax
- movl destrowbytes(%esp),%edx
- subl %ebx,%edx
- shrl $2,%ebx
- movl height(%esp),%ebp
-LLRowLoop:
- movl %ebx,%ecx
- rep/movsl (%esi),(%edi)
- addl %eax,%esi
- addl %edx,%edi
- decl %ebp
- jnz LLRowLoop
-
- popl %ebx // restore register variables
- popl %esi
- popl %edi
- popl %ebp // restore the caller's stack frame
-
- ret
-#endif
diff --git a/src/w_wad.c b/src/w_wad.c
index 14e0000aa..74a9aeebe 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -51,8 +51,8 @@
#include "filesrch.h"
#include "d_main.h"
-#include "d_netfil.h"
-#include "d_clisrv.h"
+#include "netcode/d_netfil.h"
+#include "netcode/d_clisrv.h"
#include "dehacked.h"
#include "d_main.h"
#include "g_game.h"
diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc
index 869c0e7d3..b69900746 100644
--- a/src/win32/Srb2win.rc
+++ b/src/win32/Srb2win.rc
@@ -77,8 +77,8 @@ END
#include "../doomdef.h" // Needed for version string
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,2,11,0
- PRODUCTVERSION 2,2,11,0
+ FILEVERSION 2,2,13,0
+ PRODUCTVERSION 2,2,13,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
diff --git a/src/y_inter.c b/src/y_inter.c
index 1b1f49e0b..69dc931ba 100644
--- a/src/y_inter.c
+++ b/src/y_inter.c
@@ -15,7 +15,7 @@
#include "f_finale.h"
#include "g_game.h"
#include "hu_stuff.h"
-#include "i_net.h"
+#include "netcode/i_net.h"
#include "i_video.h"
#include "p_tick.h"
#include "r_defs.h"
@@ -998,8 +998,7 @@ void Y_Ticker(void)
if (paused || P_AutoPause())
return;
- LUA_HookBool(intertype == int_spec && stagefailed,
- HOOK(IntermissionThinker));
+ LUA_HookBool(stagefailed, HOOK(IntermissionThinker));
intertic++;
@@ -1477,10 +1476,10 @@ void Y_StartIntermission(void)
if (players[consoleplayer].charflags & SF_SUPER)
{
strcpy(data.spec.passed3, "can now become");
- snprintf(data.spec.passed4,
- sizeof data.spec.passed4, "Super %s",
- skins[players[consoleplayer].skin].realname);
- data.spec.passed4[sizeof data.spec.passed4 - 1] = '\0';
+ if (strlen(skins[players[consoleplayer].skin].supername) > 20) //too long, use generic
+ strcpy(data.spec.passed4, "their super form");
+ else
+ strcpy(data.spec.passed4, skins[players[consoleplayer].skin].supername);
}
}
else
@@ -2044,7 +2043,7 @@ static void Y_AwardCoopBonuses(void)
y_bonus_t localbonuses[4];
// set score/total first
- data.coop.total = 0;
+ data.coop.total = players[consoleplayer].recordscore;
data.coop.score = players[consoleplayer].score;
data.coop.gotperfbonus = -1;
memset(data.coop.bonuses, 0, sizeof(data.coop.bonuses));
diff --git a/src/z_zone.h b/src/z_zone.h
index f00f57749..ce7af4a15 100644
--- a/src/z_zone.h
+++ b/src/z_zone.h
@@ -15,6 +15,7 @@
#define __Z_ZONE__
#include
+#include "doomdef.h"
#include "doomtype.h"
#ifdef __GNUC__ // __attribute__ ((X))
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 7aff16601..f33b3bf3f 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -9,521 +9,13 @@ else()
set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES ON)
endif()
-
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME SDL2
- VERSION 2.24.2
- URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip"
- EXCLUDE_FROM_ALL ON
- OPTIONS
- "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "SDL_TEST OFF"
- "SDL2_DISABLE_SDL2MAIN ON"
- "SDL2_DISABLE_INSTALL ON"
- )
+ include("cpm-sdl2.cmake")
+ include("cpm-sdl2-mixer.cmake")
+ include("cpm-zlib.cmake")
+ include("cpm-png.cmake")
+ include("cpm-curl.cmake")
+ include("cpm-openmpt.cmake")
endif()
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME SDL2_mixer
- VERSION 2.6.2
- URL "https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-2.6.2.zip"
- EXCLUDE_FROM_ALL ON
- OPTIONS
- "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "SDL2MIXER_INSTALL OFF"
- "SDL2MIXER_DEPS_SHARED OFF"
- "SDL2MIXER_SAMPLES OFF"
- "SDL2MIXER_VENDORED ON"
- "SDL2MIXER_FLAC ON"
- "SDL2MIXER_FLAC_LIBFLAC OFF"
- "SDL2MIXER_FLAC_DRFLAC ON"
- "SDL2MIXER_MOD OFF"
- "SDL2MIXER_MP3 ON"
- "SDL2MIXER_MP3_DRMP3 ON"
- "SDL2MIXER_MIDI ON"
- "SDL2MIXER_OPUS OFF"
- "SDL2MIXER_VORBIS STB"
- "SDL2MIXER_WAVE ON"
- )
-endif()
-
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME ZLIB
- VERSION 1.2.13
- URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip"
- EXCLUDE_FROM_ALL
- DOWNLOAD_ONLY YES
- )
- if(ZLIB_ADDED)
- set(ZLIB_SRCS
- crc32.h
- deflate.h
- gzguts.h
- inffast.h
- inffixed.h
- inflate.h
- inftrees.h
- trees.h
- zutil.h
-
- adler32.c
- compress.c
- crc32.c
- deflate.c
- gzclose.c
- gzlib.c
- gzread.c
- gzwrite.c
- inflate.c
- infback.c
- inftrees.c
- inffast.c
- trees.c
- uncompr.c
- zutil.c
- )
- list(TRANSFORM ZLIB_SRCS PREPEND "${ZLIB_SOURCE_DIR}/")
-
- configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY)
- configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY)
- configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY)
-
- add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS})
- set_target_properties(ZLIB PROPERTIES
- VERSION 1.2.13
- OUTPUT_NAME "z"
- )
- target_include_directories(ZLIB PRIVATE "${ZLIB_SOURCE_DIR}")
- target_include_directories(ZLIB PUBLIC "${ZLIB_BINARY_DIR}/include")
- if(MSVC)
- target_compile_definitions(ZLIB PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
- endif()
- add_library(ZLIB::ZLIB ALIAS ZLIB)
- endif()
-endif()
-
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME png
- VERSION 1.6.38
- URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip"
- # png cmake build is broken on msys/mingw32
- DOWNLOAD_ONLY YES
- )
-
- if(png_ADDED)
- # Since png's cmake build is broken, we're going to create a target manually
- set(
- PNG_SOURCES
-
- png.h
- pngconf.h
-
- pngpriv.h
- pngdebug.h
- pnginfo.h
- pngstruct.h
-
- png.c
- pngerror.c
- pngget.c
- pngmem.c
- pngpread.c
- pngread.c
- pngrio.c
- pngrtran.c
- pngrutil.c
- pngset.c
- pngtrans.c
- pngwio.c
- pngwrite.c
- pngwtran.c
- pngwutil.c
- )
- list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/")
-
- add_custom_command(
- OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h"
- COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include"
- DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h"
- VERBATIM
- )
- add_custom_command(
- OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h"
- COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h"
- DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt"
- VERBATIM
- )
- list(
- APPEND PNG_SOURCES
- "${png_BINARY_DIR}/include/png.h"
- "${png_BINARY_DIR}/include/pngconf.h"
- "${png_BINARY_DIR}/include/pnglibconf.h"
- )
- add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES})
-
- # Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason
- target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0)
-
- # The png includes need to be available to consumers
- target_include_directories(png PUBLIC "${png_BINARY_DIR}/include")
-
- # ... and these also need to be present only for png build
- target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}")
- target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}")
- target_include_directories(png PRIVATE "${png_BINARY_DIR}")
-
- target_link_libraries(png PRIVATE ZLIB::ZLIB)
- add_library(PNG::PNG ALIAS png)
- endif()
-endif()
-
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- set(
- internal_curl_options
-
- "BUILD_CURL_EXE OFF"
- "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "CURL_DISABLE_TESTS ON"
- "HTTP_ONLY ON"
- "CURL_DISABLE_CRYPTO_AUTH ON"
- "CURL_DISABLE_NTLM ON"
- "ENABLE_MANUAL OFF"
- "ENABLE_THREADED_RESOLVER OFF"
- "CURL_USE_LIBPSL OFF"
- "CURL_USE_LIBSSH2 OFF"
- "USE_LIBIDN2 OFF"
- "CURL_ENABLE_EXPORT_TARGET OFF"
- )
- if(${CMAKE_SYSTEM} MATCHES Windows)
- list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
- list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON")
- endif()
- if(${CMAKE_SYSTEM} MATCHES Darwin)
- list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
- list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON")
- endif()
- if(${CMAKE_SYSTEM} MATCHES Linux)
- list(APPEND internal_curl_options "CURL_USE_OPENSSL ON")
- endif()
-
- CPMAddPackage(
- NAME curl
- VERSION 7.86.0
- URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip"
- EXCLUDE_FROM_ALL ON
- OPTIONS ${internal_curl_options}
- )
-endif()
-
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME openmpt
- VERSION 0.4.30
- URL "https://github.com/OpenMPT/openmpt/archive/refs/tags/libopenmpt-0.4.30.zip"
- DOWNLOAD_ONLY ON
- )
-
- if(openmpt_ADDED)
- set(
- openmpt_SOURCES
-
- # minimp3
- # -DMPT_WITH_MINIMP3
- include/minimp3/minimp3.c
-
- common/mptStringParse.cpp
- common/mptLibrary.cpp
- common/Logging.cpp
- common/Profiler.cpp
- common/version.cpp
- common/mptCPU.cpp
- common/ComponentManager.cpp
- common/mptOS.cpp
- common/serialization_utils.cpp
- common/mptStringFormat.cpp
- common/FileReader.cpp
- common/mptWine.cpp
- common/mptPathString.cpp
- common/mptAlloc.cpp
- common/mptUUID.cpp
- common/mptTime.cpp
- common/mptString.cpp
- common/mptFileIO.cpp
- common/mptStringBuffer.cpp
- common/mptRandom.cpp
- common/mptIO.cpp
- common/misc_util.cpp
-
- common/mptCRC.h
- common/mptLibrary.h
- common/mptIO.h
- common/version.h
- common/stdafx.h
- common/ComponentManager.h
- common/Endianness.h
- common/mptStringFormat.h
- common/mptMutex.h
- common/mptUUID.h
- common/mptExceptionText.h
- common/BuildSettings.h
- common/mptAlloc.h
- common/mptTime.h
- common/FileReaderFwd.h
- common/Logging.h
- common/mptException.h
- common/mptWine.h
- common/mptStringBuffer.h
- common/misc_util.h
- common/mptBaseMacros.h
- common/mptMemory.h
- common/mptFileIO.h
- common/serialization_utils.h
- common/mptSpan.h
- common/mptThread.h
- common/FlagSet.h
- common/mptString.h
- common/mptStringParse.h
- common/mptBaseUtils.h
- common/mptRandom.h
- common/CompilerDetect.h
- common/FileReader.h
- common/mptAssert.h
- common/mptPathString.h
- common/Profiler.h
- common/mptOS.h
- common/mptBaseTypes.h
- common/mptCPU.h
- common/mptBufferIO.h
- common/versionNumber.h
-
- soundlib/WAVTools.cpp
- soundlib/ITTools.cpp
- soundlib/AudioCriticalSection.cpp
- soundlib/Load_stm.cpp
- soundlib/MixerLoops.cpp
- soundlib/Load_dbm.cpp
- soundlib/ModChannel.cpp
- soundlib/Load_gdm.cpp
- soundlib/Snd_fx.cpp
- soundlib/Load_mid.cpp
- soundlib/mod_specifications.cpp
- soundlib/Snd_flt.cpp
- soundlib/Load_psm.cpp
- soundlib/Load_far.cpp
- soundlib/patternContainer.cpp
- soundlib/Load_med.cpp
- soundlib/Load_dmf.cpp
- soundlib/Paula.cpp
- soundlib/modcommand.cpp
- soundlib/Message.cpp
- soundlib/SoundFilePlayConfig.cpp
- soundlib/Load_uax.cpp
- soundlib/plugins/PlugInterface.cpp
- soundlib/plugins/LFOPlugin.cpp
- soundlib/plugins/PluginManager.cpp
- soundlib/plugins/DigiBoosterEcho.cpp
- soundlib/plugins/dmo/DMOPlugin.cpp
- soundlib/plugins/dmo/Flanger.cpp
- soundlib/plugins/dmo/Distortion.cpp
- soundlib/plugins/dmo/ParamEq.cpp
- soundlib/plugins/dmo/Gargle.cpp
- soundlib/plugins/dmo/I3DL2Reverb.cpp
- soundlib/plugins/dmo/Compressor.cpp
- soundlib/plugins/dmo/WavesReverb.cpp
- soundlib/plugins/dmo/Echo.cpp
- soundlib/plugins/dmo/Chorus.cpp
- soundlib/Load_ams.cpp
- soundlib/tuningbase.cpp
- soundlib/ContainerUMX.cpp
- soundlib/Load_ptm.cpp
- soundlib/ContainerXPK.cpp
- soundlib/SampleFormatMP3.cpp
- soundlib/tuning.cpp
- soundlib/Sndfile.cpp
- soundlib/ContainerMMCMP.cpp
- soundlib/Load_amf.cpp
- soundlib/Load_669.cpp
- soundlib/modsmp_ctrl.cpp
- soundlib/Load_mtm.cpp
- soundlib/OggStream.cpp
- soundlib/Load_plm.cpp
- soundlib/Tables.cpp
- soundlib/Load_c67.cpp
- soundlib/Load_mod.cpp
- soundlib/Load_sfx.cpp
- soundlib/Sndmix.cpp
- soundlib/load_j2b.cpp
- soundlib/ModSequence.cpp
- soundlib/SampleFormatFLAC.cpp
- soundlib/ModInstrument.cpp
- soundlib/Load_mo3.cpp
- soundlib/ModSample.cpp
- soundlib/Dlsbank.cpp
- soundlib/Load_itp.cpp
- soundlib/UpgradeModule.cpp
- soundlib/MIDIMacros.cpp
- soundlib/ContainerPP20.cpp
- soundlib/RowVisitor.cpp
- soundlib/Load_imf.cpp
- soundlib/SampleFormatVorbis.cpp
- soundlib/Load_dsm.cpp
- soundlib/Load_mt2.cpp
- soundlib/MixerSettings.cpp
- soundlib/S3MTools.cpp
- soundlib/Load_xm.cpp
- soundlib/MIDIEvents.cpp
- soundlib/pattern.cpp
- soundlib/Load_digi.cpp
- soundlib/Load_s3m.cpp
- soundlib/tuningCollection.cpp
- soundlib/SampleIO.cpp
- soundlib/Dither.cpp
- soundlib/Load_mdl.cpp
- soundlib/OPL.cpp
- soundlib/WindowedFIR.cpp
- soundlib/SampleFormats.cpp
- soundlib/Load_wav.cpp
- soundlib/Load_it.cpp
- soundlib/UMXTools.cpp
- soundlib/Load_stp.cpp
- soundlib/Load_okt.cpp
- soundlib/Load_ult.cpp
- soundlib/MixFuncTable.cpp
- soundlib/SampleFormatOpus.cpp
- soundlib/Fastmix.cpp
- soundlib/Tagging.cpp
- soundlib/ITCompression.cpp
- soundlib/Load_dtm.cpp
- soundlib/MPEGFrame.cpp
- soundlib/XMTools.cpp
- soundlib/SampleFormatMediaFoundation.cpp
- soundlib/InstrumentExtensions.cpp
-
- soundlib/MixerInterface.h
- soundlib/SoundFilePlayConfig.h
- soundlib/ModSample.h
- soundlib/MIDIEvents.h
- soundlib/ModSampleCopy.h
- soundlib/patternContainer.h
- soundlib/ChunkReader.h
- soundlib/ITCompression.h
- soundlib/Dither.h
- soundlib/S3MTools.h
- soundlib/MPEGFrame.h
- soundlib/WAVTools.h
- soundlib/mod_specifications.h
- soundlib/ITTools.h
- soundlib/RowVisitor.h
- soundlib/plugins/PluginMixBuffer.h
- soundlib/plugins/PluginStructs.h
- soundlib/plugins/LFOPlugin.h
- soundlib/plugins/PlugInterface.h
- soundlib/plugins/DigiBoosterEcho.h
- soundlib/plugins/OpCodes.h
- soundlib/plugins/dmo/Echo.h
- soundlib/plugins/dmo/I3DL2Reverb.h
- soundlib/plugins/dmo/WavesReverb.h
- soundlib/plugins/dmo/ParamEq.h
- soundlib/plugins/dmo/Gargle.h
- soundlib/plugins/dmo/DMOPlugin.h
- soundlib/plugins/dmo/Chorus.h
- soundlib/plugins/dmo/Compressor.h
- soundlib/plugins/dmo/Distortion.h
- soundlib/plugins/dmo/Flanger.h
- soundlib/plugins/PluginManager.h
- soundlib/SampleIO.h
- soundlib/Container.h
- soundlib/ModSequence.h
- soundlib/UMXTools.h
- soundlib/Message.h
- soundlib/modcommand.h
- soundlib/XMTools.h
- soundlib/Snd_defs.h
- soundlib/MixFuncTable.h
- soundlib/pattern.h
- soundlib/modsmp_ctrl.h
- soundlib/Tagging.h
- soundlib/tuningcollection.h
- soundlib/Mixer.h
- soundlib/FloatMixer.h
- soundlib/AudioCriticalSection.h
- soundlib/Tables.h
- soundlib/tuningbase.h
- soundlib/WindowedFIR.h
- soundlib/Sndfile.h
- soundlib/Paula.h
- soundlib/ModInstrument.h
- soundlib/Dlsbank.h
- soundlib/IntMixer.h
- soundlib/OPL.h
- soundlib/Resampler.h
- soundlib/ModChannel.h
- soundlib/MixerSettings.h
- soundlib/AudioReadTarget.h
- soundlib/MixerLoops.h
- soundlib/tuning.h
- soundlib/MIDIMacros.h
- soundlib/OggStream.h
- soundlib/Loaders.h
- soundlib/BitReader.h
- soundlib/opal.h
-
- sounddsp/AGC.cpp
- sounddsp/EQ.cpp
- sounddsp/DSP.cpp
- sounddsp/Reverb.cpp
- sounddsp/Reverb.h
- sounddsp/EQ.h
- sounddsp/DSP.h
- sounddsp/AGC.h
-
- libopenmpt/libopenmpt_c.cpp
- libopenmpt/libopenmpt_cxx.cpp
- libopenmpt/libopenmpt_impl.cpp
- libopenmpt/libopenmpt_ext_impl.cpp
- )
- list(TRANSFORM openmpt_SOURCES PREPEND "${openmpt_SOURCE_DIR}/")
-
- # -DLIBOPENMPT_BUILD
- configure_file("openmpt_svn_version.h" "svn_version.h")
- add_library(openmpt "${SRB2_INTERNAL_LIBRARY_TYPE}" ${openmpt_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/svn_version.h)
- if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR "${CMAKE_C_COMPILER_ID}" STREQUAL Clang OR "${CMAKE_C_COMPILER_ID}" STREQUAL AppleClang)
- target_compile_options(openmpt PRIVATE "-g0")
- endif()
- if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND "${CMAKE_C_COMPILER_ID}" STREQUAL MSVC)
- target_link_libraries(openmpt PRIVATE Rpcrt4)
- endif()
- target_compile_features(openmpt PRIVATE cxx_std_11)
- target_compile_definitions(openmpt PRIVATE -DLIBOPENMPT_BUILD)
-
- target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/common")
- target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/src")
- target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/include")
- target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}")
- target_include_directories(openmpt PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
-
- # I wish this wasn't necessary, but it is
- target_include_directories(openmpt PUBLIC "${openmpt_SOURCE_DIR}")
- endif()
-endif()
-
-if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
- CPMAddPackage(
- NAME libgme
- VERSION 0.6.3
- URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip"
- EXCLUDE_FROM_ALL ON
- OPTIONS
- "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
- "ENABLE_UBSAN OFF"
- "GME_YM2612_EMU MAME"
- )
- target_compile_features(gme PRIVATE cxx_std_11)
- target_link_libraries(gme PRIVATE ZLIB::ZLIB)
-endif()
+include("cpm-libgme.cmake")
diff --git a/thirdparty/cpm-curl.cmake b/thirdparty/cpm-curl.cmake
new file mode 100644
index 000000000..3d8c6e61d
--- /dev/null
+++ b/thirdparty/cpm-curl.cmake
@@ -0,0 +1,35 @@
+set(
+ internal_curl_options
+
+ "BUILD_CURL_EXE OFF"
+ "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "CURL_DISABLE_TESTS ON"
+ "HTTP_ONLY ON"
+ "CURL_DISABLE_CRYPTO_AUTH ON"
+ "CURL_DISABLE_NTLM ON"
+ "ENABLE_MANUAL OFF"
+ "ENABLE_THREADED_RESOLVER OFF"
+ "CURL_USE_LIBPSL OFF"
+ "CURL_USE_LIBSSH2 OFF"
+ "USE_LIBIDN2 OFF"
+ "CURL_ENABLE_EXPORT_TARGET OFF"
+)
+if(${CMAKE_SYSTEM} MATCHES Windows)
+ list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
+ list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON")
+endif()
+if(${CMAKE_SYSTEM} MATCHES Darwin)
+ list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
+ list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON")
+endif()
+if(${CMAKE_SYSTEM} MATCHES Linux)
+ list(APPEND internal_curl_options "CURL_USE_OPENSSL ON")
+endif()
+
+CPMAddPackage(
+ NAME curl
+ VERSION 7.86.0
+ URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip"
+ EXCLUDE_FROM_ALL ON
+ OPTIONS ${internal_curl_options}
+)
diff --git a/thirdparty/cpm-libgme.cmake b/thirdparty/cpm-libgme.cmake
new file mode 100644
index 000000000..f15bc3b31
--- /dev/null
+++ b/thirdparty/cpm-libgme.cmake
@@ -0,0 +1,16 @@
+CPMAddPackage(
+ NAME libgme
+ VERSION 0.6.3
+ URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip"
+ EXCLUDE_FROM_ALL ON
+ OPTIONS
+ "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "ENABLE_UBSAN OFF"
+ "GME_YM2612_EMU MAME"
+)
+
+if(libgme_ADDED)
+ target_compile_features(gme PRIVATE cxx_std_11)
+ # libgme's CMakeLists.txt already links this
+ #target_link_libraries(gme PRIVATE ZLIB::ZLIB)
+endif()
diff --git a/thirdparty/cpm-openmpt.cmake b/thirdparty/cpm-openmpt.cmake
new file mode 100644
index 000000000..01f7ff75f
--- /dev/null
+++ b/thirdparty/cpm-openmpt.cmake
@@ -0,0 +1,289 @@
+CPMAddPackage(
+ NAME openmpt
+ VERSION 0.4.30
+ URL "https://github.com/OpenMPT/openmpt/archive/refs/tags/libopenmpt-0.4.30.zip"
+ DOWNLOAD_ONLY ON
+)
+
+if(openmpt_ADDED)
+ set(
+ openmpt_SOURCES
+
+ # minimp3
+ # -DMPT_WITH_MINIMP3
+ include/minimp3/minimp3.c
+
+ common/mptStringParse.cpp
+ common/mptLibrary.cpp
+ common/Logging.cpp
+ common/Profiler.cpp
+ common/version.cpp
+ common/mptCPU.cpp
+ common/ComponentManager.cpp
+ common/mptOS.cpp
+ common/serialization_utils.cpp
+ common/mptStringFormat.cpp
+ common/FileReader.cpp
+ common/mptWine.cpp
+ common/mptPathString.cpp
+ common/mptAlloc.cpp
+ common/mptUUID.cpp
+ common/mptTime.cpp
+ common/mptString.cpp
+ common/mptFileIO.cpp
+ common/mptStringBuffer.cpp
+ common/mptRandom.cpp
+ common/mptIO.cpp
+ common/misc_util.cpp
+
+ common/mptCRC.h
+ common/mptLibrary.h
+ common/mptIO.h
+ common/version.h
+ common/stdafx.h
+ common/ComponentManager.h
+ common/Endianness.h
+ common/mptStringFormat.h
+ common/mptMutex.h
+ common/mptUUID.h
+ common/mptExceptionText.h
+ common/BuildSettings.h
+ common/mptAlloc.h
+ common/mptTime.h
+ common/FileReaderFwd.h
+ common/Logging.h
+ common/mptException.h
+ common/mptWine.h
+ common/mptStringBuffer.h
+ common/misc_util.h
+ common/mptBaseMacros.h
+ common/mptMemory.h
+ common/mptFileIO.h
+ common/serialization_utils.h
+ common/mptSpan.h
+ common/mptThread.h
+ common/FlagSet.h
+ common/mptString.h
+ common/mptStringParse.h
+ common/mptBaseUtils.h
+ common/mptRandom.h
+ common/CompilerDetect.h
+ common/FileReader.h
+ common/mptAssert.h
+ common/mptPathString.h
+ common/Profiler.h
+ common/mptOS.h
+ common/mptBaseTypes.h
+ common/mptCPU.h
+ common/mptBufferIO.h
+ common/versionNumber.h
+
+ soundlib/WAVTools.cpp
+ soundlib/ITTools.cpp
+ soundlib/AudioCriticalSection.cpp
+ soundlib/Load_stm.cpp
+ soundlib/MixerLoops.cpp
+ soundlib/Load_dbm.cpp
+ soundlib/ModChannel.cpp
+ soundlib/Load_gdm.cpp
+ soundlib/Snd_fx.cpp
+ soundlib/Load_mid.cpp
+ soundlib/mod_specifications.cpp
+ soundlib/Snd_flt.cpp
+ soundlib/Load_psm.cpp
+ soundlib/Load_far.cpp
+ soundlib/patternContainer.cpp
+ soundlib/Load_med.cpp
+ soundlib/Load_dmf.cpp
+ soundlib/Paula.cpp
+ soundlib/modcommand.cpp
+ soundlib/Message.cpp
+ soundlib/SoundFilePlayConfig.cpp
+ soundlib/Load_uax.cpp
+ soundlib/plugins/PlugInterface.cpp
+ soundlib/plugins/LFOPlugin.cpp
+ soundlib/plugins/PluginManager.cpp
+ soundlib/plugins/DigiBoosterEcho.cpp
+ soundlib/plugins/dmo/DMOPlugin.cpp
+ soundlib/plugins/dmo/Flanger.cpp
+ soundlib/plugins/dmo/Distortion.cpp
+ soundlib/plugins/dmo/ParamEq.cpp
+ soundlib/plugins/dmo/Gargle.cpp
+ soundlib/plugins/dmo/I3DL2Reverb.cpp
+ soundlib/plugins/dmo/Compressor.cpp
+ soundlib/plugins/dmo/WavesReverb.cpp
+ soundlib/plugins/dmo/Echo.cpp
+ soundlib/plugins/dmo/Chorus.cpp
+ soundlib/Load_ams.cpp
+ soundlib/tuningbase.cpp
+ soundlib/ContainerUMX.cpp
+ soundlib/Load_ptm.cpp
+ soundlib/ContainerXPK.cpp
+ soundlib/SampleFormatMP3.cpp
+ soundlib/tuning.cpp
+ soundlib/Sndfile.cpp
+ soundlib/ContainerMMCMP.cpp
+ soundlib/Load_amf.cpp
+ soundlib/Load_669.cpp
+ soundlib/modsmp_ctrl.cpp
+ soundlib/Load_mtm.cpp
+ soundlib/OggStream.cpp
+ soundlib/Load_plm.cpp
+ soundlib/Tables.cpp
+ soundlib/Load_c67.cpp
+ soundlib/Load_mod.cpp
+ soundlib/Load_sfx.cpp
+ soundlib/Sndmix.cpp
+ soundlib/load_j2b.cpp
+ soundlib/ModSequence.cpp
+ soundlib/SampleFormatFLAC.cpp
+ soundlib/ModInstrument.cpp
+ soundlib/Load_mo3.cpp
+ soundlib/ModSample.cpp
+ soundlib/Dlsbank.cpp
+ soundlib/Load_itp.cpp
+ soundlib/UpgradeModule.cpp
+ soundlib/MIDIMacros.cpp
+ soundlib/ContainerPP20.cpp
+ soundlib/RowVisitor.cpp
+ soundlib/Load_imf.cpp
+ soundlib/SampleFormatVorbis.cpp
+ soundlib/Load_dsm.cpp
+ soundlib/Load_mt2.cpp
+ soundlib/MixerSettings.cpp
+ soundlib/S3MTools.cpp
+ soundlib/Load_xm.cpp
+ soundlib/MIDIEvents.cpp
+ soundlib/pattern.cpp
+ soundlib/Load_digi.cpp
+ soundlib/Load_s3m.cpp
+ soundlib/tuningCollection.cpp
+ soundlib/SampleIO.cpp
+ soundlib/Dither.cpp
+ soundlib/Load_mdl.cpp
+ soundlib/OPL.cpp
+ soundlib/WindowedFIR.cpp
+ soundlib/SampleFormats.cpp
+ soundlib/Load_wav.cpp
+ soundlib/Load_it.cpp
+ soundlib/UMXTools.cpp
+ soundlib/Load_stp.cpp
+ soundlib/Load_okt.cpp
+ soundlib/Load_ult.cpp
+ soundlib/MixFuncTable.cpp
+ soundlib/SampleFormatOpus.cpp
+ soundlib/Fastmix.cpp
+ soundlib/Tagging.cpp
+ soundlib/ITCompression.cpp
+ soundlib/Load_dtm.cpp
+ soundlib/MPEGFrame.cpp
+ soundlib/XMTools.cpp
+ soundlib/SampleFormatMediaFoundation.cpp
+ soundlib/InstrumentExtensions.cpp
+
+ soundlib/MixerInterface.h
+ soundlib/SoundFilePlayConfig.h
+ soundlib/ModSample.h
+ soundlib/MIDIEvents.h
+ soundlib/ModSampleCopy.h
+ soundlib/patternContainer.h
+ soundlib/ChunkReader.h
+ soundlib/ITCompression.h
+ soundlib/Dither.h
+ soundlib/S3MTools.h
+ soundlib/MPEGFrame.h
+ soundlib/WAVTools.h
+ soundlib/mod_specifications.h
+ soundlib/ITTools.h
+ soundlib/RowVisitor.h
+ soundlib/plugins/PluginMixBuffer.h
+ soundlib/plugins/PluginStructs.h
+ soundlib/plugins/LFOPlugin.h
+ soundlib/plugins/PlugInterface.h
+ soundlib/plugins/DigiBoosterEcho.h
+ soundlib/plugins/OpCodes.h
+ soundlib/plugins/dmo/Echo.h
+ soundlib/plugins/dmo/I3DL2Reverb.h
+ soundlib/plugins/dmo/WavesReverb.h
+ soundlib/plugins/dmo/ParamEq.h
+ soundlib/plugins/dmo/Gargle.h
+ soundlib/plugins/dmo/DMOPlugin.h
+ soundlib/plugins/dmo/Chorus.h
+ soundlib/plugins/dmo/Compressor.h
+ soundlib/plugins/dmo/Distortion.h
+ soundlib/plugins/dmo/Flanger.h
+ soundlib/plugins/PluginManager.h
+ soundlib/SampleIO.h
+ soundlib/Container.h
+ soundlib/ModSequence.h
+ soundlib/UMXTools.h
+ soundlib/Message.h
+ soundlib/modcommand.h
+ soundlib/XMTools.h
+ soundlib/Snd_defs.h
+ soundlib/MixFuncTable.h
+ soundlib/pattern.h
+ soundlib/modsmp_ctrl.h
+ soundlib/Tagging.h
+ soundlib/tuningcollection.h
+ soundlib/Mixer.h
+ soundlib/FloatMixer.h
+ soundlib/AudioCriticalSection.h
+ soundlib/Tables.h
+ soundlib/tuningbase.h
+ soundlib/WindowedFIR.h
+ soundlib/Sndfile.h
+ soundlib/Paula.h
+ soundlib/ModInstrument.h
+ soundlib/Dlsbank.h
+ soundlib/IntMixer.h
+ soundlib/OPL.h
+ soundlib/Resampler.h
+ soundlib/ModChannel.h
+ soundlib/MixerSettings.h
+ soundlib/AudioReadTarget.h
+ soundlib/MixerLoops.h
+ soundlib/tuning.h
+ soundlib/MIDIMacros.h
+ soundlib/OggStream.h
+ soundlib/Loaders.h
+ soundlib/BitReader.h
+ soundlib/opal.h
+
+ sounddsp/AGC.cpp
+ sounddsp/EQ.cpp
+ sounddsp/DSP.cpp
+ sounddsp/Reverb.cpp
+ sounddsp/Reverb.h
+ sounddsp/EQ.h
+ sounddsp/DSP.h
+ sounddsp/AGC.h
+
+ libopenmpt/libopenmpt_c.cpp
+ libopenmpt/libopenmpt_cxx.cpp
+ libopenmpt/libopenmpt_impl.cpp
+ libopenmpt/libopenmpt_ext_impl.cpp
+ )
+ list(TRANSFORM openmpt_SOURCES PREPEND "${openmpt_SOURCE_DIR}/")
+
+ # -DLIBOPENMPT_BUILD
+ configure_file("openmpt_svn_version.h" "svn_version.h")
+ add_library(openmpt "${SRB2_INTERNAL_LIBRARY_TYPE}" ${openmpt_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/svn_version.h)
+ if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR "${CMAKE_C_COMPILER_ID}" STREQUAL Clang OR "${CMAKE_C_COMPILER_ID}" STREQUAL AppleClang)
+ target_compile_options(openmpt PRIVATE "-g0")
+ endif()
+ if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND "${CMAKE_C_COMPILER_ID}" STREQUAL MSVC)
+ target_link_libraries(openmpt PRIVATE Rpcrt4)
+ endif()
+ target_compile_features(openmpt PRIVATE cxx_std_11)
+ target_compile_definitions(openmpt PRIVATE -DLIBOPENMPT_BUILD)
+
+ target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/common")
+ target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/src")
+ target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/include")
+ target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}")
+ target_include_directories(openmpt PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
+
+ # I wish this wasn't necessary, but it is
+ target_include_directories(openmpt PUBLIC "${openmpt_SOURCE_DIR}")
+endif()
diff --git a/thirdparty/cpm-png.cmake b/thirdparty/cpm-png.cmake
new file mode 100644
index 000000000..f16ac037b
--- /dev/null
+++ b/thirdparty/cpm-png.cmake
@@ -0,0 +1,69 @@
+CPMAddPackage(
+ NAME png
+ VERSION 1.6.38
+ URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip"
+ # png cmake build is broken on msys/mingw32
+ DOWNLOAD_ONLY YES
+)
+
+if(png_ADDED)
+ # Since png's cmake build is broken, we're going to create a target manually
+ set(
+ PNG_SOURCES
+ png.h
+ pngconf.h
+ pngpriv.h
+ pngdebug.h
+ pnginfo.h
+ pngstruct.h
+ png.c
+ pngerror.c
+ pngget.c
+ pngmem.c
+ pngpread.c
+ pngread.c
+ pngrio.c
+ pngrtran.c
+ pngrutil.c
+ pngset.c
+ pngtrans.c
+ pngwio.c
+ pngwrite.c
+ pngwtran.c
+ pngwutil.c
+ )
+ list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/")
+
+ add_custom_command(
+ OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h"
+ COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include"
+ DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h"
+ VERBATIM
+ )
+ add_custom_command(
+ OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h"
+ COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h"
+ DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt"
+ VERBATIM
+ )
+ list(
+ APPEND PNG_SOURCES
+ "${png_BINARY_DIR}/include/png.h"
+ "${png_BINARY_DIR}/include/pngconf.h"
+ "${png_BINARY_DIR}/include/pnglibconf.h"
+ )
+ add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES})
+
+ # Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason
+ target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0)
+
+ # The png includes need to be available to consumers
+ target_include_directories(png PUBLIC "${png_BINARY_DIR}/include")
+
+ # ... and these also need to be present only for png build
+ target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}")
+ target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}")
+ target_include_directories(png PRIVATE "${png_BINARY_DIR}")
+ target_link_libraries(png PRIVATE ZLIB::ZLIB)
+ add_library(PNG::PNG ALIAS png)
+endif()
diff --git a/thirdparty/cpm-sdl2-mixer.cmake b/thirdparty/cpm-sdl2-mixer.cmake
new file mode 100644
index 000000000..b7dfeae0d
--- /dev/null
+++ b/thirdparty/cpm-sdl2-mixer.cmake
@@ -0,0 +1,22 @@
+CPMAddPackage(
+ NAME SDL2_mixer
+ VERSION 2.6.2
+ URL "https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-2.6.2.zip"
+ EXCLUDE_FROM_ALL ON
+ OPTIONS
+ "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "SDL2MIXER_INSTALL OFF"
+ "SDL2MIXER_DEPS_SHARED OFF"
+ "SDL2MIXER_SAMPLES OFF"
+ "SDL2MIXER_VENDORED ON"
+ "SDL2MIXER_FLAC ON"
+ "SDL2MIXER_FLAC_LIBFLAC OFF"
+ "SDL2MIXER_FLAC_DRFLAC ON"
+ "SDL2MIXER_MOD OFF"
+ "SDL2MIXER_MP3 ON"
+ "SDL2MIXER_MP3_DRMP3 ON"
+ "SDL2MIXER_MIDI ON"
+ "SDL2MIXER_OPUS OFF"
+ "SDL2MIXER_VORBIS STB"
+ "SDL2MIXER_WAVE ON"
+)
diff --git a/thirdparty/cpm-sdl2.cmake b/thirdparty/cpm-sdl2.cmake
new file mode 100644
index 000000000..58cf9afc2
--- /dev/null
+++ b/thirdparty/cpm-sdl2.cmake
@@ -0,0 +1,13 @@
+CPMAddPackage(
+ NAME SDL2
+ VERSION 2.24.2
+ URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip"
+ EXCLUDE_FROM_ALL ON
+ OPTIONS
+ "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
+ "SDL_TEST OFF"
+ "SDL2_DISABLE_SDL2MAIN ON"
+ "SDL2_DISABLE_INSTALL ON"
+)
diff --git a/thirdparty/cpm-zlib.cmake b/thirdparty/cpm-zlib.cmake
new file mode 100644
index 000000000..5368366fd
--- /dev/null
+++ b/thirdparty/cpm-zlib.cmake
@@ -0,0 +1,53 @@
+CPMAddPackage(
+ NAME ZLIB
+ VERSION 1.2.13
+ URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip"
+ EXCLUDE_FROM_ALL
+ DOWNLOAD_ONLY YES
+)
+
+if(ZLIB_ADDED)
+ set(ZLIB_SRCS
+ crc32.h
+ deflate.h
+ gzguts.h
+ inffast.h
+ inffixed.h
+ inflate.h
+ inftrees.h
+ trees.h
+ zutil.h
+ adler32.c
+ compress.c
+ crc32.c
+ deflate.c
+ gzclose.c
+ gzlib.c
+ gzread.c
+ gzwrite.c
+ inflate.c
+ infback.c
+ inftrees.c
+ inffast.c
+ trees.c
+ uncompr.c
+ zutil.c
+ )
+ list(TRANSFORM ZLIB_SRCS PREPEND "${ZLIB_SOURCE_DIR}/")
+
+ configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY)
+ configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY)
+ configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY)
+
+ add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS})
+ set_target_properties(ZLIB PROPERTIES
+ VERSION 1.2.13
+ OUTPUT_NAME "z"
+ )
+ target_include_directories(ZLIB PRIVATE "${ZLIB_SOURCE_DIR}")
+ target_include_directories(ZLIB PUBLIC "${ZLIB_BINARY_DIR}/include")
+ if(MSVC)
+ target_compile_definitions(ZLIB PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
+ endif()
+ add_library(ZLIB::ZLIB ALIAS ZLIB)
+endif()
diff --git a/tools/anglechk.c b/tools/anglechk.c
index 4a67069bf..7f56abff7 100644
--- a/tools/anglechk.c
+++ b/tools/anglechk.c
@@ -22,7 +22,6 @@
#ifdef _MSC_VER
#include
#endif
-#define NOASM
#include "../src/tables.h"
#define NO_M
#include "../src/m_fixed.c"