SDL port of the linuxxdoom-1.10
C Assembly
Permalink
Failed to load latest commit information.
CVS
ChangeLog Inital linuxdoom 1.10 commit Dec 1, 2012
DOOMLIC.TXT Inital linuxdoom 1.10 commit Dec 1, 2012
FILES Inital linuxdoom 1.10 commit Dec 1, 2012
FILES2 Inital linuxdoom 1.10 commit Dec 1, 2012
Makefile BUGFIX: Incorrect screenblocks initialization Dec 19, 2012
README.asm Inital linuxdoom 1.10 commit Dec 1, 2012
README.b Inital linuxdoom 1.10 commit Dec 1, 2012
README.book Inital linuxdoom 1.10 commit Dec 1, 2012
README.gl Inital linuxdoom 1.10 commit Dec 1, 2012
README.sound Inital linuxdoom 1.10 commit Dec 1, 2012
TODO executable renamed, TODO updated Dec 9, 2012
am_map.c Inital linuxdoom 1.10 commit Dec 1, 2012
am_map.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_englsh.h
d_event.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_french.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_items.c
d_items.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_main.c SDL interface finished Dec 2, 2012
d_main.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_net.c
d_net.h
d_player.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_textur.h Inital linuxdoom 1.10 commit Dec 1, 2012
d_think.h
d_ticcmd.h
doomdata.h Inital linuxdoom 1.10 commit Dec 1, 2012
doomdef.c Inital linuxdoom 1.10 commit Dec 1, 2012
doomdef.h BUGFIX: Incorrect screenblocks initialization Dec 19, 2012
doomstat.c
doomstat.h
doomtype.h Inital linuxdoom 1.10 commit Dec 1, 2012
dstrings.c Inital linuxdoom 1.10 commit Dec 1, 2012
dstrings.h Inital linuxdoom 1.10 commit Dec 1, 2012
f_finale.c Inital linuxdoom 1.10 commit Dec 1, 2012
f_finale.h
f_wipe.c Inital linuxdoom 1.10 commit Dec 1, 2012
f_wipe.h Inital linuxdoom 1.10 commit Dec 1, 2012
g_game.c Inital linuxdoom 1.10 commit Dec 1, 2012
g_game.h Inital linuxdoom 1.10 commit Dec 1, 2012
hu_lib.c Inital linuxdoom 1.10 commit Dec 1, 2012
hu_lib.h Inital linuxdoom 1.10 commit Dec 1, 2012
hu_stuff.c
hu_stuff.h Inital linuxdoom 1.10 commit Dec 1, 2012
i_main.c
i_net.c Inital linuxdoom 1.10 commit Dec 1, 2012
i_net.h Inital linuxdoom 1.10 commit Dec 1, 2012
i_sdl_video.c
i_sdl_video.h X window replaced with SDL. No event handling. Dec 2, 2012
i_sound.c
i_sound.h Inital linuxdoom 1.10 commit Dec 1, 2012
i_system.c Inital linuxdoom 1.10 commit Dec 1, 2012
i_system.h
i_video.c Inital linuxdoom 1.10 commit Dec 1, 2012
i_video.h Inital linuxdoom 1.10 commit Dec 1, 2012
info.c Inital linuxdoom 1.10 commit Dec 1, 2012
info.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_argv.c Inital linuxdoom 1.10 commit Dec 1, 2012
m_argv.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_bbox.c Inital linuxdoom 1.10 commit Dec 1, 2012
m_bbox.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_cheat.c
m_cheat.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_fixed.c Inital linuxdoom 1.10 commit Dec 1, 2012
m_fixed.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_menu.c BUGFIX: Incorrect screenblocks initialization Dec 19, 2012
m_menu.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_misc.c Inital linuxdoom 1.10 commit Dec 1, 2012
m_misc.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_random.c Inital linuxdoom 1.10 commit Dec 1, 2012
m_random.h Inital linuxdoom 1.10 commit Dec 1, 2012
m_swap.c
m_swap.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_ceilng.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_doors.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_enemy.c
p_floor.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_inter.c
p_inter.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_lights.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_local.h
p_map.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_maputl.c
p_mobj.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_mobj.h
p_plats.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_pspr.c
p_pspr.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_saveg.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_saveg.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_setup.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_setup.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_sight.c
p_spec.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_spec.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_switch.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_telept.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_tick.c Inital linuxdoom 1.10 commit Dec 1, 2012
p_tick.h Inital linuxdoom 1.10 commit Dec 1, 2012
p_user.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_bsp.c
r_bsp.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_data.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_data.h
r_defs.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_draw.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_draw.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_local.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_main.c BUGFIX: Incorrect screenblocks initialization Dec 19, 2012
r_main.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_plane.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_plane.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_segs.c
r_segs.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_sky.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_sky.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_state.h Inital linuxdoom 1.10 commit Dec 1, 2012
r_things.c Inital linuxdoom 1.10 commit Dec 1, 2012
r_things.h
s_sound.c Inital linuxdoom 1.10 commit Dec 1, 2012
s_sound.h Inital linuxdoom 1.10 commit Dec 1, 2012
sounds.c Inital linuxdoom 1.10 commit Dec 1, 2012
sounds.h
st_lib.c
st_lib.h Inital linuxdoom 1.10 commit Dec 1, 2012
st_stuff.c Inital linuxdoom 1.10 commit Dec 1, 2012
st_stuff.h Inital linuxdoom 1.10 commit Dec 1, 2012
tables.c Inital linuxdoom 1.10 commit Dec 1, 2012
tables.h Inital linuxdoom 1.10 commit Dec 1, 2012
v_video.c BUGFIX: Incorrect screenblocks initialization Dec 19, 2012
v_video.h Inital linuxdoom 1.10 commit Dec 1, 2012
w_wad.c
w_wad.h Inital linuxdoom 1.10 commit Dec 1, 2012
wi_stuff.c Inital linuxdoom 1.10 commit Dec 1, 2012
wi_stuff.h Inital linuxdoom 1.10 commit Dec 1, 2012
z_zone.c Inital linuxdoom 1.10 commit Dec 1, 2012
z_zone.h

README.asm

README - DOOM assembly code

Okay, I add the DOS assembly module for the historically
inclined here (may rec.games.programmer suffer). If anyone
feels the urge to port these to GNU GCC; either inline or
as separate modules including Makefile support, be my guest.

Module tmap.S includes the inner loops for texture mapping,
the interesting one being the floor/ceiling span rendering.

There was another module in the source dump, fpfunc.S, that
had both texture mapping and fixed point functions. It
contained implementations both for i386 and M68k. For
brevity, I include only the i386 fixed point stuff below.

//====================================================
// tmap.S  as of January 10th, 1997

//================
//
// R_DrawColumn
//
//================

	.data
loopcount	.long	0
pixelcount	.long	0

	.text

	.align 16
.globl _R_DrawColumn
_R_DrawColumn:

	pushad

	movl		ebp,[_dc_yl]
	movl		ebx,ebp
	movl     edi,[_ylookup+ebx*4]
	movl		ebx,[_dc_x]
	addl     edi,[_columnofs + ebx*4]

	movl		eax,[_dc_yh]
	incl		eax
	subl     eax,ebp                   	// pixel count
	movl		[pixelcount],eax			// save for final pixel
	js		done						// nothing to scale
	shrl		eax,1						// double pixel count
	movl		[loopcount],eax
	
	movl     ecx,[_dc_iscale]

	movl		eax,[_centery]
	subl		eax,ebp
	imull	ecx
	movl		ebp,[_dc_texturemid]
	subl		ebp,eax
	shll		ebp,9							// 7 significant bits, 25 frac

	movl     esi,[_dc_source]
	

	movl		ebx,[_dc_iscale]
	shll		ebx,9
	movl		eax,OFFSET patch1+2		// convice tasm to modify code...
	movl		[eax],ebx
	movl		eax,OFFSET patch2+2		// convice tasm to modify code...
	movl		[eax],ebx
	
// eax		aligned colormap
// ebx		aligned colormap
// ecx,edx	scratch
// esi		virtual source
// edi		moving destination pointer
// ebp		frac
	
	movl	ecx,ebp					// begin calculating first pixel
	addl	ebp,ebx					// advance frac pointer
	shrl ecx,25					// finish calculation for first pixel
	movl	edx,ebp					// begin calculating second pixel
	addl	ebp,ebx					// advance frac pointer
	shrl edx,25					// finish calculation for second pixel
	movl eax,[_dc_colormap]
	movl ebx,eax
	movb	al,[esi+ecx]			// get first pixel
	movb	bl,[esi+edx]			// get second pixel
	movb	al,[eax]				// color translate first pixel
	movb	bl,[ebx]				// color translate second pixel
	
	testl	[pixelcount],0fffffffeh
	jnz	doubleloop				// at least two pixels to map
	jmp	checklast
	
	.align	16
doubleloop:
	movl	ecx,ebp					// begin calculating third pixel
patch1:
	addl	ebp,12345678h			// advance frac pointer
	movb	[edi],al				// write first pixel
	shrl ecx,25					// finish calculation for third pixel
	movl	edx,ebp					// begin calculating fourth pixel
patch2:
	addl	ebp,12345678h			// advance frac pointer
	movl	[edi+SCREENWIDTH],bl	// write second pixel
	shrl edx,25					// finish calculation for fourth pixel
	movb	al,[esi+ecx]			// get third pixel
	addl	edi,SCREENWIDTH*2		// advance to third pixel destination
	movb	bl,[esi+edx]			// get fourth pixel
	decl	[loopcount]				// done with loop?
	movb	al,[eax]				// color translate third pixel
	movb	bl,[ebx]				// color translate fourth pixel
	jnz	doubleloop
	
// check for final pixel
checklast:
	testl	[pixelcount],1
	jz	done
	movb	[edi],al				// write final pixel
	
done:
	popad
	ret
	


//================
//
// R_DrawSpan
//
// Horizontal texture mapping
//
//================


	.align	16
.globl _R_DrawSpan
_R_DrawSpan:
	pushad

//
// find loop count
//	
	movl		eax,[_ds_x2]
	incl		eax
	subl     eax,[_ds_x1]               	// pixel count
	movl		[pixelcount],eax			// save for final pixel
	js		hdone						// nothing to scale
	shrl		eax,1						// double pixel count
	movl		[loopcount],eax

//
// build composite position
//
	movl	ebp,[_ds_xfrac]
	shll	ebp,10
	andl	ebp,0ffff0000h
	movl	eax,[_ds_yfrac]
	shrl	eax,6
	andl	eax,0ffffh
	orl	ebp,eax

	movl	esi,[_ds_source]

//
// calculate screen dest
//
	movl	edi,[_ds_y]
	movl	edi,[_ylookup+edi*4]
	movl	eax,[_ds_x1]
	addl edi,[_columnofs+eax*4]

//
// build composite step
//
	movl	ebx,[_ds_xstep]
	shll	ebx,10
	andl	ebx,0ffff0000h
	movl	eax,[_ds_ystep]
	shrl	eax,6
	andl	eax,0ffffh
	orl	ebx,eax

	movl		eax,OFFSET hpatch1+2		// convice tasm to modify code...
	movl		[eax],ebx
	movl		eax,OFFSET hpatch2+2		// convice tasm to modify code...
	movl		[eax],ebx
	
// eax		aligned colormap
// ebx		aligned colormap
// ecx,edx	scratch
// esi		virtual source
// edi		moving destination pointer
// ebp		frac
	
	shldl ecx,ebp,22				// begin calculating third pixel (y units)
	shldl ecx,ebp,6				// begin calculating third pixel (x units)
	addl	ebp,ebx					// advance frac pointer
	andl ecx,4095				// finish calculation for third pixel
	shldl edx,ebp,22				// begin calculating fourth pixel (y units)
	shldl edx,ebp,6				// begin calculating fourth pixel (x units)
	addl	ebp,ebx					// advance frac pointer
	andl edx,4095				// finish calculation for fourth pixel
	movl eax,[_ds_colormap]
	movl ebx,eax
	movb	al,[esi+ecx]			// get first pixel
	movb	bl,[esi+edx]			// get second pixel
	movb	al,[eax]				// color translate first pixel
	movb	bl,[ebx]				// color translate second pixel
	
	testl	[pixelcount],0fffffffeh
	jnz	hdoubleloop				// at least two pixels to map
	jmp	hchecklast
	

	.align	16
hdoubleloop:
	shldl ecx,ebp,22				// begin calculating third pixel (y units)
	shldl ecx,ebp,6				// begin calculating third pixel (x units)
hpatch1:
	addl	ebp,12345678h			// advance frac pointer
	movb	[edi],al				// write first pixel
	andl ecx,4095				// finish calculation for third pixel
	shldl edx,ebp,22				// begin calculating fourth pixel (y units)
	shldl edx,ebp,6				// begin calculating fourth pixel (x units)
hpatch2:
	addl	ebp,12345678h			// advance frac pointer
	movb	[edi+1],bl				// write second pixel
	andl edx,4095				// finish calculation for fourth pixel
	movb	al,[esi+ecx]			// get third pixel
	addl	edi,2					// advance to third pixel destination
	movb	bl,[esi+edx]			// get fourth pixel
	decl	[loopcount]				// done with loop?
	movb	al,[eax]				// color translate third pixel
	movb	bl,[ebx]				// color translate fourth pixel
	jnz	hdoubleloop

// check for final pixel
hchecklast:
	testl	[pixelcount],1
	jz	hdone
	movb	[edi],al				// write final pixel
	
hdone:
	popad
	ret




//====================================================
// fpfunc.S  as of January 10th, 1997 (parts)

#ifdef i386

.text
	.align 4
.globl _FixedMul
_FixedMul:	
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	imull 12(%ebp)
	shrdl $16,%edx,%eax
	popl %ebp
	ret


	.align 4
.globl _FixedDiv2
_FixedDiv2:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	cdq
	shldl $16,%eax,%edx
	sall	$16,%eax
	idivl	12(%ebp)
	popl %ebp
	ret

#endif