Upload Wolfenstein 3D sources

git-svn-id: svn://kolibrios.org@8557 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
maxcodehack 2021-01-30 12:31:40 +00:00
parent d06e01cc46
commit abebbdd698
53 changed files with 39928 additions and 0 deletions

22
contrib/games/wolf3d/Makefile Executable file
View File

@ -0,0 +1,22 @@
CC = kos32-gcc
LD = kos32-ld
SDK_DIR = $(abspath ../../sdk)
CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32
LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds --image-base 0
INCLUDES = -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/SDL-1.2.2_newlib/include -I.
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib
OBJECTS = wl_cloudsky.o wl_debug.o id_sd.o wl_play.o id_vl.o wl_act2.o wl_floorceiling.o wl_dir3dspr.o wl_state.o wl_atmos.o id_in.o signon.o wl_parallax.o wl_agent.o sdl_winmain.o wl_inter.o wl_text.o id_pm.o wl_draw.o wl_menu.o wl_game.o wl_act1.o wl_main.o wl_shade.o id_us_1.o id_vh.o id_ca.o joystick_stub.o
default: $(OBJECTS)
kos32-ld $(LDFLAGS) $(LIBPATH) --subsystem native -o wolf3d $(OBJECTS) -lSDLn -lsound -lstdc++ -lsupc++ -lgcc -lc.dll
objcopy wolf3d -O binary
%.o : %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
clean:
rm *.o

142
contrib/games/wolf3d/audiosod.h Executable file
View File

@ -0,0 +1,142 @@
/////////////////////////////////////////////////
//
// MUSE Header for .SOD
// Created Thu Aug 13 09:25:58 1992
//
/////////////////////////////////////////////////
#define NUMSOUNDS 81
#define NUMSNDCHUNKS 267
//
// Sound names & indexes
//
typedef enum {
HITWALLSND, // 0
MISSILEHITSND, // 1
SELECTITEMSND, // 2
GHOSTSIGHTSND, // 3
MOVEGUN2SND, // 4
MOVEGUN1SND, // 5
NOWAYSND, // 6
NAZIHITPLAYERSND, // 7
MISSILEFIRESND, // 8
PLAYERDEATHSND, // 9
DOGDEATHSND, // 10
ATKGATLINGSND, // 11
GETKEYSND, // 12
NOITEMSND, // 13
WALK1SND, // 14
WALK2SND, // 15
TAKEDAMAGESND, // 16
GAMEOVERSND, // 17
OPENDOORSND, // 18
CLOSEDOORSND, // 19
DONOTHINGSND, // 20
HALTSND, // 21
DEATHSCREAM2SND, // 22
ATKKNIFESND, // 23
ATKPISTOLSND, // 24
DEATHSCREAM3SND, // 25
ATKMACHINEGUNSND, // 26
HITENEMYSND, // 27
SHOOTDOORSND, // 28
DEATHSCREAM1SND, // 29
GETMACHINESND, // 30
GETAMMOSND, // 31
SHOOTSND, // 32
HEALTH1SND, // 33
HEALTH2SND, // 34
BONUS1SND, // 35
BONUS2SND, // 36
BONUS3SND, // 37
GETGATLINGSND, // 38
ESCPRESSEDSND, // 39
LEVELDONESND, // 40
DOGBARKSND, // 41
ENDBONUS1SND, // 42
ENDBONUS2SND, // 43
BONUS1UPSND, // 44
BONUS4SND, // 45
PUSHWALLSND, // 46
NOBONUSSND, // 47
PERCENT100SND, // 48
BOSSACTIVESND, // 49
DEATHSCREAM4SND, // 50
SCHUTZADSND, // 51
AHHHGSND, // 52
DEATHSCREAM5SND, // 53
DEATHSCREAM7SND, // 54
DEATHSCREAM8SND, // 55
LEBENSND, // 56
DEATHSCREAM6SND, // 57
NAZIFIRESND, // 58
BOSSFIRESND, // 59
SSFIRESND, // 60
SLURPIESND, // 61
GHOSTFADESND, // 62
DEATHSCREAM9SND, // 63
GETAMMOBOXSND, // 64
ANGELSIGHTSND, // 65
SPIONSND, // 66
NEINSOVASSND, // 67
DOGATTACKSND, // 68
ANGELFIRESND, // 69
TRANSSIGHTSND, // 70
TRANSDEATHSND, // 71
WILHELMSIGHTSND, // 72
WILHELMDEATHSND, // 73
UBERDEATHSND, // 74
KNIGHTSIGHTSND, // 75
KNIGHTDEATHSND, // 76
ANGELDEATHSND, // 77
KNIGHTMISSILESND, // 78
GETSPEARSND, // 79
ANGELTIREDSND, // 80
LASTSOUND
} soundnames;
//
// Base offsets
//
#define STARTPCSOUNDS 0
#define STARTADLIBSOUNDS 81
#define STARTDIGISOUNDS 162
#define STARTMUSIC 243
//
// Music names & indexes
//
typedef enum {
XFUNKIE_MUS, // 0
DUNGEON_MUS, // 1
XDEATH_MUS, // 2
GETTHEM_MUS, // 3
XTIPTOE_MUS, // 4
GOINGAFT_MUS, // 5
URAHERO_MUS, // 6
XTHEEND_MUS, // 7
NAZI_OMI_MUS, // 8
POW_MUS, // 9
TWELFTH_MUS, // 10
SEARCHN_MUS, // 11
SUSPENSE_MUS, // 12
ZEROHOUR_MUS, // 13
WONDERIN_MUS, // 14
ULTIMATE_MUS, // 15
ENDLEVEL_MUS, // 16
XEVIL_MUS, // 17
XJAZNAZI_MUS, // 18
COPYPRO_MUS, // 19
XAWARD_MUS, // 20
XPUTIT_MUS, // 21
XGETYOU_MUS, // 22
XTOWER2_MUS, // 23
LASTMUSIC
} musicnames;
/////////////////////////////////////////////////
//
// Thanks for playing with MUSE!
//
/////////////////////////////////////////////////

153
contrib/games/wolf3d/audiowl6.h Executable file
View File

@ -0,0 +1,153 @@
/////////////////////////////////////////////////
//
// MUSE Header for .WL6
// Created Tue Jul 14 15:04:53 1992
//
/////////////////////////////////////////////////
//
// Sound names & indexes
//
typedef enum {
HITWALLSND, // 0
SELECTWPNSND, // 1
SELECTITEMSND, // 2
HEARTBEATSND, // 3
MOVEGUN2SND, // 4
MOVEGUN1SND, // 5
NOWAYSND, // 6
NAZIHITPLAYERSND, // 7
SCHABBSTHROWSND, // 8
PLAYERDEATHSND, // 9
DOGDEATHSND, // 10
ATKGATLINGSND, // 11
GETKEYSND, // 12
NOITEMSND, // 13
WALK1SND, // 14
WALK2SND, // 15
TAKEDAMAGESND, // 16
GAMEOVERSND, // 17
OPENDOORSND, // 18
CLOSEDOORSND, // 19
DONOTHINGSND, // 20
HALTSND, // 21
DEATHSCREAM2SND, // 22
ATKKNIFESND, // 23
ATKPISTOLSND, // 24
DEATHSCREAM3SND, // 25
ATKMACHINEGUNSND, // 26
HITENEMYSND, // 27
SHOOTDOORSND, // 28
DEATHSCREAM1SND, // 29
GETMACHINESND, // 30
GETAMMOSND, // 31
SHOOTSND, // 32
HEALTH1SND, // 33
HEALTH2SND, // 34
BONUS1SND, // 35
BONUS2SND, // 36
BONUS3SND, // 37
GETGATLINGSND, // 38
ESCPRESSEDSND, // 39
LEVELDONESND, // 40
DOGBARKSND, // 41
ENDBONUS1SND, // 42
ENDBONUS2SND, // 43
BONUS1UPSND, // 44
BONUS4SND, // 45
PUSHWALLSND, // 46
NOBONUSSND, // 47
PERCENT100SND, // 48
BOSSACTIVESND, // 49
MUTTISND, // 50
SCHUTZADSND, // 51
AHHHGSND, // 52
DIESND, // 53
EVASND, // 54
GUTENTAGSND, // 55
LEBENSND, // 56
SCHEISTSND, // 57
NAZIFIRESND, // 58
BOSSFIRESND, // 59
SSFIRESND, // 60
SLURPIESND, // 61
TOT_HUNDSND, // 62
MEINGOTTSND, // 63
SCHABBSHASND, // 64
HITLERHASND, // 65
SPIONSND, // 66
NEINSOVASSND, // 67
DOGATTACKSND, // 68
FLAMETHROWERSND, // 69
MECHSTEPSND, // 70
GOOBSSND, // 71
YEAHSND, // 72
#ifndef APOGEE_1_0
DEATHSCREAM4SND, // 73
DEATHSCREAM5SND, // 74
DEATHSCREAM6SND, // 75
DEATHSCREAM7SND, // 76
DEATHSCREAM8SND, // 77
DEATHSCREAM9SND, // 78
DONNERSND, // 79
EINESND, // 80
ERLAUBENSND, // 81
KEINSND, // 82
MEINSND, // 83
ROSESND, // 84
MISSILEFIRESND, // 85
MISSILEHITSND, // 86
#endif
LASTSOUND
} soundnames;
//
// Base offsets
//
#define STARTPCSOUNDS 0
#define STARTADLIBSOUNDS LASTSOUND
#define STARTDIGISOUNDS (2*LASTSOUND)
#define STARTMUSIC (3*LASTSOUND)
//
// Music names & indexes
//
typedef enum {
CORNER_MUS, // 0
DUNGEON_MUS, // 1
WARMARCH_MUS, // 2
GETTHEM_MUS, // 3
HEADACHE_MUS, // 4
HITLWLTZ_MUS, // 5
INTROCW3_MUS, // 6
NAZI_NOR_MUS, // 7
NAZI_OMI_MUS, // 8
POW_MUS, // 9
SALUTE_MUS, // 10
SEARCHN_MUS, // 11
SUSPENSE_MUS, // 12
VICTORS_MUS, // 13
WONDERIN_MUS, // 14
FUNKYOU_MUS, // 15
ENDLEVEL_MUS, // 16
GOINGAFT_MUS, // 17
PREGNANT_MUS, // 18
ULTIMATE_MUS, // 19
NAZI_RAP_MUS, // 20
ZEROHOUR_MUS, // 21
TWELFTH_MUS, // 22
ROSTER_MUS, // 23
URAHERO_MUS, // 24
VICMARCH_MUS, // 25
PACMAN_MUS, // 26
LASTMUSIC
} musicnames;
#define NUMSOUNDS LASTSOUND
#define NUMSNDCHUNKS (STARTMUSIC + LASTMUSIC)
/////////////////////////////////////////////////
//
// Thanks for playing with MUSE!
//
/////////////////////////////////////////////////

76
contrib/games/wolf3d/f_spear.h Executable file
View File

@ -0,0 +1,76 @@
#define STR_ENDGAME1 "We owe you a great debt, Mr. Blazkowicz."
#define STR_ENDGAME2 "You have served your country well."
#define STR_ENDGAME3 "With the spear gone, the Allies will finally"
#define STR_ENDGAME4 "by able to destroy Hitler..."
#define STR_COPY1 "That's close, but not close enough to get"
#define STR_COPY2 "you into the game."
#define STR_COPY3 "Wow, you must have the early version of the"
#define STR_COPY4 "manual with the totally false information in it."
#define STR_COPY5 "I would let you into the game, but seeing"
#define STR_COPY6 "as that was not at all the right answer..."
#define STR_COPY7 "It's just too bad we can't get together on"
#define STR_COPY8 "this one. Sorry."
#define STR_COPY9 "Hey, you're just SO off base!"
#define STR_COPY10 "You know, I once typed that myself when"
#define STR_COPY11 "I was your age."
#define STR_COPY12 "Nops. Zero points. Zugga."
#define STR_COPY13 "Yeah...right."
#define STR_COPY14 "You must like these quizzes."
#define STR_COPY15 "Could be called \"PixelMeister\"?"
#define STR_COPY16 "Might engineer some software?"
#define STR_COPY17 "Would be found"
#define STR_COPY18 "directing creatively?"
#define STR_COPY19 "Might be found"
#define STR_COPY20 "handling operations?"
#define STR_COPY21 "Has a name familiar"
#define STR_COPY22 "to your weatherman?"
#define STR_NOPE1 "Welcome to the DOS prompt, pirate!"
#define STR_NOPE2 "Eat hot DOS prompt, goober!"
#define STR_NOPE3 "Ya know, this program doesn't cost that much."
#define STR_NOPE4 "Hey...weren't you just AT this DOS prompt?"
#define STR_NOPE5 "What's a nice user like you doin' at a DOS prompt like this?"
#define STR_NOPE6 "Well, I'm sure you just \"misplaced\" the manual..."
#define STR_NOPE7 "Run me again when you've boned up on your manual a bit."
#define STR_NOPE8 "Nice try, but no Spear."
#define STR_NOPE9 "That information is in the Spear of Destiny manual, by the way."
#define STR_MISC1 "Under \"Killing the Enemy\", what"
#define STR_MISC2 "type of enemy is pictured?"
#define STR_MISC3 "How many eyelets are on B.J.'s"
#define STR_MISC4 "boots? (see page 2)"
#define STR_MISC5 "The word \"minister\" appears in"
#define STR_MISC6 "what gray shape on page 2?"
#define STR_MISC7 "How many bullets does B.J. have"
#define STR_MISC8 "on the screen-shot in the middle"
#define STR_MISC9 "of page 9?"
#define STR_STAR "star"
#define STR_DEBRIEF " DEBRIEFING\n SESSION\n"
#define STR_ENEMY1 "Name the member of the"
#define STR_ENEMY2 "enemy forces shown above"
#define STR_CHECKMAN "CHECK YER MANUAL!"
#define STR_MAN1 "Which manual page"
#define STR_MAN2 "is the Options Menu"
#define STR_MAN3 "function"
#define STR_MAN4 "on?"
#define STR_ID1 "Which member of Id Software:"

131
contrib/games/wolf3d/foreign.h Executable file
View File

@ -0,0 +1,131 @@
#define QUITSUR "Are you sure you want\n"\
"to quit this great game?"
#define CURGAME "You are currently in\n"\
"a game. Continuing will\n"\
"erase old game. Ok?"
#define GAMESVD "There's already a game\n"\
"saved at this position.\n"\
" Overwrite?"
#define ENDGAMESTR "Are you sure you want\n"\
"to end the game you\n"\
"are playing? (Y or N):"
#define STR_NG "New Game"
#define STR_SD "Sound"
#define STR_CL "Control"
#define STR_LG "Load Game"
#define STR_SG "Save Game"
#define STR_CV "Change View"
#define STR_VS "View Scores"
#define STR_EG "End Game"
#define STR_BD "Back to Demo"
#define STR_QT "Quit"
#define STR_LOADING "Loading"
#define STR_SAVING "Saving"
#define STR_GAME "Game"
#define STR_DEMO "Demo"
#define STR_LGC "Load Game called\n\""
#define STR_EMPTY "empty"
#define STR_CALIB "Calibrate"
#define STR_JOYST "Joystick"
#define STR_MOVEJOY "Move joystick to\nupper left and\npress button 0\n"
#define STR_MOVEJOY2 "Move joystick to\nlower right and\npress button 1\n"
#define STR_ESCEXIT "ESC to exit"
#define STR_NONE "None"
#define STR_PC "PC Speaker"
#define STR_ALSB "AdLib/Sound Blaster"
#define STR_DISNEY "Disney Sound Source"
#define STR_SB "Sound Blaster"
#define STR_MOUSEEN "Mouse Enabled"
#define STR_JOYEN "Joystick Enabled"
#define STR_PORT2 "Use joystick port 2"
#define STR_GAMEPAD "Gravis GamePad Enabled"
#define STR_SENS "Mouse Sensitivity"
#define STR_CUSTOM "Customize controls"
#define STR_DADDY "Can I play, Daddy?"
#define STR_HURTME "Don't hurt me."
#define STR_BRINGEM "Bring 'em on!"
#define STR_DEATH "I am Death incarnate!"
#define STR_MOUSEADJ "Adjust Mouse Sensitivity"
#define STR_SLOW "Slow"
#define STR_FAST "Fast"
#define STR_CRUN "Run"
#define STR_COPEN "Open"
#define STR_CFIRE "Fire"
#define STR_CSTRAFE "Strafe"
#define STR_LEFT "Left"
#define STR_RIGHT "Right"
#define STR_FRWD "Frwd"
#define STR_BKWD "Bkwrd"
#define STR_THINK "Thinking"
#define STR_SIZE1 "Use arrows to size"
#define STR_SIZE2 "ENTER to accept"
#define STR_SIZE3 "ESC to cancel"
#define STR_YOUWIN "you win!"
#define STR_TOTALTIME "total time"
#define STR_RATKILL "kill %"
#define STR_RATSECRET "secret %"
#define STR_RATTREASURE "treasure %"
#define STR_BONUS "bonus"
#define STR_TIME "time"
#define STR_PAR " par"
#define STR_RAT2KILL "kill ratio %"
#define STR_RAT2SECRET "secret ratio %"
#define STR_RAT2TREASURE "treasure ratio %"
#define STR_DEFEATED "defeated!"
#define STR_CHEATER1 "You now have 100% Health,"
#define STR_CHEATER2 "99 Ammo and both Keys!"
#define STR_CHEATER3 "Note that you have basically"
#define STR_CHEATER4 "eliminated your chances of"
#define STR_CHEATER5 "getting a high score!"
#define STR_NOSPACE1 "There is not enough space"
#define STR_NOSPACE2 "on your disk to Save Game!"
#define STR_SAVECHT1 "Your Save Game file is,"
#define STR_SAVECHT2 "shall we say, \"corrupted\"."
#define STR_SAVECHT3 "But I'll let you go on and"
#define STR_SAVECHT4 "play anyway...."
#define STR_SEEAGAIN "Let's see that again!"
#ifdef SPEAR
#define ENDSTR1 "Heroes don't quit, but\ngo ahead and press " YESBUTTONNAME "\nif you aren't one."
#define ENDSTR2 "Press " YESBUTTONNAME " to quit,\nor press " NOBUTTONNAME " to enjoy\nmore violent diversion."
#define ENDSTR3 "Depressing the " YESBUTTONNAME " key means\nyou must return to the\nhumdrum workday world."
#define ENDSTR4 "Hey, quit or play,\n" YESBUTTONNAME " or " NOBUTTONNAME ":\nit's your choice."
#define ENDSTR5 "Sure you don't want to\nwaste a few more\nproductive hours?"
#define ENDSTR6 "I think you had better\nplay some more. Please\npress " NOBUTTONNAME "...please?"
#define ENDSTR7 "If you are tough, press " NOBUTTONNAME ".\nIf not, press " YESBUTTONNAME " daintily."
#define ENDSTR8 "I'm thinkin' that\nyou might wanna press " NOBUTTONNAME "\nto play more. You do it."
#define ENDSTR9 "Sure. Fine. Quit.\nSee if we care.\nGet it over with.\nPress " YESBUTTONNAME "."
#else
#define ENDSTR1 "Dost thou wish to\nleave with such hasty\nabandon?"
#define ENDSTR2 "Chickening out...\nalready?"
#define ENDSTR3 "Press " NOBUTTONNAME " for more carnage.\nPress " YESBUTTONNAME " to be a weenie."
#define ENDSTR4 "So, you think you can\nquit this easily, huh?"
#define ENDSTR5 "Press " NOBUTTONNAME " to save the world.\nPress " YESBUTTONNAME " to abandon it in\nits hour of need."
#define ENDSTR6 "Press " NOBUTTONNAME " if you are brave.\nPress " YESBUTTONNAME " to cower in shame."
#define ENDSTR7 "Heroes, press " NOBUTTONNAME ".\nWimps, press " YESBUTTONNAME "."
#define ENDSTR8 "You are at an intersection.\nA sign says, 'Press " YESBUTTONNAME " to quit.'\n>"
#define ENDSTR9 "For guns and glory, press " NOBUTTONNAME ".\nFor work and worry, press " YESBUTTONNAME "."
#endif

244
contrib/games/wolf3d/gfxv_apo.h Executable file
View File

@ -0,0 +1,244 @@
//////////////////////////////////////
//
// Graphics .H file for Apogee v1.4
// IGRAB-ed on Sun May 03 01:19:32 1992
//
//////////////////////////////////////
typedef enum {
// Lump Start
H_BJPIC=3,
H_CASTLEPIC, // 4
H_KEYBOARDPIC, // 5
H_JOYPIC, // 6
H_HEALPIC, // 7
H_TREASUREPIC, // 8
H_GUNPIC, // 9
H_KEYPIC, // 10
H_BLAZEPIC, // 11
H_WEAPON1234PIC, // 12
H_WOLFLOGOPIC, // 13
H_VISAPIC, // 14
H_MCPIC, // 15
H_IDLOGOPIC, // 16
H_TOPWINDOWPIC, // 17
H_LEFTWINDOWPIC, // 18
H_RIGHTWINDOWPIC, // 19
H_BOTTOMINFOPIC, // 20
#if !defined(APOGEE_1_0) && !defined(APOGEE_1_1) && !defined(APOGEE_1_2)
H_SPEARADPIC, // 21
#endif
// Lump Start
C_OPTIONSPIC, // 22
C_CURSOR1PIC, // 23
C_CURSOR2PIC, // 24
C_NOTSELECTEDPIC, // 25
C_SELECTEDPIC, // 26
C_FXTITLEPIC, // 27
C_DIGITITLEPIC, // 28
C_MUSICTITLEPIC, // 29
C_MOUSELBACKPIC, // 30
C_BABYMODEPIC, // 31
C_EASYPIC, // 32
C_NORMALPIC, // 33
C_HARDPIC, // 34
C_LOADSAVEDISKPIC, // 35
C_DISKLOADING1PIC, // 36
C_DISKLOADING2PIC, // 37
C_CONTROLPIC, // 38
C_CUSTOMIZEPIC, // 39
C_LOADGAMEPIC, // 40
C_SAVEGAMEPIC, // 41
C_EPISODE1PIC, // 42
C_EPISODE2PIC, // 43
C_EPISODE3PIC, // 44
C_EPISODE4PIC, // 45
C_EPISODE5PIC, // 46
C_EPISODE6PIC, // 47
C_CODEPIC, // 48
#ifndef APOGEE_1_0
C_TIMECODEPIC, // 49
C_LEVELPIC, // 50
C_NAMEPIC, // 51
C_SCOREPIC, // 52
#if !defined(APOGEE_1_1) && !defined(APOGEE_1_2)
C_JOY1PIC, // 53
C_JOY2PIC, // 54
#endif
#else
C_TIMECODEPIC=C_CODEPIC, // 47
#endif
// Lump Start
L_GUYPIC, // 55
L_COLONPIC, // 56
L_NUM0PIC, // 57
L_NUM1PIC, // 58
L_NUM2PIC, // 59
L_NUM3PIC, // 60
L_NUM4PIC, // 61
L_NUM5PIC, // 62
L_NUM6PIC, // 63
L_NUM7PIC, // 64
L_NUM8PIC, // 65
L_NUM9PIC, // 66
L_PERCENTPIC, // 67
L_APIC, // 68
L_BPIC, // 69
L_CPIC, // 70
L_DPIC, // 71
L_EPIC, // 72
L_FPIC, // 73
L_GPIC, // 74
L_HPIC, // 75
L_IPIC, // 76
L_JPIC, // 77
L_KPIC, // 78
L_LPIC, // 79
L_MPIC, // 80
L_NPIC, // 81
L_OPIC, // 82
L_PPIC, // 83
L_QPIC, // 84
L_RPIC, // 85
L_SPIC, // 86
L_TPIC, // 87
L_UPIC, // 88
L_VPIC, // 89
L_WPIC, // 90
L_XPIC, // 91
L_YPIC, // 92
L_ZPIC, // 93
L_EXPOINTPIC, // 94
#ifndef APOGEE_1_0
L_APOSTROPHEPIC, // 95
#endif
L_GUY2PIC, // 96
L_BJWINSPIC, // 97
STATUSBARPIC, // 98
TITLEPIC, // 99
PG13PIC, // 100
CREDITSPIC, // 101
HIGHSCORESPIC, // 102
// Lump Start
KNIFEPIC, // 103
GUNPIC, // 104
MACHINEGUNPIC, // 105
GATLINGGUNPIC, // 106
NOKEYPIC, // 107
GOLDKEYPIC, // 108
SILVERKEYPIC, // 109
N_BLANKPIC, // 110
N_0PIC, // 111
N_1PIC, // 112
N_2PIC, // 113
N_3PIC, // 114
N_4PIC, // 115
N_5PIC, // 116
N_6PIC, // 117
N_7PIC, // 118
N_8PIC, // 119
N_9PIC, // 120
FACE1APIC, // 121
FACE1BPIC, // 122
FACE1CPIC, // 123
FACE2APIC, // 124
FACE2BPIC, // 125
FACE2CPIC, // 126
FACE3APIC, // 127
FACE3BPIC, // 128
FACE3CPIC, // 129
FACE4APIC, // 130
FACE4BPIC, // 131
FACE4CPIC, // 132
FACE5APIC, // 133
FACE5BPIC, // 134
FACE5CPIC, // 135
FACE6APIC, // 136
FACE6BPIC, // 137
FACE6CPIC, // 138
FACE7APIC, // 139
FACE7BPIC, // 140
FACE7CPIC, // 141
FACE8APIC, // 142
GOTGATLINGPIC, // 143
MUTANTBJPIC, // 144
PAUSEDPIC, // 145
GETPSYCHEDPIC, // 146
TILE8, // 147
ORDERSCREEN, // 148
ERRORSCREEN, // 149
T_HELPART, // 150
#ifdef APOGEE_1_0
T_ENDART1, // 143
#endif
T_DEMO0, // 151
T_DEMO1, // 152
T_DEMO2, // 153
T_DEMO3, // 154
#ifndef APOGEE_1_0
T_ENDART1, // 155
T_ENDART2, // 156
T_ENDART3, // 157
T_ENDART4, // 158
T_ENDART5, // 159
T_ENDART6, // 160
#endif
ENUMEND
} graphicnums;
//
// Data LUMPs
//
#define README_LUMP_START H_BJPIC
#define README_LUMP_END H_BOTTOMINFOPIC
#define CONTROLS_LUMP_START C_OPTIONSPIC
#define CONTROLS_LUMP_END (L_GUYPIC - 1)
#define LEVELEND_LUMP_START L_GUYPIC
#define LEVELEND_LUMP_END L_BJWINSPIC
#define LATCHPICS_LUMP_START KNIFEPIC
#define LATCHPICS_LUMP_END GETPSYCHEDPIC
//
// Amount of each data item
//
#define NUMCHUNKS ENUMEND
#define NUMFONT 2
#define NUMFONTM 0
#define NUMPICS (GETPSYCHEDPIC - NUMFONT)
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
#define NUMTILE32 0
#define NUMTILE32M 0
#define NUMEXTERNS 13
//
// File offsets for data items
//
#define STRUCTPIC 0
#define STARTFONT 1
#define STARTFONTM 3
#define STARTPICS 3
#define STARTPICM TILE8
#define STARTSPRITES TILE8
#define STARTTILE8 TILE8
#define STARTTILE8M ORDERSCREEN
#define STARTTILE16 ORDERSCREEN
#define STARTTILE16M ORDERSCREEN
#define STARTTILE32 ORDERSCREEN
#define STARTTILE32M ORDERSCREEN
#define STARTEXTERNS ORDERSCREEN
//
// Thank you for using IGRAB!
//

243
contrib/games/wolf3d/gfxv_jap.h Executable file
View File

@ -0,0 +1,243 @@
//////////////////////////////////////////
//
// Graphics .H file for Japanese version
// Recreated from images and used defines
//
//////////////////////////////////////////
typedef enum {
// Lump Start
H_HELP1PIC = 3, // 3
H_HELP2PIC, // 4
H_HELP3PIC, // 5
H_HELP4PIC, // 6
H_HELP5PIC, // 7
H_HELP6PIC, // 8
H_HELP7PIC, // 9
H_HELP8PIC, // 10
H_HELP9PIC, // 11
H_HELP10PIC, // 12
// Lump Start
C_OPTIONSPIC, // 13
C_CURSOR1PIC, // 14
C_CURSOR2PIC, // 15
C_NOTSELECTEDPIC, // 16
C_SELECTEDPIC, // 17
C_MOUSELBACKPIC, // 18
C_BABYMODEPIC, // 19
C_EASYPIC, // 20
C_NORMALPIC, // 21
C_HARDPIC, // 22
C_LOADSAVEDISKPIC, // 23
C_DISKLOADING1PIC, // 24
C_DISKLOADING2PIC, // 25
C_CONTROLPIC, // 26
C_LOADGAMEPIC, // 27
C_SAVEGAMEPIC, // 28
C_EPISODE1PIC, // 29
C_EPISODE2PIC, // 30
C_EPISODE3PIC, // 31
C_EPISODE4PIC, // 32
C_EPISODE5PIC, // 33
C_EPISODE6PIC, // 34
C_CODEPIC, // 35
C_TIMECODEPIC, // 36
C_LEVELPIC, // 37
C_NAMEPIC, // 38
C_SCOREPIC, // 39
C_JOY1PIC, // 40
C_JOY2PIC, // 41
C_QUITMSGPIC, // 42
C_JAPQUITPIC, // 43
C_UNUSED_LOADING, // 44
C_JAPNEWGAMEPIC, // 45
C_JAPSAVEOVERPIC, // 46
C_MSCORESPIC, // 47
C_MENDGAMEPIC, // 48
C_MRETDEMOPIC, // 49
C_MRETGAMEPIC, // 50
C_INTERMISSIONPIC, // 51
C_LETSSEEPIC, // 52
C_ENDRATIOSPIC, // 53
C_ENDGAME1APIC, // 54
C_ENDGAME1BPIC, // 55
C_ENDGAME2APIC, // 56
C_ENDGAME2BPIC, // 57
C_ENDGAME3APIC, // 58
C_ENDGAME3BPIC, // 59
C_ENDGAME4APIC, // 60
C_ENDGAME4BPIC, // 61
C_ENDGAME5APIC, // 62
C_ENDGAME5BPIC, // 63
C_ENDGAME6APIC, // 64
C_ENDGAME6BPIC, // 65
// Lump Start
L_GUYPIC, // 66
L_COLONPIC, // 67
L_NUM0PIC, // 68
L_NUM1PIC, // 69
L_NUM2PIC, // 70
L_NUM3PIC, // 71
L_NUM4PIC, // 72
L_NUM5PIC, // 73
L_NUM6PIC, // 74
L_NUM7PIC, // 75
L_NUM8PIC, // 76
L_NUM9PIC, // 77
L_PERCENTPIC, // 78
L_APIC, // 79
L_BPIC, // 80
L_CPIC, // 81
L_DPIC, // 82
L_EPIC, // 83
L_FPIC, // 84
L_GPIC, // 85
L_HPIC, // 86
L_IPIC, // 87
L_JPIC, // 88
L_KPIC, // 89
L_LPIC, // 90
L_MPIC, // 91
L_NPIC, // 92
L_OPIC, // 93
L_PPIC, // 94
L_QPIC, // 95
L_RPIC, // 96
L_SPIC, // 97
L_TPIC, // 98
L_UPIC, // 99
L_VPIC, // 100
L_WPIC, // 101
L_XPIC, // 102
L_YPIC, // 103
L_ZPIC, // 104
L_EXPOINTPIC, // 105
L_APOSTROPHEPIC, // 106
L_GUY2PIC, // 107
L_BJWINSPIC, // 108
STATUSBARPIC, // 109
TITLEPIC, // 110
S_MOUSESENSPIC, // 111
S_OPTIONSPIC, // 112
S_SOUNDPIC, // 113
S_SKILLPIC, // 114
S_EPISODEPIC, // 115
S_CHANGEPIC, // 116
S_CUSTOMPIC, // 117
S_CONTROLPIC, // 118
CREDITSPIC, // 119
HIGHSCORESPIC, // 120
// Lump Start
KNIFEPIC, // 121
GUNPIC, // 122
MACHINEGUNPIC, // 123
GATLINGGUNPIC, // 124
NOKEYPIC, // 125
GOLDKEYPIC, // 126
SILVERKEYPIC, // 127
N_BLANKPIC, // 128
N_0PIC, // 129
N_1PIC, // 130
N_2PIC, // 131
N_3PIC, // 132
N_4PIC, // 133
N_5PIC, // 134
N_6PIC, // 135
N_7PIC, // 136
N_8PIC, // 137
N_9PIC, // 138
FACE1APIC, // 139
FACE1BPIC, // 140
FACE1CPIC, // 141
FACE2APIC, // 142
FACE2BPIC, // 143
FACE2CPIC, // 144
FACE3APIC, // 145
FACE3BPIC, // 146
FACE3CPIC, // 147
FACE4APIC, // 148
FACE4BPIC, // 149
FACE4CPIC, // 150
FACE5APIC, // 151
FACE5BPIC, // 152
FACE5CPIC, // 153
FACE6APIC, // 154
FACE6BPIC, // 155
FACE6CPIC, // 156
FACE7APIC, // 157
FACE7BPIC, // 158
FACE7CPIC, // 159
FACE8APIC, // 160
GOTGATLINGPIC, // 161
MUTANTBJPIC, // 162
PAUSEDPIC, // 163
GETPSYCHEDPIC, // 164
TILE8, // 165
ERRORSCREEN, // 166
T_DEMO0, // 167
T_DEMO1, // 168
T_DEMO2, // 169
T_DEMO3, // 170
ENUMEND
} graphicnums;
//
// Data LUMPs
//
#define README_LUMP_START H_BJPIC
#define README_LUMP_END H_BOTTOMINFOPIC
#define CONTROLS_LUMP_START C_OPTIONSPIC
#define CONTROLS_LUMP_END (L_GUYPIC - 1)
#define LEVELEND_LUMP_START L_GUYPIC
#define LEVELEND_LUMP_END L_BJWINSPIC
#define LATCHPICS_LUMP_START KNIFEPIC
#define LATCHPICS_LUMP_END GETPSYCHEDPIC
//
// Amount of each data item
//
#define NUMCHUNKS ENUMEND
#define NUMFONT 2
#define NUMFONTM 0
#define NUMPICS (GETPSYCHEDPIC - NUMFONT)
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
#define NUMTILE32 0
#define NUMTILE32M 0
#define NUMEXTERNS 13
//
// File offsets for data items
//
#define STRUCTPIC 0
#define STARTFONT 1
#define STARTFONTM 3
#define STARTPICS 3
#define STARTPICM TILE8
#define STARTSPRITES TILE8
#define STARTTILE8 TILE8
#define STARTTILE8M ERRORSCREEN
#define STARTTILE16 ERRORSCREEN
#define STARTTILE16M ERRORSCREEN
#define STARTTILE32 ERRORSCREEN
#define STARTTILE32M ERRORSCREEN
#define STARTEXTERNS ERRORSCREEN

290
contrib/games/wolf3d/gfxv_sod.h Executable file
View File

@ -0,0 +1,290 @@
//////////////////////////////////////
//
// Graphics .H file for .SOD
// IGRAB-ed on Thu Oct 08 20:38:29 1992
//
//////////////////////////////////////
typedef enum {
// Lump Start
C_BACKDROPPIC=3,
C_MOUSELBACKPIC, // 4
C_CURSOR1PIC, // 5
C_CURSOR2PIC, // 6
C_NOTSELECTEDPIC, // 7
C_SELECTEDPIC, // 8
// Lump Start
C_CUSTOMIZEPIC, // 9
C_JOY1PIC, // 10
C_JOY2PIC, // 11
C_MOUSEPIC, // 12
C_JOYSTICKPIC, // 13
C_KEYBOARDPIC, // 14
C_CONTROLPIC, // 15
// Lump Start
C_OPTIONSPIC, // 16
// Lump Start
C_FXTITLEPIC, // 17
C_DIGITITLEPIC, // 18
C_MUSICTITLEPIC, // 19
// Lump Start
C_HOWTOUGHPIC, // 20
C_BABYMODEPIC, // 21
C_EASYPIC, // 22
C_NORMALPIC, // 23
C_HARDPIC, // 24
// Lump Start
C_DISKLOADING1PIC, // 25
C_DISKLOADING2PIC, // 26
C_LOADGAMEPIC, // 27
C_SAVEGAMEPIC, // 28
// Lump Start
HIGHSCORESPIC, // 29
C_WONSPEARPIC, // 30
#ifndef SPEARDEMO
// Lump Start
BJCOLLAPSE1PIC, // 31
BJCOLLAPSE2PIC, // 32
BJCOLLAPSE3PIC, // 33
BJCOLLAPSE4PIC, // 34
ENDPICPIC, // 35
#endif
// Lump Start
L_GUYPIC, // 36
L_COLONPIC, // 37
L_NUM0PIC, // 38
L_NUM1PIC, // 39
L_NUM2PIC, // 40
L_NUM3PIC, // 41
L_NUM4PIC, // 42
L_NUM5PIC, // 43
L_NUM6PIC, // 44
L_NUM7PIC, // 45
L_NUM8PIC, // 46
L_NUM9PIC, // 47
L_PERCENTPIC, // 48
L_APIC, // 49
L_BPIC, // 50
L_CPIC, // 51
L_DPIC, // 52
L_EPIC, // 53
L_FPIC, // 54
L_GPIC, // 55
L_HPIC, // 56
L_IPIC, // 57
L_JPIC, // 58
L_KPIC, // 59
L_LPIC, // 60
L_MPIC, // 61
L_NPIC, // 62
L_OPIC, // 63
L_PPIC, // 64
L_QPIC, // 65
L_RPIC, // 66
L_SPIC, // 67
L_TPIC, // 68
L_UPIC, // 69
L_VPIC, // 70
L_WPIC, // 71
L_XPIC, // 72
L_YPIC, // 73
L_ZPIC, // 74
L_EXPOINTPIC, // 75
L_APOSTROPHEPIC, // 76
L_GUY2PIC, // 77
L_BJWINSPIC, // 78
// Lump Start
TITLE1PIC, // 79
TITLE2PIC, // 80
#ifndef SPEARDEMO
// Lump Start
ENDSCREEN11PIC, // 81
// Lump Start
ENDSCREEN12PIC, // 82
ENDSCREEN3PIC, // 83
ENDSCREEN4PIC, // 84
ENDSCREEN5PIC, // 85
ENDSCREEN6PIC, // 86
ENDSCREEN7PIC, // 87
ENDSCREEN8PIC, // 88
ENDSCREEN9PIC, // 89
#endif
STATUSBARPIC, // 90
PG13PIC, // 91
CREDITSPIC, // 92
#ifndef SPEARDEMO
// Lump Start
IDGUYS1PIC, // 93
IDGUYS2PIC, // 94
// Lump Start
COPYPROTTOPPIC, // 95
COPYPROTBOXPIC, // 96
BOSSPIC1PIC, // 97
BOSSPIC2PIC, // 98
BOSSPIC3PIC, // 99
BOSSPIC4PIC, // 100
#endif
// Lump Start
KNIFEPIC, // 101
GUNPIC, // 102
MACHINEGUNPIC, // 103
GATLINGGUNPIC, // 104
NOKEYPIC, // 105
GOLDKEYPIC, // 106
SILVERKEYPIC, // 107
N_BLANKPIC, // 108
N_0PIC, // 109
N_1PIC, // 110
N_2PIC, // 111
N_3PIC, // 112
N_4PIC, // 113
N_5PIC, // 114
N_6PIC, // 115
N_7PIC, // 116
N_8PIC, // 117
N_9PIC, // 118
FACE1APIC, // 119
FACE1BPIC, // 120
FACE1CPIC, // 121
FACE2APIC, // 122
FACE2BPIC, // 123
FACE2CPIC, // 124
FACE3APIC, // 125
FACE3BPIC, // 126
FACE3CPIC, // 127
FACE4APIC, // 128
FACE4BPIC, // 129
FACE4CPIC, // 130
FACE5APIC, // 131
FACE5BPIC, // 132
FACE5CPIC, // 133
FACE6APIC, // 134
FACE6BPIC, // 135
FACE6CPIC, // 136
FACE7APIC, // 137
FACE7BPIC, // 138
FACE7CPIC, // 139
FACE8APIC, // 140
GOTGATLINGPIC, // 141
GODMODEFACE1PIC, // 142
GODMODEFACE2PIC, // 143
GODMODEFACE3PIC, // 144
BJWAITING1PIC, // 145
BJWAITING2PIC, // 146
BJOUCHPIC, // 147
PAUSEDPIC, // 148
GETPSYCHEDPIC, // 149
TILE8, // 150
ORDERSCREEN, // 151
ERRORSCREEN, // 152
TITLEPALETTE, // 153
#ifndef SPEARDEMO
END1PALETTE, // 154
END2PALETTE, // 155
END3PALETTE, // 156
END4PALETTE, // 157
END5PALETTE, // 158
END6PALETTE, // 159
END7PALETTE, // 160
END8PALETTE, // 161
END9PALETTE, // 162
IDGUYSPALETTE, // 163
#endif
T_DEMO0, // 164
#ifndef SPEARDEMO
T_DEMO1, // 165
T_DEMO2, // 166
T_DEMO3, // 167
T_ENDART1, // 168
#endif
ENUMEND
} graphicnums;
//
// Data LUMPs
//
#define BACKDROP_LUMP_START 3
#define BACKDROP_LUMP_END 8
#define CONTROL_LUMP_START 9
#define CONTROL_LUMP_END 15
#define OPTIONS_LUMP_START 16
#define OPTIONS_LUMP_END 16
#define SOUND_LUMP_START 17
#define SOUND_LUMP_END 19
#define NEWGAME_LUMP_START 20
#define NEWGAME_LUMP_END 24
#define LOADSAVE_LUMP_START 25
#define LOADSAVE_LUMP_END 28
#define HIGHSCORES_LUMP_START 29
#define HIGHSCORES_LUMP_END 30
#define ENDGAME_LUMP_START 31
#define ENDGAME_LUMP_END 35
#define LEVELEND_LUMP_START L_GUYPIC
#define LEVELEND_LUMP_END L_BJWINSPIC
#define TITLESCREEN_LUMP_START TITLE1PIC
#define TITLESCREEN_LUMP_END TITLE2PIC
#define ENDGAME1_LUMP_START ENDSCREEN11PIC
#define ENDGAME1_LUMP_END ENDSCREEN11PIC
#define ENDGAME2_LUMP_START ENDSCREEN12PIC
#define ENDGAME2_LUMP_END ENDSCREEN12PIC
#define EASTEREGG_LUMP_START IDGUYS1PIC
#define EASTEREGG_LUMP_END IDGUYS2PIC
#define COPYPROT_LUMP_START COPYPROTTOPPIC
#define COPYPROT_LUMP_END BOSSPIC4PIC
#define LATCHPICS_LUMP_START KNIFEPIC
#define LATCHPICS_LUMP_END GETPSYCHEDPIC
//
// Amount of each data item
//
#define NUMCHUNKS ENUMEND
#define NUMFONT 2
#define NUMFONTM 0
#define NUMPICS (GETPSYCHEDPIC - NUMFONT)
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
#define NUMTILE32 0
#define NUMTILE32M 0
#define NUMEXTERNS 18
//
// File offsets for data items
//
#define STRUCTPIC 0
#define STARTFONT 1
#define STARTFONTM 3
#define STARTPICS 3
#define STARTPICM TILE8
#define STARTSPRITES TILE8
#define STARTTILE8 TILE8
#define STARTTILE8M ORDERSCREEN
#define STARTTILE16 ORDERSCREEN
#define STARTTILE16M ORDERSCREEN
#define STARTTILE32 ORDERSCREEN
#define STARTTILE32M ORDERSCREEN
#define STARTEXTERNS ORDERSCREEN
//
// Thank you for using IGRAB!
//

216
contrib/games/wolf3d/gfxv_wl6.h Executable file
View File

@ -0,0 +1,216 @@
//////////////////////////////////////
//
// Graphics .H file for .WL6
// IGRAB-ed on Wed Apr 13 06:58:44 1994
//
//////////////////////////////////////
typedef enum {
// Lump Start
H_BJPIC=3,
H_CASTLEPIC, // 4
H_BLAZEPIC, // 5
H_TOPWINDOWPIC, // 6
H_LEFTWINDOWPIC, // 7
H_RIGHTWINDOWPIC, // 8
H_BOTTOMINFOPIC, // 9
// Lump Start
C_OPTIONSPIC, // 10
C_CURSOR1PIC, // 11
C_CURSOR2PIC, // 12
C_NOTSELECTEDPIC, // 13
C_SELECTEDPIC, // 14
C_FXTITLEPIC, // 15
C_DIGITITLEPIC, // 16
C_MUSICTITLEPIC, // 17
C_MOUSELBACKPIC, // 18
C_BABYMODEPIC, // 19
C_EASYPIC, // 20
C_NORMALPIC, // 21
C_HARDPIC, // 22
C_LOADSAVEDISKPIC, // 23
C_DISKLOADING1PIC, // 24
C_DISKLOADING2PIC, // 25
C_CONTROLPIC, // 26
C_CUSTOMIZEPIC, // 27
C_LOADGAMEPIC, // 28
C_SAVEGAMEPIC, // 29
C_EPISODE1PIC, // 30
C_EPISODE2PIC, // 31
C_EPISODE3PIC, // 32
C_EPISODE4PIC, // 33
C_EPISODE5PIC, // 34
C_EPISODE6PIC, // 35
C_CODEPIC, // 36
C_TIMECODEPIC, // 37
C_LEVELPIC, // 38
C_NAMEPIC, // 39
C_SCOREPIC, // 40
C_JOY1PIC, // 41
C_JOY2PIC, // 42
// Lump Start
L_GUYPIC, // 43
L_COLONPIC, // 44
L_NUM0PIC, // 45
L_NUM1PIC, // 46
L_NUM2PIC, // 47
L_NUM3PIC, // 48
L_NUM4PIC, // 49
L_NUM5PIC, // 50
L_NUM6PIC, // 51
L_NUM7PIC, // 52
L_NUM8PIC, // 53
L_NUM9PIC, // 54
L_PERCENTPIC, // 55
L_APIC, // 56
L_BPIC, // 57
L_CPIC, // 58
L_DPIC, // 59
L_EPIC, // 60
L_FPIC, // 61
L_GPIC, // 62
L_HPIC, // 63
L_IPIC, // 64
L_JPIC, // 65
L_KPIC, // 66
L_LPIC, // 67
L_MPIC, // 68
L_NPIC, // 69
L_OPIC, // 70
L_PPIC, // 71
L_QPIC, // 72
L_RPIC, // 73
L_SPIC, // 74
L_TPIC, // 75
L_UPIC, // 76
L_VPIC, // 77
L_WPIC, // 78
L_XPIC, // 79
L_YPIC, // 80
L_ZPIC, // 81
L_EXPOINTPIC, // 82
L_APOSTROPHEPIC, // 83
L_GUY2PIC, // 84
L_BJWINSPIC, // 85
STATUSBARPIC, // 86
TITLEPIC, // 87
PG13PIC, // 88
CREDITSPIC, // 89
HIGHSCORESPIC, // 90
// Lump Start
KNIFEPIC, // 91
GUNPIC, // 92
MACHINEGUNPIC, // 93
GATLINGGUNPIC, // 94
NOKEYPIC, // 95
GOLDKEYPIC, // 96
SILVERKEYPIC, // 97
N_BLANKPIC, // 98
N_0PIC, // 99
N_1PIC, // 100
N_2PIC, // 101
N_3PIC, // 102
N_4PIC, // 103
N_5PIC, // 104
N_6PIC, // 105
N_7PIC, // 106
N_8PIC, // 107
N_9PIC, // 108
FACE1APIC, // 109
FACE1BPIC, // 110
FACE1CPIC, // 111
FACE2APIC, // 112
FACE2BPIC, // 113
FACE2CPIC, // 114
FACE3APIC, // 115
FACE3BPIC, // 116
FACE3CPIC, // 117
FACE4APIC, // 118
FACE4BPIC, // 119
FACE4CPIC, // 120
FACE5APIC, // 121
FACE5BPIC, // 122
FACE5CPIC, // 123
FACE6APIC, // 124
FACE6BPIC, // 125
FACE6CPIC, // 126
FACE7APIC, // 127
FACE7BPIC, // 128
FACE7CPIC, // 129
FACE8APIC, // 130
GOTGATLINGPIC, // 131
MUTANTBJPIC, // 132
PAUSEDPIC, // 133
GETPSYCHEDPIC, // 134
ORDERSCREEN=136,
ERRORSCREEN, // 137
T_HELPART, // 138
T_DEMO0, // 139
T_DEMO1, // 140
T_DEMO2, // 141
T_DEMO3, // 142
T_ENDART1, // 143
T_ENDART2, // 144
T_ENDART3, // 145
T_ENDART4, // 146
T_ENDART5, // 147
T_ENDART6, // 148
ENUMEND
} graphicnums;
//
// Data LUMPs
//
#define README_LUMP_START 3
#define README_LUMP_END 9
#define CONTROLS_LUMP_START 10
#define CONTROLS_LUMP_END 42
#define LEVELEND_LUMP_START 43
#define LEVELEND_LUMP_END 85
#define LATCHPICS_LUMP_START 91
#define LATCHPICS_LUMP_END 134
//
// Amount of each data item
//
#define NUMCHUNKS 149
#define NUMFONT 2
#define NUMFONTM 0
#define NUMPICS 132
#define NUMPICM 0
#define NUMSPRITES 0
#define NUMTILE8 72
#define NUMTILE8M 0
#define NUMTILE16 0
#define NUMTILE16M 0
#define NUMTILE32 0
#define NUMTILE32M 0
#define NUMEXTERNS 13
//
// File offsets for data items
//
#define STRUCTPIC 0
#define STARTFONT 1
#define STARTFONTM 3
#define STARTPICS 3
#define STARTPICM 135
#define STARTSPRITES 135
#define STARTTILE8 135
#define STARTTILE8M 136
#define STARTTILE16 136
#define STARTTILE16M 136
#define STARTTILE32 136
#define STARTTILE32M 136
#define STARTEXTERNS 136
//
// Thank you for using IGRAB!
//

51
contrib/games/wolf3d/gp2x.h Executable file
View File

@ -0,0 +1,51 @@
#ifndef GP2X_H
#define GP2X_H
#include <SDL/SDL.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
#include "wl_def.h"
#define GP2X_BUTTON_UP (0)
#define GP2X_BUTTON_DOWN (4)
#define GP2X_BUTTON_LEFT (2)
#define GP2X_BUTTON_RIGHT (6)
#define GP2X_BUTTON_UPLEFT (1)
#define GP2X_BUTTON_UPRIGHT (7)
#define GP2X_BUTTON_DOWNLEFT (3)
#define GP2X_BUTTON_DOWNRIGHT (5)
#define GP2X_BUTTON_CLICK (18)
#define GP2X_BUTTON_A (12)
#define GP2X_BUTTON_B (13)
#define GP2X_BUTTON_X (15)
#define GP2X_BUTTON_Y (14)
#define GP2X_BUTTON_L (11)
#define GP2X_BUTTON_R (10)
#define GP2X_BUTTON_START (8)
#define GP2X_BUTTON_SELECT (9)
#define GP2X_BUTTON_VOLUP (16)
#define GP2X_BUTTON_VOLDOWN (17)
#define VOLUME_MIN 0
#define VOLUME_MAX 100
#define VOLUME_CHANGE_RATE 2
#define VOLUME_NOCHG 0
#define VOLUME_DOWN 1
#define VOLUME_UP 2
#define KEY_DOWN 1
#define KEY_UP 0
void GP2X_Init();
void GP2X_Shutdown();
void GP2X_StartMMUHack();
void GP2X_AdjustVolume( int direction );
void GP2X_ButtonDown( int button );
void GP2X_ButtonUp( int button );
void Screenshot( void );
void SetKeyboard( unsigned int key, int press );
#endif // GP2X_H

1118
contrib/games/wolf3d/id_ca.cpp Executable file

File diff suppressed because it is too large Load Diff

60
contrib/games/wolf3d/id_ca.h Executable file
View File

@ -0,0 +1,60 @@
#ifndef __ID_CA__
#define __ID_CA__
//===========================================================================
#define NUMMAPS 60
#ifdef USE_FLOORCEILINGTEX
#define MAPPLANES 3
#else
#define MAPPLANES 2
#endif
#define UNCACHEGRCHUNK(chunk) {if(grsegs[chunk]) {free(grsegs[chunk]); grsegs[chunk]=NULL;}}
#define UNCACHEAUDIOCHUNK(chunk) {if(audiosegs[chunk]) {free(audiosegs[chunk]); audiosegs[chunk]=NULL;}}
//===========================================================================
typedef struct
{
int32_t planestart[3];
word planelength[3];
word width,height;
char name[16];
} maptype;
//===========================================================================
extern int mapon;
extern word *mapsegs[MAPPLANES];
extern byte *audiosegs[NUMSNDCHUNKS];
extern byte *grsegs[NUMCHUNKS];
extern char extension[5];
extern char graphext[5];
extern char audioext[5];
//===========================================================================
boolean CA_LoadFile (const char *filename, memptr *ptr);
boolean CA_WriteFile (const char *filename, void *ptr, int32_t length);
int32_t CA_RLEWCompress (word *source, int32_t length, word *dest, word rlewtag);
void CA_RLEWexpand (word *source, word *dest, int32_t length, word rlewtag);
void CA_Startup (void);
void CA_Shutdown (void);
int32_t CA_CacheAudioChunk (int chunk);
void CA_LoadAllSounds (void);
void CA_CacheGrChunk (int chunk);
void CA_CacheMap (int mapnum);
void CA_CacheScreen (int chunk);
void CA_CannotOpen(const char *name);
#endif

683
contrib/games/wolf3d/id_in.cpp Executable file
View File

@ -0,0 +1,683 @@
//
// ID Engine
// ID_IN.c - Input Manager
// v1.0d1
// By Jason Blochowiak
//
//
// This module handles dealing with the various input devices
//
// Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff),
// User Mgr (for command line parms)
//
// Globals:
// LastScan - The keyboard scan code of the last key pressed
// LastASCII - The ASCII value of the last key pressed
// DEBUG - there are more globals
//
#include "wl_def.h"
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean MousePresent;
boolean forcegrabmouse;
// Global variables
volatile boolean Keyboard[SDLK_LAST];
volatile boolean Paused;
volatile char LastASCII;
volatile ScanCode LastScan;
//KeyboardDef KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
static KeyboardDef KbdDefs = {
sc_Control, // button0
sc_Alt, // button1
sc_Home, // upleft
sc_UpArrow, // up
sc_PgUp, // upright
sc_LeftArrow, // left
sc_RightArrow, // right
sc_End, // downleft
sc_DownArrow, // down
sc_PgDn // downright
};
static SDL_Joystick *Joystick;
int JoyNumButtons;
static int JoyNumHats;
static bool GrabInput = false;
static bool NeedRestore = false;
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
byte ASCIINames[] = // Unshifted ASCII for scan codes // TODO: keypad
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1
' ',0 ,0 ,0 ,0 ,0 ,0 ,39 ,0 ,0 ,'*','+',',','-','.','/', // 2
'0','1','2','3','4','5','6','7','8','9',0 ,';',0 ,'=',0 ,0 , // 3
'`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', // 4
'p','q','r','s','t','u','v','w','x','y','z','[',92 ,']',0 ,0 , // 5
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
};
byte ShiftNames[] = // Shifted ASCII for scan codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1
' ',0 ,0 ,0 ,0 ,0 ,0 ,34 ,0 ,0 ,'*','+','<','_','>','?', // 2
')','!','@','#','$','%','^','&','*','(',0 ,':',0 ,'+',0 ,0 , // 3
'~','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', // 4
'P','Q','R','S','T','U','V','W','X','Y','Z','{','|','}',0 ,0 , // 5
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
};
byte SpecialNames[] = // ASCII for 0xe0 prefixed codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2
0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
};
static boolean IN_Started;
static Direction DirTable[] = // Quick lookup for total direction
{
dir_NorthWest, dir_North, dir_NorthEast,
dir_West, dir_None, dir_East,
dir_SouthWest, dir_South, dir_SouthEast
};
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static int
INL_GetMouseButtons(void)
{
int buttons = SDL_GetMouseState(NULL, NULL);
int middlePressed = buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE);
int rightPressed = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT);
buttons &= ~(SDL_BUTTON(SDL_BUTTON_MIDDLE) | SDL_BUTTON(SDL_BUTTON_RIGHT));
if(middlePressed) buttons |= 1 << 2;
if(rightPressed) buttons |= 1 << 1;
return buttons;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyDelta(int *dx,int *dy)
{
if(!Joystick)
{
*dx = *dy = 0;
return;
}
SDL_JoystickUpdate();
#ifdef _arch_dreamcast
int x = 0;
int y = 0;
#else
int x = SDL_JoystickGetAxis(Joystick, 0) >> 8;
int y = SDL_JoystickGetAxis(Joystick, 1) >> 8;
#endif
if(param_joystickhat != -1)
{
uint8_t hatState = SDL_JoystickGetHat(Joystick, param_joystickhat);
if(hatState & SDL_HAT_RIGHT)
x += 127;
else if(hatState & SDL_HAT_LEFT)
x -= 127;
if(hatState & SDL_HAT_DOWN)
y += 127;
else if(hatState & SDL_HAT_UP)
y -= 127;
if(x < -128) x = -128;
else if(x > 127) x = 127;
if(y < -128) y = -128;
else if(y > 127) y = 127;
}
*dx = x;
*dy = y;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyFineDelta() - Returns the relative movement of the specified
// joystick without dividing the results by 256 (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyFineDelta(int *dx, int *dy)
{
if(!Joystick)
{
*dx = 0;
*dy = 0;
return;
}
SDL_JoystickUpdate();
int x = SDL_JoystickGetAxis(Joystick, 0);
int y = SDL_JoystickGetAxis(Joystick, 1);
if(x < -128) x = -128;
else if(x > 127) x = 127;
if(y < -128) y = -128;
else if(y > 127) y = 127;
*dx = x;
*dy = y;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
int IN_JoyButtons()
{
if(!Joystick) return 0;
SDL_JoystickUpdate();
int res = 0;
for(int i = 0; i < JoyNumButtons && i < 32; i++)
res |= SDL_JoystickGetButton(Joystick, i) << i;
return res;
}
boolean IN_JoyPresent()
{
return Joystick != NULL;
}
static void processEvent(SDL_Event *event)
{
switch (event->type)
{
// exit if the window is closed
case SDL_QUIT:
Quit(NULL);
// check for keypresses
case SDL_KEYDOWN:
{
if(event->key.keysym.sym==SDLK_SCROLLOCK || event->key.keysym.sym==SDLK_F12)
{
GrabInput = !GrabInput;
SDL_WM_GrabInput(GrabInput ? SDL_GRAB_ON : SDL_GRAB_OFF);
return;
}
LastScan = event->key.keysym.sym;
SDLMod mod = SDL_GetModState();
if(Keyboard[sc_Alt])
{
if(LastScan==SDLK_F4)
Quit(NULL);
}
if(LastScan == SDLK_KP_ENTER) LastScan = SDLK_RETURN;
else if(LastScan == SDLK_RSHIFT) LastScan = SDLK_LSHIFT;
else if(LastScan == SDLK_RALT) LastScan = SDLK_LALT;
else if(LastScan == SDLK_RCTRL) LastScan = SDLK_LCTRL;
else
{
if((mod & KMOD_NUM) == 0)
{
switch(LastScan)
{
case SDLK_KP2: LastScan = SDLK_DOWN; break;
case SDLK_KP4: LastScan = SDLK_LEFT; break;
case SDLK_KP6: LastScan = SDLK_RIGHT; break;
case SDLK_KP8: LastScan = SDLK_UP; break;
}
}
}
int sym = LastScan;
if(sym >= 'a' && sym <= 'z')
sym -= 32; // convert to uppercase
if(mod & (KMOD_SHIFT | KMOD_CAPS))
{
if(sym < lengthof(ShiftNames) && ShiftNames[sym])
LastASCII = ShiftNames[sym];
}
else
{
if(sym < lengthof(ASCIINames) && ASCIINames[sym])
LastASCII = ASCIINames[sym];
}
if(LastScan<SDLK_LAST)
Keyboard[LastScan] = 1;
if(LastScan == SDLK_PAUSE)
Paused = true;
break;
}
case SDL_KEYUP:
{
int key = event->key.keysym.sym;
if(key == SDLK_KP_ENTER) key = SDLK_RETURN;
else if(key == SDLK_RSHIFT) key = SDLK_LSHIFT;
else if(key == SDLK_RALT) key = SDLK_LALT;
else if(key == SDLK_RCTRL) key = SDLK_LCTRL;
else
{
if((SDL_GetModState() & KMOD_NUM) == 0)
{
switch(key)
{
case SDLK_KP2: key = SDLK_DOWN; break;
case SDLK_KP4: key = SDLK_LEFT; break;
case SDLK_KP6: key = SDLK_RIGHT; break;
case SDLK_KP8: key = SDLK_UP; break;
}
}
}
if(key<SDLK_LAST)
Keyboard[key] = 0;
break;
}
case SDL_ACTIVEEVENT:
{
if(fullscreen && (event->active.state & SDL_APPACTIVE) != 0)
{
if(event->active.gain)
{
if(NeedRestore)
{
FreeLatchMem();
LoadLatchMem();
}
NeedRestore = false;
}
else NeedRestore = true;
}
}
#if defined(GP2X)
case SDL_JOYBUTTONDOWN:
GP2X_ButtonDown(event->jbutton.button);
break;
case SDL_JOYBUTTONUP:
GP2X_ButtonUp(event->jbutton.button);
break;
#endif
}
}
void IN_WaitAndProcessEvents()
{
SDL_Event event;
if(!SDL_WaitEvent(&event)) return;
do
{
processEvent(&event);
}
while(SDL_PollEvent(&event));
}
void IN_ProcessEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
processEvent(&event);
}
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Startup() - Starts up the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void
IN_Startup(void)
{
if (IN_Started)
return;
IN_ClearKeysDown();
if(param_joystickindex >= 0 && param_joystickindex < SDL_NumJoysticks())
{
Joystick = SDL_JoystickOpen(param_joystickindex);
if(Joystick)
{
JoyNumButtons = SDL_JoystickNumButtons(Joystick);
if(JoyNumButtons > 32) JoyNumButtons = 32; // only up to 32 buttons are supported
JoyNumHats = SDL_JoystickNumHats(Joystick);
if(param_joystickhat < -1 || param_joystickhat >= JoyNumHats)
Quit("The joystickhat param must be between 0 and %i!", JoyNumHats - 1);
}
}
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
if(fullscreen || forcegrabmouse)
{
GrabInput = true;
SDL_WM_GrabInput(SDL_GRAB_ON);
}
// I didn't find a way to ask libSDL whether a mouse is present, yet...
#if defined(GP2X)
MousePresent = false;
#elif defined(_arch_dreamcast)
MousePresent = DC_MousePresent();
#else
MousePresent = true;
#endif
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Shutdown() - Shuts down the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void
IN_Shutdown(void)
{
if (!IN_Started)
return;
if(Joystick)
SDL_JoystickClose(Joystick);
IN_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void
IN_ClearKeysDown(void)
{
LastScan = sc_None;
LastASCII = key_None;
memset ((void *) Keyboard,0,sizeof(Keyboard));
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ReadControl() - Reads the device associated with the specified
// player and fills in the control info struct
//
///////////////////////////////////////////////////////////////////////////
void
IN_ReadControl(int player,ControlInfo *info)
{
word buttons;
int dx,dy;
Motion mx,my;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_ProcessEvents();
if (Keyboard[KbdDefs.upleft])
mx = motion_Left,my = motion_Up;
else if (Keyboard[KbdDefs.upright])
mx = motion_Right,my = motion_Up;
else if (Keyboard[KbdDefs.downleft])
mx = motion_Left,my = motion_Down;
else if (Keyboard[KbdDefs.downright])
mx = motion_Right,my = motion_Down;
if (Keyboard[KbdDefs.up])
my = motion_Up;
else if (Keyboard[KbdDefs.down])
my = motion_Down;
if (Keyboard[KbdDefs.left])
mx = motion_Left;
else if (Keyboard[KbdDefs.right])
mx = motion_Right;
if (Keyboard[KbdDefs.button0])
buttons += 1 << 0;
if (Keyboard[KbdDefs.button1])
buttons += 1 << 1;
dx = mx * 127;
dy = my * 127;
info->x = dx;
info->xaxis = mx;
info->y = dy;
info->yaxis = my;
info->button0 = (buttons & (1 << 0)) != 0;
info->button1 = (buttons & (1 << 1)) != 0;
info->button2 = (buttons & (1 << 2)) != 0;
info->button3 = (buttons & (1 << 3)) != 0;
info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
}
///////////////////////////////////////////////////////////////////////////
//
// IN_WaitForKey() - Waits for a scan code, then clears LastScan and
// returns the scan code
//
///////////////////////////////////////////////////////////////////////////
ScanCode
IN_WaitForKey(void)
{
ScanCode result;
while ((result = LastScan)==0)
IN_WaitAndProcessEvents();
LastScan = 0;
return(result);
}
///////////////////////////////////////////////////////////////////////////
//
// IN_WaitForASCII() - Waits for an ASCII char, then clears LastASCII and
// returns the ASCII value
//
///////////////////////////////////////////////////////////////////////////
char
IN_WaitForASCII(void)
{
char result;
while ((result = LastASCII)==0)
IN_WaitAndProcessEvents();
LastASCII = '\0';
return(result);
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Ack() - waits for a button or key press. If a button is down, upon
// calling, it must be released for it to be recognized
//
///////////////////////////////////////////////////////////////////////////
boolean btnstate[NUMBUTTONS];
void IN_StartAck(void)
{
IN_ProcessEvents();
//
// get initial state of everything
//
IN_ClearKeysDown();
memset(btnstate, 0, sizeof(btnstate));
int buttons = IN_JoyButtons() << 4;
if(MousePresent)
buttons |= IN_MouseButtons();
for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1)
if(buttons & 1)
btnstate[i] = true;
}
boolean IN_CheckAck (void)
{
IN_ProcessEvents();
//
// see if something has been pressed
//
if(LastScan)
return true;
int buttons = IN_JoyButtons() << 4;
if(MousePresent)
buttons |= IN_MouseButtons();
for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1)
{
if(buttons & 1)
{
if(!btnstate[i])
{
// Wait until button has been released
do
{
IN_WaitAndProcessEvents();
buttons = IN_JoyButtons() << 4;
if(MousePresent)
buttons |= IN_MouseButtons();
}
while(buttons & (1 << i));
return true;
}
}
else
btnstate[i] = false;
}
return false;
}
void IN_Ack (void)
{
IN_StartAck ();
do
{
IN_WaitAndProcessEvents();
}
while(!IN_CheckAck ());
}
///////////////////////////////////////////////////////////////////////////
//
// IN_UserInput() - Waits for the specified delay time (in ticks) or the
// user pressing a key or a mouse button. If the clear flag is set, it
// then either clears the key or waits for the user to let the mouse
// button up.
//
///////////////////////////////////////////////////////////////////////////
boolean IN_UserInput(longword delay)
{
longword lasttime;
lasttime = GetTimeCount();
IN_StartAck ();
do
{
IN_ProcessEvents();
if (IN_CheckAck())
return true;
SDL_Delay(5);
} while (GetTimeCount() - lasttime < delay);
return(false);
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
int IN_MouseButtons (void)
{
if (MousePresent)
return INL_GetMouseButtons();
else
return 0;
}
bool IN_IsInputGrabbed()
{
return GrabInput;
}
void IN_CenterMouse()
{
SDL_WarpMouse(screenWidth / 2, screenHeight / 2);
}

184
contrib/games/wolf3d/id_in.h Executable file
View File

@ -0,0 +1,184 @@
//
// ID Engine
// ID_IN.h - Header file for Input Manager
// v1.0d1
// By Jason Blochowiak
//
#ifndef __ID_IN__
#define __ID_IN__
#ifdef __DEBUG__
#define __DEBUG_InputMgr__
#endif
typedef int ScanCode;
#define sc_None 0
#define sc_Bad 0xff
#define sc_Return SDLK_RETURN
#define sc_Enter sc_Return
#define sc_Escape SDLK_ESCAPE
#define sc_Space SDLK_SPACE
#define sc_BackSpace SDLK_BACKSPACE
#define sc_Tab SDLK_TAB
#define sc_Alt SDLK_LALT
#define sc_Control SDLK_LCTRL
#define sc_CapsLock SDLK_CAPSLOCK
#define sc_LShift SDLK_LSHIFT
#define sc_RShift SDLK_RSHIFT
#define sc_UpArrow SDLK_UP
#define sc_DownArrow SDLK_DOWN
#define sc_LeftArrow SDLK_LEFT
#define sc_RightArrow SDLK_RIGHT
#define sc_Insert SDLK_INSERT
#define sc_Delete SDLK_DELETE
#define sc_Home SDLK_HOME
#define sc_End SDLK_END
#define sc_PgUp SDLK_PAGEUP
#define sc_PgDn SDLK_PAGEDOWN
#define sc_F1 SDLK_F1
#define sc_F2 SDLK_F2
#define sc_F3 SDLK_F3
#define sc_F4 SDLK_F4
#define sc_F5 SDLK_F5
#define sc_F6 SDLK_F6
#define sc_F7 SDLK_F7
#define sc_F8 SDLK_F8
#define sc_F9 SDLK_F9
#define sc_F10 SDLK_F10
#define sc_F11 SDLK_F11
#define sc_F12 SDLK_F12
#define sc_ScrollLock SDLK_SCROLLOCK
#define sc_PrintScreen SDLK_PRINT
#define sc_1 SDLK_1
#define sc_2 SDLK_2
#define sc_3 SDLK_3
#define sc_4 SDLK_4
#define sc_5 SDLK_5
#define sc_6 SDLK_6
#define sc_7 SDLK_7
#define sc_8 SDLK_8
#define sc_9 SDLK_9
#define sc_0 SDLK_0
#define sc_A SDLK_a
#define sc_B SDLK_b
#define sc_C SDLK_c
#define sc_D SDLK_d
#define sc_E SDLK_e
#define sc_F SDLK_f
#define sc_G SDLK_g
#define sc_H SDLK_h
#define sc_I SDLK_i
#define sc_J SDLK_j
#define sc_K SDLK_k
#define sc_L SDLK_l
#define sc_M SDLK_m
#define sc_N SDLK_n
#define sc_O SDLK_o
#define sc_P SDLK_p
#define sc_Q SDLK_q
#define sc_R SDLK_r
#define sc_S SDLK_s
#define sc_T SDLK_t
#define sc_U SDLK_u
#define sc_V SDLK_v
#define sc_W SDLK_w
#define sc_X SDLK_x
#define sc_Y SDLK_y
#define sc_Z SDLK_z
#define key_None 0
typedef enum {
demo_Off,demo_Record,demo_Playback,demo_PlayDone
} Demo;
typedef enum {
ctrl_Keyboard,
ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
ctrl_Joystick,
ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
ctrl_Mouse
} ControlType;
typedef enum {
motion_Left = -1,motion_Up = -1,
motion_None = 0,
motion_Right = 1,motion_Down = 1
} Motion;
typedef enum {
dir_North,dir_NorthEast,
dir_East,dir_SouthEast,
dir_South,dir_SouthWest,
dir_West,dir_NorthWest,
dir_None
} Direction;
typedef struct {
boolean button0,button1,button2,button3;
short x,y;
Motion xaxis,yaxis;
Direction dir;
} CursorInfo;
typedef CursorInfo ControlInfo;
typedef struct {
ScanCode button0,button1,
upleft, up, upright,
left, right,
downleft, down, downright;
} KeyboardDef;
typedef struct {
word joyMinX,joyMinY,
threshMinX,threshMinY,
threshMaxX,threshMaxY,
joyMaxX,joyMaxY,
joyMultXL,joyMultYL,
joyMultXH,joyMultYH;
} JoystickDef;
// Global variables
extern volatile boolean Keyboard[];
extern boolean MousePresent;
extern volatile boolean Paused;
extern volatile char LastASCII;
extern volatile ScanCode LastScan;
extern int JoyNumButtons;
extern boolean forcegrabmouse;
// Function prototypes
#define IN_KeyDown(code) (Keyboard[(code)])
#define IN_ClearKey(code) {Keyboard[code] = false;\
if (code == LastScan) LastScan = sc_None;}
// DEBUG - put names in prototypes
extern void IN_Startup(void),IN_Shutdown(void);
extern void IN_ClearKeysDown(void);
extern void IN_ReadControl(int,ControlInfo *);
extern void IN_GetJoyAbs(word joy,word *xp,word *yp);
extern void IN_SetupJoy(word joy,word minx,word maxx,
word miny,word maxy);
extern void IN_StopDemo(void),IN_FreeDemoBuffer(void),
IN_Ack(void);
extern boolean IN_UserInput(longword delay);
extern char IN_WaitForASCII(void);
extern ScanCode IN_WaitForKey(void);
extern word IN_GetJoyButtonsDB(word joy);
extern const char *IN_GetScanName(ScanCode);
void IN_WaitAndProcessEvents();
void IN_ProcessEvents();
int IN_MouseButtons (void);
boolean IN_JoyPresent();
void IN_SetJoyCurrent(int joyIndex);
int IN_JoyButtons (void);
void IN_GetJoyDelta(int *dx,int *dy);
void IN_GetJoyFineDelta(int *dx, int *dy);
void IN_StartAck(void);
boolean IN_CheckAck (void);
bool IN_IsInputGrabbed();
void IN_CenterMouse();
#endif

125
contrib/games/wolf3d/id_pm.cpp Executable file
View File

@ -0,0 +1,125 @@
#include "wl_def.h"
int ChunksInFile;
int PMSpriteStart;
int PMSoundStart;
bool PMSoundInfoPagePadded = false;
// holds the whole VSWAP
uint32_t *PMPageData;
size_t PMPageDataSize;
// ChunksInFile+1 pointers to page starts.
// The last pointer points one byte after the last page.
uint8_t **PMPages;
void PM_Startup()
{
char fname[13] = "vswap.";
strcat(fname,extension);
FILE *file = fopen(fname,"rb");
if(!file)
CA_CannotOpen(fname);
ChunksInFile = 0;
fread(&ChunksInFile, sizeof(word), 1, file);
PMSpriteStart = 0;
fread(&PMSpriteStart, sizeof(word), 1, file);
PMSoundStart = 0;
fread(&PMSoundStart, sizeof(word), 1, file);
uint32_t* pageOffsets = (uint32_t *) malloc((ChunksInFile + 1) * sizeof(int32_t));
CHECKMALLOCRESULT(pageOffsets);
fread(pageOffsets, sizeof(uint32_t), ChunksInFile, file);
word *pageLengths = (word *) malloc(ChunksInFile * sizeof(word));
CHECKMALLOCRESULT(pageLengths);
fread(pageLengths, sizeof(word), ChunksInFile, file);
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
long pageDataSize = fileSize - pageOffsets[0];
if(pageDataSize > (size_t) -1)
Quit("The page file \"%s\" is too large!", fname);
pageOffsets[ChunksInFile] = fileSize;
uint32_t dataStart = pageOffsets[0];
int i;
// Check that all pageOffsets are valid
for(i = 0; i < ChunksInFile; i++)
{
if(!pageOffsets[i]) continue; // sparse page
if(pageOffsets[i] < dataStart || pageOffsets[i] >= (size_t) fileSize)
Quit("Illegal page offset for page %i: %u (filesize: %u)",
i, pageOffsets[i], fileSize);
}
// Calculate total amount of padding needed for sprites and sound info page
int alignPadding = 0;
for(i = PMSpriteStart; i < PMSoundStart; i++)
{
if(!pageOffsets[i]) continue; // sparse page
uint32_t offs = pageOffsets[i] - dataStart + alignPadding;
if(offs & 1)
alignPadding++;
}
if((pageOffsets[ChunksInFile - 1] - dataStart + alignPadding) & 1)
alignPadding++;
PMPageDataSize = (size_t) pageDataSize + alignPadding;
PMPageData = (uint32_t *) malloc(PMPageDataSize);
CHECKMALLOCRESULT(PMPageData);
PMPages = (uint8_t **) malloc((ChunksInFile + 1) * sizeof(uint8_t *));
CHECKMALLOCRESULT(PMPages);
// Load pages and initialize PMPages pointers
uint8_t *ptr = (uint8_t *) PMPageData;
for(i = 0; i < ChunksInFile; i++)
{
if(i >= PMSpriteStart && i < PMSoundStart || i == ChunksInFile - 1)
{
size_t offs = ptr - (uint8_t *) PMPageData;
// pad with zeros to make it 2-byte aligned
if(offs & 1)
{
*ptr++ = 0;
if(i == ChunksInFile - 1) PMSoundInfoPagePadded = true;
}
}
PMPages[i] = ptr;
if(!pageOffsets[i])
continue; // sparse page
// Use specified page length, when next page is sparse page.
// Otherwise, calculate size from the offset difference between this and the next page.
uint32_t size;
if(!pageOffsets[i + 1]) size = pageLengths[i];
else size = pageOffsets[i + 1] - pageOffsets[i];
fseek(file, pageOffsets[i], SEEK_SET);
fread(ptr, 1, size, file);
ptr += size;
}
// last page points after page buffer
PMPages[ChunksInFile] = ptr;
free(pageLengths);
free(pageOffsets);
fclose(file);
}
void PM_Shutdown()
{
free(PMPages);
free(PMPageData);
}

58
contrib/games/wolf3d/id_pm.h Executable file
View File

@ -0,0 +1,58 @@
#ifndef __ID_PM__
#define __ID_PM__
#ifdef USE_HIRES
#define PMPageSize 16384
#else
#define PMPageSize 4096
#endif
extern int ChunksInFile;
extern int PMSpriteStart;
extern int PMSoundStart;
extern bool PMSoundInfoPagePadded;
// ChunksInFile+1 pointers to page starts.
// The last pointer points one byte after the last page.
extern uint8_t **PMPages;
void PM_Startup();
void PM_Shutdown();
static inline uint32_t PM_GetPageSize(int page)
{
if(page < 0 || page >= ChunksInFile)
Quit("PM_GetPageSize: Tried to access illegal page: %i", page);
return (uint32_t) (PMPages[page + 1] - PMPages[page]);
}
static inline uint8_t *PM_GetPage(int page)
{
if(page < 0 || page >= ChunksInFile)
Quit("PM_GetPage: Tried to access illegal page: %i", page);
return PMPages[page];
}
static inline uint8_t *PM_GetEnd()
{
return PMPages[ChunksInFile];
}
static inline byte *PM_GetTexture(int wallpic)
{
return PM_GetPage(wallpic);
}
static inline uint16_t *PM_GetSprite(int shapenum)
{
// correct alignment is enforced by PM_Startup()
return (uint16_t *) (void *) PM_GetPage(PMSpriteStart + shapenum);
}
static inline byte *PM_GetSound(int soundpagenum)
{
return PM_GetPage(PMSoundStart + soundpagenum);
}
#endif

144
contrib/games/wolf3d/id_sd.cpp Executable file
View File

@ -0,0 +1,144 @@
//
// ID Engine
// ID_SD.c - Sound Manager for Wolfenstein 3D
// v1.2
// By Jason Blochowiak
//
//
// This module handles dealing with generating sound on the appropriate
// hardware
//
// Depends on: User Mgr (for parm checking)
//
// Globals:
// For User Mgr:
// SoundBlasterPresent - SoundBlaster card present?
// AdLibPresent - AdLib card present?
// SoundMode - What device is used for sound effects
// (Use SM_SetSoundMode() to set)
// MusicMode - What device is used for music
// (Use SM_SetMusicMode() to set)
// DigiMode - What device is used for digitized sound effects
// (Use SM_SetDigiDevice() to set)
//
// For Cache Mgr:
// NeedsDigitized - load digitized sounds?
// NeedsMusic - load music?
//
/// ///////////// ///
/// In Kolibrios - stub
#include "wl_def.h"
//#include <SDL_mixer.h>
#if defined(GP2X_940)
#include "gp2x/fmopl.h"
#else
#ifdef USE_GPL
#include "dosbox/dbopl.h"
#else
#include "mame/fmopl.h"
#endif
#endif
#define ORIGSAMPLERATE 7042
typedef struct
{
char RIFF[4];
longword filelenminus8;
char WAVE[4];
char fmt_[4];
longword formatlen;
word val0x0001;
word channels;
longword samplerate;
longword bytespersec;
word bytespersample;
word bitspersample;
} headchunk;
typedef struct
{
char chunkid[4];
longword chunklength;
} wavechunk;
typedef struct
{
uint32_t startpage;
uint32_t length;
} digiinfo;
// Global variables
boolean AdLibPresent,
SoundBlasterPresent,SBProPresent,
SoundPositioned;
SDMode SoundMode;
SMMode MusicMode;
SDSMode DigiMode;
static byte **SoundTable;
int DigiMap[LASTSOUND];
int DigiChannel[STARTMUSIC - STARTDIGISOUNDS];
// Internal variables
static boolean SD_Started;
static boolean nextsoundpos;
static soundnames SoundNumber;
static soundnames DigiNumber;
static word SoundPriority;
static word DigiPriority;
static int LeftPosition;
static int RightPosition;
word NumDigi;
static digiinfo *DigiList;
static boolean DigiPlaying;
// PC Sound variables
static volatile byte pcLastSample;
static byte * volatile pcSound;
static longword pcLengthLeft;
// AdLib variables
static byte * volatile alSound;
static byte alBlock;
static longword alLengthLeft;
static longword alTimeCount;
static Instrument alZeroInst;
// Sequencer variables
static volatile boolean sqActive;
static word *sqHack;
static word *sqHackPtr;
static int sqHackLen;
static int sqHackSeqLen;
static longword sqHackTime;
// STUB
void SD_Startup(void){};
void SD_Shutdown(void){};
int SD_GetChannelForDigi(int which){};
void SD_PositionSound(int leftvol,int rightvol){};
boolean SD_PlaySound(soundnames sound){};
void SD_SetPosition(int channel, int leftvol,int rightvol){};
void SD_StopSound(void){};
void SD_WaitSoundDone(void){};
void SD_StartMusic(int chunk){};
void SD_ContinueMusic(int chunk, int startoffs){};
void SD_MusicOn(void){};
void SD_FadeOutMusic(void){};
int SD_MusicOff(void){};
boolean SD_MusicPlaying(void){};
boolean SD_SetSoundMode(SDMode mode){};
boolean SD_SetMusicMode(SMMode mode){};
word SD_SoundPlaying(void){};
void SD_SetDigiDevice(SDSMode){};
void SD_PrepareSound(int which){};
int SD_PlayDigitized(word which,int leftpos,int rightpos){};
void SD_StopDigitized(void){};

156
contrib/games/wolf3d/id_sd.h Executable file
View File

@ -0,0 +1,156 @@
//
// ID Engine
// ID_SD.h - Sound Manager Header
// Version for Wolfenstein
// By Jason Blochowiak
//
#ifndef __ID_SD__
#define __ID_SD__
#define alOut(n,b) YM3812Write(oplChip, n, b)
#define TickBase 70 // 70Hz per tick - used as a base for timer 0
typedef enum
{
sdm_Off,
sdm_PC,sdm_AdLib,
} SDMode;
typedef enum
{
smm_Off,smm_AdLib
} SMMode;
typedef enum
{
sds_Off,sds_PC,sds_SoundBlaster
} SDSMode;
typedef struct
{
longword length;
word priority;
} SoundCommon;
#define ORIG_SOUNDCOMMON_SIZE 6
// PC Sound stuff
#define pcTimer 0x42
#define pcTAccess 0x43
#define pcSpeaker 0x61
#define pcSpkBits 3
typedef struct
{
SoundCommon common;
byte data[1];
} PCSound;
// Register addresses
// Operator stuff
#define alChar 0x20
#define alScale 0x40
#define alAttack 0x60
#define alSus 0x80
#define alWave 0xe0
// Channel stuff
#define alFreqL 0xa0
#define alFreqH 0xb0
#define alFeedCon 0xc0
// Global stuff
#define alEffects 0xbd
typedef struct
{
byte mChar,cChar,
mScale,cScale,
mAttack,cAttack,
mSus,cSus,
mWave,cWave,
nConn,
// These are only for Muse - these bytes are really unused
voice,
mode;
byte unused[3];
} Instrument;
#define ORIG_INSTRUMENT_SIZE 16
typedef struct
{
SoundCommon common;
Instrument inst;
byte block;
byte data[1];
} AdLibSound;
#define ORIG_ADLIBSOUND_SIZE (ORIG_SOUNDCOMMON_SIZE + ORIG_INSTRUMENT_SIZE + 2)
//
// Sequencing stuff
//
#define sqMaxTracks 10
typedef struct
{
word length;
word values[1];
} MusicGroup;
typedef struct
{
int valid;
fixed globalsoundx, globalsoundy;
} globalsoundpos;
extern int channelSoundPos[];
// Global variables
extern boolean AdLibPresent,
SoundBlasterPresent,
SoundPositioned;
extern SDMode SoundMode;
extern SDSMode DigiMode;
extern SMMode MusicMode;
extern int DigiMap[];
extern int DigiChannel[];
#define GetTimeCount() ((SDL_GetTicks()*7)/100)
inline void Delay(int wolfticks)
{
if(wolfticks>0) SDL_Delay(wolfticks * 100 / 7);
}
// Function prototypes
extern void SD_Startup(void),
SD_Shutdown(void);
extern int SD_GetChannelForDigi(int which);
extern void SD_PositionSound(int leftvol,int rightvol);
extern boolean SD_PlaySound(soundnames sound);
extern void SD_SetPosition(int channel, int leftvol,int rightvol);
extern void SD_StopSound(void),
SD_WaitSoundDone(void);
extern void SD_StartMusic(int chunk);
extern void SD_ContinueMusic(int chunk, int startoffs);
extern void SD_MusicOn(void),
SD_FadeOutMusic(void);
extern int SD_MusicOff(void);
extern boolean SD_MusicPlaying(void);
extern boolean SD_SetSoundMode(SDMode mode);
extern boolean SD_SetMusicMode(SMMode mode);
extern word SD_SoundPlaying(void);
extern void SD_SetDigiDevice(SDSMode);
extern void SD_PrepareSound(int which);
extern int SD_PlayDigitized(word which,int leftpos,int rightpos);
extern void SD_StopDigitized(void);
#endif

101
contrib/games/wolf3d/id_us.h Executable file
View File

@ -0,0 +1,101 @@
//
// ID Engine
// ID_US.h - Header file for the User Manager
// v1.0d1
// By Jason Blochowiak
//
#ifndef __ID_US__
#define __ID_US__
#ifdef __DEBUG__
#define __DEBUG_UserMgr__
#endif
//#define HELPTEXTLINKED
#define MaxX 320
#define MaxY 200
#define MaxHelpLines 500
#define MaxHighName 57
#define MaxScores 7
typedef struct
{
char name[MaxHighName + 1];
int32_t score;
word completed,episode;
} HighScore;
#define MaxGameName 32
#define MaxSaveGames 6
typedef struct
{
char signature[4];
word *oldtest;
boolean present;
char name[MaxGameName + 1];
} SaveGame;
#define MaxString 128 // Maximum input string size
typedef struct
{
int x,y,
w,h,
px,py;
} WindowRec; // Record used to save & restore screen windows
extern boolean ingame, // Set by game code if a game is in progress
loadedgame; // Set if the current game was loaded
extern word PrintX,PrintY; // Current printing location in the window
extern word WindowX,WindowY,// Current location of window
WindowW,WindowH;// Current size of window
extern void (*USL_MeasureString)(const char *,word *,word *);
extern void (*USL_DrawString)(const char *);
extern boolean (*USL_SaveGame)(int),(*USL_LoadGame)(int);
extern void (*USL_ResetGame)(void);
extern SaveGame Games[MaxSaveGames];
extern HighScore Scores[];
#define US_HomeWindow() {PrintX = WindowX; PrintY = WindowY;}
void US_Startup(void);
void US_Shutdown(void);
void US_TextScreen(void),
US_UpdateTextScreen(void),
US_FinishTextScreen(void);
void US_DrawWindow(word x,word y,word w,word h);
void US_CenterWindow(word,word);
void US_SaveWindow(WindowRec *win),
US_RestoreWindow(WindowRec *win);
void US_ClearWindow(void);
void US_SetPrintRoutines(void (*measure)(const char *,word *,word *),
void (*print)(const char *));
void US_PrintCentered(const char *s),
US_CPrint(const char *s),
US_CPrintLine(const char *s),
US_Print(const char *s);
void US_Printf(const char *formatStr, ...);
void US_CPrintf(const char *formatStr, ...);
void US_PrintUnsigned(longword n);
void US_PrintSigned(int32_t n);
void US_StartCursor(void),
US_ShutCursor(void);
void US_CheckHighScore(int32_t score,word other);
void US_DisplayHighScores(int which);
extern boolean US_UpdateCursor(void);
boolean US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
int maxchars,int maxwidth);
void USL_PrintInCenter(const char *s,Rect r);
char *USL_GiveSaveName(word game);
void US_InitRndT(int randomize);
int US_RndT();
#endif

789
contrib/games/wolf3d/id_us_1.cpp Executable file
View File

@ -0,0 +1,789 @@
//
// ID Engine
// ID_US_1.c - User Manager - General routines
// v1.1d1
// By Jason Blochowiak
// Hacked up for Catacomb 3D
//
//
// This module handles dealing with user input & feedback
//
// Depends on: Input Mgr, View Mgr, some variables from the Sound, Caching,
// and Refresh Mgrs, Memory Mgr for background save/restore
//
// Globals:
// ingame - Flag set by game indicating if a game is in progress
// loadedgame - Flag set if a game was loaded
// PrintX, PrintY - Where the User Mgr will print (global coords)
// WindowX,WindowY,WindowW,WindowH - The dimensions of the current
// window
//
#include "wl_def.h"
#pragma hdrstop
#if _MSC_VER == 1200 // Visual C++ 6
#define vsnprintf _vsnprintf
#endif
// Global variables
word PrintX,PrintY;
word WindowX,WindowY,WindowW,WindowH;
// Internal variables
#define ConfigVersion 1
static boolean US_Started;
void (*USL_MeasureString)(const char *,word *,word *) = VW_MeasurePropString;
void (*USL_DrawString)(const char *) = VWB_DrawPropString;
SaveGame Games[MaxSaveGames];
HighScore Scores[MaxScores] =
{
{"id software-'92",10000,1},
{"Adrian Carmack",10000,1},
{"John Carmack",10000,1},
{"Kevin Cloud",10000,1},
{"Tom Hall",10000,1},
{"John Romero",10000,1},
{"Jay Wilbur",10000,1},
};
int rndindex = 0;
static byte rndtable[] = {
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188,
52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224,
149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242,
145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0,
175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235,
25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113,
94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75,
136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196,
135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113,
80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241,
24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224,
145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95,
28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226,
71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36,
17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106,
197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136,
120, 163, 236, 249 };
// Internal routines
// Public routines
///////////////////////////////////////////////////////////////////////////
//
// US_Startup() - Starts the User Mgr
//
///////////////////////////////////////////////////////////////////////////
void US_Startup()
{
if (US_Started)
return;
US_InitRndT(true); // Initialize the random number generator
US_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// US_Shutdown() - Shuts down the User Mgr
//
///////////////////////////////////////////////////////////////////////////
void
US_Shutdown(void)
{
if (!US_Started)
return;
US_Started = false;
}
// Window/Printing routines
///////////////////////////////////////////////////////////////////////////
//
// US_SetPrintRoutines() - Sets the routines used to measure and print
// from within the User Mgr. Primarily provided to allow switching
// between masked and non-masked fonts
//
///////////////////////////////////////////////////////////////////////////
void
US_SetPrintRoutines(void (*measure)(const char *,word *,word *),
void (*print)(const char *))
{
USL_MeasureString = measure;
USL_DrawString = print;
}
///////////////////////////////////////////////////////////////////////////
//
// US_Print() - Prints a string in the current window. Newlines are
// supported.
//
///////////////////////////////////////////////////////////////////////////
void
US_Print(const char *sorg)
{
char c;
char *sstart = strdup(sorg);
char *s = sstart;
char *se;
word w,h;
while (*s)
{
se = s;
while ((c = *se)!=0 && (c != '\n'))
se++;
*se = '\0';
USL_MeasureString(s,&w,&h);
px = PrintX;
py = PrintY;
USL_DrawString(s);
s = se;
if (c)
{
*se = c;
s++;
PrintX = WindowX;
PrintY += h;
}
else
PrintX += w;
}
free(sstart);
}
///////////////////////////////////////////////////////////////////////////
//
// US_PrintUnsigned() - Prints an unsigned long
//
///////////////////////////////////////////////////////////////////////////
void
US_PrintUnsigned(longword n)
{
char buffer[32];
sprintf(buffer, "%lu", n);
US_Print(buffer);
}
///////////////////////////////////////////////////////////////////////////
//
// US_PrintSigned() - Prints a signed long
//
///////////////////////////////////////////////////////////////////////////
void
US_PrintSigned(int32_t n)
{
char buffer[32];
US_Print(ltoa(n,buffer,10));
}
///////////////////////////////////////////////////////////////////////////
//
// USL_PrintInCenter() - Prints a string in the center of the given rect
//
///////////////////////////////////////////////////////////////////////////
void
USL_PrintInCenter(const char *s,Rect r)
{
word w,h,
rw,rh;
USL_MeasureString(s,&w,&h);
rw = r.lr.x - r.ul.x;
rh = r.lr.y - r.ul.y;
px = r.ul.x + ((rw - w) / 2);
py = r.ul.y + ((rh - h) / 2);
USL_DrawString(s);
}
///////////////////////////////////////////////////////////////////////////
//
// US_PrintCentered() - Prints a string centered in the current window.
//
///////////////////////////////////////////////////////////////////////////
void
US_PrintCentered(const char *s)
{
Rect r;
r.ul.x = WindowX;
r.ul.y = WindowY;
r.lr.x = r.ul.x + WindowW;
r.lr.y = r.ul.y + WindowH;
USL_PrintInCenter(s,r);
}
///////////////////////////////////////////////////////////////////////////
//
// US_CPrintLine() - Prints a string centered on the current line and
// advances to the next line. Newlines are not supported.
//
///////////////////////////////////////////////////////////////////////////
void
US_CPrintLine(const char *s)
{
word w,h;
USL_MeasureString(s,&w,&h);
if (w > WindowW)
Quit("US_CPrintLine() - String exceeds width");
px = WindowX + ((WindowW - w) / 2);
py = PrintY;
USL_DrawString(s);
PrintY += h;
}
///////////////////////////////////////////////////////////////////////////
//
// US_CPrint() - Prints a string centered in the current window.
// Newlines are supported.
//
///////////////////////////////////////////////////////////////////////////
void
US_CPrint(const char *sorg)
{
char c;
char *sstart = strdup(sorg);
char *s = sstart;
char *se;
while (*s)
{
se = s;
while ((c = *se)!=0 && (c != '\n'))
se++;
*se = '\0';
US_CPrintLine(s);
s = se;
if (c)
{
*se = c;
s++;
}
}
free(sstart);
}
///////////////////////////////////////////////////////////////////////////
//
// US_Printf() - Prints a formatted string in the current window.
// Newlines are supported.
//
///////////////////////////////////////////////////////////////////////////
void US_Printf(const char *formatStr, ...)
{
char strbuf[256];
va_list vlist;
va_start(vlist, formatStr);
int len = vsnprintf(strbuf, sizeof(strbuf), formatStr, vlist);
va_end(vlist);
if(len <= -1 || len >= sizeof(strbuf))
strbuf[sizeof(strbuf) - 1] = 0;
US_Print(strbuf);
}
///////////////////////////////////////////////////////////////////////////
//
// US_CPrintf() - Prints a formatted string centered in the current window.
// Newlines are supported.
//
///////////////////////////////////////////////////////////////////////////
void US_CPrintf(const char *formatStr, ...)
{
char strbuf[256];
va_list vlist;
va_start(vlist, formatStr);
int len = vsnprintf(strbuf, sizeof(strbuf), formatStr, vlist);
va_end(vlist);
if(len <= -1 || len >= sizeof(strbuf))
strbuf[sizeof(strbuf) - 1] = 0;
US_CPrint(strbuf);
}
///////////////////////////////////////////////////////////////////////////
//
// US_ClearWindow() - Clears the current window to white and homes the
// cursor
//
///////////////////////////////////////////////////////////////////////////
void
US_ClearWindow(void)
{
VWB_Bar(WindowX,WindowY,WindowW,WindowH,WHITE);
PrintX = WindowX;
PrintY = WindowY;
}
///////////////////////////////////////////////////////////////////////////
//
// US_DrawWindow() - Draws a frame and sets the current window parms
//
///////////////////////////////////////////////////////////////////////////
void
US_DrawWindow(word x,word y,word w,word h)
{
word i,
sx,sy,sw,sh;
WindowX = x * 8;
WindowY = y * 8;
WindowW = w * 8;
WindowH = h * 8;
PrintX = WindowX;
PrintY = WindowY;
sx = (x - 1) * 8;
sy = (y - 1) * 8;
sw = (w + 1) * 8;
sh = (h + 1) * 8;
US_ClearWindow();
VWB_DrawTile8(sx,sy,0),VWB_DrawTile8(sx,sy + sh,5);
for (i = sx + 8;i <= sx + sw - 8;i += 8)
VWB_DrawTile8(i,sy,1),VWB_DrawTile8(i,sy + sh,6);
VWB_DrawTile8(i,sy,2),VWB_DrawTile8(i,sy + sh,7);
for (i = sy + 8;i <= sy + sh - 8;i += 8)
VWB_DrawTile8(sx,i,3),VWB_DrawTile8(sx + sw,i,4);
}
///////////////////////////////////////////////////////////////////////////
//
// US_CenterWindow() - Generates a window of a given width & height in the
// middle of the screen
//
///////////////////////////////////////////////////////////////////////////
void
US_CenterWindow(word w,word h)
{
US_DrawWindow(((MaxX / 8) - w) / 2,((MaxY / 8) - h) / 2,w,h);
}
///////////////////////////////////////////////////////////////////////////
//
// US_SaveWindow() - Saves the current window parms into a record for
// later restoration
//
///////////////////////////////////////////////////////////////////////////
void
US_SaveWindow(WindowRec *win)
{
win->x = WindowX;
win->y = WindowY;
win->w = WindowW;
win->h = WindowH;
win->px = PrintX;
win->py = PrintY;
}
///////////////////////////////////////////////////////////////////////////
//
// US_RestoreWindow() - Sets the current window parms to those held in the
// record
//
///////////////////////////////////////////////////////////////////////////
void
US_RestoreWindow(WindowRec *win)
{
WindowX = win->x;
WindowY = win->y;
WindowW = win->w;
WindowH = win->h;
PrintX = win->px;
PrintY = win->py;
}
// Input routines
///////////////////////////////////////////////////////////////////////////
//
// USL_XORICursor() - XORs the I-bar text cursor. Used by US_LineInput()
//
///////////////////////////////////////////////////////////////////////////
static void
USL_XORICursor(int x,int y,const char *s,word cursor)
{
static boolean status; // VGA doesn't XOR...
char buf[MaxString];
int temp;
word w,h;
strcpy(buf,s);
buf[cursor] = '\0';
USL_MeasureString(buf,&w,&h);
px = x + w - 1;
py = y;
if (status^=1)
USL_DrawString("\x80");
else
{
temp = fontcolor;
fontcolor = backcolor;
USL_DrawString("\x80");
fontcolor = temp;
}
}
char USL_RotateChar(char ch, int dir)
{
static const char charSet[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ.,-!?0123456789";
const int numChars = sizeof(charSet) / sizeof(char) - 1;
int i;
for(i = 0; i < numChars; i++)
{
if(ch == charSet[i]) break;
}
if(i == numChars) i = 0;
i += dir;
if(i < 0) i = numChars - 1;
else if(i >= numChars) i = 0;
return charSet[i];
}
///////////////////////////////////////////////////////////////////////////
//
// US_LineInput() - Gets a line of user input at (x,y), the string defaults
// to whatever is pointed at by def. Input is restricted to maxchars
// chars or maxwidth pixels wide. If the user hits escape (and escok is
// true), nothing is copied into buf, and false is returned. If the
// user hits return, the current string is copied into buf, and true is
// returned
//
///////////////////////////////////////////////////////////////////////////
boolean
US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
int maxchars,int maxwidth)
{
boolean redraw,
cursorvis,cursormoved,
done,result, checkkey;
ScanCode sc;
char c;
char s[MaxString],olds[MaxString];
int cursor,len;
word i,
w,h,
temp;
longword curtime, lasttime, lastdirtime, lastbuttontime, lastdirmovetime;
ControlInfo ci;
Direction lastdir = dir_None;
if (def)
strcpy(s,def);
else
*s = '\0';
*olds = '\0';
cursor = (int) strlen(s);
cursormoved = redraw = true;
cursorvis = done = false;
lasttime = lastdirtime = lastdirmovetime = GetTimeCount();
lastbuttontime = lasttime + TickBase / 4; // 250 ms => first button press accepted after 500 ms
LastASCII = key_None;
LastScan = sc_None;
while (!done)
{
ReadAnyControl(&ci);
if (cursorvis)
USL_XORICursor(x,y,s,cursor);
sc = LastScan;
LastScan = sc_None;
c = LastASCII;
LastASCII = key_None;
checkkey = true;
curtime = GetTimeCount();
// After each direction change accept the next change after 250 ms and then everz 125 ms
if(ci.dir != lastdir || curtime - lastdirtime > TickBase / 4 && curtime - lastdirmovetime > TickBase / 8)
{
if(ci.dir != lastdir)
{
lastdir = ci.dir;
lastdirtime = curtime;
}
lastdirmovetime = curtime;
switch(ci.dir)
{
case dir_West:
if(cursor)
{
// Remove trailing whitespace if cursor is at end of string
if(s[cursor] == ' ' && s[cursor + 1] == 0)
s[cursor] = 0;
cursor--;
}
cursormoved = true;
checkkey = false;
break;
case dir_East:
if(cursor >= MaxString - 1) break;
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
if(len >= maxchars || maxwidth && w >= maxwidth) break;
s[cursor] = ' ';
s[cursor + 1] = 0;
}
cursor++;
cursormoved = true;
checkkey = false;
break;
case dir_North:
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
if(len >= maxchars || maxwidth && w >= maxwidth) break;
s[cursor + 1] = 0;
}
s[cursor] = USL_RotateChar(s[cursor], 1);
redraw = true;
checkkey = false;
break;
case dir_South:
if(!s[cursor])
{
USL_MeasureString(s,&w,&h);
if(len >= maxchars || maxwidth && w >= maxwidth) break;
s[cursor + 1] = 0;
}
s[cursor] = USL_RotateChar(s[cursor], -1);
redraw = true;
checkkey = false;
break;
}
}
if((int)(curtime - lastbuttontime) > TickBase / 4) // 250 ms
{
if(ci.button0) // acts as return
{
strcpy(buf,s);
done = true;
result = true;
checkkey = false;
}
if(ci.button1 && escok) // acts as escape
{
done = true;
result = false;
checkkey = false;
}
if(ci.button2) // acts as backspace
{
lastbuttontime = curtime;
if(cursor)
{
strcpy(s + cursor - 1,s + cursor);
cursor--;
redraw = true;
}
cursormoved = true;
checkkey = false;
}
}
if(checkkey)
{
switch (sc)
{
case sc_LeftArrow:
if (cursor)
cursor--;
c = key_None;
cursormoved = true;
break;
case sc_RightArrow:
if (s[cursor])
cursor++;
c = key_None;
cursormoved = true;
break;
case sc_Home:
cursor = 0;
c = key_None;
cursormoved = true;
break;
case sc_End:
cursor = (int) strlen(s);
c = key_None;
cursormoved = true;
break;
case sc_Return:
strcpy(buf,s);
done = true;
result = true;
c = key_None;
break;
case sc_Escape:
if (escok)
{
done = true;
result = false;
}
c = key_None;
break;
case sc_BackSpace:
if (cursor)
{
strcpy(s + cursor - 1,s + cursor);
cursor--;
redraw = true;
}
c = key_None;
cursormoved = true;
break;
case sc_Delete:
if (s[cursor])
{
strcpy(s + cursor,s + cursor + 1);
redraw = true;
}
c = key_None;
cursormoved = true;
break;
case SDLK_KP5: //0x4c: // Keypad 5 // TODO: hmmm...
case sc_UpArrow:
case sc_DownArrow:
case sc_PgUp:
case sc_PgDn:
case sc_Insert:
c = key_None;
break;
}
if (c)
{
len = (int) strlen(s);
USL_MeasureString(s,&w,&h);
if(isprint(c) && (len < MaxString - 1) && ((!maxchars) || (len < maxchars))
&& ((!maxwidth) || (w < maxwidth)))
{
for (i = len + 1;i > cursor;i--)
s[i] = s[i - 1];
s[cursor++] = c;
redraw = true;
}
}
}
if (redraw)
{
px = x;
py = y;
temp = fontcolor;
fontcolor = backcolor;
USL_DrawString(olds);
fontcolor = (byte) temp;
strcpy(olds,s);
px = x;
py = y;
USL_DrawString(s);
redraw = false;
}
if (cursormoved)
{
cursorvis = false;
lasttime = curtime - TickBase;
cursormoved = false;
}
if (curtime - lasttime > TickBase / 2) // 500 ms
{
lasttime = curtime;
cursorvis ^= true;
}
else SDL_Delay(5);
if (cursorvis)
USL_XORICursor(x,y,s,cursor);
VW_UpdateScreen();
}
if (cursorvis)
USL_XORICursor(x,y,s,cursor);
if (!result)
{
px = x;
py = y;
USL_DrawString(olds);
}
VW_UpdateScreen();
IN_ClearKeysDown();
return(result);
}
///////////////////////////////////////////////////////////////////////////
//
// US_InitRndT - Initializes the pseudo random number generator.
// If randomize is true, the seed will be initialized depending on the
// current time
//
///////////////////////////////////////////////////////////////////////////
void US_InitRndT(int randomize)
{
if(randomize)
rndindex = (SDL_GetTicks() >> 4) & 0xff;
else
rndindex = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// US_RndT - Returns the next 8-bit pseudo random number
//
///////////////////////////////////////////////////////////////////////////
int US_RndT()
{
rndindex = (rndindex+1)&0xff;
return rndtable[rndindex];
}

470
contrib/games/wolf3d/id_vh.cpp Executable file
View File

@ -0,0 +1,470 @@
#include "wl_def.h"
pictabletype *pictable;
SDL_Surface *latchpics[NUMLATCHPICS];
int px,py;
byte fontcolor,backcolor;
int fontnumber;
//==========================================================================
void VWB_DrawPropString(const char* string)
{
fontstruct *font;
int width, step, height;
byte *source, *dest;
byte ch;
int i;
unsigned sx, sy;
byte *vbuf = VL_LockSurface(curSurface);
if(vbuf == NULL) return;
font = (fontstruct *) grsegs[STARTFONT+fontnumber];
height = font->height;
dest = vbuf + scaleFactor * (py * curPitch + px);
while ((ch = (byte)*string++)!=0)
{
width = step = font->width[ch];
source = ((byte *)font)+font->location[ch];
while (width--)
{
for(i=0; i<height; i++)
{
if(source[i*step])
{
for(sy=0; sy<scaleFactor; sy++)
for(sx=0; sx<scaleFactor; sx++)
dest[(scaleFactor*i+sy)*curPitch+sx]=fontcolor;
}
}
source++;
px++;
dest+=scaleFactor;
}
}
VL_UnlockSurface(curSurface);
}
/*
=================
=
= VL_MungePic
=
=================
*/
void VL_MungePic (byte *source, unsigned width, unsigned height)
{
unsigned x,y,plane,size,pwidth;
byte *temp, *dest, *srcline;
size = width*height;
if (width&3)
Quit ("VL_MungePic: Not divisable by 4!");
//
// copy the pic to a temp buffer
//
temp=(byte *) malloc(size);
CHECKMALLOCRESULT(temp);
memcpy (temp,source,size);
//
// munge it back into the original buffer
//
dest = source;
pwidth = width/4;
for (plane=0;plane<4;plane++)
{
srcline = temp;
for (y=0;y<height;y++)
{
for (x=0;x<pwidth;x++)
*dest++ = *(srcline+x*4+plane);
srcline+=width;
}
}
free(temp);
}
void VWL_MeasureString (const char *string, word *width, word *height, fontstruct *font)
{
*height = font->height;
for (*width = 0;*string;string++)
*width += font->width[*((byte *)string)]; // proportional width
}
void VW_MeasurePropString (const char *string, word *width, word *height)
{
VWL_MeasureString(string,width,height,(fontstruct *)grsegs[STARTFONT+fontnumber]);
}
/*
=============================================================================
Double buffer management routines
=============================================================================
*/
void VH_UpdateScreen()
{
SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
SDL_Flip(screen);
}
void VWB_DrawTile8 (int x, int y, int tile)
{
LatchDrawChar(x,y,tile);
}
void VWB_DrawTile8M (int x, int y, int tile)
{
VL_MemToScreen (((byte *)grsegs[STARTTILE8M])+tile*64,8,8,x,y);
}
void VWB_DrawPic (int x, int y, int chunknum)
{
int picnum = chunknum - STARTPICS;
unsigned width,height;
x &= ~7;
width = pictable[picnum].width;
height = pictable[picnum].height;
VL_MemToScreen (grsegs[chunknum],width,height,x,y);
}
void VWB_DrawPicScaledCoord (int scx, int scy, int chunknum)
{
int picnum = chunknum - STARTPICS;
unsigned width,height;
width = pictable[picnum].width;
height = pictable[picnum].height;
VL_MemToScreenScaledCoord (grsegs[chunknum],width,height,scx,scy);
}
void VWB_Bar (int x, int y, int width, int height, int color)
{
VW_Bar (x,y,width,height,color);
}
void VWB_Plot (int x, int y, int color)
{
if(scaleFactor == 1)
VW_Plot(x,y,color);
else
VW_Bar(x, y, 1, 1, color);
}
void VWB_Hlin (int x1, int x2, int y, int color)
{
if(scaleFactor == 1)
VW_Hlin(x1,x2,y,color);
else
VW_Bar(x1, y, x2-x1+1, 1, color);
}
void VWB_Vlin (int y1, int y2, int x, int color)
{
if(scaleFactor == 1)
VW_Vlin(y1,y2,x,color);
else
VW_Bar(x, y1, 1, y2-y1+1, color);
}
/*
=============================================================================
WOLFENSTEIN STUFF
=============================================================================
*/
/*
=====================
=
= LatchDrawPic
=
=====================
*/
void LatchDrawPic (unsigned x, unsigned y, unsigned picnum)
{
VL_LatchToScreen (latchpics[2+picnum-LATCHPICS_LUMP_START], x*8, y);
}
void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum)
{
VL_LatchToScreenScaledCoord (latchpics[2+picnum-LATCHPICS_LUMP_START], scx*8, scy);
}
//==========================================================================
void FreeLatchMem()
{
int i;
for(i = 0; i < 2 + LATCHPICS_LUMP_END - LATCHPICS_LUMP_START; i++)
{
SDL_FreeSurface(latchpics[i]);
latchpics[i] = NULL;
}
}
/*
===================
=
= LoadLatchMem
=
===================
*/
void LoadLatchMem (void)
{
int i,width,height,start,end;
byte *src;
SDL_Surface *surf;
//
// tile 8s
//
surf = SDL_CreateRGBSurface(SDL_HWSURFACE, 8*8,
((NUMTILE8 + 7) / 8) * 8, 8, 0, 0, 0, 0);
if(surf == NULL)
{
Quit("Unable to create surface for tiles!");
}
SDL_SetColors(surf, gamepal, 0, 256);
latchpics[0] = surf;
CA_CacheGrChunk (STARTTILE8);
src = grsegs[STARTTILE8];
for (i=0;i<NUMTILE8;i++)
{
VL_MemToLatch (src, 8, 8, surf, (i & 7) * 8, (i >> 3) * 8);
src += 64;
}
UNCACHEGRCHUNK (STARTTILE8);
latchpics[1] = NULL; // not used
//
// pics
//
start = LATCHPICS_LUMP_START;
end = LATCHPICS_LUMP_END;
for (i=start;i<=end;i++)
{
width = pictable[i-STARTPICS].width;
height = pictable[i-STARTPICS].height;
surf = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 8, 0, 0, 0, 0);
if(surf == NULL)
{
Quit("Unable to create surface for picture!");
}
SDL_SetColors(surf, gamepal, 0, 256);
latchpics[2+i-start] = surf;
CA_CacheGrChunk (i);
VL_MemToLatch (grsegs[i], width, height, surf, 0, 0);
UNCACHEGRCHUNK(i);
}
}
//==========================================================================
/*
===================
=
= FizzleFade
=
= returns true if aborted
=
= It uses maximum-length Linear Feedback Shift Registers (LFSR) counters.
= You can find a list of them with lengths from 3 to 168 at:
= http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
= Many thanks to Xilinx for this list!!!
=
===================
*/
// XOR masks for the pseudo-random number sequence starting with n=17 bits
static const uint32_t rndmasks[] = {
// n XNOR from (starting at 1, not 0 as usual)
0x00012000, // 17 17,14
0x00020400, // 18 18,11
0x00040023, // 19 19,6,2,1
0x00090000, // 20 20,17
0x00140000, // 21 21,19
0x00300000, // 22 22,21
0x00420000, // 23 23,18
0x00e10000, // 24 24,23,22,17
0x01200000, // 25 25,22 (this is enough for 8191x4095)
};
static unsigned int rndbits_y;
static unsigned int rndmask;
extern SDL_Color curpal[256];
// Returns the number of bits needed to represent the given value
static int log2_ceil(uint32_t x)
{
int n = 0;
uint32_t v = 1;
while(v < x)
{
n++;
v <<= 1;
}
return n;
}
void VH_Startup()
{
int rndbits_x = log2_ceil(screenWidth);
rndbits_y = log2_ceil(screenHeight);
int rndbits = rndbits_x + rndbits_y;
if(rndbits < 17)
rndbits = 17; // no problem, just a bit slower
else if(rndbits > 25)
rndbits = 25; // fizzle fade will not fill whole screen
rndmask = rndmasks[rndbits - 17];
}
boolean FizzleFade (SDL_Surface *source, int x1, int y1,
unsigned width, unsigned height, unsigned frames, boolean abortable)
{
unsigned x, y, frame, pixperframe;
int32_t rndval, lastrndval;
int first = 1;
lastrndval = 0;
pixperframe = width * height / frames;
IN_StartAck ();
frame = GetTimeCount();
byte *srcptr = VL_LockSurface(source);
if(srcptr == NULL) return false;
do
{
IN_ProcessEvents();
if(abortable && IN_CheckAck ())
{
VL_UnlockSurface(source);
SDL_BlitSurface(source, NULL, screen, NULL);
SDL_Flip(screen);
return true;
}
byte *destptr = VL_LockSurface(screen);
if(destptr != NULL)
{
rndval = lastrndval;
// When using double buffering, we have to copy the pixels of the last AND the current frame.
// Only for the first frame, there is no "last frame"
for(int i = first; i < 2; i++)
{
for(unsigned p = 0; p < pixperframe; p++)
{
//
// seperate random value into x/y pair
//
x = rndval >> rndbits_y;
y = rndval & ((1 << rndbits_y) - 1);
//
// advance to next random element
//
rndval = (rndval >> 1) ^ (rndval & 1 ? 0 : rndmask);
if(x >= width || y >= height)
{
if(rndval == 0) // entire sequence has been completed
goto finished;
p--;
continue;
}
//
// copy one pixel
//
if(screenBits == 8)
{
*(destptr + (y1 + y) * screen->pitch + x1 + x)
= *(srcptr + (y1 + y) * source->pitch + x1 + x);
}
else
{
byte col = *(srcptr + (y1 + y) * source->pitch + x1 + x);
uint32_t fullcol = SDL_MapRGB(screen->format, curpal[col].r, curpal[col].g, curpal[col].b);
memcpy(destptr + (y1 + y) * screen->pitch + (x1 + x) * screen->format->BytesPerPixel,
&fullcol, screen->format->BytesPerPixel);
}
if(rndval == 0) // entire sequence has been completed
goto finished;
}
if(!i || first) lastrndval = rndval;
}
// If there is no double buffering, we always use the "first frame" case
if(usedoublebuffering) first = 0;
VL_UnlockSurface(screen);
SDL_Flip(screen);
}
else
{
// No surface, so only enhance rndval
for(int i = first; i < 2; i++)
{
for(unsigned p = 0; p < pixperframe; p++)
{
rndval = (rndval >> 1) ^ (rndval & 1 ? 0 : rndmask);
if(rndval == 0)
goto finished;
}
}
}
frame++;
Delay(frame - GetTimeCount()); // don't go too fast
} while (1);
finished:
VL_UnlockSurface(source);
VL_UnlockSurface(screen);
SDL_BlitSurface(source, NULL, screen, NULL);
SDL_Flip(screen);
return false;
}

100
contrib/games/wolf3d/id_vh.h Executable file
View File

@ -0,0 +1,100 @@
// ID_VH.H
#define WHITE 15 // graphics mode independant colors
#define BLACK 0
#define FIRSTCOLOR 1
#define SECONDCOLOR 12
#define F_WHITE 15
#define F_BLACK 0
#define F_FIRSTCOLOR 1
#define F_SECONDCOLOR 12
//===========================================================================
#define MAXSHIFTS 1
typedef struct
{
int16_t width,height;
} pictabletype;
typedef struct
{
int16_t height;
int16_t location[256];
int8_t width[256];
} fontstruct;
//===========================================================================
extern pictabletype *pictable;
extern pictabletype *picmtable;
extern byte fontcolor,backcolor;
extern int fontnumber;
extern int px,py;
#define SETFONTCOLOR(f,b) fontcolor=f;backcolor=b;
//
// mode independant routines
// coordinates in pixels, rounded to best screen res
// regions marked in double buffer
//
void VWB_DrawPropString (const char *string);
void VWB_DrawTile8 (int x, int y, int tile);
void VWB_DrawTile8M (int x, int y, int tile);
void VWB_DrawTile16 (int x, int y, int tile);
void VWB_DrawTile16M (int x, int y, int tile);
void VWB_DrawPic (int x, int y, int chunknum);
void VWB_DrawPicScaledCoord (int x, int y, int chunknum);
void VWB_DrawMPic(int x, int y, int chunknum);
void VWB_Bar (int x, int y, int width, int height, int color);
#define VWB_BarScaledCoord VL_BarScaledCoord
void VWB_Plot (int x, int y, int color);
#define VWB_PlotScaledCoord VW_Plot
void VWB_Hlin (int x1, int x2, int y, int color);
void VWB_Vlin (int y1, int y2, int x, int color);
#define VWB_HlinScaledCoord VW_Hlin
#define VWB_VlinScaledCoord VW_Vlin
void VH_UpdateScreen();
#define VW_UpdateScreen VH_UpdateScreen
//
// wolfenstein EGA compatability stuff
//
#define VW_Shutdown VL_Shutdown
#define VW_Bar VL_Bar
#define VW_Plot VL_Plot
#define VW_Hlin(x,z,y,c) VL_Hlin(x,y,(z)-(x)+1,c)
#define VW_Vlin(y,z,x,c) VL_Vlin(x,y,(z)-(y)+1,c)
#define VW_DrawPic VH_DrawPic
#define VW_WaitVBL VL_WaitVBL
#define VW_FadeIn() VL_FadeIn(0,255,gamepal,30);
#define VW_FadeOut() VL_FadeOut(0,255,0,0,0,30);
#define VW_ScreenToScreen VL_ScreenToScreen
void VW_MeasurePropString (const char *string, word *width, word *height);
#define LatchDrawChar(x,y,p) VL_LatchToScreen(latchpics[0],((p)&7)*8,((p)>>3)*8*64,8,8,x,y)
#define LatchDrawTile(x,y,p) VL_LatchToScreen(latchpics[1],(p)*64,0,16,16,x,y)
void LatchDrawPic (unsigned x, unsigned y, unsigned picnum);
void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum);
void LoadLatchMem (void);
void FreeLatchMem();
void VH_Startup();
boolean FizzleFade (SDL_Surface *source, int x1, int y1,
unsigned width, unsigned height, unsigned frames, boolean abortable);
#define NUMLATCHPICS 100
extern SDL_Surface *latchpics[NUMLATCHPICS];

792
contrib/games/wolf3d/id_vl.cpp Executable file
View File

@ -0,0 +1,792 @@
// ID_VL.C
#include <string.h>
#include "wl_def.h"
#pragma hdrstop
// Uncomment the following line, if you get destination out of bounds
// assertion errors and want to ignore them during debugging
//#define IGNORE_BAD_DEST
#ifdef IGNORE_BAD_DEST
#undef assert
#define assert(x) if(!(x)) return
#define assert_ret(x) if(!(x)) return 0
#else
#define assert_ret(x) assert(x)
#endif
boolean fullscreen = true;
#if defined(_arch_dreamcast)
boolean usedoublebuffering = false;
unsigned screenWidth = 320;
unsigned screenHeight = 200;
unsigned screenBits = 8;
#elif defined(GP2X)
boolean usedoublebuffering = true;
unsigned screenWidth = 320;
unsigned screenHeight = 240;
#if defined(GP2X_940)
unsigned screenBits = 8;
#else
unsigned screenBits = 16;
#endif
#else
boolean usedoublebuffering = true;
unsigned screenWidth = 640;
unsigned screenHeight = 400;
unsigned screenBits = -1; // use "best" color depth according to libSDL
#endif
SDL_Surface *screen = NULL;
unsigned screenPitch;
SDL_Surface *screenBuffer = NULL;
unsigned bufferPitch;
SDL_Surface *curSurface = NULL;
unsigned curPitch;
unsigned scaleFactor;
boolean screenfaded;
unsigned bordercolor;
SDL_Color palette1[256], palette2[256];
SDL_Color curpal[256];
#define CASSERT(x) extern int ASSERT_COMPILE[((x) != 0) * 2 - 1];
#define RGB(r, g, b) {(r)*255/63, (g)*255/63, (b)*255/63, 0}
SDL_Color gamepal[]={
#ifdef SPEAR
#include "sodpal.inc"
#else
#include "wolfpal.inc"
#endif
};
CASSERT(lengthof(gamepal) == 256)
//===========================================================================
/*
=======================
=
= VL_Shutdown
=
=======================
*/
void VL_Shutdown (void)
{
//VL_SetTextMode ();
}
/*
=======================
=
= VL_SetVGAPlaneMode
=
=======================
*/
void VL_SetVGAPlaneMode (void)
{
#ifdef SPEAR
SDL_WM_SetCaption("Spear of Destiny", NULL);
#else
SDL_WM_SetCaption("Wolfenstein 3D", NULL);
#endif
if(screenBits == -1)
{
const SDL_VideoInfo *vidInfo = SDL_GetVideoInfo();
screenBits = vidInfo->vfmt->BitsPerPixel;
}
screen = SDL_SetVideoMode(screenWidth, screenHeight, screenBits,
(usedoublebuffering ? SDL_HWSURFACE | SDL_DOUBLEBUF : 0)
| (screenBits == 8 ? SDL_HWPALETTE : 0)
| (fullscreen ? SDL_FULLSCREEN : 0));
if(!screen)
{
printf("Unable to set %ix%ix%i video mode: %s\n", screenWidth,
screenHeight, screenBits, SDL_GetError());
exit(1);
}
if((screen->flags & SDL_DOUBLEBUF) != SDL_DOUBLEBUF)
usedoublebuffering = false;
SDL_ShowCursor(SDL_DISABLE);
SDL_SetColors(screen, gamepal, 0, 256);
memcpy(curpal, gamepal, sizeof(SDL_Color) * 256);
screenBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, screenWidth,
screenHeight, 8, 0, 0, 0, 0);
if(!screenBuffer)
{
printf("Unable to create screen buffer surface: %s\n", SDL_GetError());
exit(1);
}
SDL_SetColors(screenBuffer, gamepal, 0, 256);
screenPitch = screen->pitch;
bufferPitch = screenBuffer->pitch;
curSurface = screenBuffer;
curPitch = bufferPitch;
scaleFactor = screenWidth/320;
if(screenHeight/200 < scaleFactor) scaleFactor = screenHeight/200;
pixelangle = (short *) malloc(screenWidth * sizeof(short));
CHECKMALLOCRESULT(pixelangle);
wallheight = (int *) malloc(screenWidth * sizeof(int));
CHECKMALLOCRESULT(wallheight);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_ConvertPalette
=
=================
*/
void VL_ConvertPalette(byte *srcpal, SDL_Color *destpal, int numColors)
{
for(int i=0; i<numColors; i++)
{
destpal[i].r = *srcpal++ * 255 / 63;
destpal[i].g = *srcpal++ * 255 / 63;
destpal[i].b = *srcpal++ * 255 / 63;
}
}
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette (int red, int green, int blue)
{
int i;
SDL_Color pal[256];
for(i=0; i<256; i++)
{
pal[i].r = red;
pal[i].g = green;
pal[i].b = blue;
}
VL_SetPalette(pal, true);
}
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor (int color, int red, int green, int blue)
{
SDL_Color col = { red, green, blue };
curpal[color] = col;
if(screenBits == 8)
SDL_SetPalette(screen, SDL_PHYSPAL, &col, color, 1);
else
{
SDL_SetPalette(curSurface, SDL_LOGPAL, &col, color, 1);
SDL_BlitSurface(curSurface, NULL, screen, NULL);
SDL_Flip(screen);
}
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor (int color, int *red, int *green, int *blue)
{
SDL_Color *col = &curpal[color];
*red = col->r;
*green = col->g;
*blue = col->b;
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void VL_SetPalette (SDL_Color *palette, bool forceupdate)
{
memcpy(curpal, palette, sizeof(SDL_Color) * 256);
if(screenBits == 8)
SDL_SetPalette(screen, SDL_PHYSPAL, palette, 0, 256);
else
{
SDL_SetPalette(curSurface, SDL_LOGPAL, palette, 0, 256);
if(forceupdate)
{
SDL_BlitSurface(curSurface, NULL, screen, NULL);
SDL_Flip(screen);
}
}
}
//===========================================================================
/*
=================
=
= VL_GetPalette
=
=================
*/
void VL_GetPalette (SDL_Color *palette)
{
memcpy(palette, curpal, sizeof(SDL_Color) * 256);
}
//===========================================================================
/*
=================
=
= VL_FadeOut
=
= Fades the current palette to the given color in the given number of steps
=
=================
*/
void VL_FadeOut (int start, int end, int red, int green, int blue, int steps)
{
int i,j,orig,delta;
SDL_Color *origptr, *newptr;
red = red * 255 / 63;
green = green * 255 / 63;
blue = blue * 255 / 63;
VL_WaitVBL(1);
VL_GetPalette(palette1);
memcpy(palette2, palette1, sizeof(SDL_Color) * 256);
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
origptr = &palette1[start];
newptr = &palette2[start];
for (j=start;j<=end;j++)
{
orig = origptr->r;
delta = red-orig;
newptr->r = orig + delta * i / steps;
orig = origptr->g;
delta = green-orig;
newptr->g = orig + delta * i / steps;
orig = origptr->b;
delta = blue-orig;
newptr->b = orig + delta * i / steps;
origptr++;
newptr++;
}
if(!usedoublebuffering || screenBits == 8) VL_WaitVBL(1);
VL_SetPalette (palette2, true);
}
//
// final color
//
VL_FillPalette (red,green,blue);
screenfaded = true;
}
/*
=================
=
= VL_FadeIn
=
=================
*/
void VL_FadeIn (int start, int end, SDL_Color *palette, int steps)
{
int i,j,delta;
VL_WaitVBL(1);
VL_GetPalette(palette1);
memcpy(palette2, palette1, sizeof(SDL_Color) * 256);
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
for (j=start;j<=end;j++)
{
delta = palette[j].r-palette1[j].r;
palette2[j].r = palette1[j].r + delta * i / steps;
delta = palette[j].g-palette1[j].g;
palette2[j].g = palette1[j].g + delta * i / steps;
delta = palette[j].b-palette1[j].b;
palette2[j].b = palette1[j].b + delta * i / steps;
}
if(!usedoublebuffering || screenBits == 8) VL_WaitVBL(1);
VL_SetPalette(palette2, true);
}
//
// final color
//
VL_SetPalette (palette, true);
screenfaded = false;
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
byte *VL_LockSurface(SDL_Surface *surface)
{
if(SDL_MUSTLOCK(surface))
{
if(SDL_LockSurface(surface) < 0)
return NULL;
}
return (byte *) surface->pixels;
}
void VL_UnlockSurface(SDL_Surface *surface)
{
if(SDL_MUSTLOCK(surface))
{
SDL_UnlockSurface(surface);
}
}
/*
=================
=
= VL_Plot
=
=================
*/
void VL_Plot (int x, int y, int color)
{
byte *ptr;
assert(x >= 0 && (unsigned) x < screenWidth
&& y >= 0 && (unsigned) y < screenHeight
&& "VL_Plot: Pixel out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
ptr[y * curPitch + x] = color;
VL_UnlockSurface(curSurface);
}
/*
=================
=
= VL_GetPixel
=
=================
*/
byte VL_GetPixel (int x, int y)
{
byte *ptr;
byte col;
assert_ret(x >= 0 && (unsigned) x < screenWidth
&& y >= 0 && (unsigned) y < screenHeight
&& "VL_GetPixel: Pixel out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return 0;
col = ((byte *) curSurface->pixels)[y * curPitch + x];
VL_UnlockSurface(curSurface);
return col;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin (unsigned x, unsigned y, unsigned width, int color)
{
byte *ptr;
assert(x >= 0 && x + width <= screenWidth
&& y >= 0 && y < screenHeight
&& "VL_Hlin: Destination rectangle out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
memset(ptr + y * curPitch + x, color, width);
VL_UnlockSurface(curSurface);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin (int x, int y, int height, int color)
{
byte *ptr;
assert(x >= 0 && (unsigned) x < screenWidth
&& y >= 0 && (unsigned) y + height <= screenHeight
&& "VL_Vlin: Destination rectangle out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
ptr += y * curPitch + x;
while (height--)
{
*ptr = color;
ptr += curPitch;
}
VL_UnlockSurface(curSurface);
}
/*
=================
=
= VL_Bar
=
=================
*/
void VL_BarScaledCoord (int scx, int scy, int scwidth, int scheight, int color)
{
byte *ptr;
assert(scx >= 0 && (unsigned) scx + scwidth <= screenWidth
&& scy >= 0 && (unsigned) scy + scheight <= screenHeight
&& "VL_BarScaledCoord: Destination rectangle out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
ptr += scy * curPitch + scx;
while (scheight--)
{
memset(ptr, color, scwidth);
ptr += curPitch;
}
VL_UnlockSurface(curSurface);
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToLatch
=
=================
*/
void VL_MemToLatch(byte *source, int width, int height,
SDL_Surface *destSurface, int x, int y)
{
byte *ptr;
int xsrc, ysrc, pitch;
assert(x >= 0 && (unsigned) x + width <= screenWidth
&& y >= 0 && (unsigned) y + height <= screenHeight
&& "VL_MemToLatch: Destination rectangle out of bounds!");
ptr = VL_LockSurface(destSurface);
if(ptr == NULL) return;
pitch = destSurface->pitch;
ptr += y * pitch + x;
for(ysrc = 0; ysrc < height; ysrc++)
{
for(xsrc = 0; xsrc < width; xsrc++)
{
ptr[ysrc * pitch + xsrc] = source[(ysrc * (width >> 2) + (xsrc >> 2))
+ (xsrc & 3) * (width >> 2) * height];
}
}
VL_UnlockSurface(destSurface);
}
//===========================================================================
/*
=================
=
= VL_MemToScreenScaledCoord
=
= Draws a block of data to the screen with scaling according to scaleFactor.
=
=================
*/
void VL_MemToScreenScaledCoord (byte *source, int width, int height, int destx, int desty)
{
byte *ptr;
int i, j, sci, scj;
unsigned m, n;
assert(destx >= 0 && destx + width * scaleFactor <= screenWidth
&& desty >= 0 && desty + height * scaleFactor <= screenHeight
&& "VL_MemToScreenScaledCoord: Destination rectangle out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
for(j = 0, scj = 0; j < height; j++, scj += scaleFactor)
{
for(i = 0, sci = 0; i < width; i++, sci += scaleFactor)
{
byte col = source[(j * (width >> 2) + (i >> 2)) + (i & 3) * (width >> 2) * height];
for(m = 0; m < scaleFactor; m++)
{
for(n = 0; n < scaleFactor; n++)
{
ptr[(scj + m + desty) * curPitch + sci + n + destx] = col;
}
}
}
}
VL_UnlockSurface(curSurface);
}
/*
=================
=
= VL_MemToScreenScaledCoord
=
= Draws a part of a block of data to the screen.
= The block has the size origwidth*origheight.
= The part at (srcx, srcy) has the size width*height
= and will be painted to (destx, desty) with scaling according to scaleFactor.
=
=================
*/
void VL_MemToScreenScaledCoord (byte *source, int origwidth, int origheight, int srcx, int srcy,
int destx, int desty, int width, int height)
{
byte *ptr;
int i, j, sci, scj;
unsigned m, n;
assert(destx >= 0 && destx + width * scaleFactor <= screenWidth
&& desty >= 0 && desty + height * scaleFactor <= screenHeight
&& "VL_MemToScreenScaledCoord: Destination rectangle out of bounds!");
ptr = VL_LockSurface(curSurface);
if(ptr == NULL) return;
for(j = 0, scj = 0; j < height; j++, scj += scaleFactor)
{
for(i = 0, sci = 0; i < width; i++, sci += scaleFactor)
{
byte col = source[((j + srcy) * (origwidth >> 2) + ((i + srcx) >>2 ))
+ ((i + srcx) & 3) * (origwidth >> 2) * origheight];
for(m = 0; m < scaleFactor; m++)
{
for(n = 0; n < scaleFactor; n++)
{
ptr[(scj + m + desty) * curPitch + sci + n + destx] = col;
}
}
}
}
VL_UnlockSurface(curSurface);
}
//==========================================================================
/*
=================
=
= VL_LatchToScreen
=
=================
*/
void VL_LatchToScreenScaledCoord(SDL_Surface *source, int xsrc, int ysrc,
int width, int height, int scxdest, int scydest)
{
assert(scxdest >= 0 && scxdest + width * scaleFactor <= screenWidth
&& scydest >= 0 && scydest + height * scaleFactor <= screenHeight
&& "VL_LatchToScreenScaledCoord: Destination rectangle out of bounds!");
if(scaleFactor == 1)
{
// HACK: If screenBits is not 8 and the screen is faded out, the
// result will be black when using SDL_BlitSurface. The reason
// is that the logical palette needed for the transformation
// to the screen color depth is not equal to the logical
// palette of the latch (the latch is not faded). Therefore,
// SDL tries to map the colors...
// The result: All colors are mapped to black.
// So, we do the blit on our own...
if(screenBits != 8)
{
byte *src, *dest;
unsigned srcPitch;
int i, j;
src = VL_LockSurface(source);
if(src == NULL) return;
srcPitch = source->pitch;
dest = VL_LockSurface(curSurface);
if(dest == NULL) return;
for(j = 0; j < height; j++)
{
for(i = 0; i < width; i++)
{
byte col = src[(ysrc + j)*srcPitch + xsrc + i];
dest[(scydest + j) * curPitch + scxdest + i] = col;
}
}
VL_UnlockSurface(curSurface);
VL_UnlockSurface(source);
}
else
{
SDL_Rect srcrect = { xsrc, ysrc, width, height };
SDL_Rect destrect = { scxdest, scydest, 0, 0 }; // width and height are ignored
SDL_BlitSurface(source, &srcrect, curSurface, &destrect);
}
}
else
{
byte *src, *dest;
unsigned srcPitch;
int i, j, sci, scj;
unsigned m, n;
src = VL_LockSurface(source);
if(src == NULL) return;
srcPitch = source->pitch;
dest = VL_LockSurface(curSurface);
if(dest == NULL) return;
for(j = 0, scj = 0; j < height; j++, scj += scaleFactor)
{
for(i = 0, sci = 0; i < width; i++, sci += scaleFactor)
{
byte col = src[(ysrc + j)*srcPitch + xsrc + i];
for(m = 0; m < scaleFactor; m++)
{
for(n = 0; n < scaleFactor; n++)
{
dest[(scydest + scj + m) * curPitch + scxdest + sci + n] = col;
}
}
}
}
VL_UnlockSurface(curSurface);
VL_UnlockSurface(source);
}
}
//===========================================================================
/*
=================
=
= VL_ScreenToScreen
=
=================
*/
void VL_ScreenToScreen (SDL_Surface *source, SDL_Surface *dest)
{
SDL_BlitSurface(source, NULL, dest, NULL);
}

98
contrib/games/wolf3d/id_vl.h Executable file
View File

@ -0,0 +1,98 @@
// ID_VL.H
// wolf compatability
void Quit (const char *error,...);
//===========================================================================
#define CHARWIDTH 2
#define TILEWIDTH 4
//===========================================================================
extern SDL_Surface *screen, *screenBuffer, *curSurface;
extern boolean fullscreen, usedoublebuffering;
extern unsigned screenWidth, screenHeight, screenBits, screenPitch, bufferPitch, curPitch;
extern unsigned scaleFactor;
extern boolean screenfaded;
extern unsigned bordercolor;
extern SDL_Color gamepal[256];
//===========================================================================
//
// VGA hardware routines
//
#define VL_WaitVBL(a) SDL_Delay((a)*8)
void VL_SetVGAPlaneMode (void);
void VL_SetTextMode (void);
void VL_Shutdown (void);
void VL_ConvertPalette(byte *srcpal, SDL_Color *destpal, int numColors);
void VL_FillPalette (int red, int green, int blue);
void VL_SetColor (int color, int red, int green, int blue);
void VL_GetColor (int color, int *red, int *green, int *blue);
void VL_SetPalette (SDL_Color *palette, bool forceupdate);
void VL_GetPalette (SDL_Color *palette);
void VL_FadeOut (int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn (int start, int end, SDL_Color *palette, int steps);
byte *VL_LockSurface(SDL_Surface *surface);
void VL_UnlockSurface(SDL_Surface *surface);
byte VL_GetPixel (int x, int y);
void VL_Plot (int x, int y, int color);
void VL_Hlin (unsigned x, unsigned y, unsigned width, int color);
void VL_Vlin (int x, int y, int height, int color);
void VL_BarScaledCoord (int scx, int scy, int scwidth, int scheight, int color);
void inline VL_Bar (int x, int y, int width, int height, int color)
{
VL_BarScaledCoord(scaleFactor*x, scaleFactor*y,
scaleFactor*width, scaleFactor*height, color);
}
void inline VL_ClearScreen(int color)
{
SDL_FillRect(curSurface, NULL, color);
}
void VL_MungePic (byte *source, unsigned width, unsigned height);
void VL_DrawPicBare (int x, int y, byte *pic, int width, int height);
void VL_MemToLatch (byte *source, int width, int height,
SDL_Surface *destSurface, int x, int y);
void VL_ScreenToScreen (SDL_Surface *source, SDL_Surface *dest);
void VL_MemToScreenScaledCoord (byte *source, int width, int height, int scx, int scy);
void VL_MemToScreenScaledCoord (byte *source, int origwidth, int origheight, int srcx, int srcy,
int destx, int desty, int width, int height);
void inline VL_MemToScreen (byte *source, int width, int height, int x, int y)
{
VL_MemToScreenScaledCoord(source, width, height,
scaleFactor*x, scaleFactor*y);
}
void VL_MaskedToScreen (byte *source, int width, int height, int x, int y);
void VL_LatchToScreenScaledCoord (SDL_Surface *source, int xsrc, int ysrc,
int width, int height, int scxdest, int scydest);
void inline VL_LatchToScreen (SDL_Surface *source, int xsrc, int ysrc,
int width, int height, int xdest, int ydest)
{
VL_LatchToScreenScaledCoord(source,xsrc,ysrc,width,height,
scaleFactor*xdest,scaleFactor*ydest);
}
void inline VL_LatchToScreenScaledCoord (SDL_Surface *source, int scx, int scy)
{
VL_LatchToScreenScaledCoord(source,0,0,source->w,source->h,scx,scy);
}
void inline VL_LatchToScreen (SDL_Surface *source, int x, int y)
{
VL_LatchToScreenScaledCoord(source,0,0,source->w,source->h,
scaleFactor*x,scaleFactor*y);
}

View File

@ -0,0 +1,156 @@
/// JOYSTICK STUB FOR Wolfenstein 3D port to KolibriOS
/// Ported by maxcodehack
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/** @file SDL_joystick.h
* @note In order to use these functions, SDL_Init() must have been called
* with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
* for joysticks, and load appropriate drivers.
*/
/** The joystick structure used to identify an SDL joystick */
struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick;
/* Function prototypes */
/**
* Count the number of joysticks attached to the system
*/
int SDL_NumJoysticks(void){};
/**
* Get the implementation dependent name of a joystick.
*
* This can be called before any joysticks are opened.
* If no name can be found, this function returns NULL.
*/
const char * SDL_JoystickName(int device_index){};
/**
* Open a joystick for use.
*
* @param[in] device_index
* The index passed as an argument refers to
* the N'th joystick on the system. This index is the value which will
* identify this joystick in future joystick events.
*
* @return This function returns a joystick identifier, or NULL if an error occurred.
*/
SDL_Joystick * SDL_JoystickOpen(int device_index){};
/**
* Returns 1 if the joystick has been opened, or 0 if it has not.
*/
int SDL_JoystickOpened(int device_index){};
/**
* Get the device index of an opened joystick.
*/
int SDL_JoystickIndex(SDL_Joystick *joystick){};
/**
* Get the number of general axis controls on a joystick
*/
int SDL_JoystickNumAxes(SDL_Joystick *joystick){};
/**
* Get the number of trackballs on a joystick
*
* Joystick trackballs have only relative motion events associated
* with them and their state cannot be polled.
*/
int SDL_JoystickNumBalls(SDL_Joystick *joystick){};
/**
* Get the number of POV hats on a joystick
*/
int SDL_JoystickNumHats(SDL_Joystick *joystick){};
/**
* Get the number of buttons on a joystick
*/
int SDL_JoystickNumButtons(SDL_Joystick *joystick){};
/**
* Update the current state of the open joysticks.
*
* This is called automatically by the event loop if any joystick
* events are enabled.
*/
void SDL_JoystickUpdate(void){};
/**
* Enable/disable joystick event polling.
*
* If joystick events are disabled, you must call SDL_JoystickUpdate()
* yourself and check the state of the joystick when you want joystick
* information.
*
* @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
*/
int SDL_JoystickEventState(int state){};
/**
* Get the current state of an axis control on a joystick
*
* @param[in] axis The axis indices start at index 0.
*
* @return The state is a value ranging from -32768 to 32767.
*/
int SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis){};
/**
* @name Hat Positions
* The return value of SDL_JoystickGetHat() is one of the following positions:
*/
/*@{*/
#define SDL_HAT_CENTERED 0x00
#define SDL_HAT_UP 0x01
#define SDL_HAT_RIGHT 0x02
#define SDL_HAT_DOWN 0x04
#define SDL_HAT_LEFT 0x08
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
/*@}*/
/**
* Get the current state of a POV hat on a joystick
*
* @param[in] hat The hat indices start at index 0.
*/
int SDL_JoystickGetHat(SDL_Joystick *joystick, int hat){};
/**
* Get the ball axis change since the last poll
*
* @param[in] ball The ball indices start at index 0.
*
* @return This returns 0, or -1 if you passed it invalid parameters.
*/
int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy){};
/**
* Get the current state of a button on a joystick
*
* @param[in] button The button indices start at index 0.
*/
int SDL_JoystickGetButton(SDL_Joystick *joystick, int button){};
/**
* Close a joystick previously opened with SDL_JoystickOpen()
*/
void SDL_JoystickClose(SDL_Joystick *joystick){};
bool mkdir(const char* dir){};
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,378 @@
#ifdef _WIN32
/*
SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98
Modified to write stdout/stderr to a message box at shutdown by Ripper 2007-12-27
The WinMain function -- calls your program's main() function
*/
#include <stdio.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef _WIN32_WCE
# define DIR_SEPERATOR TEXT("\\")
# undef _getcwd
# define _getcwd(str,len) wcscpy(str,TEXT(""))
# define setbuf(f,b)
# define setvbuf(w,x,y,z)
# define fopen _wfopen
# define freopen _wfreopen
# define remove(x) DeleteFile(x)
#else
# define DIR_SEPERATOR TEXT("/")
# include <direct.h>
#endif
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
#ifdef main
# ifndef _WIN32_WCE_EMULATION
# undef main
# endif /* _WIN32_WCE_EMULATION */
#endif /* main */
/* The standard output files */
#define STDOUT_FILE TEXT("stdout.txt")
#define STDERR_FILE TEXT("stderr.txt")
#ifndef NO_STDIO_REDIRECT
# ifdef _WIN32_WCE
static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];
# else
static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];
# endif
#endif
#if defined(_WIN32_WCE) && _WIN32_WCE < 300
/* seems to be undefined in Win CE although in online help */
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
#endif /* _WIN32_WCE < 300 */
/* Parse a command line buffer into arguments */
static int ParseCommandLine(char *cmdline, char **argv)
{
char *bufp;
int argc;
argc = 0;
for ( bufp = cmdline; *bufp; ) {
/* Skip leading whitespace */
while ( isspace(*bufp) ) {
++bufp;
}
/* Skip over argument */
if ( *bufp == '"' ) {
++bufp;
if ( *bufp ) {
if ( argv ) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
while ( *bufp && (*bufp != '"') ) {
++bufp;
}
} else {
if ( *bufp ) {
if ( argv ) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
while ( *bufp && ! isspace(*bufp) ) {
++bufp;
}
}
if ( *bufp ) {
if ( argv ) {
*bufp = '\0';
}
++bufp;
}
}
if ( argv ) {
argv[argc] = NULL;
}
return(argc);
}
/* Show an error message */
static void ShowError(const char *title, const char *message)
{
/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
#ifdef USE_MESSAGEBOX
MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK);
#else
fprintf(stderr, "%s: %s\n", title, message);
#endif
}
/* Pop up an out of memory message, returns to Windows */
static BOOL OutOfMemory(void)
{
ShowError("Fatal Error", "Out of memory - aborting");
return FALSE;
}
/* SDL_Quit() shouldn't be used with atexit() directly because
calling conventions may differ... */
static void cleanup(void)
{
SDL_Quit();
}
/* Remove the output files if there was no output written */
static void cleanup_output(void)
{
#if 1
#ifndef NO_STDIO_REDIRECT
FILE *file;
#endif
#endif
/* Flush the output in case anything is queued */
fclose(stdout);
fclose(stderr);
#if 1
#ifndef NO_STDIO_REDIRECT
/* See if the files have any output in them */
if ( stdoutPath[0] ) {
file = fopen(stdoutPath, TEXT("r"));
if ( file ) {
char buf[16384];
size_t readbytes = fread(buf, 1, 16383, file);
fclose(file);
if(readbytes != 0)
{
buf[readbytes] = 0; // cut after last byte (<=16383)
MessageBox(NULL, buf, "Wolf4SDL", MB_OK);
}
else
remove(stdoutPath); // remove empty file
}
}
if ( stderrPath[0] ) {
file = fopen(stderrPath, TEXT("rb"));
if ( file ) {
char buf[16384];
size_t readbytes = fread(buf, 1, 16383, file);
fclose(file);
if(readbytes != 0)
{
buf[readbytes] = 0; // cut after last byte (<=16383)
MessageBox(NULL, buf, "Wolf4SDL", MB_OK);
}
else
remove(stderrPath); // remove empty file
}
}
#endif
#endif
}
//#if defined(_MSC_VER) && !defined(_WIN32_WCE)
///* The VC++ compiler needs main defined */
//#define console_main main
//#endif
/* This is where execution begins [console apps] */
int console_main(int argc, char *argv[])
{
size_t n;
char *bufp, *appname;
int status;
/* Get the class name from argv[0] */
appname = argv[0];
if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) {
appname = bufp+1;
} else
if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) {
appname = bufp+1;
}
if ( (bufp=SDL_strrchr(appname, '.')) == NULL )
n = SDL_strlen(appname);
else
n = (bufp-appname);
bufp = SDL_stack_alloc(char, n+1);
if ( bufp == NULL ) {
return OutOfMemory();
}
SDL_strlcpy(bufp, appname, n+1);
appname = bufp;
/* Load SDL dynamic link library */
if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
ShowError("WinMain() error", SDL_GetError());
return(FALSE);
}
atexit(cleanup_output);
atexit(cleanup);
/* Sam:
We still need to pass in the application handle so that
DirectInput will initialize properly when SDL_RegisterApp()
is called later in the video initialization.
*/
SDL_SetModuleHandle(GetModuleHandle(NULL));
/* Run the application main() code */
status = SDL_main(argc, argv);
/* Exit cleanly, calling atexit() functions */
exit(status);
/* Hush little compiler, don't you cry... */
return 0;
}
/* This is where execution begins [windowed apps] */
#ifdef _WIN32_WCE
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw)
#else
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
HINSTANCE handle;
char **argv;
int argc;
char *cmdline;
#ifdef _WIN32_WCE
wchar_t *bufp;
int nLen;
#else
char *bufp;
size_t nLen;
#endif
#ifndef NO_STDIO_REDIRECT
DWORD pathlen;
#ifdef _WIN32_WCE
wchar_t path[MAX_PATH];
#else
char path[MAX_PATH];
#endif
FILE *newfp;
#endif
/* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
keep them open. This is a hack.. hopefully it will be fixed
someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded.
*/
handle = LoadLibrary(TEXT("DDRAW.DLL"));
if ( handle != NULL ) {
FreeLibrary(handle);
}
#ifndef NO_STDIO_REDIRECT
pathlen = GetModuleFileName(NULL, path, SDL_arraysize(path));
while ( pathlen > 0 && path[pathlen] != '\\' ) {
--pathlen;
}
path[pathlen] = '\0';
#ifdef _WIN32_WCE
wcsncpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
wcsncat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
#else
SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
#endif
/* Redirect standard input and standard output */
newfp = freopen(stdoutPath, TEXT("w"), stdout);
#ifndef _WIN32_WCE
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stdout)
stdout = fopen(stdoutPath, TEXT("w"));
#else
newfp = fopen(stdoutPath, TEXT("w"));
if ( newfp ) {
*stdout = *newfp;
}
#endif
}
#endif /* _WIN32_WCE */
#ifdef _WIN32_WCE
wcsncpy( stderrPath, path, SDL_arraysize(stdoutPath) );
wcsncat( stderrPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
#else
SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) );
SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) );
#endif
newfp = freopen(stderrPath, TEXT("w"), stderr);
#ifndef _WIN32_WCE
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stderr)
stderr = fopen(stderrPath, TEXT("w"));
#else
newfp = fopen(stderrPath, TEXT("w"));
if ( newfp ) {
*stderr = *newfp;
}
#endif
}
#endif /* _WIN32_WCE */
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */
setbuf(stderr, NULL); /* No buffering */
#endif /* !NO_STDIO_REDIRECT */
#ifdef _WIN32_WCE
nLen = wcslen(szCmdLine)+128+1;
bufp = SDL_stack_alloc(wchar_t, nLen*2);
wcscpy (bufp, TEXT("\""));
GetModuleFileName(NULL, bufp+1, 128-3);
wcscpy (bufp+wcslen(bufp), TEXT("\" "));
wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
nLen = wcslen(bufp)+1;
cmdline = SDL_stack_alloc(char, nLen);
if ( cmdline == NULL ) {
return OutOfMemory();
}
WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
#else
/* Grab the command line */
bufp = GetCommandLine();
nLen = SDL_strlen(bufp)+1;
cmdline = SDL_stack_alloc(char, nLen);
if ( cmdline == NULL ) {
return OutOfMemory();
}
SDL_strlcpy(cmdline, bufp, nLen);
#endif
/* Parse it into argv and argc */
argc = ParseCommandLine(cmdline, NULL);
argv = SDL_stack_alloc(char*, argc+1);
if ( argv == NULL ) {
return OutOfMemory();
}
ParseCommandLine(cmdline, argv);
/* Run the main program (after a little SDL initialization) */
console_main(argc, argv);
/* Hush little compiler, don't you cry... */
return 0;
}
#endif // _WIN32

8007
contrib/games/wolf3d/signon.cpp Executable file

File diff suppressed because it is too large Load Diff

52
contrib/games/wolf3d/sodpal.inc Executable file
View File

@ -0,0 +1,52 @@
RGB( 0, 0, 0),RGB( 0, 0, 42),RGB( 0, 42, 0),RGB( 0, 42, 42),RGB( 42, 0, 0),
RGB( 42, 0, 42),RGB( 42, 21, 0),RGB( 42, 42, 42),RGB( 21, 21, 21),RGB( 21, 21, 63),
RGB( 21, 63, 21),RGB( 21, 63, 63),RGB( 63, 21, 21),RGB( 63, 21, 63),RGB( 63, 63, 21),
RGB( 63, 63, 63),RGB( 59, 59, 59),RGB( 55, 55, 55),RGB( 52, 52, 52),RGB( 48, 48, 48),
RGB( 45, 45, 45),RGB( 42, 42, 42),RGB( 38, 38, 38),RGB( 35, 35, 35),RGB( 31, 31, 31),
RGB( 28, 28, 28),RGB( 25, 25, 25),RGB( 21, 21, 21),RGB( 18, 18, 18),RGB( 14, 14, 14),
RGB( 11, 11, 11),RGB( 8, 8, 8),RGB( 63, 0, 0),RGB( 59, 0, 0),RGB( 56, 0, 0),
RGB( 53, 0, 0),RGB( 50, 0, 0),RGB( 47, 0, 0),RGB( 44, 0, 0),RGB( 41, 0, 0),
RGB( 38, 0, 0),RGB( 34, 0, 0),RGB( 31, 0, 0),RGB( 28, 0, 0),RGB( 25, 0, 0),
RGB( 22, 0, 0),RGB( 19, 0, 0),RGB( 16, 0, 0),RGB( 63, 54, 54),RGB( 63, 46, 46),
RGB( 63, 39, 39),RGB( 63, 31, 31),RGB( 63, 23, 23),RGB( 63, 16, 16),RGB( 63, 8, 8),
RGB( 63, 0, 0),RGB( 63, 42, 23),RGB( 63, 38, 16),RGB( 63, 34, 8),RGB( 63, 30, 0),
RGB( 57, 27, 0),RGB( 51, 24, 0),RGB( 45, 21, 0),RGB( 39, 19, 0),RGB( 63, 63, 54),
RGB( 63, 63, 46),RGB( 63, 63, 39),RGB( 63, 63, 31),RGB( 63, 62, 23),RGB( 63, 61, 16),
RGB( 63, 61, 8),RGB( 63, 61, 0),RGB( 57, 54, 0),RGB( 51, 49, 0),RGB( 45, 43, 0),
RGB( 39, 39, 0),RGB( 33, 33, 0),RGB( 28, 27, 0),RGB( 22, 21, 0),RGB( 16, 16, 0),
RGB( 52, 63, 23),RGB( 49, 63, 16),RGB( 45, 63, 8),RGB( 40, 63, 0),RGB( 36, 57, 0),
RGB( 32, 51, 0),RGB( 29, 45, 0),RGB( 24, 39, 0),RGB( 54, 63, 54),RGB( 47, 63, 46),
RGB( 39, 63, 39),RGB( 32, 63, 31),RGB( 24, 63, 23),RGB( 16, 63, 16),RGB( 8, 63, 8),
RGB( 0, 63, 0),RGB( 0, 63, 0),RGB( 0, 59, 0),RGB( 0, 56, 0),RGB( 0, 53, 0),
RGB( 1, 50, 0),RGB( 1, 47, 0),RGB( 1, 44, 0),RGB( 1, 41, 0),RGB( 1, 38, 0),
RGB( 1, 34, 0),RGB( 1, 31, 0),RGB( 1, 28, 0),RGB( 1, 25, 0),RGB( 1, 22, 0),
RGB( 1, 19, 0),RGB( 1, 16, 0),RGB( 54, 63, 63),RGB( 46, 63, 63),RGB( 39, 63, 63),
RGB( 31, 63, 62),RGB( 23, 63, 63),RGB( 16, 63, 63),RGB( 8, 63, 63),RGB( 0, 63, 63),
RGB( 0, 57, 57),RGB( 0, 51, 51),RGB( 0, 45, 45),RGB( 0, 39, 39),RGB( 0, 33, 33),
RGB( 0, 28, 28),RGB( 0, 22, 22),RGB( 0, 16, 16),RGB( 23, 47, 63),RGB( 16, 44, 63),
RGB( 8, 42, 63),RGB( 0, 39, 63),RGB( 0, 35, 57),RGB( 0, 31, 51),RGB( 0, 27, 45),
RGB( 0, 23, 39),RGB( 54, 54, 63),RGB( 46, 47, 63),RGB( 39, 39, 63),RGB( 31, 32, 63),
RGB( 23, 24, 63),RGB( 16, 16, 63),RGB( 8, 9, 63),RGB( 0, 1, 63),RGB( 0, 0, 63),
RGB( 0, 0, 59),RGB( 0, 0, 56),RGB( 0, 0, 53),RGB( 0, 0, 50),RGB( 0, 0, 47),
RGB( 0, 0, 44),RGB( 0, 0, 41),RGB( 0, 0, 38),RGB( 0, 0, 34),RGB( 0, 0, 31),
RGB( 0, 0, 28),RGB( 0, 0, 25),RGB( 0, 0, 22),RGB( 0, 0, 19),RGB( 0, 0, 16),
RGB( 10, 10, 10),RGB( 63, 56, 13),RGB( 63, 53, 9),RGB( 63, 51, 6),RGB( 63, 48, 2),
RGB( 63, 45, 0),RGB( 0, 14, 0),RGB( 0, 10, 0),RGB( 38, 0, 57),RGB( 32, 0, 51),
RGB( 29, 0, 45),RGB( 24, 0, 39),RGB( 20, 0, 33),RGB( 17, 0, 28),RGB( 13, 0, 22),
RGB( 10, 0, 16),RGB( 63, 54, 63),RGB( 63, 46, 63),RGB( 63, 39, 63),RGB( 63, 31, 63),
RGB( 63, 23, 63),RGB( 63, 16, 63),RGB( 63, 8, 63),RGB( 63, 0, 63),RGB( 56, 0, 57),
RGB( 50, 0, 51),RGB( 45, 0, 45),RGB( 39, 0, 39),RGB( 33, 0, 33),RGB( 27, 0, 28),
RGB( 22, 0, 22),RGB( 16, 0, 16),RGB( 63, 58, 55),RGB( 63, 56, 52),RGB( 63, 54, 49),
RGB( 63, 53, 47),RGB( 63, 51, 44),RGB( 63, 49, 41),RGB( 63, 47, 39),RGB( 63, 46, 36),
RGB( 63, 44, 32),RGB( 63, 41, 28),RGB( 63, 39, 24),RGB( 60, 37, 23),RGB( 58, 35, 22),
RGB( 55, 34, 21),RGB( 52, 32, 20),RGB( 50, 31, 19),RGB( 47, 30, 18),RGB( 45, 28, 17),
RGB( 42, 26, 16),RGB( 40, 25, 15),RGB( 39, 24, 14),RGB( 36, 23, 13),RGB( 34, 22, 12),
RGB( 32, 20, 11),RGB( 29, 19, 10),RGB( 27, 18, 9),RGB( 23, 16, 8),RGB( 21, 15, 7),
RGB( 18, 14, 6),RGB( 16, 12, 6),RGB( 14, 11, 5),RGB( 10, 8, 3),RGB( 24, 0, 25),
RGB( 0, 25, 25),RGB( 0, 24, 24),RGB( 0, 0, 7),RGB( 0, 0, 11),RGB( 12, 9, 4),
RGB( 18, 0, 18),RGB( 20, 0, 20),RGB( 0, 0, 13),RGB( 7, 7, 7),RGB( 19, 19, 19),
RGB( 23, 23, 23),RGB( 16, 16, 16),RGB( 12, 12, 12),RGB( 13, 13, 13),RGB( 54, 61, 61),
RGB( 46, 58, 58),RGB( 39, 55, 55),RGB( 29, 50, 50),RGB( 18, 48, 48),RGB( 8, 45, 45),
RGB( 8, 44, 44),RGB( 0, 41, 41),RGB( 0, 38, 38),RGB( 0, 35, 35),RGB( 0, 33, 33),
RGB( 0, 31, 31),RGB( 0, 30, 30),RGB( 0, 29, 29),RGB( 0, 28, 28),RGB( 0, 27, 27),
RGB( 38, 0, 34)

54
contrib/games/wolf3d/version.h Executable file
View File

@ -0,0 +1,54 @@
#ifndef _VERSION_H_
#define _VERSION_H_
#ifndef VERSIONALREADYCHOSEN // used for batch compiling
/* Defines used for different versions */
//#define SPEAR
//#define SPEARDEMO
//#define UPLOAD
#define GOODTIMES
#define CARMACIZED
//#define APOGEE_1_0
//#define APOGEE_1_1
//#define APOGEE_1_2
//#define JAPAN
/*
Wolf3d Full v1.1 Apogee (with ReadThis) - define CARMACIZED and APOGEE_1_1
Wolf3d Full v1.4 Apogee (with ReadThis) - define CARMACIZED
Wolf3d Full v1.4 GT/ID/Activision - define CARMACIZED and GOODTIMES
Wolf3d Full v1.4 Imagineer (Japanese) - define CARMACIZED and JAPAN
Wolf3d Shareware v1.0 - define UPLOAD and APOGEE_1_0
Wolf3d Shareware v1.1 - define CARMACIZED and UPLOAD and APOGEE_1_1
Wolf3d Shareware v1.2 - define CARMACIZED and UPLOAD and APOGEE_1_2
Wolf3d Shareware v1.4 - define CARMACIZED and UPLOAD
Spear of Destiny Full and Mission Disks - define CARMACIZED and SPEAR
(and GOODTIMES for no FormGen quiz)
Spear of Destiny Demo - define CARMACIZED and SPEAR and SPEARDEMO
*/
#endif
//#define USE_FEATUREFLAGS // Enables the level feature flags (see bottom of wl_def.h)
//#define USE_SHADING // Enables shading support (see wl_shade.cpp)
//#define USE_DIR3DSPR // Enables directional 3d sprites (see wl_dir3dspr.cpp)
//#define USE_FLOORCEILINGTEX // Enables floor and ceiling textures stored in the third mapplane (see wl_floorceiling.cpp)
//#define USE_HIRES // Enables high resolution textures/sprites (128x128)
//#define USE_PARALLAX 16 // Enables parallax sky with 16 textures per sky (see wl_parallax.cpp)
//#define USE_CLOUDSKY // Enables cloud sky support (see wl_cloudsky.cpp)
//#define USE_STARSKY // Enables star sky support (see wl_atmos.cpp)
//#define USE_RAIN // Enables rain support (see wl_atmos.cpp)
//#define USE_SNOW // Enables snow support (see wl_atmos.cpp)
//#define FIXRAINSNOWLEAKS // Enables leaking ceilings fix (by Adam Biser, only needed if maps with rain/snow and ceilings exist)
#define DEBUGKEYS // Comment this out to compile without the Tab debug keys
#define ARTSEXTERN
#define DEMOSEXTERN
#define PLAYDEMOLIKEORIGINAL // When playing or recording demos, several bug fixes do not take
// effect to let the original demos work as in the original Wolf3D v1.4
// (actually better, as the second demo rarely worked)
//#define USE_GPL // Replaces the MAME OPL emulator by the DosBox one, which is under a GPL license
#endif

859
contrib/games/wolf3d/wl_act1.cpp Executable file
View File

@ -0,0 +1,859 @@
// WL_ACT1.C
#include "wl_def.h"
#pragma hdrstop
/*
=============================================================================
STATICS
=============================================================================
*/
statobj_t statobjlist[MAXSTATS];
statobj_t *laststatobj;
struct
{
short picnum;
wl_stat_t type;
uint32_t specialFlags; // they are ORed to the statobj_t flags
} statinfo[] =
{
{SPR_STAT_0}, // puddle spr1v
{SPR_STAT_1,block}, // Green Barrel "
{SPR_STAT_2,block}, // Table/chairs "
{SPR_STAT_3,block,FL_FULLBRIGHT}, // Floor lamp "
{SPR_STAT_4,none,FL_FULLBRIGHT}, // Chandelier "
{SPR_STAT_5,block}, // Hanged man "
{SPR_STAT_6,bo_alpo}, // Bad food "
{SPR_STAT_7,block}, // Red pillar "
//
// NEW PAGE
//
{SPR_STAT_8,block}, // Tree spr2v
{SPR_STAT_9}, // Skeleton flat "
{SPR_STAT_10,block}, // Sink " (SOD:gibs)
{SPR_STAT_11,block}, // Potted plant "
{SPR_STAT_12,block}, // Urn "
{SPR_STAT_13,block}, // Bare table "
{SPR_STAT_14,none,FL_FULLBRIGHT}, // Ceiling light "
#ifndef SPEAR
{SPR_STAT_15}, // Kitchen stuff "
#else
{SPR_STAT_15,block}, // Gibs!
#endif
//
// NEW PAGE
//
{SPR_STAT_16,block}, // suit of armor spr3v
{SPR_STAT_17,block}, // Hanging cage "
{SPR_STAT_18,block}, // SkeletoninCage "
{SPR_STAT_19}, // Skeleton relax "
{SPR_STAT_20,bo_key1}, // Key 1 "
{SPR_STAT_21,bo_key2}, // Key 2 "
{SPR_STAT_22,block}, // stuff (SOD:gibs)
{SPR_STAT_23}, // stuff
//
// NEW PAGE
//
{SPR_STAT_24,bo_food}, // Good food spr4v
{SPR_STAT_25,bo_firstaid}, // First aid "
{SPR_STAT_26,bo_clip}, // Clip "
{SPR_STAT_27,bo_machinegun}, // Machine gun "
{SPR_STAT_28,bo_chaingun}, // Gatling gun "
{SPR_STAT_29,bo_cross}, // Cross "
{SPR_STAT_30,bo_chalice}, // Chalice "
{SPR_STAT_31,bo_bible}, // Bible "
//
// NEW PAGE
//
{SPR_STAT_32,bo_crown}, // crown spr5v
{SPR_STAT_33,bo_fullheal,FL_FULLBRIGHT},// one up "
{SPR_STAT_34,bo_gibs}, // gibs "
{SPR_STAT_35,block}, // barrel "
{SPR_STAT_36,block}, // well "
{SPR_STAT_37,block}, // Empty well "
{SPR_STAT_38,bo_gibs}, // Gibs 2 "
{SPR_STAT_39,block}, // flag "
//
// NEW PAGE
//
#ifndef SPEAR
{SPR_STAT_40,block}, // Call Apogee spr7v
#else
{SPR_STAT_40}, // Red light
#endif
//
// NEW PAGE
//
{SPR_STAT_41}, // junk "
{SPR_STAT_42}, // junk "
{SPR_STAT_43}, // junk "
#ifndef SPEAR
{SPR_STAT_44}, // pots "
#else
{SPR_STAT_44,block}, // Gibs!
#endif
{SPR_STAT_45,block}, // stove " (SOD:gibs)
{SPR_STAT_46,block}, // spears " (SOD:gibs)
{SPR_STAT_47}, // vines "
//
// NEW PAGE
//
#ifdef SPEAR
{SPR_STAT_48,block}, // marble pillar
{SPR_STAT_49,bo_25clip}, // bonus 25 clip
{SPR_STAT_50,block}, // truck
{SPR_STAT_51,bo_spear}, // SPEAR OF DESTINY!
#endif
{SPR_STAT_26,bo_clip2}, // Clip "
#ifdef USE_DIR3DSPR
// These are just two examples showing the new way of using dir 3d sprites.
// You can find the allowed values in the objflag_t enum in wl_def.h.
{SPR_STAT_47,none,FL_DIR_VERT_MID},
{SPR_STAT_47,block,FL_DIR_HORIZ_MID},
#endif
{-1} // terminator
};
/*
===============
=
= InitStaticList
=
===============
*/
void InitStaticList (void)
{
laststatobj = &statobjlist[0];
}
/*
===============
=
= SpawnStatic
=
===============
*/
void SpawnStatic (int tilex, int tiley, int type)
{
laststatobj->shapenum = statinfo[type].picnum;
laststatobj->tilex = tilex;
laststatobj->tiley = tiley;
laststatobj->visspot = &spotvis[tilex][tiley];
switch (statinfo[type].type)
{
case block:
actorat[tilex][tiley] = (objtype *) 64; // consider it a blocking tile
case none:
laststatobj->flags = 0;
break;
case bo_cross:
case bo_chalice:
case bo_bible:
case bo_crown:
case bo_fullheal:
if (!loadedgame)
gamestate.treasuretotal++;
case bo_firstaid:
case bo_key1:
case bo_key2:
case bo_key3:
case bo_key4:
case bo_clip:
case bo_25clip:
case bo_machinegun:
case bo_chaingun:
case bo_food:
case bo_alpo:
case bo_gibs:
case bo_spear:
laststatobj->flags = FL_BONUS;
laststatobj->itemnumber = statinfo[type].type;
break;
}
laststatobj->flags |= statinfo[type].specialFlags;
laststatobj++;
if (laststatobj == &statobjlist[MAXSTATS])
Quit ("Too many static objects!\n");
}
/*
===============
=
= PlaceItemType
=
= Called during game play to drop actors' items. It finds the proper
= item number based on the item type (bo_???). If there are no free item
= spots, nothing is done.
=
===============
*/
void PlaceItemType (int itemtype, int tilex, int tiley)
{
int type;
statobj_t *spot;
//
// find the item number
//
for (type=0; ; type++)
{
if (statinfo[type].picnum == -1) // end of list
Quit ("PlaceItemType: couldn't find type!");
if (statinfo[type].type == itemtype)
break;
}
//
// find a spot in statobjlist to put it in
//
for (spot=&statobjlist[0]; ; spot++)
{
if (spot==laststatobj)
{
if (spot == &statobjlist[MAXSTATS])
return; // no free spots
laststatobj++; // space at end
break;
}
if (spot->shapenum == -1) // -1 is a free spot
break;
}
//
// place it
//
spot->shapenum = statinfo[type].picnum;
spot->tilex = tilex;
spot->tiley = tiley;
spot->visspot = &spotvis[tilex][tiley];
spot->flags = FL_BONUS | statinfo[type].specialFlags;
spot->itemnumber = statinfo[type].type;
}
/*
=============================================================================
DOORS
doorobjlist[] holds most of the information for the doors
doorposition[] holds the amount the door is open, ranging from 0 to 0xffff
this is directly accessed by AsmRefresh during rendering
The number of doors is limited to 64 because a spot in tilemap holds the
door number in the low 6 bits, with the high bit meaning a door center
and bit 6 meaning a door side tile
Open doors conect two areas, so sounds will travel between them and sight
will be checked when the player is in a connected area.
Areaconnect is incremented/decremented by each door. If >0 they connect
Every time a door opens or closes the areabyplayer matrix gets recalculated.
An area is true if it connects with the player's current spor.
=============================================================================
*/
#define DOORWIDTH 0x7800
#define OPENTICS 300
doorobj_t doorobjlist[MAXDOORS],*lastdoorobj;
short doornum;
word doorposition[MAXDOORS]; // leading edge of door 0=closed
// 0xffff = fully open
byte areaconnect[NUMAREAS][NUMAREAS];
boolean areabyplayer[NUMAREAS];
/*
==============
=
= ConnectAreas
=
= Scans outward from playerarea, marking all connected areas
=
==============
*/
void RecursiveConnect (int areanumber)
{
int i;
for (i=0;i<NUMAREAS;i++)
{
if (areaconnect[areanumber][i] && !areabyplayer[i])
{
areabyplayer[i] = true;
RecursiveConnect (i);
}
}
}
void ConnectAreas (void)
{
memset (areabyplayer,0,sizeof(areabyplayer));
areabyplayer[player->areanumber] = true;
RecursiveConnect (player->areanumber);
}
void InitAreas (void)
{
memset (areabyplayer,0,sizeof(areabyplayer));
if (player->areanumber < NUMAREAS)
areabyplayer[player->areanumber] = true;
}
/*
===============
=
= InitDoorList
=
===============
*/
void InitDoorList (void)
{
memset (areabyplayer,0,sizeof(areabyplayer));
memset (areaconnect,0,sizeof(areaconnect));
lastdoorobj = &doorobjlist[0];
doornum = 0;
}
/*
===============
=
= SpawnDoor
=
===============
*/
void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)
{
word *map;
if (doornum==MAXDOORS)
Quit ("64+ doors on level!");
doorposition[doornum] = 0; // doors start out fully closed
lastdoorobj->tilex = tilex;
lastdoorobj->tiley = tiley;
lastdoorobj->vertical = vertical;
lastdoorobj->lock = lock;
lastdoorobj->action = dr_closed;
actorat[tilex][tiley] = (objtype *)(uintptr_t)(doornum | 0x80); // consider it a solid wall
//
// make the door tile a special tile, and mark the adjacent tiles
// for door sides
//
tilemap[tilex][tiley] = doornum | 0x80;
map = mapsegs[0] + (tiley<<mapshift) +tilex;
if (vertical)
{
*map = *(map-1); // set area number
tilemap[tilex][tiley-1] |= 0x40;
tilemap[tilex][tiley+1] |= 0x40;
}
else
{
*map = *(map-mapwidth); // set area number
tilemap[tilex-1][tiley] |= 0x40;
tilemap[tilex+1][tiley] |= 0x40;
}
doornum++;
lastdoorobj++;
}
//===========================================================================
/*
=====================
=
= OpenDoor
=
=====================
*/
void OpenDoor (int door)
{
if (doorobjlist[door].action == dr_open)
doorobjlist[door].ticcount = 0; // reset open time
else
doorobjlist[door].action = dr_opening; // start it opening
}
/*
=====================
=
= CloseDoor
=
=====================
*/
void CloseDoor (int door)
{
int tilex,tiley,area;
objtype *check;
//
// don't close on anything solid
//
tilex = doorobjlist[door].tilex;
tiley = doorobjlist[door].tiley;
if (actorat[tilex][tiley])
return;
if (player->tilex == tilex && player->tiley == tiley)
return;
if (doorobjlist[door].vertical)
{
if ( player->tiley == tiley )
{
if ( ((player->x+MINDIST) >>TILESHIFT) == tilex )
return;
if ( ((player->x-MINDIST) >>TILESHIFT) == tilex )
return;
}
check = actorat[tilex-1][tiley];
if (ISPOINTER(check) && ((check->x+MINDIST) >> TILESHIFT) == tilex )
return;
check = actorat[tilex+1][tiley];
if (ISPOINTER(check) && ((check->x-MINDIST) >> TILESHIFT) == tilex )
return;
}
else if (!doorobjlist[door].vertical)
{
if (player->tilex == tilex)
{
if ( ((player->y+MINDIST) >>TILESHIFT) == tiley )
return;
if ( ((player->y-MINDIST) >>TILESHIFT) == tiley )
return;
}
check = actorat[tilex][tiley-1];
if (ISPOINTER(check) && ((check->y+MINDIST) >> TILESHIFT) == tiley )
return;
check = actorat[tilex][tiley+1];
if (ISPOINTER(check) && ((check->y-MINDIST) >> TILESHIFT) == tiley )
return;
}
//
// play door sound if in a connected area
//
area = *(mapsegs[0] + (doorobjlist[door].tiley<<mapshift)
+doorobjlist[door].tilex)-AREATILE;
if (areabyplayer[area])
{
PlaySoundLocTile(CLOSEDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley); // JAB
}
doorobjlist[door].action = dr_closing;
//
// make the door space solid
//
actorat[tilex][tiley] = (objtype *)(uintptr_t)(door | 0x80);
}
/*
=====================
=
= OperateDoor
=
= The player wants to change the door's direction
=
=====================
*/
void OperateDoor (int door)
{
int lock;
lock = doorobjlist[door].lock;
if (lock >= dr_lock1 && lock <= dr_lock4)
{
if ( ! (gamestate.keys & (1 << (lock-dr_lock1) ) ) )
{
SD_PlaySound (NOWAYSND); // locked
return;
}
}
switch (doorobjlist[door].action)
{
case dr_closed:
case dr_closing:
OpenDoor (door);
break;
case dr_open:
case dr_opening:
CloseDoor (door);
break;
}
}
//===========================================================================
/*
===============
=
= DoorOpen
=
= Close the door after three seconds
=
===============
*/
void DoorOpen (int door)
{
if ( (doorobjlist[door].ticcount += (short) tics) >= OPENTICS)
CloseDoor (door);
}
/*
===============
=
= DoorOpening
=
===============
*/
void DoorOpening (int door)
{
unsigned area1,area2;
word *map;
int32_t position;
position = doorposition[door];
if (!position)
{
//
// door is just starting to open, so connect the areas
//
map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift)
+doorobjlist[door].tilex;
if (doorobjlist[door].vertical)
{
area1 = *(map+1);
area2 = *(map-1);
}
else
{
area1 = *(map-mapwidth);
area2 = *(map+mapwidth);
}
area1 -= AREATILE;
area2 -= AREATILE;
if (area1 < NUMAREAS && area2 < NUMAREAS)
{
areaconnect[area1][area2]++;
areaconnect[area2][area1]++;
if (player->areanumber < NUMAREAS)
ConnectAreas ();
if (areabyplayer[area1])
PlaySoundLocTile(OPENDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley); // JAB
}
}
//
// slide the door by an adaptive amount
//
position += tics<<10;
if (position >= 0xffff)
{
//
// door is all the way open
//
position = 0xffff;
doorobjlist[door].ticcount = 0;
doorobjlist[door].action = dr_open;
actorat[doorobjlist[door].tilex][doorobjlist[door].tiley] = 0;
}
doorposition[door] = (word) position;
}
/*
===============
=
= DoorClosing
=
===============
*/
void DoorClosing (int door)
{
unsigned area1,area2;
word *map;
int32_t position;
int tilex,tiley;
tilex = doorobjlist[door].tilex;
tiley = doorobjlist[door].tiley;
if ( ((int)(uintptr_t)actorat[tilex][tiley] != (door | 0x80))
|| (player->tilex == tilex && player->tiley == tiley) )
{ // something got inside the door
OpenDoor (door);
return;
};
position = doorposition[door];
//
// slide the door by an adaptive amount
//
position -= tics<<10;
if (position <= 0)
{
//
// door is closed all the way, so disconnect the areas
//
position = 0;
doorobjlist[door].action = dr_closed;
map = mapsegs[0] + (doorobjlist[door].tiley<<mapshift) + doorobjlist[door].tilex;
if (doorobjlist[door].vertical)
{
area1 = *(map+1);
area2 = *(map-1);
}
else
{
area1 = *(map-mapwidth);
area2 = *(map+mapwidth);
}
area1 -= AREATILE;
area2 -= AREATILE;
if (area1 < NUMAREAS && area2 < NUMAREAS)
{
areaconnect[area1][area2]--;
areaconnect[area2][area1]--;
if (player->areanumber < NUMAREAS)
ConnectAreas ();
}
}
doorposition[door] = (word) position;
}
/*
=====================
=
= MoveDoors
=
= Called from PlayLoop
=
=====================
*/
void MoveDoors (void)
{
int door;
if (gamestate.victoryflag) // don't move door during victory sequence
return;
for (door = 0; door < doornum; door++)
{
switch (doorobjlist[door].action)
{
case dr_open:
DoorOpen (door);
break;
case dr_opening:
DoorOpening(door);
break;
case dr_closing:
DoorClosing(door);
break;
}
}
}
/*
=============================================================================
PUSHABLE WALLS
=============================================================================
*/
word pwallstate;
word pwallpos; // amount a pushable wall has been moved (0-63)
word pwallx,pwally;
byte pwalldir,pwalltile;
int dirs[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
/*
===============
=
= PushWall
=
===============
*/
void PushWall (int checkx, int checky, int dir)
{
int oldtile, dx, dy;
if (pwallstate)
return;
oldtile = tilemap[checkx][checky];
if (!oldtile)
return;
dx = dirs[dir][0];
dy = dirs[dir][1];
if (actorat[checkx+dx][checky+dy])
{
SD_PlaySound (NOWAYSND);
return;
}
actorat[checkx+dx][checky+dy] = (objtype *)(uintptr_t) (tilemap[checkx+dx][checky+dy] = oldtile);
gamestate.secretcount++;
pwallx = checkx;
pwally = checky;
pwalldir = dir;
pwallstate = 1;
pwallpos = 0;
pwalltile = tilemap[pwallx][pwally];
tilemap[pwallx][pwally] = 64;
tilemap[pwallx+dx][pwally+dy] = 64;
*(mapsegs[1]+(pwally<<mapshift)+pwallx) = 0; // remove P tile info
*(mapsegs[0]+(pwally<<mapshift)+pwallx) = *(mapsegs[0]+(player->tiley<<mapshift)+player->tilex); // set correct floorcode (BrotherTank's fix)
SD_PlaySound (PUSHWALLSND);
}
/*
=================
=
= MovePWalls
=
=================
*/
void MovePWalls (void)
{
int oldblock,oldtile;
if (!pwallstate)
return;
oldblock = pwallstate/128;
pwallstate += (word)tics;
if (pwallstate/128 != oldblock)
{
// block crossed into a new block
oldtile = pwalltile;
//
// the tile can now be walked into
//
tilemap[pwallx][pwally] = 0;
actorat[pwallx][pwally] = 0;
*(mapsegs[0]+(pwally<<mapshift)+pwallx) = player->areanumber+AREATILE;
int dx=dirs[pwalldir][0], dy=dirs[pwalldir][1];
//
// see if it should be pushed farther
//
if (pwallstate>=256) // only move two tiles fix
{
//
// the block has been pushed two tiles
//
pwallstate = 0;
tilemap[pwallx+dx][pwally+dy] = oldtile;
return;
}
else
{
int xl,yl,xh,yh;
xl = (player->x-PLAYERSIZE) >> TILESHIFT;
yl = (player->y-PLAYERSIZE) >> TILESHIFT;
xh = (player->x+PLAYERSIZE) >> TILESHIFT;
yh = (player->y+PLAYERSIZE) >> TILESHIFT;
pwallx += dx;
pwally += dy;
if (actorat[pwallx+dx][pwally+dy]
|| xl<=pwallx+dx && pwallx+dx<=xh && yl<=pwally+dy && pwally+dy<=yh)
{
pwallstate = 0;
tilemap[pwallx][pwally] = oldtile;
return;
}
actorat[pwallx+dx][pwally+dy] = (objtype *)(uintptr_t) (tilemap[pwallx+dx][pwally+dy] = oldtile);
tilemap[pwallx+dx][pwally+dy] = 64;
}
}
pwallpos = (pwallstate/2)&63;
}

3899
contrib/games/wolf3d/wl_act2.cpp Executable file

File diff suppressed because it is too large Load Diff

1500
contrib/games/wolf3d/wl_agent.cpp Executable file

File diff suppressed because it is too large Load Diff

229
contrib/games/wolf3d/wl_atmos.cpp Executable file
View File

@ -0,0 +1,229 @@
#include "version.h"
#if defined(USE_STARSKY) || defined(USE_RAIN) || defined(USE_SNOW)
#include "wl_def.h"
#if defined(USE_RAIN) || defined(USE_SNOW)
uint32_t rainpos = 0;
#endif
typedef struct {
int32_t x, y, z;
} point3d_t;
#define MAXPOINTS 400
point3d_t points[MAXPOINTS];
byte moon[100]={
0, 0, 27, 18, 15, 16, 19, 29, 0, 0,
0, 22, 16, 15, 15, 16, 16, 18, 24, 0,
27, 17, 15, 17, 16, 16, 17, 17, 18, 29,
18, 15, 15, 15, 16, 16, 17, 17, 18, 20,
16, 15, 15, 16, 16, 17, 17, 18, 19, 21,
16, 15, 17, 20, 18, 17, 18, 18, 20, 22,
19, 16, 18, 19, 17, 17, 18, 19, 22, 24,
28, 19, 17, 17, 17, 18, 19, 21, 25, 31,
0, 23, 18, 19, 18, 20, 22, 24, 28, 0,
0, 0, 28, 21, 20, 22, 28, 30, 0, 0 };
void Init3DPoints()
{
int hvheight = viewheight >> 1;
for(int i = 0; i < MAXPOINTS; i++)
{
point3d_t *pt = &points[i];
pt->x = 16384 - (rand() & 32767);
pt->z = 16384 - (rand() & 32767);
float len = sqrt((float)pt->x * pt->x + (float)pt->z * pt->z);
int j=50;
do
{
pt->y = 1024 + (rand() & 8191);
j--;
}
while(j > 0 && (float)pt->y * 256.F / len >= hvheight);
}
}
#endif
#ifdef USE_STARSKY
void DrawStarSky(byte *vbuf, uint32_t vbufPitch)
{
int hvheight = viewheight >> 1;
int hvwidth = viewwidth >> 1;
byte *ptr = vbuf;
int i;
for(i = 0; i < hvheight; i++, ptr += vbufPitch)
memset(ptr, 0, viewwidth);
for(i = 0; i < MAXPOINTS; i++)
{
point3d_t *pt = &points[i];
int32_t x = pt->x * viewcos + pt->z * viewsin;
int32_t y = pt->y << 16;
int32_t z = (pt->z * viewcos - pt->x * viewsin) >> 8;
if(z <= 0) continue;
int shade = z >> 18;
if(shade > 15) continue;
int32_t xx = x / z + hvwidth;
int32_t yy = hvheight - y / z;
if(xx >= 0 && xx < viewwidth && yy >= 0 && yy < hvheight)
vbuf[yy * vbufPitch + xx] = shade + 15;
}
int32_t x = 16384 * viewcos + 16384 * viewsin;
int32_t z = (16384 * viewcos - 16384 * viewsin) >> 8;
if(z <= 0) return;
int32_t xx = x / z + hvwidth;
int32_t yy = hvheight - ((hvheight - (hvheight >> 3)) << 22) / z;
if(xx > -10 && xx < viewwidth)
{
int stopx = 10, starty = 0, stopy = 10;
i = 0;
if(xx < 0) i = -xx;
if(xx > viewwidth - 11) stopx = viewwidth - xx;
if(yy < 0) startj = -yy;
if(yy > viewheight - 11) stopy = viewheight - yy;
for(; i < stopx; i++)
for(int j = starty; j < stopy; j++)
vbuf[(yy + j) * vbufPitch + xx + i] = moon[j * 10 + i];
}
}
#endif
#ifdef USE_RAIN
void DrawRain(byte *vbuf, uint32_t vbufPitch)
{
#if defined(USE_FLOORCEILINGTEX) && defined(FIXRAINSNOWLEAKS)
fixed dist; // distance to row projection
fixed tex_step; // global step per one screen pixel
fixed gu, gv, floorx, floory; // global texture coordinates
#endif
fixed px = (player->y + FixedMul(0x7900, viewsin)) >> 6;
fixed pz = (player->x - FixedMul(0x7900, viewcos)) >> 6;
int32_t ax, az, x, y, z, xx, yy, height, actheight;
int shade;
int hvheight = viewheight >> 1;
int hvwidth = viewwidth >> 1;
rainpos -= tics * 900;
for(int i = 0; i < MAXPOINTS; i++)
{
point3d_t *pt = &points[i];
ax = pt->x + px;
ax = 0x1fff - (ax & 0x3fff);
az = pt->z + pz;
az = 0x1fff - (az & 0x3fff);
x = ax * viewcos + az * viewsin;
y = -(heightnumerator << 7) + ((((pt->y << 6) + rainpos) & 0x0ffff) << 11);
z = (az * viewcos - ax * viewsin) >> 8;
if(z <= 0) continue;
shade = z >> 17;
if(shade > 13) continue;
xx = x / z + hvwidth;
if(xx < 0 || xx >= viewwidth) continue;
actheight = y / z;
yy = hvheight - actheight;
height = (heightnumerator << 10) / z;
if(actheight < 0) actheight = -actheight;
if(actheight < (wallheight[xx] >> 3) && height < wallheight[xx]) continue;
if(xx >= 0 && xx < viewwidth && yy > 0 && yy < viewheight)
{
#if defined(USE_FLOORCEILINGTEX) && defined(FIXRAINSNOWLEAKS)
// Find the rain's tile coordinate
// NOTE: This sometimes goes over the map edges.
dist = ((heightnumerator / ((height >> 3) + 1)) << 5);
gu = viewx + FixedMul(dist, viewcos);
gv = -viewy + FixedMul(dist, viewsin);
floorx = ( gu >> TILESHIFT ) & 63;
floory = (-(gv >> TILESHIFT) - 1) & 63;
// Is there a ceiling tile?
if(MAPSPOT(floorx, floory, 2) >> 8) continue;
#endif
vbuf[yy * vbufPitch + xx] = shade+15;
vbuf[(yy - 1) * vbufPitch + xx] = shade+16;
if(yy > 2)
vbuf[(yy - 2) * vbufPitch + xx] = shade+17;
}
}
}
#endif
#ifdef USE_SNOW
void DrawSnow(byte *vbuf, uint32_t vbufPitch)
{
#if defined(USE_FLOORCEILINGTEX) && defined(FIXRAINSNOWLEAKS)
fixed dist; // distance to row projection
fixed tex_step; // global step per one screen pixel
fixed gu, gv, floorx, floory; // global texture coordinates
#endif
fixed px = (player->y + FixedMul(0x7900, viewsin)) >> 6;
fixed pz = (player->x - FixedMul(0x7900, viewcos)) >> 6;
int32_t ax, az, x, y, z, xx, yy, height, actheight;
int shade;
int hvheight = viewheight >> 1;
int hvwidth = viewwidth >> 1;
rainpos -= tics * 256;
for(int i = 0; i < MAXPOINTS; i++)
{
point3d_t *pt = &points[i];
ax = pt->x + px;
ax = 0x1fff - (ax & 0x3fff);
az = pt->z + pz;
az = 0x1fff - (az & 0x3fff);
x = ax * viewcos + az * viewsin;
y = -(heightnumerator << 7) + ((((pt->y << 6) + rainpos) & 0x0ffff) << 11);
z = (az * viewcos - ax * viewsin) >> 8;
if(z <= 0) continue;
shade = z >> 17;
if(shade > 13) continue;
xx = x / z + hvwidth;
if(xx < 0 || xx >= viewwidth) continue;
actheight = y / z;
yy = hvheight - actheight;
height = (heightnumerator << 10) / z;
if(actheight < 0) actheight = -actheight;
if(actheight < (wallheight[xx] >> 3) && height < wallheight[xx]) continue;
if(xx > 0 && xx < viewwidth && yy > 0 && yy < viewheight)
{
#if defined(USE_FLOORCEILINGTEX) && defined(FIXRAINSNOWLEAKS)
// Find the snow's tile coordinate
// NOTE: This sometimes goes over the map edges.
dist = ((heightnumerator / ((height >> 3) + 1)) << 5);
gu = viewx + FixedMul(dist, viewcos);
gv = -viewy + FixedMul(dist, viewsin);
floorx = ( gu >> TILESHIFT ) & 63;
floory = (-(gv >> TILESHIFT) - 1) & 63;
// Is there a ceiling tile?
if(MAPSPOT(floorx, floory, 2) >> 8) continue;
#endif
if(shade < 10)
{
vbuf[yy * vbufPitch + xx] = shade+17;
vbuf[yy * vbufPitch + xx - 1] = shade+16;
vbuf[(yy - 1) * vbufPitch + xx] = shade+16;
vbuf[(yy - 1) * vbufPitch + xx - 1] = shade+15;
}
else
vbuf[yy * vbufPitch + xx] = shade+15;
}
}
}
#endif

20
contrib/games/wolf3d/wl_atmos.h Executable file
View File

@ -0,0 +1,20 @@
#ifndef _WL_ATMOS_H_
#define _WL_ATMOS_H_
#if defined(USE_STARSKY) || defined(USE_RAIN) || defined(USE_SNOW)
void Init3DPoints();
#endif
#ifdef USE_STARSKY
void DrawStarSky(byte *vbuf, uint32_t vbufPitch);
#endif
#ifdef USE_RAIN
void DrawRain(byte *vbuf, uint32_t vbufPitch);
#endif
#ifdef USE_SNOW
void DrawSnow(byte *vbuf, uint32_t vbufPitch);
#endif
#endif

View File

@ -0,0 +1,259 @@
#include "version.h"
#ifdef USE_CLOUDSKY
#include "wl_def.h"
#include "wl_cloudsky.h"
// Each colormap defines a number of colors which should be mapped from
// the skytable. The according colormapentry_t array defines how these colors should
// be mapped to the wolfenstein palette. The first int of each entry defines
// how many colors are grouped to this entry and the absolute value of the
// second int sets the starting palette index for this pair. If this value is
// negative the index will be decremented for every color, if it's positive
// it will be incremented.
//
// Example colormap:
// colormapentry_t colmapents_1[] = { { 6, -10 }, { 2, 40 } };
// colormap_t colorMaps[] = {
// { 8, colmapents_1 }
// };
//
// The colormap 0 consists of 8 colors. The first color group consists of 6
// colors and starts descending at palette index 10: 10, 9, 8, 7, 6, 5
// The second color group consists of 2 colors and starts ascending at
// index 40: 40, 41
// There's no other color group because all colors of this colormap are
// already used (6+2=8)
//
// Warning: Always make sure that the sum of the amount of the colors in all
// color groups is the number of colors used for your colormap!
colormapentry_t colmapents_1[] = { { 16, -31 }, { 16, 136 } };
colormapentry_t colmapents_2[] = { { 16, -31 } };
colormap_t colorMaps[] = {
{ 32, colmapents_1 },
{ 16, colmapents_2 }
};
const int numColorMaps = lengthof(colorMaps);
// The sky definitions which can be selected as defined by GetCloudSkyDefID() in wl_def.h
// You can use <TAB>+Z in debug mode to find out suitable values for seed and colorMapIndex
// Each entry consists of seed, speed, angle and colorMapIndex
cloudsky_t cloudSkys[] = {
{ 626, 800, 20, 0 },
{ 1234, 650, 60, 1 },
{ 0, 700, 120, 0 },
{ 0, 0, 0, 0 },
{ 11243, 750, 310, 0 },
{ 32141, 750, 87, 0 },
{ 12124, 750, 64, 0 },
{ 55543, 500, 240, 0 },
{ 65535, 200, 54, 1 },
{ 4, 1200, 290, 0 },
};
byte skyc[65536L];
long cloudx = 0, cloudy = 0;
cloudsky_t *curSky = NULL;
#ifdef USE_FEATUREFLAGS
// The lower left tile of every map determines the used cloud sky definition from cloudSkys.
static int GetCloudSkyDefID()
{
int skyID = ffDataBottomLeft;
assert(skyID >= 0 && skyID < lengthof(cloudSkys));
return skyID;
}
#else
static int GetCloudSkyDefID()
{
int skyID;
switch(gamestate.episode * 10 + mapon)
{
case 0: skyID = 0; break;
case 1: skyID = 1; break;
case 2: skyID = 2; break;
case 3: skyID = 3; break;
case 4: skyID = 4; break;
case 5: skyID = 5; break;
case 6: skyID = 6; break;
case 7: skyID = 7; break;
case 8: skyID = 8; break;
case 9: skyID = 9; break;
default: skyID = 9; break;
}
assert(skyID >= 0 && skyID < lengthof(cloudSkys));
return skyID;
}
#endif
void SplitS(unsigned size,unsigned x1,unsigned y1,unsigned x2,unsigned y2)
{
if(size==1) return;
if(!skyc[((x1+size/2)*256+y1)])
{
skyc[((x1+size/2)*256+y1)]=(byte)(((int)skyc[(x1*256+y1)]
+(int)skyc[((x2&0xff)*256+y1)])/2)+rand()%(size*2)-size;
if(!skyc[((x1+size/2)*256+y1)]) skyc[((x1+size/2)*256+y1)]=1;
}
if(!skyc[((x1+size/2)*256+(y2&0xff))])
{
skyc[((x1+size/2)*256+(y2&0xff))]=(byte)(((int)skyc[(x1*256+(y2&0xff))]
+(int)skyc[((x2&0xff)*256+(y2&0xff))])/2)+rand()%(size*2)-size;
if(!skyc[((x1+size/2)*256+(y2&0xff))])
skyc[((x1+size/2)*256+(y2&0xff))]=1;
}
if(!skyc[(x1*256+y1+size/2)])
{
skyc[(x1*256+y1+size/2)]=(byte)(((int)skyc[(x1*256+y1)]
+(int)skyc[(x1*256+(y2&0xff))])/2)+rand()%(size*2)-size;
if(!skyc[(x1*256+y1+size/2)]) skyc[(x1*256+y1+size/2)]=1;
}
if(!skyc[((x2&0xff)*256+y1+size/2)])
{
skyc[((x2&0xff)*256+y1+size/2)]=(byte)(((int)skyc[((x2&0xff)*256+y1)]
+(int)skyc[((x2&0xff)*256+(y2&0xff))])/2)+rand()%(size*2)-size;
if(!skyc[((x2&0xff)*256+y1+size/2)]) skyc[((x2&0xff)*256+y1+size/2)]=1;
}
skyc[((x1+size/2)*256+y1+size/2)]=(byte)(((int)skyc[(x1*256+y1)]
+(int)skyc[((x2&0xff)*256+y1)]+(int)skyc[(x1*256+(y2&0xff))]
+(int)skyc[((x2&0xff)*256+(y2&0xff))])/4)+rand()%(size*2)-size;
SplitS(size/2,x1,y1+size/2,x1+size/2,y2);
SplitS(size/2,x1+size/2,y1,x2,y1+size/2);
SplitS(size/2,x1+size/2,y1+size/2,x2,y2);
SplitS(size/2,x1,y1,x1+size/2,y1+size/2);
}
void InitSky()
{
unsigned cloudskyid = GetCloudSkyDefID();
if(cloudskyid >= lengthof(cloudSkys))
Quit("Illegal cloud sky id: %u", cloudskyid);
curSky = &cloudSkys[cloudskyid];
memset(skyc, 0, sizeof(skyc));
// funny water texture if used instead of memset ;D
// for(int i = 0; i < 65536; i++)
// skyc[i] = rand() % 32 * 8;
srand(curSky->seed);
skyc[0] = rand() % 256;
SplitS(256, 0, 0, 256, 256);
// Smooth the clouds a bit
for(int k = 0; k < 2; k++)
{
for(int i = 0; i < 256; i++)
{
for(int j = 0; j < 256; j++)
{
int32_t val = -skyc[j * 256 + i];
for(int m = 0; m < 3; m++)
{
for(int n = 0; n < 3; n++)
{
val += skyc[((j + n - 1) & 0xff) * 256 + ((i + m - 1) & 0xff)];
}
}
skyc[j * 256 + i] = (byte)(val >> 3);
}
}
}
// the following commented line could be useful, if you're trying to
// create a new color map. This will display your current color map
// in one (of course repeating) stripe of the sky
// for(int i = 0; i < 256; i++)
// skyc[i] = skyc[i + 256] = skyc[i + 512] = i;
if(curSky->colorMapIndex >= lengthof(colorMaps))
Quit("Illegal colorMapIndex for cloud sky def %u: %u", cloudskyid, curSky->colorMapIndex);
colormap_t *curMap = &colorMaps[curSky->colorMapIndex];
int numColors = curMap->numColors;
byte colormap[256];
colormapentry_t *curEntry = curMap->entries;
for(int calcedCols = 0; calcedCols < numColors; curEntry++)
{
if(curEntry->startAndDir < 0)
{
for(int i = 0, ind = -curEntry->startAndDir; i < curEntry->length; i++, ind--)
colormap[calcedCols++] = ind;
}
else
{
for(int i = 0, ind = curEntry->startAndDir; i < curEntry->length; i++, ind++)
colormap[calcedCols++] = ind;
}
}
for(int i = 0; i < 256; i++)
{
for(int j = 0; j < 256; j++)
{
skyc[i * 256 + j] = colormap[skyc[i * 256 + j] * numColors / 256];
}
}
}
// Based on Textured Floor and Ceiling by DarkOne
void DrawClouds(byte *vbuf, unsigned vbufPitch, int min_wallheight)
{
// Move clouds
fixed moveDist = tics * curSky->speed;
cloudx += FixedMul(moveDist,sintable[curSky->angle]);
cloudy -= FixedMul(moveDist,costable[curSky->angle]);
// Draw them
int y0, halfheight;
unsigned top_offset0;
fixed dist; // distance to row projection
fixed tex_step; // global step per one screen pixel
fixed gu, gv, du, dv; // global texture coordinates
int u, v; // local texture coordinates
// ------ * prepare * --------
halfheight = viewheight >> 1;
y0 = min_wallheight >> 3; // starting y value
if(y0 > halfheight)
return; // view obscured by walls
if(!y0) y0 = 1; // don't let division by zero
top_offset0 = vbufPitch * (halfheight - y0 - 1);
// draw horizontal lines
for(int y = y0, top_offset = top_offset0; y < halfheight; y++, top_offset -= vbufPitch)
{
dist = (heightnumerator / y) << 8;
gu = viewx + FixedMul(dist, viewcos) + cloudx;
gv = -viewy + FixedMul(dist, viewsin) + cloudy;
tex_step = (dist << 8) / viewwidth / 175;
du = FixedMul(tex_step, viewsin);
dv = -FixedMul(tex_step, viewcos);
gu -= (viewwidth >> 1)*du;
gv -= (viewwidth >> 1)*dv; // starting point (leftmost)
for(int x = 0, top_add = top_offset; x < viewwidth; x++, top_add++)
{
if(wallheight[x] >> 3 <= y)
{
u = (gu >> 13) & 255;
v = (gv >> 13) & 255;
vbuf[top_add] = skyc[((255 - u) << 8) + 255 - v];
}
gu += du;
gv += dv;
}
}
}
#endif

View File

@ -0,0 +1,46 @@
#if defined(USE_CLOUDSKY) && !defined(_WL_CLOUDSKY_H_)
#define _WL_CLOUDSKY_H_
typedef struct
{
int length;
int startAndDir;
} colormapentry_t;
typedef struct
{
int numColors;
colormapentry_t *entries;
} colormap_t;
typedef struct
{
// The seed defines the look of the sky and every value (0-4294967295)
// describes an unique sky. You can play around with these inside the game
// when pressing <TAB>+Z in debug mode. There you'll be able to change the
// active seed to find out a value, which is suitable for your needs.
uint32_t seed;
// The speed defines how fast the clouds will move (0-65535)
uint32_t speed;
// The angle defines the move direction (0-359)
uint32_t angle;
// An index selecting the color map to be used for this sky definition.
// This value can also be chosen with <TAB>+Z
uint32_t colorMapIndex;
} cloudsky_t;
extern cloudsky_t *curSky;
extern colormap_t colorMaps[];
extern const int numColorMaps;
void InitSky();
void DrawClouds(byte *vbuf, unsigned vbufPitch, int min_wallheight);
#ifndef USE_FEATUREFLAGS
int GetCloudSkyDefID();
#endif
#endif

869
contrib/games/wolf3d/wl_debug.cpp Executable file
View File

@ -0,0 +1,869 @@
// WL_DEBUG.C
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "wl_def.h"
#pragma hdrstop
#ifdef USE_CLOUDSKY
#include "wl_cloudsky.h"
#endif
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define VIEWTILEX (viewwidth/16)
#define VIEWTILEY (viewheight/16)
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
#ifdef DEBUGKEYS
int DebugKeys (void);
// from WL_DRAW.C
void ScalePost();
void SimpleScaleShape (int xcenter, int shapenum, unsigned height);
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
int maporgx;
int maporgy;
enum {mapview,tilemapview,actoratview,visview} viewtype;
void ViewMap (void);
//===========================================================================
/*
==================
=
= CountObjects
=
==================
*/
void CountObjects (void)
{
int i,total,count,active,inactive,doors;
objtype *obj;
CenterWindow (17,7);
active = inactive = count = doors = 0;
US_Print ("Total statics :");
total = (int)(laststatobj-&statobjlist[0]);
US_PrintUnsigned (total);
char str[60];
sprintf(str,"\nlaststatobj=%.8X",(int32_t)(uintptr_t)laststatobj);
US_Print(str);
US_Print ("\nIn use statics:");
for (i=0;i<total;i++)
{
if (statobjlist[i].shapenum != -1)
count++;
else
doors++; //debug
}
US_PrintUnsigned (count);
US_Print ("\nDoors :");
US_PrintUnsigned (doornum);
for (obj=player->next;obj;obj=obj->next)
{
if (obj->active)
active++;
else
inactive++;
}
US_Print ("\nTotal actors :");
US_PrintUnsigned (active+inactive);
US_Print ("\nActive actors :");
US_PrintUnsigned (active);
VW_UpdateScreen();
IN_Ack ();
}
//===========================================================================
/*
===================
=
= PictureGrabber
=
===================
*/
void PictureGrabber (void)
{
static char fname[] = "WSHOT000.BMP";
for(int i = 0; i < 1000; i++)
{
fname[7] = i % 10 + '0';
fname[6] = (i / 10) % 10 + '0';
fname[5] = i / 100 + '0';
int file = open(fname, O_RDONLY | O_BINARY);
if(file == -1) break; // file does not exist, so use that filename
close(file);
}
// overwrites WSHOT999.BMP if all wshot files exist
SDL_SaveBMP(curSurface, fname);
CenterWindow (18,2);
US_PrintCentered ("Screenshot taken");
VW_UpdateScreen();
IN_Ack();
}
//===========================================================================
/*
===================
=
= BasicOverhead
=
===================
*/
void BasicOverhead (void)
{
int x, y, z, offx, offy;
z = 128/MAPSIZE; // zoom scale
offx = 320/2;
offy = (160-MAPSIZE*z)/2;
#ifdef MAPBORDER
int temp = viewsize;
NewViewSize(16);
DrawPlayBorder();
#endif
// right side (raw)
for(x=0;x<MAPSIZE;x++)
for(y=0;y<MAPSIZE;y++)
VWB_Bar(x*z+offx, y*z+offy,z,z,(unsigned)(uintptr_t)actorat[x][y]);
// left side (filtered)
uintptr_t tile;
int color;
offx -= 128;
for(x=0;x<MAPSIZE;x++)
{
for(y=0;y<MAPSIZE;y++)
{
tile = (uintptr_t)actorat[x][y];
if (ISPOINTER(tile) && ((objtype *)tile)->flags&FL_SHOOTABLE) color = 72; // enemy
else if (!tile || ISPOINTER(tile))
{
if (spotvis[x][y]) color = 111; // visable
else color = 0; // nothing
}
else if (MAPSPOT(x,y,1) == PUSHABLETILE) color = 171; // pushwall
else if (tile == 64) color = 158; // solid obj
else if (tile < 128) color = 154; // walls
else if (tile < 256) color = 146; // doors
VWB_Bar(x*z+offx, y*z+offy,z,z,color);
}
}
VWB_Bar(player->tilex*z+offx,player->tiley*z+offy,z,z,15); // player
// resize the border to match
VW_UpdateScreen();
IN_Ack();
#ifdef MAPBORDER
NewViewSize(temp);
DrawPlayBorder();
#endif
}
//===========================================================================
/*
================
=
= ShapeTest
=
================
*/
void ShapeTest (void)
{
//TODO
#if NOTYET
extern word NumDigi;
extern word *DigiList;
extern int postx;
extern int postwidth;
extern byte *postsource;
static char buf[10];
boolean done;
ScanCode scan;
int i,j,k,x;
longword l;
byte *addr;
soundnames sound;
// PageListStruct far *page;
CenterWindow(20,16);
VW_UpdateScreen();
for (i = 0,done = false; !done;)
{
US_ClearWindow();
sound = (soundnames) -1;
// page = &PMPages[i];
US_Print(" Page #");
US_PrintUnsigned(i);
if (i < PMSpriteStart)
US_Print(" (Wall)");
else if (i < PMSoundStart)
US_Print(" (Sprite)");
else if (i == ChunksInFile - 1)
US_Print(" (Sound Info)");
else
US_Print(" (Sound)");
/* US_Print("\n XMS: ");
if (page->xmsPage != -1)
US_PrintUnsigned(page->xmsPage);
else
US_Print("No");
US_Print("\n Main: ");
if (page->mainPage != -1)
US_PrintUnsigned(page->mainPage);
else if (page->emsPage != -1)
{
US_Print("EMS ");
US_PrintUnsigned(page->emsPage);
}
else
US_Print("No");
US_Print("\n Last hit: ");
US_PrintUnsigned(page->lastHit);*/
US_Print("\n Address: ");
addr = (byte *) PM_GetPage(i);
sprintf(buf,"0x%08X",(int32_t) addr);
US_Print(buf);
if (addr)
{
if (i < PMSpriteStart)
{
//
// draw the wall
//
vbuf += 32*SCREENWIDTH;
postx = 128;
postwidth = 1;
postsource = addr;
for (x=0;x<64;x++,postx++,postsource+=64)
{
wallheight[postx] = 256;
ScalePost ();
}
vbuf -= 32*SCREENWIDTH;
}
else if (i < PMSoundStart)
{
//
// draw the sprite
//
vbuf += 32*SCREENWIDTH;
SimpleScaleShape (160, i-PMSpriteStart, 64);
vbuf -= 32*SCREENWIDTH;
}
else if (i == ChunksInFile - 1)
{
US_Print("\n\n Number of sounds: ");
US_PrintUnsigned(NumDigi);
for (l = j = k = 0;j < NumDigi;j++)
{
l += DigiList[(j * 2) + 1];
k += (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;
}
US_Print("\n Total bytes: ");
US_PrintUnsigned(l);
US_Print("\n Total pages: ");
US_PrintUnsigned(k);
}
else
{
byte *dp = addr;
for (j = 0;j < NumDigi;j++)
{
k = (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;
if ((i >= PMSoundStart + DigiList[j * 2])
&& (i < PMSoundStart + DigiList[j * 2] + k))
break;
}
if (j < NumDigi)
{
sound = (soundnames) j;
US_Print("\n Sound #");
US_PrintUnsigned(j);
US_Print("\n Segment #");
US_PrintUnsigned(i - PMSoundStart - DigiList[j * 2]);
}
for (j = 0;j < PageLengths[i];j += 32)
{
byte v = dp[j];
int v2 = (unsigned)v;
v2 -= 128;
v2 /= 4;
if (v2 < 0)
VWB_Vlin(WindowY + WindowH - 32 + v2,
WindowY + WindowH - 32,
WindowX + 8 + (j / 32),BLACK);
else
VWB_Vlin(WindowY + WindowH - 32,
WindowY + WindowH - 32 + v2,
WindowX + 8 + (j / 32),BLACK);
}
}
}
VW_UpdateScreen();
IN_Ack();
scan = LastScan;
IN_ClearKey(scan);
switch (scan)
{
case sc_LeftArrow:
if (i)
i--;
break;
case sc_RightArrow:
if (++i >= ChunksInFile)
i--;
break;
case sc_W: // Walls
i = 0;
break;
case sc_S: // Sprites
i = PMSpriteStart;
break;
case sc_D: // Digitized
i = PMSoundStart;
break;
case sc_I: // Digitized info
i = ChunksInFile - 1;
break;
/* case sc_L: // Load all pages
for (j = 0;j < ChunksInFile;j++)
PM_GetPage(j);
break;*/
case sc_P:
if (sound != -1)
SD_PlayDigitized(sound,8,8);
break;
case sc_Escape:
done = true;
break;
/* case sc_Enter:
PM_GetPage(i);
break;*/
}
}
SD_StopDigitized();
#endif
}
//===========================================================================
/*
================
=
= DebugKeys
=
================
*/
int DebugKeys (void)
{
boolean esc;
int level;
if (Keyboard[sc_B]) // B = border color
{
CenterWindow(20,3);
PrintY+=6;
US_Print(" Border color (0-56): ");
VW_UpdateScreen();
esc = !US_LineInput (px,py,str,NULL,true,2,0);
if (!esc)
{
level = atoi (str);
if (level>=0 && level<=99)
{
if (level<30) level += 31;
else
{
if (level > 56) level=31;
else level -= 26;
}
bordercol=level*4+3;
if (bordercol == VIEWCOLOR)
DrawStatusBorder(bordercol);
DrawPlayBorder();
return 0;
}
}
return 1;
}
if (Keyboard[sc_C]) // C = count objects
{
CountObjects();
return 1;
}
if (Keyboard[sc_D]) // D = Darkone's FPS counter
{
CenterWindow (22,2);
if (fpscounter)
US_PrintCentered ("Darkone's FPS Counter OFF");
else
US_PrintCentered ("Darkone's FPS Counter ON");
VW_UpdateScreen();
IN_Ack();
fpscounter ^= 1;
return 1;
}
if (Keyboard[sc_E]) // E = quit level
playstate = ex_completed;
if (Keyboard[sc_F]) // F = facing spot
{
char str[60];
CenterWindow (14,6);
US_Print ("x:"); US_PrintUnsigned (player->x);
US_Print (" ("); US_PrintUnsigned (player->x%65536);
US_Print (")\ny:"); US_PrintUnsigned (player->y);
US_Print (" ("); US_PrintUnsigned (player->y%65536);
US_Print (")\nA:"); US_PrintUnsigned (player->angle);
US_Print (" X:"); US_PrintUnsigned (player->tilex);
US_Print (" Y:"); US_PrintUnsigned (player->tiley);
US_Print ("\n1:"); US_PrintUnsigned (tilemap[player->tilex][player->tiley]);
sprintf(str," 2:%.8X",(unsigned)(uintptr_t)actorat[player->tilex][player->tiley]); US_Print(str);
US_Print ("\nf 1:"); US_PrintUnsigned (player->areanumber);
US_Print (" 2:"); US_PrintUnsigned (MAPSPOT(player->tilex,player->tiley,1));
US_Print (" 3:");
if ((unsigned)(uintptr_t)actorat[player->tilex][player->tiley] < 256)
US_PrintUnsigned (spotvis[player->tilex][player->tiley]);
else
US_PrintUnsigned (actorat[player->tilex][player->tiley]->flags);
VW_UpdateScreen();
IN_Ack();
return 1;
}
if (Keyboard[sc_G]) // G = god mode
{
CenterWindow (12,2);
if (godmode == 0)
US_PrintCentered ("God mode ON");
else if (godmode == 1)
US_PrintCentered ("God (no flash)");
else if (godmode == 2)
US_PrintCentered ("God mode OFF");
VW_UpdateScreen();
IN_Ack();
if (godmode != 2)
godmode++;
else
godmode = 0;
return 1;
}
if (Keyboard[sc_H]) // H = hurt self
{
IN_ClearKeysDown ();
TakeDamage (16,NULL);
}
else if (Keyboard[sc_I]) // I = item cheat
{
CenterWindow (12,3);
US_PrintCentered ("Free items!");
VW_UpdateScreen();
GivePoints (100000);
HealSelf (99);
if (gamestate.bestweapon<wp_chaingun)
GiveWeapon (gamestate.bestweapon+1);
gamestate.ammo += 50;
if (gamestate.ammo > 99)
gamestate.ammo = 99;
DrawAmmo ();
IN_Ack ();
return 1;
}
else if (Keyboard[sc_K]) // K = give keys
{
CenterWindow(16,3);
PrintY+=6;
US_Print(" Give Key (1-4): ");
VW_UpdateScreen();
esc = !US_LineInput (px,py,str,NULL,true,1,0);
if (!esc)
{
level = atoi (str);
if (level>0 && level<5)
GiveKey(level-1);
}
return 1;
}
else if (Keyboard[sc_L]) // L = level ratios
{
byte x,start,end=LRpack;
if (end == 8) // wolf3d
{
CenterWindow(17,10);
start = 0;
}
else // sod
{
CenterWindow(17,12);
start = 0; end = 10;
}
again:
for(x=start;x<end;x++)
{
US_PrintUnsigned(x+1);
US_Print(" ");
US_PrintUnsigned(LevelRatios[x].time/60);
US_Print(":");
if (LevelRatios[x].time%60 < 10)
US_Print("0");
US_PrintUnsigned(LevelRatios[x].time%60);
US_Print(" ");
US_PrintUnsigned(LevelRatios[x].kill);
US_Print("% ");
US_PrintUnsigned(LevelRatios[x].secret);
US_Print("% ");
US_PrintUnsigned(LevelRatios[x].treasure);
US_Print("%\n");
}
VW_UpdateScreen();
IN_Ack();
if (end == 10 && gamestate.mapon > 9)
{
start = 10; end = 20;
CenterWindow(17,12);
goto again;
}
return 1;
}
else if (Keyboard[sc_N]) // N = no clip
{
noclip^=1;
CenterWindow (18,3);
if (noclip)
US_PrintCentered ("No clipping ON");
else
US_PrintCentered ("No clipping OFF");
VW_UpdateScreen();
IN_Ack ();
return 1;
}
else if (Keyboard[sc_O]) // O = basic overhead
{
BasicOverhead();
return 1;
}
else if(Keyboard[sc_P]) // P = Ripper's picture grabber
{
PictureGrabber();
return 1;
}
else if (Keyboard[sc_Q]) // Q = fast quit
Quit (NULL);
else if (Keyboard[sc_S]) // S = slow motion
{
CenterWindow(30,3);
PrintY+=6;
US_Print(" Slow Motion steps (default 14): ");
VW_UpdateScreen();
esc = !US_LineInput (px,py,str,NULL,true,2,0);
if (!esc)
{
level = atoi (str);
if (level>=0 && level<=50)
singlestep = level;
}
return 1;
}
else if (Keyboard[sc_T]) // T = shape test
{
ShapeTest ();
return 1;
}
else if (Keyboard[sc_V]) // V = extra VBLs
{
CenterWindow(30,3);
PrintY+=6;
US_Print(" Add how many extra VBLs(0-8): ");
VW_UpdateScreen();
esc = !US_LineInput (px,py,str,NULL,true,1,0);
if (!esc)
{
level = atoi (str);
if (level>=0 && level<=8)
extravbls = level;
}
return 1;
}
else if (Keyboard[sc_W]) // W = warp to level
{
CenterWindow(26,3);
PrintY+=6;
#ifndef SPEAR
US_Print(" Warp to which level(1-10): ");
#else
US_Print(" Warp to which level(1-21): ");
#endif
VW_UpdateScreen();
esc = !US_LineInput (px,py,str,NULL,true,2,0);
if (!esc)
{
level = atoi (str);
#ifndef SPEAR
if (level>0 && level<11)
#else
if (level>0 && level<22)
#endif
{
gamestate.mapon = level-1;
playstate = ex_warped;
}
}
return 1;
}
else if (Keyboard[sc_X]) // X = item cheat
{
CenterWindow (12,3);
US_PrintCentered ("Extra stuff!");
VW_UpdateScreen();
// DEBUG: put stuff here
IN_Ack ();
return 1;
}
#ifdef USE_CLOUDSKY
else if(Keyboard[sc_Z])
{
char defstr[15];
CenterWindow(34,4);
PrintY+=6;
US_Print(" Recalculate sky with seek: ");
int seekpx = px, seekpy = py;
US_PrintUnsigned(curSky->seed);
US_Print("\n Use color map (0-");
US_PrintUnsigned(numColorMaps - 1);
US_Print("): ");
int mappx = px, mappy = py;
US_PrintUnsigned(curSky->colorMapIndex);
VW_UpdateScreen();
sprintf(defstr, "%u", curSky->seed);
esc = !US_LineInput(seekpx, seekpy, str, defstr, true, 10, 0);
if(esc) return 0;
curSky->seed = (uint32_t) atoi(str);
sprintf(defstr, "%u", curSky->colorMapIndex);
esc = !US_LineInput(mappx, mappy, str, defstr, true, 10, 0);
if(esc) return 0;
uint32_t newInd = (uint32_t) atoi(str);
if(newInd < (uint32_t) numColorMaps)
{
curSky->colorMapIndex = newInd;
InitSky();
}
else
{
CenterWindow (18,3);
US_PrintCentered ("Illegal color map!");
VW_UpdateScreen();
IN_Ack ();
}
}
#endif
return 0;
}
#if 0
/*
===================
=
= OverheadRefresh
=
===================
*/
void OverheadRefresh (void)
{
unsigned x,y,endx,endy,sx,sy;
unsigned tile;
endx = maporgx+VIEWTILEX;
endy = maporgy+VIEWTILEY;
for (y=maporgy;y<endy;y++)
{
for (x=maporgx;x<endx;x++)
{
sx = (x-maporgx)*16;
sy = (y-maporgy)*16;
switch (viewtype)
{
#if 0
case mapview:
tile = *(mapsegs[0]+farmapylookup[y]+x);
break;
case tilemapview:
tile = tilemap[x][y];
break;
case visview:
tile = spotvis[x][y];
break;
#endif
case actoratview:
tile = (unsigned)actorat[x][y];
break;
}
if (tile<MAXWALLTILES)
LatchDrawTile(sx,sy,tile);
else
{
LatchDrawChar(sx,sy,NUMBERCHARS+((tile&0xf000)>>12));
LatchDrawChar(sx+8,sy,NUMBERCHARS+((tile&0x0f00)>>8));
LatchDrawChar(sx,sy+8,NUMBERCHARS+((tile&0x00f0)>>4));
LatchDrawChar(sx+8,sy+8,NUMBERCHARS+(tile&0x000f));
}
}
}
}
#endif
#if 0
/*
===================
=
= ViewMap
=
===================
*/
void ViewMap (void)
{
boolean button0held;
viewtype = actoratview;
// button0held = false;
maporgx = player->tilex - VIEWTILEX/2;
if (maporgx<0)
maporgx = 0;
if (maporgx>MAPSIZE-VIEWTILEX)
maporgx=MAPSIZE-VIEWTILEX;
maporgy = player->tiley - VIEWTILEY/2;
if (maporgy<0)
maporgy = 0;
if (maporgy>MAPSIZE-VIEWTILEY)
maporgy=MAPSIZE-VIEWTILEY;
do
{
//
// let user pan around
//
PollControls ();
if (controlx < 0 && maporgx>0)
maporgx--;
if (controlx > 0 && maporgx<mapwidth-VIEWTILEX)
maporgx++;
if (controly < 0 && maporgy>0)
maporgy--;
if (controly > 0 && maporgy<mapheight-VIEWTILEY)
maporgy++;
#if 0
if (c.button0 && !button0held)
{
button0held = true;
viewtype++;
if (viewtype>visview)
viewtype = mapview;
}
if (!c.button0)
button0held = false;
#endif
OverheadRefresh ();
} while (!Keyboard[sc_Escape]);
IN_ClearKeysDown ();
}
#endif
#endif

1485
contrib/games/wolf3d/wl_def.h Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,230 @@
#include "version.h"
#ifdef USE_DIR3DSPR
#include "wl_def.h"
#include "wl_shade.h"
// Define directional 3d sprites in wl_act1.cpp (there are two examples)
// Make sure you have according entries in ScanInfoPlane in wl_game.cpp.
void Scale3DShaper(int x1, int x2, int shapenum, uint32_t flags, fixed ny1, fixed ny2,
fixed nx1, fixed nx2, byte *vbuf, unsigned vbufPitch)
{
t_compshape *shape;
unsigned scale1,starty,endy;
word *cmdptr;
byte *line;
byte *vmem;
int dx,len,i,newstart,ycnt,pixheight,screndy,upperedge,scrstarty;
unsigned j;
fixed height,dheight,height1,height2;
int xpos[TEXTURESIZE+1];
int slinex;
fixed dxx=(ny2-ny1)<<8,dzz=(nx2-nx1)<<8;
fixed dxa=0,dza=0;
byte col;
shape = (t_compshape *) PM_GetSprite(shapenum);
len=shape->rightpix-shape->leftpix+1;
if(!len) return;
ny1+=dxx>>9;
nx1+=dzz>>9;
dxa=-(dxx>>1),dza=-(dzz>>1);
dxx>>=TEXTURESHIFT,dzz>>=TEXTURESHIFT;
dxa+=shape->leftpix*dxx,dza+=shape->leftpix*dzz;
xpos[0]=(int)((ny1+(dxa>>8))*scale/(nx1+(dza>>8))+centerx);
height1 = heightnumerator/((nx1+(dza>>8))>>8);
height=(((fixed)height1)<<12)+2048;
for(i=1;i<=len;i++)
{
dxa+=dxx,dza+=dzz;
xpos[i]=(int)((ny1+(dxa>>8))*scale/(nx1+(dza>>8))+centerx);
if(xpos[i-1]>viewwidth) break;
}
len=i-1;
dx = xpos[len] - xpos[0];
if(!dx) return;
height2 = heightnumerator/((nx1+(dza>>8))>>8);
dheight=(((fixed)height2-(fixed)height1)<<12)/(fixed)dx;
cmdptr = (word *) shape->dataofs;
i=0;
if(x2>viewwidth) x2=viewwidth;
for(i=0;i<len;i++)
{
for(slinex=xpos[i];slinex<xpos[i+1] && slinex<x2;slinex++)
{
height+=dheight;
if(slinex<0) continue;
scale1=(unsigned)(height>>15);
if(wallheight[slinex]<(height>>12) && scale1 /*&& scale1<=maxscale*/)
{
#ifdef USE_SHADING
byte *curshades;
if(flags & FL_FULLBRIGHT)
curshades = shadetable[0];
else
curshades = shadetable[GetShade(scale1<<3)];
#endif
pixheight=scale1*SPRITESCALEFACTOR;
upperedge=viewheight/2-scale1;
line=(byte *)shape + cmdptr[i];
while((endy = READWORD(line)) != 0)
{
endy >>= 1;
newstart = READWORD(line);
starty = READWORD(line) >> 1;
j=starty;
ycnt=j*pixheight;
screndy=(ycnt>>6)+upperedge;
if(screndy<0) vmem=vbuf+slinex;
else vmem=vbuf+screndy*vbufPitch+slinex;
for(;j<endy;j++)
{
scrstarty=screndy;
ycnt+=pixheight;
screndy=(ycnt>>6)+upperedge;
if(scrstarty!=screndy && screndy>0)
{
#ifdef USE_SHADING
col=curshades[((byte *)shape)[newstart+j]];
#else
col=((byte *)shape)[newstart+j];
#endif
if(scrstarty<0) scrstarty=0;
if(screndy>viewheight) screndy=viewheight,j=endy;
while(scrstarty<screndy)
{
*vmem=col;
vmem+=vbufPitch;
scrstarty++;
}
}
}
}
}
}
}
}
void Scale3DShape(byte *vbuf, unsigned vbufPitch, statobj_t *ob)
{
fixed nx1,nx2,ny1,ny2;
int viewx1,viewx2;
fixed diradd;
fixed playx = viewx;
fixed playy = viewy;
//
// the following values for "diradd" aren't optimized yet
// if you have problems with sprites being visible through wall edges
// where they shouldn't, you can try to adjust these values and SIZEADD
//
#define SIZEADD 1024
switch(ob->flags & FL_DIR_POS_MASK)
{
case FL_DIR_POS_FW: diradd=0x7ff0+0x8000; break;
case FL_DIR_POS_BW: diradd=-0x7ff0+0x8000; break;
case FL_DIR_POS_MID: diradd=0x8000; break;
default:
Quit("Unknown directional 3d sprite position (shapenum = %i)", ob->shapenum);
}
if(ob->flags & FL_DIR_VERT_FLAG) // vertical dir 3d sprite
{
fixed gy1,gy2,gx,gyt1,gyt2,gxt;
//
// translate point to view centered coordinates
//
gy1 = (((long)ob->tiley) << TILESHIFT)+0x8000-playy-0x8000L-SIZEADD;
gy2 = gy1+0x10000L+2*SIZEADD;
gx = (((long)ob->tilex) << TILESHIFT)+diradd-playx;
//
// calculate newx
//
gxt = FixedMul(gx,viewcos);
gyt1 = FixedMul(gy1,viewsin);
gyt2 = FixedMul(gy2,viewsin);
nx1 = gxt-gyt1;
nx2 = gxt-gyt2;
//
// calculate newy
//
gxt = FixedMul(gx,viewsin);
gyt1 = FixedMul(gy1,viewcos);
gyt2 = FixedMul(gy2,viewcos);
ny1 = gyt1+gxt;
ny2 = gyt2+gxt;
}
else // horizontal dir 3d sprite
{
fixed gx1,gx2,gy,gxt1,gxt2,gyt;
//
// translate point to view centered coordinates
//
gx1 = (((long)ob->tilex) << TILESHIFT)+0x8000-playx-0x8000L-SIZEADD;
gx2 = gx1+0x10000L+2*SIZEADD;
gy = (((long)ob->tiley) << TILESHIFT)+diradd-playy;
//
// calculate newx
//
gxt1 = FixedMul(gx1,viewcos);
gxt2 = FixedMul(gx2,viewcos);
gyt = FixedMul(gy,viewsin);
nx1 = gxt1-gyt;
nx2 = gxt2-gyt;
//
// calculate newy
//
gxt1 = FixedMul(gx1,viewsin);
gxt2 = FixedMul(gx2,viewsin);
gyt = FixedMul(gy,viewcos);
ny1 = gyt+gxt1;
ny2 = gyt+gxt2;
}
if(nx1 < 0 || nx2 < 0) return; // TODO: Clip on viewplane
//
// calculate perspective ratio
//
if(nx1>=0 && nx1<=1792) nx1=1792;
if(nx1<0 && nx1>=-1792) nx1=-1792;
if(nx2>=0 && nx2<=1792) nx2=1792;
if(nx2<0 && nx2>=-1792) nx2=-1792;
viewx1=(int)(centerx+ny1*scale/nx1);
viewx2=(int)(centerx+ny2*scale/nx2);
if(viewx2 < viewx1)
{
Scale3DShaper(viewx2,viewx1,ob->shapenum,ob->flags,ny2,ny1,nx2,nx1,vbuf,vbufPitch);
}
else
{
Scale3DShaper(viewx1,viewx2,ob->shapenum,ob->flags,ny1,ny2,nx1,nx2,vbuf,vbufPitch);
}
}
#endif

1649
contrib/games/wolf3d/wl_draw.cpp Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
#include "version.h"
#ifdef USE_FLOORCEILINGTEX
#include "wl_def.h"
#include "wl_shade.h"
// Textured Floor and Ceiling by DarkOne
// With multi-textured floors and ceilings stored in lower and upper bytes of
// according tile in third mapplane, respectively.
void DrawFloorAndCeiling(byte *vbuf, unsigned vbufPitch, int min_wallheight)
{
fixed dist; // distance to row projection
fixed tex_step; // global step per one screen pixel
fixed gu, gv, du, dv; // global texture coordinates
int u, v; // local texture coordinates
byte *toptex, *bottex;
unsigned lasttoptex = 0xffffffff, lastbottex = 0xffffffff;
int halfheight = viewheight >> 1;
int y0 = min_wallheight >> 3; // starting y value
if(y0 > halfheight)
return; // view obscured by walls
if(!y0) y0 = 1; // don't let division by zero
unsigned bot_offset0 = vbufPitch * (halfheight + y0);
unsigned top_offset0 = vbufPitch * (halfheight - y0 - 1);
// draw horizontal lines
for(int y = y0, bot_offset = bot_offset0, top_offset = top_offset0;
y < halfheight; y++, bot_offset += vbufPitch, top_offset -= vbufPitch)
{
dist = (heightnumerator / (y + 1)) << 5;
gu = viewx + FixedMul(dist, viewcos);
gv = -viewy + FixedMul(dist, viewsin);
tex_step = (dist << 8) / viewwidth / 175;
du = FixedMul(tex_step, viewsin);
dv = -FixedMul(tex_step, viewcos);
gu -= (viewwidth >> 1) * du;
gv -= (viewwidth >> 1) * dv; // starting point (leftmost)
#ifdef USE_SHADING
byte *curshades = shadetable[GetShade(y << 3)];
#endif
for(int x = 0, bot_add = bot_offset, top_add = top_offset;
x < viewwidth; x++, bot_add++, top_add++)
{
if(wallheight[x] >> 3 <= y)
{
int curx = (gu >> TILESHIFT) & (MAPSIZE - 1);
int cury = (-(gv >> TILESHIFT) - 1) & (MAPSIZE - 1);
unsigned curtex = MAPSPOT(curx, cury, 2);
if(curtex)
{
unsigned curtoptex = curtex >> 8;
if (curtoptex != lasttoptex)
{
lasttoptex = curtoptex;
toptex = PM_GetTexture(curtoptex);
}
unsigned curbottex = curtex & 0xff;
if (curbottex != lastbottex)
{
lastbottex = curbottex;
bottex = PM_GetTexture(curbottex);
}
u = (gu >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
unsigned texoffs = (u << TEXTURESHIFT) + (TEXTURESIZE - 1) - v;
#ifdef USE_SHADING
if(curtoptex)
vbuf[top_add] = curshades[toptex[texoffs]];
if(curbottex)
vbuf[bot_add] = curshades[bottex[texoffs]];
#else
if(curtoptex)
vbuf[top_add] = toptex[texoffs];
if(curbottex)
vbuf[bot_add] = bottex[texoffs];
#endif
}
}
gu += du;
gv += dv;
}
}
}
#endif

1604
contrib/games/wolf3d/wl_game.cpp Executable file

File diff suppressed because it is too large Load Diff

1723
contrib/games/wolf3d/wl_inter.cpp Executable file

File diff suppressed because it is too large Load Diff

1962
contrib/games/wolf3d/wl_main.cpp Executable file

File diff suppressed because it is too large Load Diff

4161
contrib/games/wolf3d/wl_menu.cpp Executable file

File diff suppressed because it is too large Load Diff

241
contrib/games/wolf3d/wl_menu.h Executable file
View File

@ -0,0 +1,241 @@
//
// WL_MENU.H
//
#ifdef SPEAR
#define BORDCOLOR 0x99
#define BORD2COLOR 0x93
#define DEACTIVE 0x9b
#define BKGDCOLOR 0x9d
//#define STRIPE 0x9c
#define MenuFadeOut() VL_FadeOut(0,255,0,0,51,10)
#else
#define BORDCOLOR 0x29
#define BORD2COLOR 0x23
#define DEACTIVE 0x2b
#define BKGDCOLOR 0x2d
#define STRIPE 0x2c
#define MenuFadeOut() VL_FadeOut(0,255,43,0,0,10)
#endif
#define READCOLOR 0x4a
#define READHCOLOR 0x47
#define VIEWCOLOR 0x7f
#define TEXTCOLOR 0x17
#define HIGHLIGHT 0x13
#define MenuFadeIn() VL_FadeIn(0,255,gamepal,10)
#define MENUSONG WONDERIN_MUS
#ifndef SPEAR
#define INTROSONG NAZI_NOR_MUS
#else
#define INTROSONG XTOWER2_MUS
#endif
#define SENSITIVE 60
#define CENTERX ((int) screenWidth / 2)
#define CENTERY ((int) screenHeight / 2)
#define MENU_X 76
#define MENU_Y 55
#define MENU_W 178
#ifndef SPEAR
#ifndef GOODTIMES
#define MENU_H 13*10+6
#else
#define MENU_H 13*9+6
#endif
#else
#define MENU_H 13*9+6
#endif
#define SM_X 48
#define SM_W 250
#define SM_Y1 20
#define SM_H1 4*13-7
#define SM_Y2 SM_Y1+5*13
#define SM_H2 4*13-7
#define SM_Y3 SM_Y2+5*13
#define SM_H3 3*13-7
#define CTL_X 24
#ifdef JAPAN
#define CTL_Y 70
#else
#define CTL_Y 86
#endif
#define CTL_W 284
#define CTL_H 60
#define LSM_X 85
#define LSM_Y 55
#define LSM_W 175
#define LSM_H 10*13+10
#define NM_X 50
#define NM_Y 100
#define NM_W 225
#define NM_H 13*4+15
#define NE_X 10
#define NE_Y 23
#define NE_W 320-NE_X*2
#define NE_H 200-NE_Y*2
#define CST_X 20
#define CST_Y 48
#define CST_START 60
#define CST_SPC 60
//
// TYPEDEFS
//
typedef struct {
short x,y,amount,curpos,indent;
} CP_iteminfo;
typedef struct {
short active;
char string[36];
int (* routine)(int temp1);
} CP_itemtype;
typedef struct {
short allowed[4];
} CustomCtrls;
extern CP_itemtype MainMenu[];
extern CP_iteminfo MainItems;
//
// FUNCTION PROTOTYPES
//
void US_ControlPanel(ScanCode);
void EnableEndGameMenuItem();
void SetupControlPanel(void);
void SetupSaveGames();
void CleanupControlPanel(void);
void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items);
int HandleMenu(CP_iteminfo *item_i,
CP_itemtype *items,
void (*routine)(int w));
void ClearMScreen(void);
void DrawWindow(int x,int y,int w,int h,int wcolor);
void DrawOutline(int x,int y,int w,int h,int color1,int color2);
void WaitKeyUp(void);
void ReadAnyControl(ControlInfo *ci);
void TicDelay(int count);
void CacheLump(int lumpstart,int lumpend);
void UnCacheLump(int lumpstart,int lumpend);
int StartCPMusic(int song);
int Confirm(const char *string);
void Message(const char *string);
void CheckPause(void);
void ShootSnd(void);
void CheckSecretMissions(void);
void BossKey(void);
void DrawGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int *y,int which,int basey,void (*routine)(int w));
void DrawHalfStep(int x,int y);
void EraseGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int y,int which);
void SetTextColor(CP_itemtype *items,int hlight);
void DrawMenuGun(CP_iteminfo *iteminfo);
void DrawStripes(int y);
void DefineMouseBtns(void);
void DefineJoyBtns(void);
void DefineKeyBtns(void);
void DefineKeyMove(void);
void EnterCtrlData(int index,CustomCtrls *cust,void (*DrawRtn)(int),void (*PrintRtn)(int),int type);
void DrawMainMenu(void);
void DrawSoundMenu(void);
void DrawLoadSaveScreen(int loadsave);
void DrawNewEpisode(void);
void DrawNewGame(void);
void DrawChangeView(int view);
void DrawMouseSens(void);
void DrawCtlScreen(void);
void DrawCustomScreen(void);
void DrawLSAction(int which);
void DrawCustMouse(int hilight);
void DrawCustJoy(int hilight);
void DrawCustKeybd(int hilight);
void DrawCustKeys(int hilight);
void PrintCustMouse(int i);
void PrintCustJoy(int i);
void PrintCustKeybd(int i);
void PrintCustKeys(int i);
void PrintLSEntry(int w,int color);
void TrackWhichGame(int w);
void DrawNewGameDiff(int w);
void FixupCustom(int w);
int CP_NewGame(int);
int CP_Sound(int);
int CP_LoadGame(int quick);
int CP_SaveGame(int quick);
int CP_Control(int);
int CP_ChangeView(int);
int CP_ExitOptions(int);
int CP_Quit(int);
int CP_ViewScores(int);
int CP_EndGame(int);
int CP_CheckQuick(ScanCode scancode);
int CustomControls(int);
int MouseSensitivity(int);
void CheckForEpisodes(void);
void FreeMusic(void);
enum {MOUSE,JOYSTICK,KEYBOARDBTNS,KEYBOARDMOVE}; // FOR INPUT TYPES
enum menuitems
{
newgame,
soundmenu,
control,
loadgame,
savegame,
changeview,
#ifndef GOODTIMES
#ifndef SPEAR
readthis,
#endif
#endif
viewscores,
backtodemo,
quit
};
//
// WL_INTER
//
typedef struct {
int kill,secret,treasure;
int32_t time;
} LRstruct;
extern LRstruct LevelRatios[];
void Write (int x,int y,const char *string);
void NonShareware(void);
int GetYorN(int x,int y,int pic);

View File

@ -0,0 +1,64 @@
#include "version.h"
#ifdef USE_PARALLAX
#include "wl_def.h"
#ifdef USE_FEATUREFLAGS
// The lower left tile of every map determines the start texture of the parallax sky.
static int GetParallaxStartTexture()
{
int startTex = ffDataBottomLeft;
assert(startTex >= 0 && startTex < PMSpriteStart);
return startTex;
}
#else
static int GetParallaxStartTexture()
{
int startTex;
switch(gamestate.episode * 10 + mapon)
{
case 0: startTex = 20; break;
default: startTex = 0; break;
}
assert(startTex >= 0 && startTex < PMSpriteStart);
return startTex;
}
#endif
void DrawParallax(byte *vbuf, unsigned vbufPitch)
{
int startpage = GetParallaxStartTexture();
int midangle = player->angle * (FINEANGLES / ANGLES);
int skyheight = viewheight >> 1;
int curtex = -1;
byte *skytex;
startpage += USE_PARALLAX - 1;
for(int x = 0; x < viewwidth; x++)
{
int curang = pixelangle[x] + midangle;
if(curang < 0) curang += FINEANGLES;
else if(curang >= FINEANGLES) curang -= FINEANGLES;
int xtex = curang * USE_PARALLAX * TEXTURESIZE / FINEANGLES;
int newtex = xtex >> TEXTURESHIFT;
if(newtex != curtex)
{
curtex = newtex;
skytex = PM_GetTexture(startpage - curtex);
}
int texoffs = TEXTUREMASK - ((xtex & (TEXTURESIZE - 1)) << TEXTURESHIFT);
int yend = skyheight - (wallheight[x] >> 3);
if(yend <= 0) continue;
for(int y = 0, offs = x; y < yend; y++, offs += vbufPitch)
vbuf[offs] = skytex[texoffs + (y * TEXTURESIZE) / skyheight];
}
}
#endif

1353
contrib/games/wolf3d/wl_play.cpp Executable file

File diff suppressed because it is too large Load Diff

143
contrib/games/wolf3d/wl_shade.cpp Executable file
View File

@ -0,0 +1,143 @@
#include "version.h"
#ifdef USE_SHADING
#include "wl_def.h"
#include "wl_shade.h"
typedef struct {
uint8_t destRed, destGreen, destBlue; // values between 0 and 255
uint8_t fogStrength;
} shadedef_t;
shadedef_t shadeDefs[] = {
{ 0, 0, 0, LSHADE_NOSHADING },
{ 0, 0, 0, LSHADE_NORMAL },
{ 0, 0, 0, LSHADE_FOG },
{ 40, 40, 40, LSHADE_NORMAL },
{ 60, 60, 60, LSHADE_FOG }
};
uint8_t shadetable[SHADE_COUNT][256];
int LSHADE_flag;
#ifdef USE_FEATUREFLAGS
// The lower 8-bit of the upper left tile of every map determine
// the used shading definition of shadeDefs.
static inline int GetShadeDefID()
{
int shadeID = ffDataTopLeft & 0x00ff;
assert(shadeID >= 0 && shadeID < lengthof(shadeDefs));
return shadeID;
}
#else
static int GetShadeDefID()
{
int shadeID;
switch(gamestate.episode * 10 + mapon)
{
case 0: shadeID = 4; break;
case 1:
case 2:
case 6: shadeID = 1; break;
case 3: shadeID = 0; break;
case 5: shadeID = 2; break;
default: shadeID = 3; break;
}
assert(shadeID >= 0 && shadeID < lengthof(shadeDefs));
return shadeID;
}
#endif
// Returns the palette index of the nearest matching color of the
// given RGB color in given palette
byte GetColor(byte red, byte green, byte blue, SDL_Color *palette)
{
byte mincol = 0;
double mindist = 200000.F, curdist, DRed, DGreen, DBlue;
SDL_Color *palPtr = palette;
for(int col = 0; col < 256; col++, palPtr++)
{
DRed = (double) (red - palPtr->r);
DGreen = (double) (green - palPtr->g);
DBlue = (double) (blue - palPtr->b);
curdist = DRed * DRed + DGreen * DGreen + DBlue * DBlue;
if(curdist < mindist)
{
mindist = curdist;
mincol = (byte) col;
}
}
return mincol;
}
// Fade all colors in 32 steps down to the destination-RGB
// (use gray for fogging, black for standard shading)
void GenerateShadeTable(byte destRed, byte destGreen, byte destBlue,
SDL_Color *palette, int fog)
{
double curRed, curGreen, curBlue, redStep, greenStep, blueStep;
SDL_Color *palPtr = palette;
// Set the fog-flag
LSHADE_flag=fog;
// Color loop
for(int i = 0; i < 256; i++, palPtr++)
{
// Get original palette color
curRed = palPtr->r;
curGreen = palPtr->g;
curBlue = palPtr->b;
// Calculate increment per step
redStep = ((double) destRed - curRed) / (SHADE_COUNT + 8);
greenStep = ((double) destGreen - curGreen) / (SHADE_COUNT + 8);
blueStep = ((double) destBlue - curBlue) / (SHADE_COUNT + 8);
// Calc color for each shade of the current color
for (int shade = 0; shade < SHADE_COUNT; shade++)
{
shadetable[shade][i] = GetColor((byte) curRed, (byte) curGreen, (byte) curBlue, palette);
// Inc to next shade
curRed += redStep;
curGreen += greenStep;
curBlue += blueStep;
}
}
}
void NoShading()
{
for(int shade = 0; shade < SHADE_COUNT; shade++)
for(int i = 0; i < 256; i++)
shadetable[shade][i] = i;
}
void InitLevelShadeTable()
{
shadedef_t *shadeDef = &shadeDefs[GetShadeDefID()];
if(shadeDef->fogStrength == LSHADE_NOSHADING)
NoShading();
else
GenerateShadeTable(shadeDef->destRed, shadeDef->destGreen, shadeDef->destBlue, gamepal, shadeDef->fogStrength);
}
int GetShade(int scale)
{
int shade = (scale >> 1) / (((viewwidth * 3) >> 8) + 1 + LSHADE_flag); // TODO: reconsider this...
if(shade > 32) shade = 32;
else if(shade < 1) shade = 1;
shade = 32 - shade;
return shade;
}
#endif

15
contrib/games/wolf3d/wl_shade.h Executable file
View File

@ -0,0 +1,15 @@
#if defined(USE_SHADING) && !defined(_WL_SHADE_H_)
#define _WL_SHADE_H_
#define SHADE_COUNT 32
#define LSHADE_NOSHADING 0xff
#define LSHADE_NORMAL 0
#define LSHADE_FOG 5
extern uint8_t shadetable[SHADE_COUNT][256];
void InitLevelShadeTable();
int GetShade(int scale);
#endif

1530
contrib/games/wolf3d/wl_state.cpp Executable file

File diff suppressed because it is too large Load Diff

855
contrib/games/wolf3d/wl_text.cpp Executable file
View File

@ -0,0 +1,855 @@
// WL_TEXT.C
#include "wl_def.h"
#pragma hdrstop
/*
=============================================================================
TEXT FORMATTING COMMANDS
------------------------
^C<hex digit> Change text color
^E[enter] End of layout (all pages)
^G<y>,<x>,<pic>[enter] Draw a graphic and push margins
^P[enter] start new page, must be the first chars in a layout
^L<x>,<y>[ENTER] Locate to a specific spot, x in pixels, y in lines
=============================================================================
*/
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#ifndef SPEAR
#define BACKCOLOR 0x11
#define WORDLIMIT 80
#define FONTHEIGHT 10
#define TOPMARGIN 16
#define BOTTOMMARGIN 32
#define LEFTMARGIN 16
#define RIGHTMARGIN 16
#define PICMARGIN 8
#define TEXTROWS ((200-TOPMARGIN-BOTTOMMARGIN)/FONTHEIGHT)
#define SPACEWIDTH 7
#define SCREENPIXWIDTH 320
#define SCREENMID (SCREENPIXWIDTH/2)
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
static int pagenum;
static int numpages;
static unsigned leftmargin[TEXTROWS];
static unsigned rightmargin[TEXTROWS];
static char* text;
static unsigned rowon;
static int picx;
static int picy;
static int picnum;
static int picdelay;
static boolean layoutdone;
//===========================================================================
#ifndef JAPAN
/*
=====================
=
= RipToEOL
=
=====================
*/
void RipToEOL (void)
{
while (*text++ != '\n') // scan to end of line
;
}
/*
=====================
=
= ParseNumber
=
=====================
*/
int ParseNumber (void)
{
char ch;
char num[80];
char *numptr;
//
// scan until a number is found
//
ch = *text;
while (ch < '0' || ch >'9')
ch = *++text;
//
// copy the number out
//
numptr = num;
do
{
*numptr++ = ch;
ch = *++text;
} while (ch >= '0' && ch <= '9');
*numptr = 0;
return atoi (num);
}
/*
=====================
=
= ParsePicCommand
=
= Call with text pointing just after a ^P
= Upon exit text points to the start of next line
=
=====================
*/
void ParsePicCommand (void)
{
picy=ParseNumber();
picx=ParseNumber();
picnum=ParseNumber();
RipToEOL ();
}
void ParseTimedCommand (void)
{
picy=ParseNumber();
picx=ParseNumber();
picnum=ParseNumber();
picdelay=ParseNumber();
RipToEOL ();
}
/*
=====================
=
= TimedPicCommand
=
= Call with text pointing just after a ^P
= Upon exit text points to the start of next line
=
=====================
*/
void TimedPicCommand (void)
{
ParseTimedCommand ();
//
// update the screen, and wait for time delay
//
VW_UpdateScreen ();
//
// wait for time
//
Delay(picdelay);
//
// draw pic
//
VWB_DrawPic (picx&~7,picy,picnum);
}
/*
=====================
=
= HandleCommand
=
=====================
*/
void HandleCommand (void)
{
int i,margin,top,bottom;
int picwidth,picheight,picmid;
switch (toupper(*++text))
{
case 'B':
picy=ParseNumber();
picx=ParseNumber();
picwidth=ParseNumber();
picheight=ParseNumber();
VWB_Bar(picx,picy,picwidth,picheight,BACKCOLOR);
RipToEOL();
break;
case ';': // comment
RipToEOL();
break;
case 'P': // ^P is start of next page, ^E is end of file
case 'E':
layoutdone = true;
text--; // back up to the '^'
break;
case 'C': // ^c<hex digit> changes text color
i = toupper(*++text);
if (i>='0' && i<='9')
fontcolor = i-'0';
else if (i>='A' && i<='F')
fontcolor = i-'A'+10;
fontcolor *= 16;
i = toupper(*++text);
if (i>='0' && i<='9')
fontcolor += i-'0';
else if (i>='A' && i<='F')
fontcolor += i-'A'+10;
text++;
break;
case '>':
px = 160;
text++;
break;
case 'L':
py=ParseNumber();
rowon = (py-TOPMARGIN)/FONTHEIGHT;
py = TOPMARGIN+rowon*FONTHEIGHT;
px=ParseNumber();
while (*text++ != '\n') // scan to end of line
;
break;
case 'T': // ^Tyyy,xxx,ppp,ttt waits ttt tics, then draws pic
TimedPicCommand ();
break;
case 'G': // ^Gyyy,xxx,ppp draws graphic
ParsePicCommand ();
VWB_DrawPic (picx&~7,picy,picnum);
picwidth = pictable[picnum-STARTPICS].width;
picheight = pictable[picnum-STARTPICS].height;
//
// adjust margins
//
picmid = picx + picwidth/2;
if (picmid > SCREENMID)
margin = picx-PICMARGIN; // new right margin
else
margin = picx+picwidth+PICMARGIN; // new left margin
top = (picy-TOPMARGIN)/FONTHEIGHT;
if (top<0)
top = 0;
bottom = (picy+picheight-TOPMARGIN)/FONTHEIGHT;
if (bottom>=TEXTROWS)
bottom = TEXTROWS-1;
for (i=top;i<=bottom;i++)
if (picmid > SCREENMID)
rightmargin[i] = margin;
else
leftmargin[i] = margin;
//
// adjust this line if needed
//
if (px < (int) leftmargin[rowon])
px = leftmargin[rowon];
break;
}
}
/*
=====================
=
= NewLine
=
=====================
*/
void NewLine (void)
{
char ch;
if (++rowon == TEXTROWS)
{
//
// overflowed the page, so skip until next page break
//
layoutdone = true;
do
{
if (*text == '^')
{
ch = toupper(*(text+1));
if (ch == 'E' || ch == 'P')
{
layoutdone = true;
return;
}
}
text++;
} while (1);
}
px = leftmargin[rowon];
py+= FONTHEIGHT;
}
/*
=====================
=
= HandleCtrls
=
=====================
*/
void HandleCtrls (void)
{
char ch;
ch = *text++; // get the character and advance
if (ch == '\n')
{
NewLine ();
return;
}
}
/*
=====================
=
= HandleWord
=
=====================
*/
void HandleWord (void)
{
char wword[WORDLIMIT];
int wordindex;
word wwidth,wheight,newpos;
//
// copy the next word into [word]
//
wword[0] = *text++;
wordindex = 1;
while (*text>32)
{
wword[wordindex] = *text++;
if (++wordindex == WORDLIMIT)
Quit ("PageLayout: Word limit exceeded");
}
wword[wordindex] = 0; // stick a null at end for C
//
// see if it fits on this line
//
VW_MeasurePropString (wword,&wwidth,&wheight);
while (px+wwidth > (int) rightmargin[rowon])
{
NewLine ();
if (layoutdone)
return; // overflowed page
}
//
// print it
//
newpos = px+wwidth;
VWB_DrawPropString (wword);
px = newpos;
//
// suck up any extra spaces
//
while (*text == ' ')
{
px += SPACEWIDTH;
text++;
}
}
/*
=====================
=
= PageLayout
=
= Clears the screen, draws the pics on the page, and word wraps the text.
= Returns a pointer to the terminating command
=
=====================
*/
void PageLayout (boolean shownumber)
{
int i,oldfontcolor;
char ch;
oldfontcolor = fontcolor;
fontcolor = 0;
//
// clear the screen
//
VWB_Bar (0,0,320,200,BACKCOLOR);
VWB_DrawPic (0,0,H_TOPWINDOWPIC);
VWB_DrawPic (0,8,H_LEFTWINDOWPIC);
VWB_DrawPic (312,8,H_RIGHTWINDOWPIC);
VWB_DrawPic (8,176,H_BOTTOMINFOPIC);
for (i=0; i<TEXTROWS; i++)
{
leftmargin[i] = LEFTMARGIN;
rightmargin[i] = SCREENPIXWIDTH-RIGHTMARGIN;
}
px = LEFTMARGIN;
py = TOPMARGIN;
rowon = 0;
layoutdone = false;
//
// make sure we are starting layout text (^P first command)
//
while (*text <= 32)
text++;
if (*text != '^' || toupper(*++text) != 'P')
Quit ("PageLayout: Text not headed with ^P");
while (*text++ != '\n')
;
//
// process text stream
//
do
{
ch = *text;
if (ch == '^')
HandleCommand ();
else
if (ch == 9)
{
px = (px+8)&0xf8;
text++;
}
else if (ch <= 32)
HandleCtrls ();
else
HandleWord ();
} while (!layoutdone);
pagenum++;
if (shownumber)
{
#ifdef SPANISH
sprintf(str, "Hoja %d de %d", pagenum, numpages);
px = 208;
#else
sprintf(str, "pg %d of %d", pagenum, numpages);
px = 213;
#endif
py = 183;
fontcolor = 0x4f; //12^BACKCOLOR;
VWB_DrawPropString (str);
}
fontcolor = oldfontcolor;
}
//===========================================================================
/*
=====================
=
= BackPage
=
= Scans for a previous ^P
=
=====================
*/
void BackPage (void)
{
pagenum--;
do
{
text--;
if (*text == '^' && toupper(*(text+1)) == 'P')
return;
} while (1);
}
//===========================================================================
/*
=====================
=
= CacheLayoutGraphics
=
= Scans an entire layout file (until a ^E) marking all graphics used, and
= counting pages, then caches the graphics in
=
=====================
*/
void CacheLayoutGraphics (void)
{
char *bombpoint, *textstart;
char ch;
textstart = text;
bombpoint = text+30000;
numpages = pagenum = 0;
do
{
if (*text == '^')
{
ch = toupper(*++text);
if (ch == 'P') // start of a page
numpages++;
if (ch == 'E') // end of file, so load graphics and return
{
#ifndef SPEAR
CA_CacheGrChunk(H_TOPWINDOWPIC);
CA_CacheGrChunk(H_LEFTWINDOWPIC);
CA_CacheGrChunk(H_RIGHTWINDOWPIC);
CA_CacheGrChunk(H_BOTTOMINFOPIC);
#endif
// CA_CacheMarks ();
text = textstart;
return;
}
if (ch == 'G') // draw graphic command, so mark graphics
{
ParsePicCommand ();
CA_CacheGrChunk (picnum);
}
if (ch == 'T') // timed draw graphic command, so mark graphics
{
ParseTimedCommand ();
CA_CacheGrChunk (picnum);
}
}
else
text++;
} while (text<bombpoint);
Quit ("CacheLayoutGraphics: No ^E to terminate file!");
}
#endif
/*
=====================
=
= ShowArticle
=
=====================
*/
#ifdef JAPAN
void ShowArticle (int which)
#else
void ShowArticle (char *article)
#endif
{
#ifdef JAPAN
int snames[10] = {
H_HELP1PIC,
H_HELP2PIC,
H_HELP3PIC,
H_HELP4PIC,
H_HELP5PIC,
H_HELP6PIC,
H_HELP7PIC,
H_HELP8PIC,
H_HELP9PIC,
H_HELP10PIC};
int enames[14] = {
0,0,
#ifndef JAPDEMO
C_ENDGAME1APIC,
C_ENDGAME1BPIC,
C_ENDGAME2APIC,
C_ENDGAME2BPIC,
C_ENDGAME3APIC,
C_ENDGAME3BPIC,
C_ENDGAME4APIC,
C_ENDGAME4BPIC,
C_ENDGAME5APIC,
C_ENDGAME5BPIC,
C_ENDGAME6APIC,
C_ENDGAME6BPIC
#endif
};
#endif
unsigned oldfontnumber;
boolean newpage,firstpage;
ControlInfo ci;
#ifdef JAPAN
pagenum = 1;
if (!which)
numpages = 10;
else
numpages = 2;
#else
text = article;
oldfontnumber = fontnumber;
fontnumber = 0;
CA_CacheGrChunk(STARTFONT);
VWB_Bar (0,0,320,200,BACKCOLOR);
CacheLayoutGraphics ();
#endif
newpage = true;
firstpage = true;
do
{
if (newpage)
{
newpage = false;
#ifdef JAPAN
if (!which)
CA_CacheScreen(snames[pagenum - 1]);
else
CA_CacheScreen(enames[which*2 + pagenum - 1]);
#else
PageLayout (true);
#endif
VW_UpdateScreen ();
if (firstpage)
{
VL_FadeIn(0,255,gamepal,10);
firstpage = false;
}
}
SDL_Delay(5);
LastScan = 0;
ReadAnyControl(&ci);
Direction dir = ci.dir;
switch(dir)
{
case dir_North:
case dir_South:
break;
default:
if(ci.button0) dir = dir_South;
switch(LastScan)
{
case sc_UpArrow:
case sc_PgUp:
case sc_LeftArrow:
dir = dir_North;
break;
case sc_Enter:
case sc_DownArrow:
case sc_PgDn:
case sc_RightArrow:
dir = dir_South;
break;
}
break;
}
switch(dir)
{
case dir_North:
case dir_West:
if (pagenum>1)
{
#ifndef JAPAN
BackPage ();
BackPage ();
#else
pagenum--;
#endif
newpage = true;
}
TicDelay(20);
break;
case dir_South:
case dir_East:
if (pagenum<numpages)
{
newpage = true;
#ifdef JAPAN
pagenum++;
#endif
}
TicDelay(20);
break;
}
} while (LastScan != sc_Escape && !ci.button1);
IN_ClearKeysDown ();
fontnumber = oldfontnumber;
}
//===========================================================================
#ifndef JAPAN
#ifdef ARTSEXTERN
int endextern = T_ENDART1;
#ifndef SPEAR
int helpextern = T_HELPART;
#endif
#endif
char helpfilename[13] = "HELPART.",
endfilename[13] = "ENDART1.";
#endif
/*
=================
=
= HelpScreens
=
=================
*/
#ifndef SPEAR
void HelpScreens (void)
{
int artnum;
char *text;
#ifndef ARTSEXTERN
memptr layout;
#endif
#ifdef JAPAN
ShowArticle (0);
VW_FadeOut();
FreeMusic ();
#else
#ifdef ARTSEXTERN
artnum = helpextern;
CA_CacheGrChunk (artnum);
text = (char *)grsegs[artnum];
#else
CA_LoadFile (helpfilename,&layout);
text = (char *)layout;
#endif
ShowArticle (text);
#ifdef ARTSEXTERN
UNCACHEGRCHUNK(artnum);
#else
free(layout);
#endif
VW_FadeOut();
FreeMusic ();
#endif
}
#endif
//
// END ARTICLES
//
void EndText (void)
{
int artnum;
char *text;
#ifndef ARTSEXTERN
memptr layout;
#endif
ClearMemory ();
#ifdef JAPAN
ShowArticle(gamestate.episode + 1);
VW_FadeOut();
SETFONTCOLOR(0,15);
IN_ClearKeysDown();
if (MousePresent && IN_IsInputGrabbed())
IN_CenterMouse(); // Clear accumulated mouse movement
FreeMusic ();
#else
#ifdef ARTSEXTERN
artnum = endextern+gamestate.episode;
CA_CacheGrChunk (artnum);
text = (char *)grsegs[artnum];
#else
endfilename[6] = '1'+gamestate.episode;
CA_LoadFile (endfilename,&layout);
text = (char *)layout;
#endif
ShowArticle (text);
#ifdef ARTSEXTERN
UNCACHEGRCHUNK(artnum);
#else
free(layout);
#endif
VW_FadeOut();
SETFONTCOLOR(0,15);
IN_ClearKeysDown();
if (MousePresent && IN_IsInputGrabbed())
IN_CenterMouse(); // Clear accumulated mouse movement
FreeMusic ();
#endif
}
#endif

View File

@ -0,0 +1,52 @@
RGB( 0, 0, 0),RGB( 0, 0, 42),RGB( 0, 42, 0),RGB( 0, 42, 42),RGB( 42, 0, 0),
RGB( 42, 0, 42),RGB( 42, 21, 0),RGB( 42, 42, 42),RGB( 21, 21, 21),RGB( 21, 21, 63),
RGB( 21, 63, 21),RGB( 21, 63, 63),RGB( 63, 21, 21),RGB( 63, 21, 63),RGB( 63, 63, 21),
RGB( 63, 63, 63),RGB( 59, 59, 59),RGB( 55, 55, 55),RGB( 52, 52, 52),RGB( 48, 48, 48),
RGB( 45, 45, 45),RGB( 42, 42, 42),RGB( 38, 38, 38),RGB( 35, 35, 35),RGB( 31, 31, 31),
RGB( 28, 28, 28),RGB( 25, 25, 25),RGB( 21, 21, 21),RGB( 18, 18, 18),RGB( 14, 14, 14),
RGB( 11, 11, 11),RGB( 8, 8, 8),RGB( 63, 0, 0),RGB( 59, 0, 0),RGB( 56, 0, 0),
RGB( 53, 0, 0),RGB( 50, 0, 0),RGB( 47, 0, 0),RGB( 44, 0, 0),RGB( 41, 0, 0),
RGB( 38, 0, 0),RGB( 34, 0, 0),RGB( 31, 0, 0),RGB( 28, 0, 0),RGB( 25, 0, 0),
RGB( 22, 0, 0),RGB( 19, 0, 0),RGB( 16, 0, 0),RGB( 63, 54, 54),RGB( 63, 46, 46),
RGB( 63, 39, 39),RGB( 63, 31, 31),RGB( 63, 23, 23),RGB( 63, 16, 16),RGB( 63, 8, 8),
RGB( 63, 0, 0),RGB( 63, 42, 23),RGB( 63, 38, 16),RGB( 63, 34, 8),RGB( 63, 30, 0),
RGB( 57, 27, 0),RGB( 51, 24, 0),RGB( 45, 21, 0),RGB( 39, 19, 0),RGB( 63, 63, 54),
RGB( 63, 63, 46),RGB( 63, 63, 39),RGB( 63, 63, 31),RGB( 63, 62, 23),RGB( 63, 61, 16),
RGB( 63, 61, 8),RGB( 63, 61, 0),RGB( 57, 54, 0),RGB( 51, 49, 0),RGB( 45, 43, 0),
RGB( 39, 39, 0),RGB( 33, 33, 0),RGB( 28, 27, 0),RGB( 22, 21, 0),RGB( 16, 16, 0),
RGB( 52, 63, 23),RGB( 49, 63, 16),RGB( 45, 63, 8),RGB( 40, 63, 0),RGB( 36, 57, 0),
RGB( 32, 51, 0),RGB( 29, 45, 0),RGB( 24, 39, 0),RGB( 54, 63, 54),RGB( 47, 63, 46),
RGB( 39, 63, 39),RGB( 32, 63, 31),RGB( 24, 63, 23),RGB( 16, 63, 16),RGB( 8, 63, 8),
RGB( 0, 63, 0),RGB( 0, 63, 0),RGB( 0, 59, 0),RGB( 0, 56, 0),RGB( 0, 53, 0),
RGB( 1, 50, 0),RGB( 1, 47, 0),RGB( 1, 44, 0),RGB( 1, 41, 0),RGB( 1, 38, 0),
RGB( 1, 34, 0),RGB( 1, 31, 0),RGB( 1, 28, 0),RGB( 1, 25, 0),RGB( 1, 22, 0),
RGB( 1, 19, 0),RGB( 1, 16, 0),RGB( 54, 63, 63),RGB( 46, 63, 63),RGB( 39, 63, 63),
RGB( 31, 63, 62),RGB( 23, 63, 63),RGB( 16, 63, 63),RGB( 8, 63, 63),RGB( 0, 63, 63),
RGB( 0, 57, 57),RGB( 0, 51, 51),RGB( 0, 45, 45),RGB( 0, 39, 39),RGB( 0, 33, 33),
RGB( 0, 28, 28),RGB( 0, 22, 22),RGB( 0, 16, 16),RGB( 23, 47, 63),RGB( 16, 44, 63),
RGB( 8, 42, 63),RGB( 0, 39, 63),RGB( 0, 35, 57),RGB( 0, 31, 51),RGB( 0, 27, 45),
RGB( 0, 23, 39),RGB( 54, 54, 63),RGB( 46, 47, 63),RGB( 39, 39, 63),RGB( 31, 32, 63),
RGB( 23, 24, 63),RGB( 16, 16, 63),RGB( 8, 9, 63),RGB( 0, 1, 63),RGB( 0, 0, 63),
RGB( 0, 0, 59),RGB( 0, 0, 56),RGB( 0, 0, 53),RGB( 0, 0, 50),RGB( 0, 0, 47),
RGB( 0, 0, 44),RGB( 0, 0, 41),RGB( 0, 0, 38),RGB( 0, 0, 34),RGB( 0, 0, 31),
RGB( 0, 0, 28),RGB( 0, 0, 25),RGB( 0, 0, 22),RGB( 0, 0, 19),RGB( 0, 0, 16),
RGB( 10, 10, 10),RGB( 63, 56, 13),RGB( 63, 53, 9),RGB( 63, 51, 6),RGB( 63, 48, 2),
RGB( 63, 45, 0),RGB( 45, 8, 63),RGB( 42, 0, 63),RGB( 38, 0, 57),RGB( 32, 0, 51),
RGB( 29, 0, 45),RGB( 24, 0, 39),RGB( 20, 0, 33),RGB( 17, 0, 28),RGB( 13, 0, 22),
RGB( 10, 0, 16),RGB( 63, 54, 63),RGB( 63, 46, 63),RGB( 63, 39, 63),RGB( 63, 31, 63),
RGB( 63, 23, 63),RGB( 63, 16, 63),RGB( 63, 8, 63),RGB( 63, 0, 63),RGB( 56, 0, 57),
RGB( 50, 0, 51),RGB( 45, 0, 45),RGB( 39, 0, 39),RGB( 33, 0, 33),RGB( 27, 0, 28),
RGB( 22, 0, 22),RGB( 16, 0, 16),RGB( 63, 58, 55),RGB( 63, 56, 52),RGB( 63, 54, 49),
RGB( 63, 53, 47),RGB( 63, 51, 44),RGB( 63, 49, 41),RGB( 63, 47, 39),RGB( 63, 46, 36),
RGB( 63, 44, 32),RGB( 63, 41, 28),RGB( 63, 39, 24),RGB( 60, 37, 23),RGB( 58, 35, 22),
RGB( 55, 34, 21),RGB( 52, 32, 20),RGB( 50, 31, 19),RGB( 47, 30, 18),RGB( 45, 28, 17),
RGB( 42, 26, 16),RGB( 40, 25, 15),RGB( 39, 24, 14),RGB( 36, 23, 13),RGB( 34, 22, 12),
RGB( 32, 20, 11),RGB( 29, 19, 10),RGB( 27, 18, 9),RGB( 23, 16, 8),RGB( 21, 15, 7),
RGB( 18, 14, 6),RGB( 16, 12, 6),RGB( 14, 11, 5),RGB( 10, 8, 3),RGB( 24, 0, 25),
RGB( 0, 25, 25),RGB( 0, 24, 24),RGB( 0, 0, 7),RGB( 0, 0, 11),RGB( 12, 9, 4),
RGB( 18, 0, 18),RGB( 20, 0, 20),RGB( 0, 0, 13),RGB( 7, 7, 7),RGB( 19, 19, 19),
RGB( 23, 23, 23),RGB( 16, 16, 16),RGB( 12, 12, 12),RGB( 13, 13, 13),RGB( 54, 61, 61),
RGB( 46, 58, 58),RGB( 39, 55, 55),RGB( 29, 50, 50),RGB( 18, 48, 48),RGB( 8, 45, 45),
RGB( 8, 44, 44),RGB( 0, 41, 41),RGB( 0, 38, 38),RGB( 0, 35, 35),RGB( 0, 33, 33),
RGB( 0, 31, 31),RGB( 0, 30, 30),RGB( 0, 29, 29),RGB( 0, 28, 28),RGB( 0, 27, 27),
RGB( 38, 0, 34)