├── CONTRIBUTORS.md ├── ERRORDETECTION.md ├── LICENSE ├── PSXDOOM ├── GAME │ ├── CD │ │ └── PSXDOOM │ │ │ ├── ABIN │ │ │ └── MOVIE.STR │ │ │ ├── CDAUDIO │ │ │ └── tmp.txt │ │ │ ├── MAPDIR0 │ │ │ └── tmp.txt │ │ │ ├── MAPDIR1 │ │ │ └── tmp.txt │ │ │ ├── MAPDIR2 │ │ │ └── tmp.txt │ │ │ ├── MAPDIR3 │ │ │ └── tmp.txt │ │ │ ├── MUSIC │ │ │ └── tmp.txt │ │ │ ├── SNDMAPS1 │ │ │ └── tmp.txt │ │ │ ├── SNDMAPS2 │ │ │ └── tmp.txt │ │ │ └── SNDMAPS3 │ │ │ └── tmp.txt │ ├── MAKE_CD.bat │ ├── PSXDOOMCD.xml │ ├── libgcc_s_dw2-1.dll │ ├── libstdc++-6.dll │ ├── licensea.dat │ └── mkpsxiso.exe ├── LCDLOAD.C ├── LCDLOAD.H ├── MAIN.LNK ├── MAKEFILE.bat ├── PSXCD.C ├── PSXCD.H ├── PSXCDABS.C ├── PSXCDABS.H ├── PSXCMD.C ├── PSXDOOM.cbp ├── PSXSPU.C ├── PSXSPU.H ├── PSX_FILE.C ├── PSX_PAD.C ├── SEQLOAD.C ├── SEQLOAD.H ├── SEQLOADR.C ├── WESSAPI.C ├── WESSAPI.H ├── WESSAPIM.C ├── WESSAPIP.C ├── WESSAPIT.C ├── WESSARC.C ├── WESSARC.H ├── WESSBASE.C ├── WESSSEQ.C ├── WESSSEQ.H ├── am_main.c ├── asm │ └── tmp.txt ├── c_main.c ├── cf_main.c ├── d_main.c ├── doomdata.h ├── doomdef.h ├── f_main.c ├── g_game.c ├── in_main.c ├── info.c ├── info.h ├── l_main.c ├── m_fixed.c ├── m_fixed.s ├── m_main.c ├── m_password.c ├── o_main.c ├── obj │ └── tmp.txt ├── p_base.c ├── p_ceilng.c ├── p_change.c ├── p_doors.c ├── p_enemy.c ├── p_floor.c ├── p_inter.c ├── p_lights.c ├── p_local.h ├── p_map.c ├── p_maputl.c ├── p_mobj.c ├── p_move.c ├── p_plats.c ├── p_pspr.c ├── p_setup.c ├── p_shoot.c ├── p_sight.c ├── p_slide.c ├── p_spec.c ├── p_spec.h ├── p_switch.c ├── p_telept.c ├── p_tick.c ├── p_user.c ├── psxmain.c ├── pw_main.c ├── r_data.c ├── r_local.h ├── r_main.c ├── r_phase1.c ├── r_phase2.c ├── s_sound.c ├── snmain.s ├── sounds.h ├── soundst.h ├── sprinfo.c ├── st_main.c ├── st_main.h ├── t_main.c ├── tables.c ├── vsprintf.c ├── w_wad.c └── z_zone.c ├── PSYQ ├── CPE2X.EXE ├── README.txt └── cpe2x_gec.exe └── README.md /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | 2 | = PSXFINALDOOM RE contributors (sorted alphabetically) 3 | = 4 | 5 | * **[Darragh Coy (intacowetrust)](https://github.com/BodbDearg)** 6 | 7 | * Various information and code for PSX DOOM based on his own extensive reverse engineering efforts, including: 8 | 9 | * Suggestions for changing names in variables: 10 | 11 | cheatfullbright -> viewlighting 12 | solidseg -> solidsubsectors 13 | newend-> endsubsector 14 | numsegs-> numdrawsubsectors 15 | xtoviewangle -> yslope 16 | vissprites_tmp ->visspritehead 17 | lastsprite_p -> next 18 | 19 | * Identification of differences in the DrawImage and I_DrawSprite code: 20 | https://github.com/BodbDearg/PsyDoom/commit/9360bd322bc939a29903f21b19f216931b67f196#r37085143 21 | 22 | * Bug identification, on line 259 in p_tick.c: 23 | https://github.com/BodbDearg/PsyDoom/commit/50862aab3a3511dbc33269ee1249429314a71c18#commitcomment-37125911 24 | 25 | * Identification of non-existent lines in the original code: 26 | https://github.com/BodbDearg/PsyDoom/commit/8b7afc9d06f76c9f7fd00fc2e840107dd79a01de#r37163087 27 | https://github.com/BodbDearg/PsyDoom/commit/775e02de38cd3bf50e3dfa7173529c6ff783d641#r37185771 28 | 29 | * Update Identification from Psx Doom Greatest Hits: 30 | https://github.com/BodbDearg/PsyDoom/commit/775e02de38cd3bf50e3dfa7173529c6ff783d641#r37185747 31 | 32 | * Fire sky width repair in title: 33 | https://github.com/BodbDearg/PsyDoom/commit/9bd75ff52b517bec0737d946b12db5254a1d0e95 34 | 35 | * Identification of error in the CD_TRACK array: 36 | https://github.com/BodbDearg/PsyDoom/commit/7f75f07502bcac6557c7d026f0188f07704899a6#r37223485 37 | 38 | * Identification of non-existent lines, in the first version of Psx Doom, but which were subsequently added in the Greatest Hits version: 39 | https://github.com/BodbDearg/PsyDoom/commit/0457990ceebdf6e0e5cd9279e63a25b97f96a28c#r37246141 40 | 41 | * Line identification that is present in the 'Greatest Hits' version 42 | https://github.com/BodbDearg/PsyDoom/commit/f258d1713611a4e3ea3766f4e02266f3a0772638#r37268303 43 | 44 | * Identification of a small correction on line 265 in am_main.cpp 45 | https://github.com/BodbDearg/PsyDoom/commit/40816754f7978d4c2b3c34bf0cdb31c8e50abd0b#r37315450 46 | 47 | * Error identification in state blocks (else / if), in the files (f_main.c and st_main.c) 48 | https://github.com/BodbDearg/PsyDoom/commit/f4d6fb8b428ff0262cde02f7c77fdd71dc45d0bc#r37348133 49 | https://github.com/BodbDearg/PsyDoom/commit/201f293f0473e288c77b2f6e3c1a4c8b622c2968#commitcomment-37368964 50 | 51 | * Non-existent lines are blocked in Psx Doom 52 | https://github.com/BodbDearg/PsyDoom/commit/d60da8761208e3cb137e5b5fb85c6dd3a9ff514c#r37805111 53 | 54 | * Wess_malloc : fix function signature 55 | https://github.com/BodbDearg/PsyDoom/commit/a89ae26943fe08dc213d77bcabc50090c74316f0 56 | 57 | * Return fix in wess_seq_loader_init function 58 | https://github.com/BodbDearg/PsyDoom/commit/81f2bdc65724d2d7bce01e89900845803edeb957#r38278381 59 | 60 | * Error identification on the line (168) in wess_seq_load_sub function 61 | https://github.com/BodbDearg/PsyDoom/commit/89b38b23f6e0067d7ac123960c0cdc6064a8ef51#r38286066 62 | 63 | * Changes in data types in variable ptk_stat->psp 64 | https://github.com/BodbDearg/PsyDoom/commit/3eea78ba5a31da31f1007061f95bd6e32d275754#commitcomment-38312476 65 | https://github.com/BodbDearg/PsyDoom/commit/b952d4be8126ae1fa16f3dfdb87b190c5db6aabb 66 | 67 | * Changes in (Write_Vlq and Len_Vlq) functions 68 | https://github.com/BodbDearg/PsyDoom/commit/f5e0d69afeb1dee45b699002ee26fe513ae2271d 69 | 70 | * Non-existent return statement identification 71 | https://github.com/BodbDearg/PsyDoom/commit/1a01906c71ea7aadd5a1393cb0cf3365ed68138e#r38841312 72 | 73 | * Identification Missing sum in damagecount 74 | https://github.com/BodbDearg/PsyDoom/commit/69dd2e3ad910eb1dcf5bd159651aafea7e21e3fa 75 | 76 | * Automap: fix a PSX DOOM bug where lines flagged with ML_DONTDRAW 77 | https://github.com/BodbDearg/PsyDoom/commit/5a9b4059ac7a18b724edc380c26fa3fc6e548f5a 78 | 79 | * Range checks, added from Psy Doom to avoid alterations in P_RadiusAttack 80 | https://github.com/BodbDearg/PsyDoom/commit/107f7d3d91824e06f3b9e5106e3498e98a590ebe 81 | 82 | * P_FindNextHighestFloor: rewritten to avoid possible undefined behavior, from PsyDoom 83 | https://github.com/BodbDearg/PsyDoom/commit/91a3cc54e050d1ebba3572fb935a2625717ee21f 84 | 85 | * P_CheckKeyLock and P_SpawnSpecials: added skull key detection code from Greatest Hits version, also fatal BUFFER OVERFLOW is corrected in the D_memset assignment in activeceilings and activeplats 86 | https://github.com/BodbDearg/PsyDoom/commit/227fbaddf5237088d236865169cb2cae995043a5 87 | https://github.com/BodbDearg/PsyDoom/commit/f9e7295f63a2757f68bca66eb83661de71b184e5 88 | 89 | * P_SpawnStrobeFlashFast: Fixed `minlight` and` maxlight` assignments, as they were reversed. 90 | https://github.com/BodbDearg/PsyDoom/commit/8dec4ccbbd73d278b7b1d0d8e1090b0e39ad539d 91 | 92 | * T_CountdownTimer: Correction of regressive count, the code towards which an extra tick will be delayed to carry out the action 93 | https://github.com/BodbDearg/PsyDoom/commit/890d7dd90474b837d552b45cd38d737f11f7477f 94 | 95 | * P_UseLines: Another blockmap check ranges is added 96 | https://github.com/BodbDearg/PsyDoom/commit/ea5f99886ae054ac89c88dc961402b681a5b1562 97 | 98 | * A_CheckReload: Eliminate the return status and change a "void" like in Doom PC, since it's return is unnecessary. 99 | https://github.com/BodbDearg/PsyDoom/commit/7c6d6d851cd6f7f9ac6c3ddd04ce37c8ca53632b 100 | 101 | * A_Punch and A_Saw: (angle_t) identification is added before (P_Random () - P_Random ()), in order to avoid demo desynchronization 102 | https://github.com/BodbDearg/PsyDoom/commit/7b3d77fdb689f98808faf7a0d3a77f80556dd079 103 | https://github.com/BodbDearg/PsyDoom/commit/dc56fa6d91ee6d8f54aa11e9053fafd85ddad7f3 104 | 105 | * Suggestion to create a code to increase the map limit to 255 106 | https://github.com/BodbDearg/PsyDoom/commit/78436a90bfb8e2318141c13bce2e9c8f313af814 107 | 108 | * Floor rendering fix, from PsyDoom 109 | https://github.com/BodbDearg/PsyDoom/commit/2a0250ca6b43d920706849d0d9018cc4656cb1f1 110 | 111 | * **[Fabien Sanglard](https://github.com/fabiensanglard)** 112 | 113 | * Article **[The Polygons of Doom: PSX](http://fabiensanglard.net/doom_psx/index.html)** 114 | * Fix cryptic magic number "mode" for Plane rendition 115 | 116 | * **[James Haley (Quasar)](https://github.com/haleyjd)** 117 | * Wrong name identification in the PA_PointOnDivlineSide function, which must be called PA_DivlineSide 118 | 119 | * **[Samuel Villarreal (svkaiser)](https://github.com/svkaiser)** 120 | 121 | * Console DOOM reverse engineering, specs & tools: 122 | https://www.doomworld.com/forum/topic/38608-the-console-doom-hacking-project-console-specs 123 | * Doom64-EX source code (DOOM 64 was based on PSX DOOM, thus can serve as a reference point for it): 124 | https://github.com/svkaiser/Doom64EX 125 | -------------------------------------------------------------------------------- /ERRORDETECTION.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/ERRORDETECTION.md -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/ABIN/MOVIE.STR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/GAME/CD/PSXDOOM/ABIN/MOVIE.STR -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/CDAUDIO/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/MAPDIR0/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/MAPDIR1/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/MAPDIR2/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/MAPDIR3/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/MUSIC/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/SNDMAPS1/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/SNDMAPS2/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/CD/PSXDOOM/SNDMAPS3/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/GAME/MAKE_CD.bat: -------------------------------------------------------------------------------- 1 | mkpsxiso.exe -y -makeabs -lba2 doom.txt -lba doom_.txt PSXDOOMCD.xml 2 | 3 | copy PSXCDABS.C ..\ 4 | copy PSXCDABS.H ..\ 5 | pause -------------------------------------------------------------------------------- /PSXDOOM/GAME/libgcc_s_dw2-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/GAME/libgcc_s_dw2-1.dll -------------------------------------------------------------------------------- /PSXDOOM/GAME/libstdc++-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/GAME/libstdc++-6.dll -------------------------------------------------------------------------------- /PSXDOOM/GAME/licensea.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/GAME/licensea.dat -------------------------------------------------------------------------------- /PSXDOOM/GAME/mkpsxiso.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/GAME/mkpsxiso.exe -------------------------------------------------------------------------------- /PSXDOOM/LCDLOAD.H: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------*/ 2 | /* 3 | Williams Entertainment Sound System 4 | by Scott Patterson 5 | 6 | Application Programming Interface Routines: 7 | 8 | - digital (in linear .LCD file) load functions 9 | */ 10 | /*------------------------------------------------------------------*/ 11 | 12 | #define SAMPLE_RECORD_SIZE 100 13 | 14 | typedef struct SampleBlock { 15 | unsigned short numsamps;//r* 16 | unsigned short sampindx[SAMPLE_RECORD_SIZE];//r*2 17 | unsigned short samppos[SAMPLE_RECORD_SIZE];//r*4 18 | }SampleBlock; 19 | 20 | extern int wess_dig_lcd_loader_init(void *input_pm_stat); 21 | 22 | extern void wess_dig_set_sample_position(int samplenum, char *samplepos); 23 | 24 | extern int wess_dig_lcd_load(char *lcdfilename,void *memptr,SampleBlock *sampblk, int override); 25 | 26 | 27 | -------------------------------------------------------------------------------- /PSXDOOM/MAIN.LNK: -------------------------------------------------------------------------------- 1 | 2 | org $80010000 3 | 4 | text group ; main text group 5 | bss group bss ; main data group 6 | 7 | section .rdata,text ; main sections 8 | section .text,text 9 | section .data,text 10 | section .sdata,text 11 | 12 | section .sbss,bss ; The bss sections 13 | section .bss,bss 14 | 15 | ; 16 | ; Object files 17 | ; 18 | 19 | include "obj\d_main.obj" 20 | include "obj\info.obj" 21 | include "obj\sprinfo.obj" 22 | include "obj\g_game.obj" 23 | include "obj\p_base.obj" 24 | include "obj\p_ceilng.obj" 25 | include "obj\p_change.obj" 26 | include "obj\p_doors.obj" 27 | include "obj\p_enemy.obj" 28 | include "obj\p_floor.obj" 29 | include "obj\p_inter.obj" 30 | include "obj\p_lights.obj" 31 | include "obj\p_map.obj" 32 | include "obj\p_maputl.obj" 33 | include "obj\p_mobj.obj" 34 | include "obj\p_move.obj" 35 | include "obj\p_plats.obj" 36 | include "obj\p_pspr.obj" 37 | include "obj\p_setup.obj" 38 | include "obj\p_shoot.obj" 39 | include "obj\p_sight.obj" 40 | include "obj\p_slide.obj" 41 | include "obj\p_spec.obj" 42 | include "obj\p_switch.obj" 43 | include "obj\p_telept.obj" 44 | include "obj\p_tick.obj" 45 | include "obj\p_user.obj" 46 | include "obj\r_phase1.obj" 47 | include "obj\r_phase2.obj" 48 | include "obj\r_data.obj" 49 | include "obj\r_main.obj" 50 | include "obj\vsprintf.obj" 51 | include "obj\w_wad.obj" 52 | include "obj\psx_file.obj" 53 | include "obj\z_zone.obj" 54 | include "obj\psxmain.obj" 55 | ;include "obj\psxmain_mip.obj" ;//-----MIPS 56 | include "obj\l_main.obj" 57 | include "obj\t_main.obj" 58 | include "obj\m_main.obj" 59 | include "obj\c_main.obj" 60 | include "obj\pw_main.obj" 61 | include "obj\cf_main.obj" 62 | include "obj\m_password.obj" 63 | include "obj\psx_pad.obj" 64 | include "obj\st_main.obj" 65 | include "obj\am_main.obj" 66 | include "obj\in_main.obj" 67 | include "obj\f_main.obj" 68 | include "obj\o_main.obj" 69 | include "obj\m_fixed.obj" 70 | include "obj\tables.obj" 71 | include "obj\psxcd.obj" 72 | include "obj\s_sound.obj" 73 | include "obj\psxspu.obj" 74 | include "obj\psxcmd.obj" 75 | include "obj\wessapip.obj" 76 | include "obj\wessapi.obj" 77 | include "obj\wessarc.obj" 78 | include "obj\wessapit.obj" 79 | include "obj\wessseq.obj" 80 | include "obj\seqload.obj" 81 | include "obj\lcdload.obj" 82 | include "obj\wessapim.obj" 83 | include "obj\seqloadr.obj" 84 | 85 | include "obj\wessbase.obj" 86 | 87 | include "obj\snmain.obj" 88 | 89 | ; 90 | ; Library files 91 | ; 92 | 93 | inclib "C:\psyq\lib\libsn.lib" 94 | inclib "C:\psyq\lib\libapi.lib" 95 | inclib "C:\psyq\lib\libetc.lib" 96 | inclib "C:\psyq\lib\libgpu.lib" 97 | inclib "C:\psyq\lib\libgte.lib" 98 | inclib "C:\psyq\lib\libspu.lib" 99 | inclib "C:\psyq\lib\libc.lib" 100 | inclib "C:\psyq\lib\libcd.lib" 101 | inclib "C:\psyq\lib\libc2.lib" 102 | inclib "C:\psyq\lib\libcomb.lib" 103 | 104 | ; The following line initializes the program counter register so 105 | ; that the downloader sets the entry point before the program 106 | ; is executed. SN_ENTRY_POINT is defined in a module in 107 | ; ligsn.lib and clears the bss, sets up the heap, etc., before 108 | ; calling main(). 109 | 110 | regs pc=__SN_ENTRY_POINT ; entry point 111 | 112 | -------------------------------------------------------------------------------- /PSXDOOM/MAKEFILE.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set PATH=C:\psyq\bin 3 | set PSYQ_PATH=C:\psyq\bin 4 | 5 | ::remove_all: 6 | del obj\*.obj 7 | del asm\*.s 8 | @echo on 9 | 10 | ::all: 11 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/d_main.obj d_main.c 12 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/info.obj info.c 13 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/sprinfo.obj sprinfo.c 14 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/g_game.obj g_game.c 15 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_base.obj p_base.c 16 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_ceilng.obj p_ceilng.c 17 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_change.obj p_change.c 18 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_doors.obj p_doors.c 19 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_enemy.obj p_enemy.c 20 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_floor.obj p_floor.c 21 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_inter.obj p_inter.c 22 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_lights.obj p_lights.c 23 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_map.obj p_map.c 24 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_maputl.obj p_maputl.c 25 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_mobj.obj p_mobj.c 26 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_move.obj p_move.c 27 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_plats.obj p_plats.c 28 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_pspr.obj p_pspr.c 29 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_setup.obj p_setup.c 30 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_shoot.obj p_shoot.c 31 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_sight.obj p_sight.c 32 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_slide.obj p_slide.c 33 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_spec.obj p_spec.c 34 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_switch.obj p_switch.c 35 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_telept.obj p_telept.c 36 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_tick.obj p_tick.c 37 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/p_user.obj p_user.c 38 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/r_phase1.obj r_phase1.c 39 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/r_phase2.obj r_phase2.c 40 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/r_data.obj r_data.c 41 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/r_main.obj r_main.c 42 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/vsprintf.obj vsprintf.c 43 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/w_wad.obj w_wad.c 44 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psx_file.obj psx_file.c 45 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/z_zone.obj z_zone.c 46 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psxmain.obj psxmain.c 47 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/l_main.obj l_main.c 48 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/t_main.obj t_main.c 49 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/m_main.obj m_main.c 50 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/c_main.obj c_main.c 51 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/pw_main.obj pw_main.c 52 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/cf_main.obj cf_main.c 53 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/m_password.obj m_password.c 54 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psx_pad.obj psx_pad.c 55 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/st_main.obj st_main.c 56 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/am_main.obj am_main.c 57 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/in_main.obj in_main.c 58 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/f_main.obj f_main.c 59 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/o_main.obj o_main.c 60 | ::ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/m_fixed.obj m_fixed.c 61 | asmpsx /l m_fixed.s,obj\m_fixed.obj 62 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/tables.obj tables.c 63 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psxcd.obj psxcd.c 64 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/s_sound.obj s_sound.c 65 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psxspu.obj psxspu.c 66 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/psxcmd.obj psxcmd.c 67 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessapip.obj wessapip.c 68 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessapi.obj wessapi.c 69 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessarc.obj wessarc.c 70 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessapit.obj wessapit.c 71 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessseq.obj wessseq.c 72 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/seqload.obj seqload.c 73 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/lcdload.obj lcdload.c 74 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessapim.obj wessapim.c 75 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/seqloadr.obj seqloadr.c 76 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj/wessbase.obj wessbase.c 77 | asmpsx /l snmain.s,obj\snmain.obj 78 | 79 | ::child: 80 | ccpsx -comments-c++ -Wreturn-type -c -O2 -g -o obj\psxmain.obj psxmain.c 81 | psylink /m /g /c /q /o$80010000 @main.lnk,main.cpe,main.sym,main.map 82 | ::cpe2x main.cpe 83 | cpe2x_gec main.cpe 84 | 85 | @echo off 86 | ::asm: 87 | ccpsx -O2 -S -Xo$80010000 -o asm\d_main.s d_main.c 88 | ccpsx -O2 -S -Xo$80010000 -o asm\info.s info.c 89 | ccpsx -O2 -S -Xo$80010000 -o asm\sprinfo.s sprinfo.c 90 | ccpsx -O2 -S -Xo$80010000 -o asm\g_game.s g_game.c 91 | ccpsx -O2 -S -Xo$80010000 -o asm\p_base.s p_base.c 92 | ccpsx -O2 -S -Xo$80010000 -o asm\p_ceilng.s p_ceilng.c 93 | ccpsx -O2 -S -Xo$80010000 -o asm\p_change.s p_change.c 94 | ccpsx -O2 -S -Xo$80010000 -o asm\p_doors.s p_doors.c 95 | ccpsx -O2 -S -Xo$80010000 -o asm\p_enemy.s p_enemy.c 96 | ccpsx -O2 -S -Xo$80010000 -o asm\p_floor.s p_floor.c 97 | ccpsx -O2 -S -Xo$80010000 -o asm\p_inter.s p_inter.c 98 | ccpsx -O2 -S -Xo$80010000 -o asm\p_lights.s p_lights.c 99 | ccpsx -O2 -S -Xo$80010000 -o asm\p_map.s p_map.c 100 | ccpsx -O2 -S -Xo$80010000 -o asm\p_maputl.s p_maputl.c 101 | ccpsx -O2 -S -Xo$80010000 -o asm\p_mobj.s p_mobj.c 102 | ccpsx -O2 -S -Xo$80010000 -o asm\p_move.s p_move.c 103 | ccpsx -O2 -S -Xo$80010000 -o asm\p_plats.s p_plats.c 104 | ccpsx -O2 -S -Xo$80010000 -o asm\p_pspr.s p_pspr.c 105 | ccpsx -O2 -S -Xo$80010000 -o asm\p_setup.s p_setup.c 106 | ccpsx -O2 -S -Xo$80010000 -o asm\p_shoot.s p_shoot.c 107 | ccpsx -O2 -S -Xo$80010000 -o asm\p_sight.s p_sight.c 108 | ccpsx -O2 -S -Xo$80010000 -o asm\p_slide.s p_slide.c 109 | ccpsx -O2 -S -Xo$80010000 -o asm\p_spec.s p_spec.c 110 | ccpsx -O2 -S -Xo$80010000 -o asm\p_switch.s p_switch.c 111 | ccpsx -O2 -S -Xo$80010000 -o asm\p_telept.s p_telept.c 112 | ccpsx -O2 -S -Xo$80010000 -o asm\p_tick.s p_tick.c 113 | ccpsx -O2 -S -Xo$80010000 -o asm\p_user.s p_user.c 114 | ccpsx -O2 -S -Xo$80010000 -o asm\r_phase1.s r_phase1.c 115 | ccpsx -O2 -S -Xo$80010000 -o asm\r_phase2.s r_phase2.c 116 | ccpsx -O2 -S -Xo$80010000 -o asm\r_data.s r_data.c 117 | ccpsx -O2 -S -Xo$80010000 -o asm\r_main.s r_main.c 118 | ccpsx -O2 -S -Xo$80010000 -o asm\vsprintf.s vsprintf.c 119 | ccpsx -O2 -S -Xo$80010000 -o asm\w_wad.s w_wad.c 120 | ccpsx -O2 -S -Xo$80010000 -o asm\psx_file.s psx_file.c 121 | ccpsx -O2 -S -Xo$80010000 -o asm\z_zone.s z_zone.c 122 | ccpsx -O2 -S -Xo$80010000 -o asm\psxmain.s psxmain.c 123 | ccpsx -O2 -S -Xo$80010000 -o asm\l_main.s l_main.c 124 | ccpsx -O2 -S -Xo$80010000 -o asm\t_main.s t_main.c 125 | ccpsx -O2 -S -Xo$80010000 -o asm\m_main.s m_main.c 126 | ccpsx -O2 -S -Xo$80010000 -o asm\c_main.s c_main.c 127 | ccpsx -O2 -S -Xo$80010000 -o asm\pw_main.s pw_main.c 128 | ccpsx -O2 -S -Xo$80010000 -o asm\cfm_main.s cfm_main.c 129 | ccpsx -O2 -S -Xo$80010000 -o asm\m_password.s m_password.c 130 | ccpsx -O2 -S -Xo$80010000 -o asm\psx_pad.s psx_pad.c 131 | ccpsx -O2 -S -Xo$80010000 -o asm\st_main.s st_main.c 132 | ccpsx -O2 -S -Xo$80010000 -o asm\am_main.s am_main.c 133 | ccpsx -O2 -S -Xo$80010000 -o asm\in_main.s in_main.c 134 | ccpsx -O2 -S -Xo$80010000 -o asm\f_main.s f_main.c 135 | ccpsx -O2 -S -Xo$80010000 -o asm\o_main.s o_main.c 136 | ::ccpsx -O2 -S -Xo$80010000 -o asm\m_fixed.s m_fixed.c 137 | ccpsx -O2 -S -Xo$80010000 -o asm\tables.s tables.c 138 | ccpsx -O2 -S -Xo$80010000 -o asm\psxcd.s psxcd.c 139 | ccpsx -O2 -S -Xo$80010000 -o asm\s_sound.s s_sound.c 140 | ccpsx -O2 -S -Xo$80010000 -o asm\psxspu.s psxspu.c 141 | ccpsx -O2 -S -Xo$80010000 -o asm\psxcmd.s psxcmd.c 142 | ccpsx -O2 -S -Xo$80010000 -o asm\wessapip.s wessapip.c 143 | ccpsx -O2 -S -Xo$80010000 -o asm\wessapi.s wessapi.c 144 | ccpsx -O2 -S -Xo$80010000 -o asm\wessarc.s wessarc.c 145 | ccpsx -O2 -S -Xo$80010000 -o asm\wessapit.s wessapit.c 146 | ccpsx -O2 -S -Xo$80010000 -o asm\wessseq.s wessseq.c 147 | ccpsx -O2 -S -Xo$80010000 -o asm\seqload.s seqload.c 148 | ccpsx -O2 -S -Xo$80010000 -o asm\lcdload.s lcdload.c 149 | ccpsx -O2 -S -Xo$80010000 -o asm\wessapim.s wessapim.c 150 | ccpsx -O2 -S -Xo$80010000 -o asm\seqloadr.s seqloadr.c 151 | ccpsx -O2 -S -Xo$80010000 -o asm\wessbase.s wessbase.c 152 | 153 | @echo on 154 | 155 | @echo off 156 | copy main.exe GAME 157 | @echo on 158 | pause 159 | -------------------------------------------------------------------------------- /PSXDOOM/PSXCD.H: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------*/ 2 | /* 3 | Sony CD Architecture Specific Routines 4 | by Scott Patterson 5 | 6 | development and testing period on this code: 7 | 4/18/95 - 9/28/95 8 | */ 9 | /*------------------------------------------------------------------*/ 10 | 11 | #ifndef _PSXCD_H 12 | #define _PSXCD_H 13 | 14 | /* 15 | The following functions will pause for a short CD volume fade if 16 | the CD volume is not zero (and _CD_SPU_LINK_ == 1): 17 | 18 | psxcd_async_read() 19 | psxcd_read() 20 | psxcd_stop() 21 | psxcd_pause() 22 | 23 | To asyncronously fade the CD volume beforehand so these functions 24 | will not have any delays see comments in "psxspu.h" 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #define _CD_VERSION_ 1 31 | #define _CD_SPU_LINK_ 1//para cd tracks 32 | #define _CD_ABS_OPEN_ 1 33 | 34 | #define PSXCD_SEEK_SET 0 35 | #define PSXCD_SEEK_CUR 1 36 | #define PSXCD_SEEK_END 2 37 | 38 | #if _CD_VERSION_ == 0 39 | #include 40 | #endif 41 | 42 | typedef struct PsxCd_File { 43 | CdlFILE file; 44 | CdlLOC new_io_loc; 45 | unsigned long io_block_offset; 46 | unsigned char io_result[8]; 47 | }PsxCd_File; 48 | 49 | #if _CD_ABS_OPEN_ == 1 50 | 51 | typedef struct PsxCd_MapTbl { 52 | int abs; 53 | u_long size; 54 | }PsxCd_MapTbl; 55 | 56 | extern PsxCd_MapTbl cdmaptbl[]; 57 | 58 | #endif 59 | 60 | // CD-data read stuff 61 | #define CD_ROM_SECTOR_SIZE 2048 62 | #define SECTORS_PER_SECOND 75 63 | #define SECONDS_PER_MINUTE 60 64 | 65 | /* 66 | Asyncronous read function: psxcd_async_on() 67 | 68 | this function returns non-zero during asyncronous reading 69 | 70 | to code an asyncronous read: 71 | 72 | psxcd_async_read(destptr,readbytes,fileptr); 73 | 74 | // do your other shit here 75 | // (don't mess with the RAM you are reading to!) 76 | 77 | // to check for completion 78 | if(!psxcd_async_on()) 79 | { 80 | // psxcd_async_read is complete 81 | } 82 | 83 | // to wait for completion: 84 | while(psxcd_async_on()); // wait for completion of psxcd_async_read 85 | */ 86 | 87 | extern int psxcd_async_on(void); 88 | 89 | /* 90 | CD-DA play seek variable: seeking_for_play 91 | 92 | after psxcd_seek_for_play(track) call is made 93 | 94 | this function returns non-zero until seeking is done 95 | */ 96 | 97 | extern int psxcd_seeking_for_play(void); 98 | 99 | /* 100 | CD-DA play stop/pause variable: waiting_for_pause 101 | 102 | after psxcd_stop/psxcd_pause call is made 103 | 104 | this function returns non-zero until pause operation is done 105 | */ 106 | 107 | extern int psxcd_waiting_for_pause(void); 108 | 109 | extern int cdl_insetmode; 110 | extern int cdl_intr; 111 | extern unsigned char cdl_stat; 112 | extern unsigned char cdl_com; 113 | 114 | extern int cdl_errcount; 115 | extern int cdl_errintr; 116 | extern unsigned char cdl_errstat; 117 | extern unsigned char cdl_errcom; 118 | extern int readcount; 119 | extern int playcount; 120 | 121 | // PSX CD-MODE1 DATA commands 122 | 123 | extern void psxcd_init(void); 124 | 125 | extern void psxcd_exit(void); 126 | 127 | extern void psxcd_disable_callbacks(void); 128 | 129 | extern void psxcd_enable_callbacks(void); 130 | 131 | extern void psxcd_set_data_mode(void); 132 | 133 | extern PsxCd_File *psxcd_open(char *filename); 134 | 135 | extern void psxcd_async_read_cancel(void); 136 | 137 | extern int psxcd_async_read(void *destptr,int readbytes,PsxCd_File *fileptr); 138 | 139 | extern int psxcd_read(void *destptr,int readbytes,PsxCd_File *fileptr); 140 | 141 | extern int psxcd_seek(PsxCd_File *fileptr,int seekpos,int seekmode); 142 | 143 | extern unsigned long psxcd_tell(PsxCd_File *fileptr); 144 | 145 | extern void psxcd_close(PsxCd_File *fileptr); 146 | 147 | // PSX CD-AUDIO commands 148 | 149 | extern void psxcd_set_stereo(int stereo_true); 150 | 151 | extern void psxcd_set_audio_mode(void); 152 | 153 | extern void psxcd_seek_for_play(int track); 154 | 155 | extern void psxcd_seek_for_play_at(int track, 156 | int sectoroffset); 157 | 158 | extern void psxcd_play(int track, int vol); 159 | 160 | extern void psxcd_play_at(int track, 161 | int vol, 162 | int sectoroffset); 163 | 164 | extern void psxcd_set_loop_volume(int volforloop); 165 | 166 | extern void psxcd_play_at_andloop(int track, 167 | int vol, 168 | int sectoroffset, 169 | int fadeuptime, 170 | int tracktoloop, 171 | int volforloop, 172 | int loopstartsectoroffset, 173 | int loopstartfadeuptime); 174 | 175 | extern void psxcd_stop(void); 176 | 177 | extern void psxcd_pause(void); 178 | 179 | extern void psxcd_restart(int vol); 180 | 181 | int psxcd_play_status(void); 182 | 183 | int psxcd_elapsed_sectors(void); 184 | 185 | // PSX low level CD extras 186 | 187 | extern char sectorbuf[CD_ROM_SECTOR_SIZE]; 188 | 189 | extern void psxcd_init_pos(void); 190 | 191 | #endif 192 | 193 | -------------------------------------------------------------------------------- /PSXDOOM/PSXCDABS.C: -------------------------------------------------------------------------------- 1 | 2 | PsxCd_MapTbl cdmaptbl[] = 3 | { 4 | {23, 68}, 5 | {24, 913408}, 6 | {472, 16384}, 7 | {480, 16384}, 8 | {488, 3387200}, 9 | {1938, 376832}, 10 | {2122, 5136600}, 11 | {4632, 85868}, 12 | {4674, 67988}, 13 | {4708, 78404}, 14 | {4747, 51376}, 15 | {4773, 75840}, 16 | {4811, 51724}, 17 | {4837, 99460}, 18 | {4886, 86356}, 19 | {4929, 686056}, 20 | {5264, 732792}, 21 | {5622, 716652}, 22 | {5972, 444732}, 23 | {6190, 698124}, 24 | {6531, 784608}, 25 | {6915, 614896}, 26 | {7216, 649376}, 27 | {7534, 132784}, 28 | {7599, 129480}, 29 | {7663, 136540}, 30 | {7730, 102480}, 31 | {7781, 110356}, 32 | {7835, 107072}, 33 | {7888, 124092}, 34 | {7949, 117552}, 35 | {8008, 57568}, 36 | {8037, 81988}, 37 | {8078, 57900}, 38 | {8107, 62468}, 39 | {8138, 87788}, 40 | {8181, 32396}, 41 | {8197, 46772}, 42 | {8220, 87672}, 43 | {8263, 781504}, 44 | {8645, 645684}, 45 | {8961, 789280}, 46 | {9347, 713148}, 47 | {9696, 615120}, 48 | {9997, 856336}, 49 | {10416, 771696}, 50 | {10793, 526456}, 51 | {11051, 118976}, 52 | {11110, 120884}, 53 | {11170, 99168}, 54 | {11219, 132384}, 55 | {11284, 133332}, 56 | {11350, 100776}, 57 | {11400, 128900}, 58 | {11463, 134756}, 59 | {11530, 103792}, 60 | {11581, 76864}, 61 | {11619, 113652}, 62 | {11675, 59648}, 63 | {11705, 95884}, 64 | {11752, 62544}, 65 | {11783, 104704}, 66 | {11835, 72684}, 67 | {11871, 598040}, 68 | {12164, 719768}, 69 | {12516, 487476}, 70 | {12755, 748404}, 71 | {13121, 596992}, 72 | {13413, 809008}, 73 | {13809, 597436}, 74 | {14101, 649132}, 75 | {14418, 118976}, 76 | {14477, 111900}, 77 | {14532, 167684}, 78 | {14614, 109696}, 79 | {14668, 129760}, 80 | {14732, 132596}, 81 | {14797, 161984}, 82 | {14877, 156996}, 83 | {14955, 66776}, 84 | {14988, 76200}, 85 | {15026, 67720}, 86 | {15060, 80656}, 87 | {15100, 63044}, 88 | {15131, 64892}, 89 | {15163, 8}, 90 | {15164, 8}, 91 | {15165, 645020}, 92 | {15480, 713964}, 93 | {15829, 813564}, 94 | {16227, 642416}, 95 | {16541, 835336}, 96 | {16949, 778648}, 97 | {17330, 657392}, 98 | {17651, 8}, 99 | {17652, 116796}, 100 | {17710, 137288}, 101 | {17778, 143776}, 102 | {17849, 133496}, 103 | {17915, 128796}, 104 | {17978, 116360}, 105 | {18035, 8}, 106 | {18036, 8}, 107 | {18038, 205024}, 108 | {18139, 199920}, 109 | {18237, 179056}, 110 | {18325, 111456}, 111 | {18380, 167280}, 112 | {18462, 186336}, 113 | {18553, 181696}, 114 | {18642, 181568}, 115 | {18731, 207360}, 116 | {18833, 184160}, 117 | {18923, 199920}, 118 | {19021, 183328}, 119 | {19111, 179056}, 120 | {19199, 167696}, 121 | {19281, 180544}, 122 | {19370, 164176}, 123 | {19451, 170832}, 124 | {19535, 184160}, 125 | {19625, 143312}, 126 | {19695, 229824}, 127 | {19809, 152304}, 128 | {19884, 201680}, 129 | {19983, 160832}, 130 | {20062, 182544}, 131 | {20152, 184032}, 132 | {20242, 194800}, 133 | {20338, 175424}, 134 | {20424, 165232}, 135 | {20505, 231712}, 136 | {20619, 167568}, 137 | {20702, 105632}, 138 | {20754, 69600}, 139 | {20788, 83424}, 140 | {20829, 88192}, 141 | {20873, 97808}, 142 | {20921, 89376}, 143 | {20965, 109408}, 144 | {21019, 111120}, 145 | {21074, 115008}, 146 | {21131, 141792}, 147 | {21201, 425904}, 148 | {21410, 177104}, 149 | {21497, 104766}, 150 | {21549, 61232}, 151 | {21579, 67280}, 152 | {21612, 136496}, 153 | {21679, 103328}, 154 | {21730, 116512}, 155 | {21787, 101168}, 156 | {21837, 104528}, 157 | {21889, 116944}, 158 | {21947, 121216}, 159 | {22007, 77280}, 160 | {22045, 103120}, 161 | {22096, 111968}, 162 | {22151, 73968}, 163 | {22188, 104656}, 164 | {22240, 85488}, 165 | {22282, 71008}, 166 | {22317, 83584}, 167 | {22358, 93136}, 168 | {22404, 92528}, 169 | {22450, 120992}, 170 | {0, 0} 171 | }; -------------------------------------------------------------------------------- /PSXDOOM/PSXCDABS.H: -------------------------------------------------------------------------------- 1 | #define _SYSTEM_CNF 0 2 | #define _SLUS_003_31 1 3 | #define _DEMO1_LMP 2 4 | #define _DEMO2_LMP 3 5 | #define _MOVIE_STR 4 6 | #define _PSXDOOM_EXE 5 7 | #define _PSXDOOM_WAD 6 8 | #define _MAP01_ROM 7 9 | #define _MAP02_ROM 8 10 | #define _MAP03_ROM 9 11 | #define _MAP04_ROM 10 12 | #define _MAP05_ROM 11 13 | #define _MAP06_ROM 12 14 | #define _MAP07_ROM 13 15 | #define _MAP08_ROM 14 16 | #define _MAPSPR01_IMG 15 17 | #define _MAPSPR02_IMG 16 18 | #define _MAPSPR03_IMG 17 19 | #define _MAPSPR04_IMG 18 20 | #define _MAPSPR05_IMG 19 21 | #define _MAPSPR06_IMG 20 22 | #define _MAPSPR07_IMG 21 23 | #define _MAPSPR08_IMG 22 24 | #define _MAPTEX01_IMG 23 25 | #define _MAPTEX02_IMG 24 26 | #define _MAPTEX03_IMG 25 27 | #define _MAPTEX04_IMG 26 28 | #define _MAPTEX05_IMG 27 29 | #define _MAPTEX06_IMG 28 30 | #define _MAPTEX07_IMG 29 31 | #define _MAPTEX08_IMG 30 32 | #define _MAP09_ROM 31 33 | #define _MAP10_ROM 32 34 | #define _MAP11_ROM 33 35 | #define _MAP12_ROM 34 36 | #define _MAP13_ROM 35 37 | #define _MAP14_ROM 36 38 | #define _MAP15_ROM 37 39 | #define _MAP16_ROM 38 40 | #define _MAPSPR09_IMG 39 41 | #define _MAPSPR10_IMG 40 42 | #define _MAPSPR11_IMG 41 43 | #define _MAPSPR12_IMG 42 44 | #define _MAPSPR13_IMG 43 45 | #define _MAPSPR14_IMG 44 46 | #define _MAPSPR15_IMG 45 47 | #define _MAPSPR16_IMG 46 48 | #define _MAPTEX09_IMG 47 49 | #define _MAPTEX10_IMG 48 50 | #define _MAPTEX11_IMG 49 51 | #define _MAPTEX12_IMG 50 52 | #define _MAPTEX13_IMG 51 53 | #define _MAPTEX14_IMG 52 54 | #define _MAPTEX15_IMG 53 55 | #define _MAPTEX16_IMG 54 56 | #define _MAP17_ROM 55 57 | #define _MAP18_ROM 56 58 | #define _MAP19_ROM 57 59 | #define _MAP20_ROM 58 60 | #define _MAP21_ROM 59 61 | #define _MAP22_ROM 60 62 | #define _MAP23_ROM 61 63 | #define _MAP24_ROM 62 64 | #define _MAPSPR17_IMG 63 65 | #define _MAPSPR18_IMG 64 66 | #define _MAPSPR19_IMG 65 67 | #define _MAPSPR20_IMG 66 68 | #define _MAPSPR21_IMG 67 69 | #define _MAPSPR22_IMG 68 70 | #define _MAPSPR23_IMG 69 71 | #define _MAPSPR24_IMG 70 72 | #define _MAPTEX17_IMG 71 73 | #define _MAPTEX18_IMG 72 74 | #define _MAPTEX19_IMG 73 75 | #define _MAPTEX20_IMG 74 76 | #define _MAPTEX21_IMG 75 77 | #define _MAPTEX22_IMG 76 78 | #define _MAPTEX23_IMG 77 79 | #define _MAPTEX24_IMG 78 80 | #define _MAP25_ROM 79 81 | #define _MAP26_ROM 80 82 | #define _MAP27_ROM 81 83 | #define _MAP28_ROM 82 84 | #define _MAP29_ROM 83 85 | #define _MAP30_ROM 84 86 | #define _MAP31_ROM 85 87 | #define _MAP32_ROM 86 88 | #define _MAPSPR25_IMG 87 89 | #define _MAPSPR26_IMG 88 90 | #define _MAPSPR27_IMG 89 91 | #define _MAPSPR28_IMG 90 92 | #define _MAPSPR29_IMG 91 93 | #define _MAPSPR30_IMG 92 94 | #define _MAPSPR31_IMG 93 95 | #define _MAPSPR32_IMG 94 96 | #define _MAPTEX25_IMG 95 97 | #define _MAPTEX26_IMG 96 98 | #define _MAPTEX27_IMG 97 99 | #define _MAPTEX28_IMG 98 100 | #define _MAPTEX29_IMG 99 101 | #define _MAPTEX30_IMG 100 102 | #define _MAPTEX31_IMG 101 103 | #define _MAPTEX32_IMG 102 104 | #define _MAP01_LCD 103 105 | #define _MAP02_LCD 104 106 | #define _MAP03_LCD 105 107 | #define _MAP04_LCD 106 108 | #define _MAP05_LCD 107 109 | #define _MAP06_LCD 108 110 | #define _MAP07_LCD 109 111 | #define _MAP08_LCD 110 112 | #define _MAP09_LCD 111 113 | #define _MAP10_LCD 112 114 | #define _MAP11_LCD 113 115 | #define _MAP12_LCD 114 116 | #define _MAP13_LCD 115 117 | #define _MAP14_LCD 116 118 | #define _MAP15_LCD 117 119 | #define _MAP16_LCD 118 120 | #define _MAP17_LCD 119 121 | #define _MAP18_LCD 120 122 | #define _MAP19_LCD 121 123 | #define _MAP20_LCD 122 124 | #define _MAP21_LCD 123 125 | #define _MAP22_LCD 124 126 | #define _MAP23_LCD 125 127 | #define _MAP24_LCD 126 128 | #define _MAP25_LCD 127 129 | #define _MAP26_LCD 128 130 | #define _MAP27_LCD 129 131 | #define _MAP28_LCD 130 132 | #define _MAP29_LCD 131 133 | #define _MAP30_LCD 132 134 | #define _MUSLEV21_LCD 133 135 | #define _MUSLEV22_LCD 134 136 | #define _MUSLEV23_LCD 135 137 | #define _MUSLEV24_LCD 136 138 | #define _MUSLEV25_LCD 137 139 | #define _MUSLEV26_LCD 138 140 | #define _MUSLEV27_LCD 139 141 | #define _MUSLEV28_LCD 140 142 | #define _MUSLEV29_LCD 141 143 | #define _MUSLEV30_LCD 142 144 | #define _MAP60_LCD 143 145 | #define _DOOMSFX_LCD 144 146 | #define _DOOMSND_WMD 145 147 | #define _MUSLEV1_LCD 146 148 | #define _MUSLEV2_LCD 147 149 | #define _MUSLEV3_LCD 148 150 | #define _MUSLEV4_LCD 149 151 | #define _MUSLEV5_LCD 150 152 | #define _MUSLEV6_LCD 151 153 | #define _MUSLEV7_LCD 152 154 | #define _MUSLEV8_LCD 153 155 | #define _MUSLEV9_LCD 154 156 | #define _MUSLEV10_LCD 155 157 | #define _MUSLEV11_LCD 156 158 | #define _MUSLEV12_LCD 157 159 | #define _MUSLEV13_LCD 158 160 | #define _MUSLEV14_LCD 159 161 | #define _MUSLEV15_LCD 160 162 | #define _MUSLEV16_LCD 161 163 | #define _MUSLEV17_LCD 162 164 | #define _MUSLEV18_LCD 163 165 | #define _MUSLEV19_LCD 164 166 | #define _MUSLEV20_LCD 165 167 | #define MAX_ABS_FILES 166 168 | -------------------------------------------------------------------------------- /PSXDOOM/PSXDOOM.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 243 | 244 | -------------------------------------------------------------------------------- /PSXDOOM/PSXSPU.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update_1 20/10/2019 [GEC] 3 | // Update_2 31/01/2020 [GEC] 4 | 5 | #include 6 | #include "psxspu.h" 7 | #include "wessapi.h" 8 | 9 | extern void SpuSetCommonAttr (SpuCommonAttr *attr); 10 | 11 | #define MALLOC_MAX 1 12 | extern char spu_malloc_rec[SPU_MALLOC_RECSIZ * (MALLOC_MAX + 1)]; 13 | 14 | extern unsigned int psxspu_initialized; 15 | extern unsigned int psxspu_status; 16 | extern unsigned long end_of_sram; 17 | 18 | extern int psxspu_master_vol; 19 | extern int psxspu_master_fadecount; 20 | extern int psxspu_master_vol_fixed; 21 | extern int psxspu_master_destvol; 22 | extern int psxspu_master_changeval; 23 | 24 | extern int psxspu_cd_vol; 25 | extern int psxspu_cd_fadecount; 26 | extern int psxspu_cd_vol_fixed; 27 | extern int psxspu_cd_destvol; 28 | extern int psxspu_cd_changeval; 29 | 30 | extern SpuReverbAttr rev_attr;//8007EEA4 31 | 32 | unsigned long SpuGetReverbOffsetAddr[10] = // equivale a la función SpuGetReverbOffsetAddr() 33 | { 34 | 520192, 514368, 516288, 505792, 495648, 35 | 479776, 461120, 425920, 425920, 508928 36 | }; 37 | 38 | #define END_O_SRAM 520192 39 | void psxspu_init_reverb(long rev_mode, short depthleft, short depthright, long delay, long feedback)//L80045f70() 40 | { 41 | psxspu_status = 0; 42 | 43 | rev_attr.mask = (SPU_REV_MODE|SPU_REV_DEPTHL|SPU_REV_DEPTHR|SPU_REV_DELAYTIME|SPU_REV_FEEDBACK); 44 | rev_attr.mode = rev_mode | SPU_REV_MODE_CLEAR_WA; 45 | rev_attr.depth.left = depthleft; 46 | rev_attr.depth.right = depthright; 47 | rev_attr.delay = delay; 48 | rev_attr.feedback = feedback; 49 | 50 | SpuSetReverbModeParam (&rev_attr); 51 | SpuSetReverbDepth (&rev_attr); 52 | 53 | if(rev_mode == PSXSPU_REV_MODE_OFF) 54 | { 55 | SpuSetReverb(SPU_OFF); 56 | end_of_sram = END_O_SRAM; 57 | } 58 | else 59 | { 60 | SpuSetReverb(SPU_ON); 61 | end_of_sram = SpuGetReverbOffsetAddr[rev_mode];//SpuGetReverbOffsetAddr(); 62 | } 63 | 64 | SpuSetReverbVoice((rev_mode != PSXSPU_REV_MODE_OFF), SPU_ALLCH); 65 | psxspu_status = 1; 66 | 67 | //printf("End_Of_Sram %d\n", end_of_sram); 68 | } 69 | 70 | void psxspu_set_reverb_depth(short depthleft,short depthright)//L80046050() 71 | { 72 | psxspu_status = 0; 73 | rev_attr.depth.left = depthleft; 74 | rev_attr.depth.right = depthright; 75 | SpuSetReverbDepth(&rev_attr); 76 | psxspu_status = 1; 77 | 78 | } 79 | 80 | void psxspu_init(void)//L80046098() 81 | { 82 | SpuCommonAttr com_attr; 83 | 84 | if (psxspu_initialized == 0) 85 | { 86 | //printf("psxspu_init\n"); 87 | psxspu_status = 0; 88 | psxspu_initialized = 1; 89 | 90 | SpuInit(); 91 | SpuInitMalloc(MALLOC_MAX, spu_malloc_rec); 92 | SpuSetTransMode(SpuTransferByDMA); 93 | 94 | psxspu_init_reverb(0, 0, 0, 0, 0); 95 | 96 | com_attr.mask = (SPU_COMMON_MVOLL | SPU_COMMON_MVOLR | SPU_COMMON_CDVOLL | SPU_COMMON_CDVOLR | SPU_COMMON_CDVOLR| SPU_COMMON_CDREV | SPU_COMMON_CDMIX); 97 | com_attr.mvol.left = MAX_MASTER_VOL; 98 | com_attr.mvol.right = MAX_MASTER_VOL; 99 | com_attr.cd.volume.left = MAX_CD_VOL; 100 | com_attr.cd.volume.right = MAX_CD_VOL; 101 | com_attr.cd.reverb = 0; 102 | com_attr.cd.mix = 1; 103 | SpuSetCommonAttr(&com_attr); 104 | psxspu_status = 1; 105 | } 106 | } 107 | 108 | void psxspu_set_master_volume(int vol)//L80046144() 109 | { 110 | SpuCommonAttr com_attr; 111 | 112 | psxspu_status = 0; 113 | com_attr.mvol.left = vol; 114 | com_attr.mvol.right = vol; 115 | com_attr.mask = (SPU_COMMON_MVOLL | SPU_COMMON_MVOLR); 116 | SpuSetCommonAttr(&com_attr); 117 | psxspu_status = 1; 118 | } 119 | 120 | void psxspu_set_cd_volume(int vol)//L80046188() 121 | { 122 | SpuCommonAttr com_attr; 123 | 124 | psxspu_status = 0; 125 | com_attr.cd.volume.left = vol; 126 | com_attr.cd.volume.right = vol; 127 | com_attr.mask = (SPU_COMMON_CDVOLL | SPU_COMMON_CDVOLR); 128 | SpuSetCommonAttr(&com_attr); 129 | psxspu_status = 1; 130 | } 131 | 132 | void psxspu_setcdmixon(void)//L800461CC() 133 | { 134 | SpuCommonAttr com_attr; 135 | 136 | psxspu_status = 0; 137 | com_attr.mask = (SPU_COMMON_CDMIX); 138 | com_attr.cd.mix = 1; 139 | SpuSetCommonAttr(&com_attr); 140 | psxspu_status = 1; 141 | } 142 | 143 | void psxspu_setcdmixoff(void)//L80046214() 144 | { 145 | SpuCommonAttr com_attr; 146 | 147 | psxspu_status = 0; 148 | com_attr.mask = (SPU_COMMON_CDMIX); 149 | com_attr.cd.mix = 0; 150 | SpuSetCommonAttr(&com_attr); 151 | psxspu_status = 1; 152 | } 153 | 154 | void psxspu_fadeengine(void)//L80046254() 155 | { 156 | if (psxspu_status != 0) 157 | { 158 | if (psxspu_cd_fadecount > 0) 159 | { 160 | psxspu_cd_fadecount -= 1; 161 | psxspu_cd_vol_fixed += psxspu_cd_changeval; 162 | 163 | if (psxspu_cd_fadecount == 0) 164 | psxspu_cd_vol_fixed = psxspu_cd_destvol; 165 | 166 | psxspu_cd_vol = psxspu_cd_vol_fixed >> 16; 167 | 168 | psxspu_set_cd_volume(psxspu_cd_vol); 169 | } 170 | 171 | if (psxspu_master_fadecount > 0) 172 | { 173 | psxspu_master_fadecount -= 1; 174 | psxspu_master_vol_fixed += psxspu_master_changeval; 175 | 176 | if (psxspu_master_fadecount == 0) 177 | psxspu_master_vol_fixed = psxspu_master_destvol; 178 | 179 | psxspu_master_vol = psxspu_master_vol_fixed >> 16; 180 | psxspu_set_master_volume(psxspu_master_vol); 181 | } 182 | } 183 | } 184 | 185 | void psxspu_set_cd_vol(int vol)//L80046368() 186 | { 187 | psxspu_status = 0; 188 | psxspu_cd_vol = vol; 189 | psxspu_cd_vol_fixed = psxspu_cd_vol << 16; 190 | psxspu_cd_fadecount = 0; 191 | psxspu_set_cd_volume(psxspu_cd_vol); 192 | psxspu_status = 1; 193 | } 194 | 195 | int psxspu_get_cd_vol(void)//L800463C4() 196 | { 197 | return psxspu_cd_vol; 198 | } 199 | 200 | void psxspu_start_cd_fade(int msec, int destvol)//L800463D4() 201 | { 202 | psxspu_status = 0; 203 | if (WessTimerActive == 0) 204 | { 205 | psxspu_cd_fadecount = 0; 206 | } 207 | else 208 | { 209 | psxspu_cd_destvol = destvol * 0x10000; 210 | psxspu_cd_fadecount = (msec * 0x78) / 1000 + 1; 211 | psxspu_cd_changeval = (psxspu_cd_destvol - psxspu_cd_vol_fixed) / psxspu_cd_fadecount; 212 | } 213 | psxspu_status = 1; 214 | } 215 | 216 | void psxspu_stop_cd_fade(void)//L8004648C() 217 | { 218 | psxspu_status = 0; 219 | psxspu_cd_fadecount = 0; 220 | psxspu_status = 1; 221 | } 222 | 223 | int psxspu_get_cd_fade_status(void)//L800464B0() 224 | { 225 | return (psxspu_cd_fadecount < 2) ^ 1; 226 | } 227 | 228 | void psxspu_set_master_vol(int vol)//L800464C8() 229 | { 230 | psxspu_status = 0; 231 | psxspu_master_vol = vol; 232 | psxspu_master_vol_fixed = psxspu_master_vol << 16; 233 | psxspu_master_fadecount = 0; 234 | psxspu_set_master_volume(psxspu_master_vol); 235 | psxspu_status = 1; 236 | } 237 | 238 | int psxspu_get_master_vol(void)//L80046524() 239 | { 240 | return psxspu_master_vol; 241 | } 242 | 243 | void psxspu_start_master_fade(int msec, int destvol)//L80046534() 244 | { 245 | psxspu_status = 0; 246 | if (WessTimerActive == 0) 247 | { 248 | psxspu_master_fadecount = 0; 249 | } 250 | else 251 | { 252 | psxspu_master_destvol = destvol * 0x10000; 253 | psxspu_master_fadecount = (msec * 0x78) / 1000 + 1; 254 | psxspu_master_changeval = (psxspu_master_destvol - psxspu_master_vol_fixed) / psxspu_master_fadecount; 255 | } 256 | psxspu_status = 1; 257 | } 258 | 259 | void psxspu_stop_master_fade(void)//L800465EC() 260 | { 261 | psxspu_status = 0; 262 | psxspu_master_fadecount = 0; 263 | psxspu_status = 1; 264 | } 265 | 266 | int psxspu_get_master_fade_status(void)//L80046610() 267 | { 268 | return (psxspu_master_fadecount < 2) ^ 1; 269 | } 270 | -------------------------------------------------------------------------------- /PSXDOOM/PSXSPU.H: -------------------------------------------------------------------------------- 1 | 2 | /*------------------------------------------------------------------*/ 3 | /* 4 | Williams Entertainment Sound System 5 | by Scott Patterson 6 | 7 | PSX SPU Volume and Reverb controls. 8 | */ 9 | /*------------------------------------------------------------------*/ 10 | 11 | #ifndef _PSXSPU_H 12 | #define _PSXSPU_H 13 | 14 | #define FADE_TIME 250 15 | 16 | /* 17 | Notes on fade calls: 18 | 19 | To do a syncronous fade to zero volume: 20 | 21 | psxspu_start_cd_fade(FADE_TIME,0); 22 | while(psxspu_get_cd_fade_status()); 23 | 24 | To do an asyncronous fade to zero volume: 25 | 26 | psxspu_start_cd_fade(FADE_TIME,0); 27 | . 28 | . 29 | . 30 | if(!psxspu_get_cd_fade_status()) 31 | { 32 | //fade is now done 33 | } 34 | */ 35 | 36 | #define MAX_MASTER_VOL 0x3fff 37 | #define MAX_CD_VOL 0x3cff 38 | #define MED_CD_VOL 0x2fff 39 | #define MIN_CD_VOL 0x1fff 40 | 41 | #define SRAM_ADDRESS_LIMIT 520192 42 | #define SRAM_RESERVED_SIZE 4112 43 | #define SRAM_TO_ALLOC_SPU (SRAM_ADDRESS_LIMIT-SRAM_RESERVED_SIZE) 44 | 45 | #define PSXSPU_REV_MODE_OFF 0 46 | #define PSXSPU_REV_MODE_ROOM 1 47 | #define PSXSPU_REV_MODE_STUDIO_A 2 48 | #define PSXSPU_REV_MODE_STUDIO_B 3 49 | #define PSXSPU_REV_MODE_STUDIO_C 4 50 | #define PSXSPU_REV_MODE_HALL 5 51 | #define PSXSPU_REV_MODE_SPACE 6 52 | #define PSXSPU_REV_MODE_ECHO 7 53 | #define PSXSPU_REV_MODE_DELAY 8 54 | #define PSXSPU_REV_MODE_PIPE 9 55 | 56 | extern unsigned long end_of_sram; 57 | 58 | extern void psxspu_init(void); 59 | 60 | extern void psxspu_init_reverb(long rev_mode, 61 | short depthleft, 62 | short depthright, 63 | long delay, 64 | long feedback); 65 | 66 | extern void psxspu_set_reverb_depth(short depthleft, 67 | short depthright); 68 | 69 | extern void psxspu_fadeengine(void); 70 | 71 | extern void psxspu_set_master_vol(int vol); 72 | extern int psxspu_get_master_vol(void); 73 | extern void psxspu_start_master_fade(int msec,int destvol); 74 | extern void psxspu_stop_master_fade(void); 75 | 76 | //returns zero when fade is done 77 | extern int psxspu_get_master_fade_status(void); 78 | 79 | extern void psxspu_set_cd_vol(int vol); 80 | extern int psxspu_get_cd_vol(void); 81 | extern void psxspu_start_cd_fade(int msec,int destvol); 82 | extern void psxspu_stop_cd_fade(void); 83 | 84 | //returns zero when fade is done 85 | extern int psxspu_get_cd_fade_status(void); 86 | 87 | extern void psxspu_setcdmixon(void); 88 | extern void psxspu_setcdmixoff(void); 89 | 90 | #endif 91 | 92 | -------------------------------------------------------------------------------- /PSXDOOM/PSX_FILE.C: -------------------------------------------------------------------------------- 1 | /* PSX_FILE.c */ 2 | 3 | #include "doomdef.h" 4 | #include "r_local.h" 5 | 6 | /* 7 | ============================================================================ 8 | 9 | READ/OPEN/CLOSE/SEEK/CLEAR PSX FILE BASED ROUTINES 10 | 11 | ============================================================================ 12 | */ 13 | 14 | PsxCd_File files[4]; //800A9B74 psxdoom 15 | 16 | /* 17 | == == == == == == == == == == 18 | = 19 | = ClearFiles 20 | = 21 | = Exclusive Psx Doom 22 | == == == == == == == == == == 23 | */ 24 | 25 | void ClearFiles(void)//L80032140() 26 | { 27 | int i; 28 | 29 | for (i = 0; i < 4; i++) 30 | { 31 | files[i].file.size = 0; 32 | } 33 | } 34 | 35 | /* 36 | == == == == == == == == == == 37 | = 38 | = OpenFile 39 | = 40 | = Exclusive Psx Doom 41 | == == == == == == == == == == 42 | */ 43 | 44 | int OpenFile(char *filename)//L80032168() 45 | { 46 | PsxCd_File *fp; 47 | int i, j; 48 | 49 | fp = psxcd_open(filename); 50 | 51 | if (!fp) 52 | I_Error("Cannot open %s", filename); 53 | 54 | //get free file 55 | for (i = 0; i < 4; i++) 56 | { 57 | if (files[i].file.size == 0) 58 | break; 59 | } 60 | 61 | if (!(i < 4)) 62 | I_Error("OpenFile: Too many open files!"); 63 | 64 | //copy file pointer 65 | files[i] = *fp; 66 | return i; 67 | } 68 | 69 | /* 70 | == == == == == == == == == == 71 | = 72 | = CloseFile 73 | = 74 | = Exclusive Psx Doom 75 | == == == == == == == == == == 76 | */ 77 | 78 | void CloseFile(int file_num)//L80032264() 79 | { 80 | files[file_num].file.size = 0; 81 | psxcd_close(&files[file_num]); 82 | } 83 | 84 | /* 85 | == == == == == == == == == == 86 | = 87 | = SeekFile 88 | = 89 | = Exclusive Psx Doom 90 | == == == == == == == == == == 91 | */ 92 | 93 | int SeekFile(int file_num, int seekpos, int seekmode)//L800322b0() 94 | { 95 | PsxCd_File *fileptr; 96 | int tell; 97 | 98 | //printf("seekpos %d\n",seekpos); 99 | 100 | fileptr = &files[file_num]; 101 | psxcd_seek(fileptr, seekpos, seekmode); 102 | tell = psxcd_tell(fileptr); 103 | //printf("tell %d\n",tell); 104 | return tell; 105 | } 106 | 107 | /* 108 | == == == == == == == == == == 109 | = 110 | = ReadFile 111 | = 112 | = Exclusive Psx Doom 113 | == == == == == == == == == == 114 | */ 115 | 116 | void ReadFile(int file_num, void *destptr, unsigned int readbytes)//L800322f8() 117 | { 118 | unsigned long tell; 119 | unsigned int rbytes; 120 | PsxCd_File *fileptr; 121 | 122 | fileptr = &files[file_num]; 123 | //printf("0x%X, [%d]", (unsigned long)fileptr, file_num); 124 | 125 | tell = psxcd_tell(fileptr); 126 | 127 | rbytes = readbytes; 128 | if (0x2000 < readbytes) 129 | rbytes = 0x2000; //max 32 kb 130 | 131 | psxcd_seek(fileptr, 0, PSXCD_SEEK_SET); 132 | psxcd_read(destptr, rbytes, fileptr); 133 | psxcd_seek(fileptr, tell, PSXCD_SEEK_SET); 134 | 135 | rbytes = psxcd_read(destptr, readbytes, fileptr); 136 | if (rbytes != readbytes) 137 | I_Error("ReadFile: error reading %d of %d bytes\n", rbytes, readbytes); 138 | } 139 | -------------------------------------------------------------------------------- /PSXDOOM/PSX_PAD.C: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | 3 | /* 4 | ================= 5 | = 6 | = Get_PadButtons 7 | = PS1 Mouse or PS1 Control 8 | = 9 | ================= 10 | */ 11 | 12 | int Get_PadButtons(int *buttons)//L80038FDC() 13 | { 14 | int mouse_x, mouse_y; 15 | int b_code, b_code1, b_code2; 16 | 17 | /* Apply current buttons */ 18 | b_code1 = *buttons; 19 | 20 | /* Reads the X / Y movement of the mouse, the left / right buttons, */ 21 | /* and converts them into flag codes like a normal control */ 22 | 23 | mouse_x = ((m_sensitivity + 5) * (signed char)(b_code1 >> 16)) / 100; 24 | mouse_y = ((m_sensitivity + 5) * (signed char)(b_code1 >> 24)) / 100; 25 | 26 | if (mouse_y >= 2) 27 | { 28 | b_code1 |= PAD_DOWN; 29 | } 30 | else if (mouse_y < -1) 31 | { 32 | b_code1 |= PAD_UP; 33 | } 34 | 35 | if (mouse_x >= 2) 36 | { 37 | b_code1 |= PAD_RIGHT; 38 | } 39 | else if (mouse_x < -1) 40 | { 41 | b_code1 |= PAD_LEFT; 42 | } 43 | 44 | b_code2 = b_code1; 45 | if (b_code1 & MOUSE_RIGHT) 46 | { 47 | b_code2 = b_code1 | PAD_TRIANGLE; 48 | *buttons = *buttons | PAD_TRIANGLE; 49 | } 50 | 51 | b_code = b_code2 & 0xffff; 52 | if (b_code1 & MOUSE_LEFT) 53 | { 54 | *buttons = *buttons | PAD_CROSS; 55 | b_code = b_code2 & 0xffff | PAD_CROSS; 56 | } 57 | 58 | return b_code; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /PSXDOOM/SEQLOAD.H: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------*/ 2 | /* 3 | The Williams Entertainment Sound System 4 | by Scott Patterson 5 | */ 6 | /*------------------------------------------------------------------*/ 7 | 8 | #ifndef _SEQLOAD_H 9 | #define _SEQLOAD_H 10 | 11 | #include 12 | #include "wessapi.h" 13 | #include "wessarc.h" 14 | 15 | enum Seq_Load_Error { 16 | 17 | SEQLOAD_NO_ERROR, 18 | SEQLOAD_FOPEN, 19 | SEQLOAD_FREAD, 20 | SEQLOAD_FSEEK 21 | }; 22 | 23 | enum OpenSeqHandleFlag {NoOpenSeqHandle,YesOpenSeqHandle}; 24 | 25 | /* 26 | routine: wess_seq_loader_init() 27 | 28 | - this routine must be called before and seq_loader_routines 29 | - input_pm_stat is returned by wess_get_master_status() 30 | - seqfile is the .wmd filename 31 | - flag specifies if the file handle will be opened during init or 32 | each time file is accessed 33 | */ 34 | 35 | 36 | extern int wess_seq_loader_init(void *input_pm_stat, 37 | char *seqfile, 38 | enum OpenSeqHandleFlag flag); 39 | 40 | /* 41 | routine: wess_seq_loader_exit() 42 | 43 | - closes file handle if not already closed 44 | - disables sequence loading calls 45 | */ 46 | 47 | extern void wess_seq_loader_exit(void); 48 | 49 | /* 50 | routine: wess_seq_loader_install_error_handler() 51 | 52 | - for installing an error callback to notify file access errors 53 | - module is your own ID returned as err_module parameter 54 | - err_enum is the returned Seq_Load_Error enum parameter 55 | */ 56 | 57 | extern void wess_seq_loader_install_error_handler(int (*error_func)(int, int), 58 | int module); 59 | 60 | /* 61 | general loading guidelines: 62 | 63 | - sizeof functions return the amount of bytes needed for data 64 | not already loaded, therefore, when sizeof returns 0, this 65 | means the data referred to is already loaded 66 | 67 | - load functions only load data that is not already loaded 68 | and return the amount of bytes loaded, memory is not allocated 69 | internally, you must use the sizeof functions and allocate 70 | memory yourself 71 | 72 | - free functions mark data as not loaded, memory is not freed 73 | internally, you must free memory yourself 74 | */ 75 | 76 | /* 77 | individual sequence loading 78 | */ 79 | 80 | extern int wess_seq_sizeof(int seqnum); 81 | 82 | extern int wess_seq_load(int seqnum,void *memptr); 83 | 84 | extern int wess_seq_free(int seqnum); 85 | 86 | /* 87 | sequence list loading 88 | 89 | - pass in a list of sequnce numbers to be loaded 90 | - end this list with the END_SEQ_LIST define 91 | */ 92 | 93 | #define END_SEQ_LIST -1 94 | 95 | extern int wess_seq_list_sizeof(short *seqlist); 96 | 97 | extern int wess_seq_list_load(short *seqlist,void *memptr); 98 | 99 | extern int wess_seq_list_free(short *seqlist); 100 | 101 | /* 102 | sequence range loading 103 | 104 | - specify a number of consecutive sequences to be loaded 105 | */ 106 | 107 | extern int wess_seq_range_sizeof(int seqfirst,int numseqs); 108 | 109 | extern int wess_seq_range_load(int seqfirst,int numseqs,void *memptr); 110 | 111 | extern int wess_seq_range_free(int seqfirst,int numseqs); 112 | 113 | #endif 114 | 115 | -------------------------------------------------------------------------------- /PSXDOOM/SEQLOADR.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update 20/10/2019 [GEC] 3 | 4 | #include "seqload.h" 5 | #define _ALIGN4_ 1 6 | 7 | #include 8 | 9 | extern pmasterstat *pm_stat; 10 | 11 | extern int seq_loader_enable; //80075790 12 | extern char *seqfilename; //80075794 13 | extern pmasterstat *seq_pm_stat; //80075798 14 | extern int seq_maxsequences; //8007579C 15 | extern char Driver_Init; //800757A0 16 | extern char Reset_Gates; //800757A1 17 | extern int seqopen; //800757A4 18 | extern int(*Seq_Error_func)(int, int); //800757A8 19 | extern int Seq_Error_module; //800757AC 20 | extern Wess_File_IO_Struct *seqfileptr; //800757B0 21 | 22 | extern track_header scratch_trk_hdr; //8007EDE8 23 | extern track_header seq_track_header; //8007EE74 24 | extern track_header base_track_header; //8007EE8C 25 | 26 | 27 | int wess_seq_range_sizeof(int seqfirst, int numseqs)//800497C0 28 | { 29 | int count; 30 | 31 | count = 0; 32 | if (seq_loader_enable) 33 | { 34 | if (numseqs == 0) 35 | return 0; 36 | 37 | while (numseqs--) 38 | { 39 | count += wess_seq_sizeof(seqfirst); 40 | seqfirst += 1; 41 | } 42 | } 43 | return (count); 44 | } 45 | 46 | int wess_seq_range_load(int seqfirst, int numseqs, void *memptr)//8004984C 47 | { 48 | int count; 49 | char *pmem; 50 | 51 | pmem = (char *)memptr; 52 | 53 | count = 0; 54 | if (seq_loader_enable) 55 | { 56 | if (!open_sequence_data() || !numseqs) 57 | return 0; 58 | 59 | while (numseqs--) 60 | { 61 | //printf("----------------------\n"); 62 | count += wess_seq_load(seqfirst, pmem+count); 63 | seqfirst += 1; 64 | } 65 | 66 | close_sequence_data(); 67 | } 68 | 69 | return count; 70 | } 71 | 72 | int wess_seq_range_free(int seqfirst, int numseqs)//80049900 73 | { 74 | if (seq_loader_enable) 75 | { 76 | if (numseqs == 0) 77 | return 0; 78 | 79 | while (numseqs--) 80 | { 81 | wess_seq_free(seqfirst); 82 | seqfirst += 1; 83 | } 84 | return 1; 85 | } 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /PSXDOOM/WESSAPIM.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update_1 20/10/2019 [GEC] 3 | // Update_2 31/01/2020 [GEC] 4 | 5 | #include "kernel.h" 6 | #include "wessarc.h" 7 | #include "wessapi.h" 8 | #include "wessseq.h" 9 | 10 | extern unsigned char master_sfx_volume; //*L80075834 11 | extern unsigned char master_mus_volume; //*L80075835 12 | extern unsigned char pan_status; //*L80075836 13 | extern unsigned char release_rate; //*L80075837 14 | extern pmasterstat *pm_stat; //800A8538 15 | extern int SeqOn; //80075778 16 | 17 | char wess_master_sfx_volume_get (void)//80049548 18 | { 19 | #ifndef BLOCK_SOUND_WESS 20 | if (!Is_Module_Loaded()) 21 | { 22 | return 0; 23 | } 24 | 25 | return (master_sfx_volume); 26 | #endif 27 | } 28 | 29 | char wess_master_mus_volume_get (void)//80049578 30 | { 31 | #ifndef BLOCK_SOUND_WESS 32 | if (!Is_Module_Loaded()) 33 | { 34 | return 0; 35 | } 36 | 37 | return (master_mus_volume); 38 | #endif 39 | } 40 | 41 | void wess_master_sfx_vol_set (char volume)//800495A8 42 | { 43 | #ifndef BLOCK_SOUND_WESS 44 | if (!Is_Module_Loaded()) 45 | { 46 | return; 47 | } 48 | 49 | master_sfx_volume = volume; 50 | #endif 51 | } 52 | void wess_master_mus_vol_set (char volume)//800495E0 53 | { 54 | #ifndef BLOCK_SOUND_WESS 55 | char nt, na; 56 | sequence_status *psq_stat; 57 | track_status *ptmp; 58 | char *lpdest; 59 | char *temp; 60 | int li, lj; 61 | char action[8]; 62 | 63 | if (!Is_Module_Loaded()) 64 | { 65 | return; 66 | } 67 | 68 | /* immediate pause of all sequences */ 69 | SeqOn = 0; 70 | 71 | master_mus_volume = volume; 72 | 73 | /* search for all sequences with this number and turn them off */ 74 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 75 | na = pm_stat->seqs_active; 76 | psq_stat = pm_stat->pseqstattbl; 77 | 78 | if (na) 79 | { 80 | while (nt--) 81 | { 82 | if (psq_stat->flags & SEQ_ACTIVE) 83 | { 84 | li = psq_stat->tracks_active; 85 | lj = pm_stat->max_trks_perseq; 86 | /* *lpdest refers to an active track if not 0xFF */ 87 | lpdest = psq_stat->ptrk_indxs; 88 | while (lj--) 89 | { 90 | if (*lpdest != 0xFF) 91 | { 92 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 93 | 94 | if (ptmp->sndclass == MUSIC_CLASS) 95 | { 96 | temp = ptmp->ppos; //copy 97 | ptmp->ppos = action;//action 98 | action[0] = 12; 99 | ptmp->ppos[1] = ptmp->volume_cntrl; 100 | CmdFuncArr[ptmp->patchtype][12](ptmp); 101 | ptmp->ppos = temp; //restore 102 | } 103 | if (!--li) break; 104 | } 105 | lpdest++; 106 | } 107 | 108 | if (!--na) break; 109 | } 110 | psq_stat++; 111 | } 112 | } 113 | 114 | SeqOn = 1; 115 | #endif 116 | } 117 | 118 | char wess_pan_mode_get (void)//800497A0 119 | { 120 | #ifndef BLOCK_SOUND_WESS 121 | return pan_status; 122 | #endif 123 | } 124 | 125 | void wess_pan_mode_set (char mode)//800497B0 126 | { 127 | #ifndef BLOCK_SOUND_WESS 128 | pan_status = mode; 129 | #endif 130 | } 131 | 132 | 133 | -------------------------------------------------------------------------------- /PSXDOOM/WESSAPIP.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update_1 20/10/2019 [GEC] 3 | // Update_2 31/01/2020 [GEC] 4 | 5 | #include "kernel.h" 6 | #include "wessarc.h" 7 | #include "wessapi.h" 8 | #include "wessseq.h" 9 | 10 | extern int num_sd; //80075714 11 | extern char *wmd_file_ptr; //80075718 12 | extern char *wmd_file_ptr2; //8007571C 13 | extern Wess_File_IO_Struct *fp_wmd_file; //80075720 14 | extern int sysinit; //80075724 15 | extern int module_loaded; //80075728 16 | extern int early_exit; //8007572C 17 | extern int max_seq_num; //80075730 18 | extern int mem_limit; //80075734 19 | extern patch_group_header scratch_pat_grp_hdr; //8007EDE8 20 | extern track_header scratch_trk_hdr; //8007EE04 21 | extern int wmd_mem_is_mine; //80075738 22 | extern char *wmd_mem; //8007573C 23 | extern char *wmd_end; //80075740 24 | extern int wmd_size; //80075744 25 | extern int (*Error_func)(int, int); //80075748 26 | extern int Error_module; //8007574C 27 | extern pmasterstat *pm_stat; //800A8538 28 | 29 | void trackstart(track_status *ptmp, sequence_status *psq_stat)//800414A4 30 | { 31 | #ifndef BLOCK_SOUND_WESS 32 | 33 | if (ptmp->flags & TRK_STOPPED) 34 | { 35 | ptmp->flags &= ~TRK_STOPPED; 36 | if (++psq_stat->tracks_playing) 37 | { 38 | psq_stat->playmode = SEQ_STATE_PLAYING; 39 | } 40 | } 41 | #endif 42 | } 43 | 44 | void trackstop(track_status *ptmp, sequence_status *psq_stat)//800414E8 45 | { 46 | #ifndef BLOCK_SOUND_WESS 47 | 48 | if (!(ptmp->flags & TRK_STOPPED)) 49 | { 50 | ptmp->flags |= TRK_STOPPED; 51 | if (!--psq_stat->tracks_playing) 52 | { 53 | psq_stat->playmode = SEQ_STATE_STOPPED; 54 | } 55 | } 56 | #endif 57 | } 58 | 59 | 60 | void wess_seq_pause(int sequence_number, enum MuteFlag mflag)//80041528 61 | { 62 | #ifndef BLOCK_SOUND_WESS 63 | 64 | char nt, na; 65 | sequence_status *psq_stat; 66 | track_status *ptmp; 67 | char *lpdest; 68 | int li, lj; 69 | 70 | if (!Is_Seq_Num_Valid(sequence_number)) 71 | { 72 | return; 73 | } 74 | 75 | /* immediate pause of sequence */ 76 | SeqOn = 0; 77 | 78 | /* search for all sequences with this number and turn them off */ 79 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 80 | na = pm_stat->seqs_active; 81 | psq_stat = pm_stat->pseqstattbl; 82 | if (na) 83 | { 84 | while (nt--) 85 | { 86 | if (psq_stat->flags & SEQ_ACTIVE) 87 | { 88 | if (psq_stat->seq_num == sequence_number) 89 | { 90 | li = psq_stat->tracks_active; 91 | lj = pm_stat->max_trks_perseq; 92 | /* *lpdest refers to an active track if not 0xFF */ 93 | lpdest = psq_stat->ptrk_indxs; 94 | while (lj--) 95 | { 96 | if (*lpdest != 0xFF) 97 | { 98 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 99 | trackstop(ptmp, psq_stat); 100 | if (mflag == YesMute) 101 | { 102 | CmdFuncArr[ptmp->patchtype][TrkMute](ptmp); 103 | } 104 | if (!--li) break; 105 | } 106 | lpdest++; 107 | } 108 | } 109 | if (!--na) break; 110 | } 111 | psq_stat++; 112 | } 113 | } 114 | 115 | SeqOn = 1; 116 | #endif 117 | } 118 | 119 | void wess_seq_restart(int sequence_number)//800416D0 120 | { 121 | #ifndef BLOCK_SOUND_WESS 122 | 123 | char nt, na; 124 | sequence_status *psq_stat; 125 | track_status *ptmp; 126 | char *lpdest; 127 | int li, lj; 128 | 129 | if (!Is_Seq_Num_Valid(sequence_number)) 130 | { 131 | return; 132 | } 133 | 134 | /* immediate restart of sequence */ 135 | SeqOn = 0; 136 | 137 | /* search for all sequences with this number and turn them off */ 138 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 139 | na = pm_stat->seqs_active; 140 | psq_stat = pm_stat->pseqstattbl; 141 | if (na) 142 | { 143 | while (nt--) 144 | { 145 | if (psq_stat->flags & SEQ_ACTIVE) 146 | { 147 | if (psq_stat->seq_num == sequence_number) 148 | { 149 | li = psq_stat->tracks_active; 150 | lj = pm_stat->max_trks_perseq; 151 | /* *lpdest refers to an active track if not 0xFF */ 152 | lpdest = psq_stat->ptrk_indxs; 153 | while (lj--) 154 | { 155 | if (*lpdest != 0xFF) 156 | { 157 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 158 | trackstart(ptmp, psq_stat); 159 | if (!--li) break; 160 | } 161 | lpdest++; 162 | } 163 | } 164 | if (!--na) break; 165 | } 166 | psq_stat++; 167 | } 168 | } 169 | 170 | SeqOn = 1; 171 | #endif 172 | } 173 | 174 | void wess_seq_pauseall(enum MuteFlag mflag, NoteState *pns)//8004183C 175 | { 176 | #ifndef BLOCK_SOUND_WESS 177 | 178 | char nt, na; 179 | sequence_status *psq_stat; 180 | track_status *ptmp; 181 | char *lpdest; 182 | int li, lj; 183 | 184 | if (!Is_Module_Loaded()) 185 | { 186 | return; 187 | } 188 | 189 | /* immediate pause of all sequences */ 190 | SeqOn = 0; 191 | 192 | //Doom PSX New 193 | if (mflag == YesMute) 194 | { 195 | start_record_music_mute(pns); 196 | } 197 | 198 | /* search for all sequences with this number and turn them off */ 199 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 200 | na = pm_stat->seqs_active; 201 | psq_stat = pm_stat->pseqstattbl; 202 | if (na) 203 | { 204 | while (nt--) 205 | { 206 | if (psq_stat->flags & SEQ_ACTIVE) 207 | { 208 | li = psq_stat->tracks_active; 209 | lj = pm_stat->max_trks_perseq; 210 | /* *lpdest refers to an active track if not 0xFF */ 211 | lpdest = psq_stat->ptrk_indxs; 212 | while (lj--) 213 | { 214 | if (*lpdest != 0xFF) 215 | { 216 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 217 | if (mflag == YesMute) 218 | { 219 | CmdFuncArr[ptmp->patchtype][TrkMute](ptmp); 220 | } 221 | trackstop(ptmp, psq_stat); 222 | if (!--li) break; 223 | } 224 | lpdest++; 225 | } 226 | 227 | if (!--na) break; 228 | } 229 | psq_stat++; 230 | } 231 | } 232 | 233 | //Doom PSX New 234 | if (mflag == YesMute) 235 | { 236 | end_record_music_mute(); 237 | } 238 | 239 | SeqOn = 1; 240 | #endif 241 | } 242 | 243 | void wess_seq_restartall(NoteState *pns)//800419f8 244 | { 245 | #ifndef BLOCK_SOUND_WESS 246 | 247 | char nt, na; 248 | sequence_status *psq_stat; 249 | track_status *ptmp; 250 | char *lpdest; 251 | int li, lj, nc; 252 | 253 | if (!Is_Module_Loaded()) 254 | { 255 | return; 256 | } 257 | 258 | /* immediate restart of all sequences */ 259 | SeqOn = 0; 260 | 261 | /* search for all sequences with this number and turn them off */ 262 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 263 | na = pm_stat->seqs_active; 264 | psq_stat = pm_stat->pseqstattbl; 265 | if (na) 266 | { 267 | while (nt--) 268 | { 269 | if (psq_stat->flags & SEQ_ACTIVE) 270 | { 271 | li = psq_stat->tracks_active; 272 | lj = pm_stat->max_trks_perseq; 273 | /* *lpdest refers to an active track if not 0xFF */ 274 | lpdest = psq_stat->ptrk_indxs; 275 | while (lj--) 276 | { 277 | if (*lpdest != 0xFF) 278 | { 279 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 280 | trackstart(ptmp, psq_stat); 281 | 282 | if (pns != 0) 283 | { 284 | for (nc = 0; nc < pns->numnotes; nc++) 285 | { 286 | if (*lpdest == pns->nd[nc].track) 287 | { 288 | if (psq_stat->seq_num == pns->nd[nc].seq_num) 289 | { 290 | PSX_voicenote(ptmp, 291 | pns->nd[nc].patchmap, 292 | pns->nd[nc].patchinfo, 293 | pns->nd[nc].keynum, 294 | pns->nd[nc].velnum); 295 | } 296 | } 297 | } 298 | } 299 | 300 | if (!--li) break; 301 | } 302 | lpdest++; 303 | } 304 | 305 | if (!--na) break; 306 | } 307 | psq_stat++; 308 | } 309 | } 310 | 311 | if (pns != 0) 312 | { 313 | pns->numnotes = 0; 314 | } 315 | 316 | SeqOn = 1; 317 | #endif 318 | } 319 | -------------------------------------------------------------------------------- /PSXDOOM/WESSAPIT.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update_1 20/10/2019 [GEC] 3 | // Update_2 31/01/2020 [GEC] 4 | 5 | #include "kernel.h" 6 | #include "wessarc.h" 7 | #include "wessapi.h" 8 | #include "wessseq.h" 9 | 10 | extern int num_sd; //80075714 11 | extern char *wmd_file_ptr; //80075718 12 | extern char *wmd_file_ptr2; //8007571C 13 | extern Wess_File_IO_Struct *fp_wmd_file; //80075720 14 | extern int sysinit; //80075724 15 | extern int module_loaded; //80075728 16 | extern int early_exit; //8007572C 17 | extern int max_seq_num; //80075730 18 | extern int mem_limit; //80075734 19 | extern patch_group_header scratch_pat_grp_hdr; //8007EDE8 20 | extern track_header scratch_trk_hdr; //8007EE04 21 | extern int wmd_mem_is_mine; //80075738 22 | extern char *wmd_mem; //8007573C 23 | extern char *wmd_end; //80075740 24 | extern int wmd_size; //80075744 25 | extern int (*Error_func)(int, int); //80075748 26 | extern int Error_module; //8007574C 27 | extern pmasterstat *pm_stat; //800A8538 28 | 29 | void updatetrackstat(track_status *ptk_stat, TriggerPlayAttr *attr)//L80043E08 30 | { 31 | //CODE---------------------------------------------------- 32 | int tempmask; 33 | char *temp; 34 | char action[8]; 35 | 36 | if ((attr == NULL) || (!attr->mask)) 37 | return; 38 | 39 | tempmask = attr->mask; 40 | 41 | if (tempmask & TRIGGER_VOLUME) //0x01 42 | { 43 | ptk_stat->volume_cntrl = attr->volume; 44 | } 45 | 46 | if (tempmask & TRIGGER_PAN) //0x02 47 | { 48 | ptk_stat->pan_cntrl = attr->pan; 49 | } 50 | 51 | if (tempmask & (TRIGGER_VOLUME | TRIGGER_PAN)) //0x03 52 | { 53 | ptk_stat->volume_cntrl = attr->volume; 54 | ptk_stat->pan_cntrl = attr->pan; 55 | 56 | temp = ptk_stat->ppos; //copy 57 | ptk_stat->ppos = action; //action 58 | action[0] = 12; 59 | ptk_stat->ppos[1] = ptk_stat->volume_cntrl; 60 | CmdFuncArr[ptk_stat->patchtype][12](ptk_stat); 61 | ptk_stat->ppos = temp; //restore 62 | } 63 | else 64 | { 65 | if (tempmask & TRIGGER_VOLUME) //0x01 66 | { 67 | ptk_stat->volume_cntrl = attr->volume; 68 | 69 | temp = ptk_stat->ppos; //copy 70 | ptk_stat->ppos = action; //action 71 | action[0] = 12; 72 | ptk_stat->ppos[1] = ptk_stat->volume_cntrl; 73 | CmdFuncArr[ptk_stat->patchtype][12](ptk_stat); 74 | ptk_stat->ppos = temp; //restore 75 | } 76 | else if (tempmask & TRIGGER_PAN) 77 | { 78 | ptk_stat->pan_cntrl = attr->pan; 79 | 80 | temp = ptk_stat->ppos; //copy 81 | ptk_stat->ppos = action; //action 82 | action[0] = 13; 83 | ptk_stat->ppos[1] = ptk_stat->pan_cntrl; 84 | CmdFuncArr[ptk_stat->patchtype][13](ptk_stat); 85 | ptk_stat->ppos = temp; //restore 86 | } 87 | } 88 | 89 | if (tempmask & TRIGGER_PATCH) //0x04 90 | { 91 | ptk_stat->patchnum = attr->patch; 92 | } 93 | 94 | if (tempmask & TRIGGER_PITCH) //0x08 95 | { 96 | ptk_stat->pitch_cntrl = attr->pitch; 97 | 98 | temp = ptk_stat->ppos; //copy 99 | ptk_stat->ppos = action; //action 100 | action[0] = 9; 101 | ptk_stat->ppos[1] = (char)(ptk_stat->pitch_cntrl & 0xff); 102 | ptk_stat->ppos[2] = (char)(ptk_stat->pitch_cntrl >> 8); 103 | CmdFuncArr[ptk_stat->patchtype][9](ptk_stat); 104 | ptk_stat->ppos = temp; //restore 105 | } 106 | 107 | if (tempmask & TRIGGER_MUTEMODE) //0x10 108 | { 109 | if (ptk_stat->mutemask & (1 << attr->mutemode)) 110 | { 111 | ptk_stat->flags |= TRK_MUTE; 112 | } 113 | else { 114 | ptk_stat->flags &= ~TRK_MUTE; 115 | } 116 | } 117 | 118 | if (tempmask & TRIGGER_TEMPO) //0x20 119 | { 120 | ptk_stat->qpm = attr->tempo; 121 | ptk_stat->ppi = CalcPartsPerInt(GetIntsPerSec(), 122 | ptk_stat->ppq, 123 | ptk_stat->qpm); 124 | } 125 | 126 | if (tempmask & TRIGGER_TIMED) //0x40 127 | { 128 | ptk_stat->endppi = ptk_stat->totppi + attr->timeppq; 129 | ptk_stat->flags |= TRK_TIMED; 130 | } 131 | 132 | if (tempmask&TRIGGER_LOOPED) //0x80 133 | { 134 | ptk_stat->flags |= TRK_LOOPED; 135 | } 136 | } 137 | 138 | void wess_seq_trigger_type (int seq_num, unsigned long seq_type)//800440FC 139 | { 140 | #ifndef BLOCK_SOUND_WESS 141 | 142 | sequence_data *psq_info; 143 | 144 | psq_info = pm_stat->pmod_info->pseq_info+seq_num; /* pointer math */ 145 | 146 | wess_seq_structrig (psq_info, seq_num, seq_type, NoHandle, NULL); 147 | #endif 148 | } 149 | 150 | void wess_seq_trigger_type_special (int seq_num, 151 | unsigned long seq_type, 152 | TriggerPlayAttr *attr)//8004414C 153 | { 154 | #ifndef BLOCK_SOUND_WESS 155 | 156 | sequence_data *psq_info; 157 | 158 | psq_info = pm_stat->pmod_info->pseq_info+seq_num; /* pointer math */ 159 | 160 | wess_seq_structrig (psq_info, seq_num, seq_type, NoHandle, attr); 161 | #endif 162 | } 163 | 164 | void wess_seq_update_type_special(unsigned long seq_type, TriggerPlayAttr *attr)//800441A0 165 | { 166 | #ifndef BLOCK_SOUND_WESS 167 | 168 | /* immediate stop of sequence */ 169 | char nt, na; 170 | sequence_status *psq_stat; 171 | track_status *ptmp; 172 | char *lpdest; 173 | int li, lj; 174 | 175 | if (!Is_Module_Loaded()) 176 | { 177 | return; 178 | } 179 | 180 | SeqOn = 0; 181 | 182 | /* search for all sequences with this number and turn them off */ 183 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 184 | na = pm_stat->seqs_active; 185 | psq_stat = pm_stat->pseqstattbl; 186 | if (na) 187 | { 188 | while (nt--) 189 | { 190 | if (psq_stat->flags & SEQ_ACTIVE) 191 | { 192 | if (psq_stat->seq_type == seq_type) 193 | { 194 | li = psq_stat->tracks_active; 195 | lj = pm_stat->max_trks_perseq; 196 | /* *lpdest refers to an active track if not 0xFF */ 197 | lpdest = psq_stat->ptrk_indxs; 198 | while (lj--) 199 | { 200 | if (*lpdest != 0xFF) 201 | { 202 | ptmp = (pm_stat->ptrkstattbl + (*lpdest)); 203 | if (attr != 0) 204 | { 205 | updatetrackstat(ptmp, attr); 206 | } 207 | if (!--li) break; 208 | } 209 | lpdest++; 210 | } 211 | } 212 | if (!--na) break; 213 | } 214 | psq_stat++; 215 | } 216 | } 217 | 218 | SeqOn = 1; 219 | #endif 220 | } 221 | 222 | void wess_seq_stoptype (unsigned long type_number)//8004431C 223 | { 224 | #ifndef BLOCK_SOUND_WESS 225 | 226 | /* immediate stop of sequence */ 227 | char nt,na; 228 | sequence_status *psq_stat; 229 | track_status *ptmp; 230 | char *lpdest; 231 | int li,lj; 232 | 233 | if(!Is_Module_Loaded()) 234 | { 235 | return; 236 | } 237 | 238 | SeqOn = 0; 239 | 240 | /* search for all sequences with this number and turn them off */ 241 | nt = pm_stat->pmod_info->mod_hdr.seq_work_areas; 242 | na = pm_stat->seqs_active; 243 | psq_stat = pm_stat->pseqstattbl; 244 | if(na) 245 | { 246 | while(nt--) 247 | { 248 | if (psq_stat->flags & SEQ_ACTIVE) 249 | { 250 | if(psq_stat->seq_type==type_number) 251 | { 252 | li = psq_stat->tracks_active; 253 | lj = pm_stat->max_trks_perseq; 254 | /* *lpdest refers to an active track if not 0xFF */ 255 | lpdest = psq_stat->ptrk_indxs; 256 | while(lj--) 257 | { 258 | if(*lpdest!=0xFF) 259 | { 260 | ptmp = (pm_stat->ptrkstattbl+(*lpdest)); 261 | CmdFuncArr[ptmp->patchtype][TrkOff](ptmp); 262 | if(!--li) break; 263 | } 264 | lpdest++; 265 | } 266 | } 267 | if(!--na) break; 268 | } 269 | psq_stat++; 270 | } 271 | } 272 | 273 | SeqOn = 1; 274 | #endif 275 | } 276 | -------------------------------------------------------------------------------- /PSXDOOM/WESSARC.C: -------------------------------------------------------------------------------- 1 | // Reconstruido por Erick Vasquez Garcia 16/05/2019 [GEC] 2 | // Update_1 20/10/2019 [GEC] 3 | // Update_2 31/01/2020 [GEC] 4 | 5 | /*------------------------------------------------------------------*/ 6 | /* 7 | The Williams Entertainment Sound System 8 | Sony Architecture Specific Routines 9 | by Scott Patterson 10 | */ 11 | /*------------------------------------------------------------------*/ 12 | 13 | //#include "win_port.h" 14 | 15 | 16 | //#define BLOCK_SOUND_WESS 17 | //#ifndef BLOCK_SOUND_WESS 18 | 19 | 20 | #include "kernel.h" 21 | #include 22 | #include "wessarc.h" 23 | #include "wessapi.h" 24 | #include "wessseq.h" 25 | 26 | /*extern long EnableEvent(unsigned long event); 27 | extern long DisableEvent(unsigned long event); 28 | extern long OpenEvent(unsigned long desc,long spec,long mode,long (*func)(void)); 29 | extern long CloseEvent(unsigned long event); 30 | extern long SetRCnt(unsigned long spec,unsigned long target,long mode); 31 | extern long StartRCnt(unsigned long spec);*/ 32 | 33 | //#include "psxspu.h" 34 | #include "psxcd.h" 35 | 36 | void (**CmdFuncArr[10])(track_status *) = { 37 | DrvFunctions, 38 | drv_cmds, 39 | DrvFunctions, 40 | DrvFunctions, 41 | DrvFunctions, 42 | DrvFunctions, 43 | DrvFunctions, 44 | DrvFunctions, 45 | DrvFunctions, 46 | DrvFunctions 47 | }; 48 | 49 | short GetIntsPerSec(void); 50 | unsigned long CalcPartsPerInt(short ips,short ppq,short qpm); 51 | static long WessInterruptHandler(void); 52 | extern void SeqEngine(void); 53 | 54 | /* Movido a WESSBASE.C 55 | int SeqOn = 0; 56 | unsigned long millicount = 0; 57 | unsigned long millisum = 0; 58 | 59 | int WessTimerActive = 0; 60 | 61 | int T2counter = 0; 62 | */ 63 | extern volatile int SeqOn; 64 | extern volatile long millisum; 65 | extern volatile int WessTimerActive; 66 | extern volatile int T2counter; 67 | 68 | static unsigned long EV2 = 0; /* interrupt event var */ 69 | 70 | // module loader stuff 71 | 72 | static Wess_File_IO_Struct module_fileref;//8007EE20 73 | 74 | // data loader stuff 75 | //static unsigned long addr; 76 | //static unsigned long size; 77 | 78 | //#define MALLOC_MAX 1 79 | //char spu_malloc_rec [SPU_MALLOC_RECSIZ * (MALLOC_MAX + 1)]; 80 | 81 | static Wess_Data_IO_Struct data_fileref;//8007EE48 82 | 83 | // sram transfer stuff 84 | 85 | #define CHUNKSIZE 2048 86 | extern char chunk[CHUNKSIZE];//80096394 87 | extern char chunk2[CHUNKSIZE];//80096BA4 88 | 89 | #define SRAM_TO_ALLOC 520192 90 | 91 | // while I thought end of sram should be 524288, it seems to be 520192 92 | //#define END_O_SRAM 520192 93 | extern unsigned long end_of_sram; 94 | 95 | void wess_low_level_init(void)//80043868 96 | { 97 | psxspu_init(); 98 | } 99 | 100 | void wess_low_level_exit(void)//80043888 101 | { 102 | return; 103 | } 104 | 105 | void *wess_malloc(int size)//80043890 106 | { 107 | return 0; 108 | } 109 | 110 | void wess_free(char *mem)//80043898 111 | { 112 | return; 113 | } 114 | 115 | short GetIntsPerSec(void)//800438A0 116 | { 117 | return(120); 118 | } 119 | 120 | unsigned long CalcPartsPerInt(short ips,short ppq,short qpm)//800438A8 121 | { 122 | unsigned long ppi; 123 | ppi = ((((unsigned long)qpm*0x10000)+((unsigned long)ips*30)+30)/((unsigned long)ips*60))*(unsigned long)ppq; 124 | return(ppi); 125 | } 126 | 127 | static long WessInterruptHandler(void)//800438F8 128 | { 129 | unsigned int millitemp; 130 | 131 | //printf("millicount %d\n",millicount); 132 | //printf("SeqOn %d\n",SeqOn); 133 | //printf("WessTimerActive %d\n",WessTimerActive); 134 | 135 | millitemp = millisum + 0x85555; 136 | T2counter += 1; 137 | millisum = millitemp & 0xffff; 138 | millicount += (millitemp >> 0x10); 139 | 140 | psxspu_fadeengine(); 141 | if (SeqOn) 142 | { 143 | //printf("SeqOn %d\n",SeqOn); 144 | SeqEngine(); 145 | } 146 | return (0); 147 | } 148 | 149 | void init_WessTimer(void)//8004398C 150 | { 151 | //printf("init_WessTimer\n"); 152 | 153 | SeqOn = 0; 154 | EnterCriticalSection(); 155 | 156 | EV2 = OpenEvent(RCntCNT2, EvSpINT, EvMdINTR, WessInterruptHandler); 157 | EnableEvent(EV2); 158 | SetRCnt(RCntCNT2, 34722, RCntMdINTR); // 33038 is ~120 Hz 159 | StartRCnt(RCntCNT2); 160 | 161 | WessTimerActive = 1; 162 | 163 | ExitCriticalSection(); 164 | } 165 | 166 | void exit_WessTimer(void)//80043A18 167 | { 168 | psxspu_set_master_vol(psxspu_get_master_vol()); 169 | psxspu_set_cd_vol(psxspu_get_cd_vol()); 170 | 171 | EnterCriticalSection(); 172 | 173 | WessTimerActive = 0; 174 | 175 | DisableEvent(EV2); 176 | CloseEvent(EV2); 177 | 178 | ExitCriticalSection(); 179 | } 180 | 181 | 182 | //static SpuReverbAttr rev_attr; 183 | int Wess_init_for_LoadFileData(char *filename)//80043A88 184 | { 185 | /*SpuInitMalloc (MALLOC_MAX, spu_malloc_rec); 186 | rev_attr.mask = SPU_REV_MODE; 187 | rev_attr.mode = SPU_REV_MODE_OFF; 188 | SpuSetReverbModeParam (&rev_attr); 189 | SpuSetReverbVoice (SpuOff, SPU_ALLCH); 190 | SpuReserveReverbWorkArea(SpuOff); 191 | SpuSetReverb (SpuOff); 192 | SpuMalloc (520192); 193 | SpuSetTransMode (SpuTransferByDMA);*/ 194 | return(1); 195 | } 196 | 197 | Wess_File_IO_Struct *module_open(char *filename)//80043A90 198 | { 199 | Wess_File_IO_Struct *fp; 200 | 201 | fp = psxcd_open(filename); 202 | 203 | module_fileref = *fp; 204 | 205 | return(&module_fileref); 206 | } 207 | 208 | int module_read(void *destptr,int readbytes,Wess_File_IO_Struct *fileptr)//80043B04 209 | { 210 | return(psxcd_read(destptr,readbytes,fileptr)); 211 | } 212 | 213 | int module_seek(Wess_File_IO_Struct *fileptr,int seekpos,int seekmode)//80043B24 214 | { 215 | return(psxcd_seek(fileptr,seekpos,seekmode)); 216 | } 217 | 218 | unsigned long module_tell(Wess_File_IO_Struct *fileptr)//80043B44 219 | { 220 | return(psxcd_tell(fileptr)); 221 | } 222 | 223 | void module_close(Wess_File_IO_Struct *fileptr)//80043B64 224 | { 225 | psxcd_close(fileptr); 226 | } 227 | 228 | int get_num_Wess_Sound_Drivers(int **settings_tag_lists)//80043B84 229 | { 230 | return(1); 231 | } 232 | 233 | Wess_Data_IO_Struct *data_open(char *filename) 234 | { 235 | Wess_File_IO_Struct *fp; 236 | 237 | fp = psxcd_open(filename); 238 | 239 | data_fileref = *fp; 240 | 241 | return(&data_fileref); 242 | } 243 | 244 | extern int ReadChunk1;//*L8007EE70 245 | extern int ReadChunk2;//*L8007EE1C 246 | 247 | void data_read_chunk(Wess_Data_IO_Struct *fileptr, int totaltogo, unsigned long spuptr)//80043C00 248 | { 249 | if (ReadChunk1)//Read to chunk 250 | { 251 | psxcd_read(chunk, totaltogo, fileptr); 252 | SpuSetTransferStartAddr(spuptr); 253 | SpuWrite(chunk, totaltogo); 254 | ReadChunk2 = 1; 255 | ReadChunk1 = 0; 256 | } 257 | else 258 | { 259 | if (ReadChunk2)//Read to chunk2 260 | { 261 | psxcd_read(chunk2, totaltogo, fileptr); 262 | SpuIsTransferCompleted(SPU_TRANSFER_WAIT); 263 | SpuSetTransferStartAddr(spuptr); 264 | SpuWrite(chunk2, totaltogo); 265 | ReadChunk2 = 0; 266 | } 267 | else//Read to chunk 268 | { 269 | psxcd_read(chunk, totaltogo, fileptr); 270 | SpuIsTransferCompleted(SPU_TRANSFER_WAIT); 271 | SpuSetTransferStartAddr(spuptr); 272 | SpuWrite(chunk, totaltogo); 273 | ReadChunk2 = 1; 274 | } 275 | } 276 | } 277 | 278 | int data_read(Wess_Data_IO_Struct *fileptr,void *destptr,int readbytes,int filepos)//80043D1C 279 | { 280 | int totaltogo; 281 | unsigned long spuptr; 282 | 283 | totaltogo = readbytes; 284 | spuptr = (unsigned long)destptr; 285 | 286 | if ((end_of_sram - spuptr) < readbytes) 287 | { 288 | return(0); 289 | } 290 | 291 | psxcd_seek(fileptr, filepos, PSXCD_SEEK_SET); 292 | 293 | ReadChunk1 = 1; 294 | while (CHUNKSIZE <= totaltogo) 295 | { 296 | data_read_chunk(fileptr, CHUNKSIZE, spuptr); 297 | 298 | totaltogo -= CHUNKSIZE; 299 | spuptr += CHUNKSIZE; 300 | } 301 | 302 | if (totaltogo) 303 | { 304 | data_read_chunk(fileptr, totaltogo, spuptr); 305 | } 306 | 307 | SpuIsTransferCompleted(SPU_TRANSFER_WAIT); 308 | 309 | return(readbytes); 310 | } 311 | 312 | void data_close(Wess_Data_IO_Struct *fileptr)//80043DE8 313 | { 314 | psxcd_close(fileptr); 315 | } 316 | -------------------------------------------------------------------------------- /PSXDOOM/WESSSEQ.H: -------------------------------------------------------------------------------- 1 | #ifndef _WESSSEQ_H 2 | #define _WESSSEQ_H 3 | 4 | #include 5 | #include "wessapi.h" 6 | #include "wessarc.h" 7 | 8 | extern unsigned char master_sfx_volume; 9 | extern unsigned char master_mus_volume; 10 | extern unsigned char pan_status; 11 | extern unsigned char release_rate; 12 | 13 | extern char *Read_Vlq(char *pstart, void *deltatime); 14 | extern char *Write_Vlq(char *dest, unsigned int deltatime); 15 | extern int Len_Vlq(unsigned int deltatime); 16 | 17 | extern volatile int SeqOn; 18 | extern void(*drv_cmds[19])(); 19 | 20 | extern void add_music_mute_note(unsigned short seq_num, unsigned char track, unsigned char keynum, unsigned char velnum, patchmaps_header *patchmap, patchinfo_header *patchinfo); 21 | 22 | extern void Dvr_NoteSetHandle(voice_status *pvoices_stat); 23 | extern void Dvr_NoteOn(track_status *ptk_stat, 24 | patchmaps_header *patchmap, patchinfo_header *patchinfo, 25 | unsigned char keynum, unsigned char velnum); 26 | extern void Eng_TrkOff(); 27 | 28 | extern void(*DrvFunctions[36])(); 29 | extern void SeqEngine(void); 30 | 31 | #endif // _WESSSEQ_H 32 | -------------------------------------------------------------------------------- /PSXDOOM/asm/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/c_main.c: -------------------------------------------------------------------------------- 1 | /* c_main.c -- credits intro */ 2 | 3 | #include "doomdef.h" 4 | #include "r_local.h" 5 | 6 | psxobj_t idcredpic[2]; //80097910, 80097930 7 | psxobj_t wmscredpic[2]; //80097950, 80097970 8 | psxobj_t levelcredpic; //8009a6f0 9 | 10 | int c_vframe1 = 0; //80077AFC iGp000006ec 11 | int c_yscroll; //80078080 uGp00000c70 12 | int c_next; //80077FCC uGp00000bbc 13 | 14 | /* 15 | ======================= 16 | = 17 | = C_Start 18 | = 19 | ======================= 20 | */ 21 | 22 | void C_Start(void)//L80036E68() 23 | { 24 | ImageToVram(&titlepic, "TITLE", 0); 25 | ImageToVram(&idcredpic[0], "IDCRED1", 0); 26 | ImageToVram(&idcredpic[1], "IDCRED2", 0); 27 | ImageToVram(&wmscredpic[0], "WMSCRED1", 0); 28 | ImageToVram(&wmscredpic[1], "WMSCRED2", 0); 29 | ImageToVram(&levelcredpic, "LEVCRED2", 0); 30 | 31 | c_yscroll = 240;//80078080 32 | c_next = 0;//80077FCC 33 | 34 | psxcd_play_at_andloop(CD_TRACK[cdmusic_credits_demo],CDVolume,0,0,CD_TRACK[cdmusic_credits_demo],CDVolume,0,0); 35 | do {} while (psxcd_elapsed_sectors() == 0); 36 | } 37 | 38 | /* 39 | ======================= 40 | = 41 | = C_Stop 42 | = 43 | ======================= 44 | */ 45 | 46 | void C_Stop(int exit)//L80036F5C() 47 | { 48 | psxcd_stop(); 49 | } 50 | 51 | /* 52 | ======================= 53 | = 54 | = C_Ticker 55 | = 56 | ======================= 57 | */ 58 | 59 | int C_Ticker(void)//L80036F7C() 60 | { 61 | int exit; 62 | 63 | exit = ga_nothing; 64 | 65 | if (ticbuttons[0]) 66 | { 67 | exit = ga_exit; 68 | } 69 | else 70 | { 71 | c_vframe1 -= vblsinframe[0]; 72 | if (c_vframe1 <= 0) 73 | { 74 | c_vframe1 = 2; 75 | c_yscroll--; 76 | if (c_next > -1) 77 | { 78 | if (c_next < 2) 79 | { 80 | if (c_yscroll < -256) 81 | { 82 | c_vframe1 = 2; 83 | c_next += 1; 84 | c_yscroll = 240; 85 | } 86 | } 87 | else 88 | { 89 | if (c_next != 2) 90 | { 91 | c_vframe1 = 2; 92 | } 93 | else if (c_yscroll < -256) 94 | { 95 | c_vframe1 = 2; 96 | exit = ga_exitdemo; 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | return exit; 104 | } 105 | 106 | /* 107 | ======================= 108 | = 109 | = C_Draw 110 | = 111 | ======================= 112 | */ 113 | 114 | void C_Draw(void) //L8003701C() 115 | { 116 | int xpos; 117 | int pal; 118 | psxobj_t *pic; 119 | 120 | NextTextureCacheIdx(); 121 | 122 | if (c_next == 0) 123 | { 124 | DrawStaticImage(&titlepic,0,0,(int)palette[17]); 125 | pic = &levelcredpic; 126 | pal = palette[19]; 127 | xpos = 11; 128 | } 129 | else if (c_next == 1) 130 | { 131 | DrawStaticImage(&wmscredpic[0],0,0,(int)palette[19]); 132 | pic = &wmscredpic[1]; 133 | pal = palette[19]; 134 | xpos = 5; 135 | } 136 | else if (c_next == 2) 137 | { 138 | DrawStaticImage(&idcredpic[0],0,0,(int)palette[18]); 139 | pic = &idcredpic[1]; 140 | pal = palette[19]; 141 | xpos = 9; 142 | } 143 | 144 | DrawStaticImage(pic, xpos, c_yscroll, pal); 145 | 146 | UpdateDrawOTag(); 147 | DrawRender(); 148 | } 149 | -------------------------------------------------------------------------------- /PSXDOOM/doomdata.h: -------------------------------------------------------------------------------- 1 | /* DoomData.h */ 2 | 3 | /* all external data is defined here */ 4 | /* most of the data is loaded into different structures at run time */ 5 | 6 | #ifndef __DOOMDATA__ 7 | #define __DOOMDATA__ 8 | 9 | #ifndef __BYTEBOOL__ 10 | #define __BYTEBOOL__ 11 | typedef enum {false, true} boolean; 12 | typedef unsigned char byte; 13 | #endif 14 | 15 | /* 16 | =============================================================================== 17 | 18 | map level types 19 | 20 | =============================================================================== 21 | */ 22 | 23 | /* lump order in a map wad */ 24 | enum {ML_LABEL, ML_THINGS, ML_LINEDEFS, ML_SIDEDEFS, ML_VERTEXES, ML_SEGS, 25 | ML_SSECTORS, ML_NODES, ML_SECTORS , ML_REJECT, ML_BLOCKMAP, ML_LEAFS, ENDOFWAD 26 | }; 27 | 28 | 29 | typedef struct 30 | { 31 | int x, y; //Psx Doom 32 | } mapvertex_t; 33 | 34 | typedef struct 35 | { 36 | short textureoffset; 37 | short rowoffset; 38 | //char toptexture[8], bottomtexture[8], midtexture[8]; 39 | short toptexture, bottomtexture, midtexture; 40 | short sector; /* on viewer's side */ 41 | } mapsidedef_t; 42 | 43 | typedef struct 44 | { 45 | short v1, v2; 46 | short flags; 47 | short special, tag; 48 | short sidenum[2]; /* sidenum[1] will be -1 if one sided */ 49 | } maplinedef_t; 50 | 51 | #define ML_BLOCKING 1 52 | #define ML_BLOCKMONSTERS 2 53 | #define ML_TWOSIDED 4 /* backside will not be present at all */ 54 | /* if not two sided ???:obsolete */ 55 | 56 | /* if a texture is pegged, the texture will have the end exposed to air held */ 57 | /* constant at the top or bottom of the texture (stairs or pulled down things) */ 58 | /* and will move with a height change of one of the neighbor sectors */ 59 | /* Unpegged textures allways have the first row of the texture at the top */ 60 | /* pixel of the line for both top and bottom textures (windows) */ 61 | #define ML_DONTPEGTOP 8 62 | #define ML_DONTPEGBOTTOM 16 63 | 64 | #define ML_SECRET 32 /* don't map as two sided: IT'S A SECRET! */ 65 | #define ML_SOUNDBLOCK 64 /* don't let sound cross two of these */ 66 | #define ML_DONTDRAW 128 /* don't draw on the automap */ 67 | #define ML_MAPPED 256 /* set if allready drawn in automap */ 68 | 69 | // Psx Doom New Flags 70 | #define ML_MIDMASKED 0x200 71 | #define ML_MIDTRANSLUCENT 0x400 72 | #define ML_BLOCKPRJECTILE 0x800 73 | // Psx Final Doom New Flag 74 | #define ML_MIDCLIPTEXTURE 0x1000 75 | 76 | typedef struct 77 | { 78 | short floorheight, ceilingheight; //*, *2 79 | //char floorpic[8], ceilingpic[8]; //*4 ,*12 80 | short floorpic, ceilingpic; 81 | char lightlevel; //*20 82 | char colorid; //*21 83 | short special, tag; //*22, *24 84 | short flags; //Psx Doom *26 85 | } mapsector_t; 86 | 87 | typedef struct 88 | { 89 | short numsegs; 90 | short firstseg; /* segs are stored sequentially */ 91 | } mapsubsector_t; 92 | 93 | typedef struct 94 | { 95 | short v1, v2; 96 | short angle; /* ???: make this a sidedef? */ 97 | short linedef, side; 98 | short offset; 99 | } mapseg_t; 100 | 101 | enum {BOXTOP,BOXBOTTOM,BOXLEFT,BOXRIGHT}; /* bbox coordinates */ 102 | 103 | #define NF_SUBSECTOR 0x8000 104 | typedef struct 105 | { 106 | short x,y,dx,dy; /* partition line */ 107 | short bbox[2][4]; /* bounding box for each child */ 108 | unsigned short children[2]; /* if NF_SUBSECTOR its a subsector */ 109 | } mapnode_t; 110 | 111 | typedef struct 112 | { 113 | short x,y; 114 | short angle; 115 | short type; 116 | short options; 117 | } mapthing_t; 118 | 119 | #define MTF_EASY 1 120 | #define MTF_NORMAL 2 121 | #define MTF_HARD 4 122 | #define MTF_AMBUSH 8 123 | //Psx Doom 124 | #define MTF_BLENDMASK1 0x20 125 | #define MTF_BLENDMASK2 0x40 126 | #define MTF_BLENDMASK3 0x80 127 | 128 | /* 129 | =============================================================================== 130 | 131 | texture definition 132 | 133 | =============================================================================== 134 | */ 135 | 136 | typedef struct 137 | { 138 | short originx; 139 | short originy; 140 | short patch; 141 | short stepdir; 142 | short colormap; 143 | } mappatch_t; 144 | 145 | typedef struct 146 | { 147 | //char name[8]; 148 | //boolean masked; 149 | short leftoffset; 150 | short topoffset; 151 | short width; 152 | short height; 153 | //void **columndirectory; /* OBSOLETE */ 154 | //short patchcount; 155 | //mappatch_t patches[1]; 156 | } maptexture_t; 157 | 158 | 159 | /* 160 | =============================================================================== 161 | 162 | graphics 163 | 164 | =============================================================================== 165 | */ 166 | 167 | /* shorts are stored BIG ENDIAN */ 168 | 169 | 170 | /* column_t are runs of non masked source pixels */ 171 | typedef struct 172 | { 173 | byte topdelta; /* 0xff is the last post in a column */ 174 | byte length; 175 | unsigned short dataofs; /* from data start in patch_t */ 176 | } column_t; 177 | 178 | /* a patch holds one or more columns */ 179 | /* patches are used for sprites and all masked pictures */ 180 | typedef struct 181 | { 182 | short width; /* bounding box size */ 183 | short height; 184 | short leftoffset; /* pixels to the left of origin */ 185 | short topoffset; /* pixels below the origin */ 186 | unsigned short columnofs[8]; /* only [width] used */ 187 | /* the [0] is &columnofs[width] */ 188 | } patch_t; 189 | 190 | 191 | /* 192 | =============================================================================== 193 | 194 | status 195 | 196 | =============================================================================== 197 | */ 198 | 199 | 200 | 201 | 202 | #endif /* __DOOMDATA__ */ 203 | 204 | -------------------------------------------------------------------------------- /PSXDOOM/l_main.c: -------------------------------------------------------------------------------- 1 | /* l_main.c -- legal intro */ 2 | 3 | #if 0 // Final Doom has no legal introduction 4 | 5 | #include "doomdef.h" 6 | #include "r_local.h" 7 | 8 | psxobj_t legalspic;//0x800979b0 9 | 10 | /* 11 | ======================= 12 | = 13 | = L_Start 14 | = 15 | ======================= 16 | */ 17 | 18 | void L_Start(void)//L80034D5C() 19 | { 20 | Valloc_Init(); 21 | ImageToVram(&legalspic, "LEGALS", 0); 22 | S_StartSound(NULL, sfx_sgcock); 23 | y_scroll = 240; 24 | } 25 | 26 | /* 27 | ======================= 28 | = 29 | = L_Stop 30 | = 31 | ======================= 32 | */ 33 | 34 | void L_Stop(int exit)//L80034DA8() 35 | { 36 | S_StartSound(NULL, sfx_barexp); 37 | M_CrossFadeWipe(); 38 | } 39 | 40 | /* 41 | ======================= 42 | = 43 | = L_Ticker 44 | = 45 | ======================= 46 | */ 47 | 48 | int L_Ticker(void)//L80034DD4() 49 | { 50 | int exit; 51 | 52 | exit = ga_nothing; 53 | 54 | if (y_scroll > 0) 55 | { 56 | y_scroll--; 57 | 58 | if (y_scroll == 0) 59 | last_ticon = ticon; 60 | } 61 | else if ((ticon - last_ticon) > 120) 62 | { 63 | exit = ga_timeout; 64 | 65 | if ((ticon - last_ticon) < 180) 66 | exit = -(unsigned int)(ticbuttons[0] != 0) & ga_exit; 67 | } 68 | 69 | return exit; 70 | } 71 | 72 | /* 73 | ======================= 74 | = 75 | = L_Draw 76 | = 77 | ======================= 78 | */ 79 | 80 | void L_Draw(void)//L80034E54() 81 | { 82 | NextTextureCacheIdx(); 83 | DrawStaticImage(&legalspic, 0, y_scroll, palette[16]); 84 | UpdateDrawOTag(); 85 | DrawRender(); 86 | } 87 | 88 | #endif // 0 89 | -------------------------------------------------------------------------------- /PSXDOOM/m_fixed.c: -------------------------------------------------------------------------------- 1 | /* Fixed_t.c */ 2 | 3 | #include "doomdef.h" 4 | 5 | fixed_t FixedMul(register fixed_t a, register fixed_t b)//L8003EEA4() 6 | { 7 | register int sign; 8 | register unsigned c; 9 | 10 | sign = a^b; 11 | 12 | if (a <= 0) 13 | a = -a; 14 | 15 | if (b <= 0) 16 | b = -b; 17 | 18 | //ASM CODE 19 | __asm__("multu %0, %1;" \ 20 | "mfhi %2;" \ 21 | "mflo %3;" \ 22 | : "=r"(a), \ 23 | "=r"(b) \ 24 | : "r" (a), \ 25 | "r" (b)); 26 | 27 | c = (a << 16) + (b >> 16); 28 | if (sign < 0) 29 | c = -c; 30 | 31 | return c; 32 | } 33 | 34 | fixed_t FixedDiv(register fixed_t a, register fixed_t b)//L8003EEF0() 35 | { 36 | register unsigned c; 37 | register unsigned bit; 38 | register int sign; 39 | 40 | sign = a^b; 41 | 42 | if (a <= 0) 43 | a = -a; 44 | 45 | if (b <= 0) 46 | b = -b; 47 | 48 | bit = 0x10000; 49 | do 50 | { 51 | b <<= 1; 52 | bit <<= 1; 53 | } while (b < a); 54 | 55 | c = 0; 56 | do 57 | { 58 | if (a >= b) 59 | { 60 | a -= b; 61 | c |= bit; 62 | } 63 | a <<= 1; 64 | bit >>= 1; 65 | } while (bit && a); 66 | 67 | if (sign < 0) 68 | c = -c; 69 | 70 | return c; 71 | } 72 | -------------------------------------------------------------------------------- /PSXDOOM/m_fixed.s: -------------------------------------------------------------------------------- 1 | opt at-,w-,c+,m- 2 | 3 | section asm 4 | 5 | xdef FixedMul,FixedDiv 6 | 7 | FixedMul: 8 | xor t0, a0, a1 9 | bgtz a0, loc_8003EEB4 10 | move v0, a0 11 | neg v0, a0 12 | 13 | loc_8003EEB4: 14 | bgtz a1, loc_8003EEC0 15 | move v1, a1 16 | neg v1, a1 17 | 18 | loc_8003EEC0: 19 | multu v0, v1 20 | mfhi a0 21 | mflo a1 22 | sll v0, a0, 16 23 | srl v1, a1, 16 24 | nop 25 | addu a0, v0, v1 26 | bgez t0, locret_8003EEE8 27 | move v0, a0 28 | neg v0, a0 29 | 30 | locret_8003EEE8: 31 | jr ra 32 | nop 33 | 34 | FixedDiv: 35 | xor t0, a0, a1 36 | bgtz a0, loc_8003EF00 37 | move v0, a0 38 | neg v0, a0 39 | 40 | loc_8003EF00: 41 | bgtz a1, loc_8003EF0C 42 | move v1, a1 43 | neg v1, a1 44 | 45 | loc_8003EF0C: 46 | lui a2, 1 47 | sltu at, v1, v0 48 | beqz at, loc_8003EF30 49 | and t2, zero, a2 50 | 51 | loc_8003EF1C: 52 | sll v1, 1 53 | sll a2, 1 54 | sltu at, v1, v0 55 | bnez at, loc_8003EF1C 56 | and t2, zero, a2 57 | 58 | loc_8003EF30: 59 | 60 | slt at, v0, v1 61 | bnez at, loc_8003EF44 62 | nop 63 | sub v0, v1 64 | or t2, a2 65 | 66 | loc_8003EF44: 67 | sll v0, 1 68 | srl a2, 1 69 | beqz a2, loc_8003EF5C 70 | nop 71 | bnez v0, loc_8003EF30 72 | nop 73 | 74 | loc_8003EF5C: 75 | bgez t0, locret_8003EF68 76 | move v0, t2 77 | neg v0, t2 78 | 79 | locret_8003EF68: 80 | jr ra 81 | nop 82 | end 83 | -------------------------------------------------------------------------------- /PSXDOOM/m_password.c: -------------------------------------------------------------------------------- 1 | /* m_password.c -- password encode/decode */ 2 | 3 | #include "doomdef.h" 4 | #include "p_local.h" 5 | #include "st_main.h" 6 | #include "r_local.h" 7 | 8 | // [GEC] MASTER EDITION NEW FLAGS 9 | #define MAPUP1 0x20 10 | #define MAPUP2 0x40 11 | #define NIGHTMARE 0x80 12 | 13 | void Encode_Password(byte *buff)//L80038840() 14 | { 15 | int i, j, shift, code, pos; 16 | char tmpbuff[8]; 17 | player_t *player; 18 | int maxclip, maxshell, maxcell, maxmisl; 19 | int val, newval; 20 | 21 | #if ENABLE_NIGHTMARE == 1 22 | int skillnightmare; 23 | #endif // ENABLE_NIGHTMARE 24 | 25 | player = &players[consoleplayer]; 26 | D_memset(tmpbuff, 0, 8); 27 | 28 | #if ENABLE_NIGHTMARE == 1 29 | //Check the nightmare difficulty 30 | skillnightmare = 0; 31 | if(gameskill == sk_nightmare) 32 | { 33 | skillnightmare = sk_nightmare; 34 | } 35 | #endif // ENABLE_NIGHTMARE 36 | 37 | tmpbuff[0] = ((byte)nextmap & 63) << 2;//map 38 | tmpbuff[0] |= (byte)gameskill & 3;//skill 39 | 40 | // Weapons 41 | for (i = 0; i < 7; i++) 42 | { 43 | if (player->weaponowned[wp_shotgun + i]) 44 | { 45 | tmpbuff[1] |= (1 << i); 46 | } 47 | } 48 | 49 | //Get Maximun Ammo 50 | maxclip = maxammo[am_clip]; 51 | maxshell = maxammo[am_shell]; 52 | maxcell = maxammo[am_cell]; 53 | maxmisl = maxammo[am_misl]; 54 | 55 | // Backpack 56 | if (player->backpack) 57 | { 58 | maxclip <<= 1; 59 | maxshell <<= 1; 60 | maxcell <<= 1; 61 | maxmisl <<= 1; 62 | tmpbuff[1] |= 0x80; 63 | } 64 | 65 | // Clip 66 | val = (player->ammo[am_clip] << 3) / maxclip; 67 | if ((player->ammo[am_clip] << 3) % maxclip) { val += 1; } 68 | tmpbuff[2] = val << 4; 69 | 70 | // Shell 71 | val = (player->ammo[am_shell] << 3) / maxshell; 72 | if ((player->ammo[am_shell] << 3) % maxshell) { val += 1; } 73 | tmpbuff[2] |= val; 74 | 75 | // Cell 76 | val = (player->ammo[am_cell] << 3) / maxcell; 77 | if ((player->ammo[am_cell] << 3) % maxcell) { val += 1; } 78 | tmpbuff[3] = val << 4; 79 | 80 | // Missile 81 | val = (player->ammo[am_misl] << 3) / maxmisl; 82 | if ((player->ammo[am_misl] << 3) % maxmisl) { val += 1; } 83 | tmpbuff[3] |= val; 84 | 85 | // Health 86 | val = (player->health << 3) / 200; 87 | if ((player->health << 3) % 200) { val += 1; } 88 | tmpbuff[4] = val << 4; 89 | 90 | // Armor 91 | val = (player->armorpoints << 3) / 200; 92 | if ((player->armorpoints << 3) % 200) { val += 1; } 93 | tmpbuff[4] |= val; 94 | 95 | // ArmorType 96 | tmpbuff[5] = (byte)player->armortype << 3; 97 | 98 | #if ENABLE_NIGHTMARE == 1 99 | //I used the ArmorType space to add the 0x80 flag to identify that the difficulty is nightmare 100 | if(skillnightmare != 0) { 101 | tmpbuff[5] |= 0x80; 102 | } 103 | #endif // ENABLE_NIGHTMARE 104 | 105 | #if ENABLE_MOREMAPS == 1 106 | //Enables the possibility of incorporating more maps, maximum 255 107 | if(nextmap >= 192) { 108 | tmpbuff[5] |= (MAPUP1|MAPUP2); 109 | } 110 | else if(nextmap >= 128) { 111 | tmpbuff[5] |= MAPUP2; 112 | } 113 | else if(nextmap >= 64) { 114 | tmpbuff[5] |= MAPUP1; 115 | } 116 | #endif // ENABLE_MOREMAPS 117 | 118 | //Encode Encrypt System 119 | for (i = 0; i < 45;) 120 | { 121 | newval = 0; 122 | shift = 16; 123 | 124 | for (j = 4; j >= 0; j--) 125 | { 126 | pos = i; 127 | if (i < 0) { pos = i + 7;} 128 | 129 | pos >>= 3; 130 | code = tmpbuff[pos] & (0x80 >> (i - (pos << 3))); 131 | 132 | if (code != 0) 133 | newval |= shift; 134 | 135 | shift >>= 1; 136 | i++; 137 | } 138 | 139 | pos = ((i - 1) / 5); 140 | buff[pos] = newval; 141 | } 142 | 143 | buff[9] = 0; 144 | 145 | for (i = 0; i < 9; i++) 146 | buff[9] ^= buff[i]; 147 | 148 | for (i = 0; i < 9; i++) 149 | buff[i] ^= buff[9]; 150 | } 151 | 152 | int Decode_Password(byte *inbuff, int *levelnum, int *skill, player_t *player)//L80038C34() 153 | { 154 | int val, newval, i, j, shift, code, pos; 155 | byte decbuff[8]; 156 | byte buff[10]; 157 | 158 | D_memcpy(buff, inbuff, 10); 159 | 160 | val = 0; 161 | 162 | for (i = 0; i < 9; i++) 163 | buff[i] ^= buff[9]; 164 | 165 | for (i = 0; i < 9; i++) 166 | val ^= buff[i]; 167 | 168 | if (val == buff[9]) 169 | { 170 | //Decode Encrypt System 171 | for (i = 0; i < 48;) 172 | { 173 | newval = 0; 174 | shift = 0x80; 175 | 176 | for (j = 7; j >= 0; j--) 177 | { 178 | pos = (i / 5); 179 | code = buff[pos] & (16 >> (i - (pos * 5))); 180 | 181 | if (code != 0) 182 | newval |= shift; 183 | 184 | shift >>= 1; 185 | i++; 186 | } 187 | 188 | pos = (i - 1); 189 | if (pos < 0) { pos = i + 6; } 190 | pos >>= 3; 191 | 192 | decbuff[pos] = newval; 193 | } 194 | 195 | *levelnum = decbuff[0] >> 2; 196 | 197 | #if ENABLE_MOREMAPS == 1 198 | if (decbuff[5] & MAPUP1) { 199 | decbuff[5] &= ~MAPUP1; 200 | *levelnum |= 64; 201 | } 202 | if (decbuff[5] & MAPUP2) { 203 | decbuff[5] &= ~MAPUP2; 204 | *levelnum |= 128; 205 | } 206 | #endif // ENABLE_MOREMAPS 207 | 208 | if (*levelnum != 0 && (*levelnum < LASTLEVEL)) 209 | { 210 | *skill = decbuff[0] & 3; 211 | 212 | #if ENABLE_NIGHTMARE == 1 213 | //Check that the flag is 0x80, add the nightmare difficulty and remove the flag 0x80 214 | if (decbuff[5] & NIGHTMARE) 215 | { 216 | decbuff[5] &= ~NIGHTMARE; 217 | *skill = sk_nightmare; 218 | } 219 | #endif // ENABLE_NIGHTMARE 220 | 221 | #if GH_UPDATES == 1 222 | if (((decbuff[2] & 15) < 9) && // Shell 223 | ((decbuff[2] >> 4) < 9) && // Clip 224 | ((decbuff[3] & 15) < 9) && // Missile 225 | ((decbuff[3] >> 4) < 9) && // Cell 226 | ((decbuff[4] & 15) < 9) && // Armor 227 | ((decbuff[4] >> 4) < 9)) // Health 228 | #endif // GH_UPDATES 229 | { 230 | // ArmorType 231 | if ((decbuff[5] >> 3) < 3) 232 | { 233 | // Health 234 | if ((decbuff[4] >> 4) != 0) 235 | { 236 | if (player != 0) 237 | { 238 | // Weapons 239 | for (i = 0; i < 7; i++) 240 | { 241 | if ((decbuff[1] >> i) & 1) 242 | { 243 | player->weaponowned[wp_shotgun + i] = 1; 244 | } 245 | } 246 | 247 | // Backpack 248 | if (decbuff[1] & 0x80) 249 | { 250 | if (!player->backpack) 251 | { 252 | player->backpack = 1; 253 | 254 | for (i = 0; i < 4; i++) 255 | player->maxammo[i] <<= 1; 256 | } 257 | } 258 | 259 | // Clip 260 | val = decbuff[2] >> 4; 261 | val *= player->maxammo[am_clip]; 262 | if (val < 0) { val += 7; } 263 | player->ammo[am_clip] = val >> 3; 264 | 265 | // Shell 266 | val = decbuff[2] & 0xf; 267 | val *= player->maxammo[am_shell]; 268 | if (val < 0) { val += 7; } 269 | player->ammo[am_shell] = val >> 3; 270 | 271 | // Cell 272 | val = decbuff[3] >> 4; 273 | val *= player->maxammo[am_cell]; 274 | if (val < 0) { val += 7; } 275 | player->ammo[am_cell] = val >> 3; 276 | 277 | // Shell 278 | val = decbuff[3] & 0xf; 279 | val *= player->maxammo[am_misl]; 280 | if (val < 0) { val += 7; } 281 | player->ammo[am_misl] = val >> 3; 282 | 283 | // Health 284 | player->health = (decbuff[4] >> 4) * 25; 285 | 286 | // Armor 287 | player->armorpoints = (decbuff[4] & 15) * 25; 288 | 289 | // ArmorType 290 | player->armortype = decbuff[5] >> 3; 291 | 292 | // Apply Health on mobj_t 293 | player->mo->health = player->health; 294 | } 295 | 296 | return 1; 297 | } 298 | } 299 | } 300 | } 301 | } 302 | 303 | return 0; 304 | } 305 | -------------------------------------------------------------------------------- /PSXDOOM/obj/tmp.txt: -------------------------------------------------------------------------------- 1 | temp file -------------------------------------------------------------------------------- /PSXDOOM/p_ceilng.c: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | #include "p_local.h" 3 | 4 | /*================================================================== */ 5 | /*================================================================== */ 6 | /* */ 7 | /* CEILINGS */ 8 | /* */ 9 | /*================================================================== */ 10 | /*================================================================== */ 11 | 12 | ceiling_t *activeceilings[MAXCEILINGS];//800A9AFC 13 | 14 | /*================================================================== */ 15 | /* */ 16 | /* T_MoveCeiling */ 17 | /* */ 18 | /*================================================================== */ 19 | void T_MoveCeiling (ceiling_t *ceiling)//L80014A04() 20 | { 21 | result_e res; 22 | 23 | switch(ceiling->direction) 24 | { 25 | case 0: /* IN STASIS */ 26 | break; 27 | case 1: /* UP */ 28 | res = T_MovePlane(ceiling->sector,ceiling->speed, 29 | ceiling->topheight,false,1,ceiling->direction); 30 | if (!(gametic & 7)) 31 | { 32 | switch (ceiling->type) 33 | { 34 | case silentCrushAndRaise: 35 | break; 36 | default: 37 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov); 38 | break; 39 | } 40 | } 41 | 42 | if (res == pastdest) 43 | { 44 | switch(ceiling->type) 45 | { 46 | case raiseToHighest: 47 | P_RemoveActiveCeiling(ceiling); 48 | break; 49 | case silentCrushAndRaise: 50 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_pstop); 51 | case fastCrushAndRaise: 52 | case crushAndRaise: 53 | ceiling->direction = -1; 54 | break; 55 | default: 56 | break; 57 | } 58 | } 59 | break; 60 | case -1: /* DOWN */ 61 | res = T_MovePlane(ceiling->sector,ceiling->speed, 62 | ceiling->bottomheight,ceiling->crush,1,ceiling->direction); 63 | if (!(gametic & 7)) 64 | { 65 | switch (ceiling->type) 66 | { 67 | case silentCrushAndRaise: 68 | break; 69 | default: 70 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov); 71 | break; 72 | } 73 | } 74 | if (res == pastdest) 75 | { 76 | switch(ceiling->type) 77 | { 78 | case silentCrushAndRaise: 79 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_pstop); 80 | case crushAndRaise: 81 | ceiling->speed = CEILSPEED; 82 | case fastCrushAndRaise: 83 | ceiling->direction = 1; 84 | break; 85 | case lowerAndCrush: 86 | case lowerToFloor: 87 | P_RemoveActiveCeiling(ceiling); 88 | break; 89 | default: 90 | break; 91 | } 92 | } 93 | else if (res == crushed) 94 | { 95 | switch(ceiling->type) 96 | { 97 | case silentCrushAndRaise: 98 | case crushAndRaise: 99 | case lowerAndCrush: 100 | ceiling->speed = CEILSPEED / 8; 101 | break; 102 | default: 103 | break; 104 | } 105 | } 106 | break; 107 | } 108 | } 109 | 110 | /*================================================================== */ 111 | /* */ 112 | /* EV_DoCeiling */ 113 | /* Move a ceiling up/down and all around! */ 114 | /* */ 115 | /*================================================================== */ 116 | int EV_DoCeiling (line_t *line, ceiling_e type)//L80015118() 117 | { 118 | int secnum,rtn; 119 | sector_t *sec; 120 | ceiling_t *ceiling; 121 | 122 | secnum = -1; 123 | rtn = 0; 124 | 125 | /* */ 126 | /* Reactivate in-stasis ceilings...for certain types. */ 127 | /* */ 128 | switch(type) 129 | { 130 | case fastCrushAndRaise: 131 | case silentCrushAndRaise: 132 | case crushAndRaise: 133 | P_ActivateInStasisCeiling(line); 134 | default: 135 | break; 136 | } 137 | 138 | while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) 139 | { 140 | sec = §ors[secnum]; 141 | if (sec->specialdata) 142 | continue; 143 | 144 | /* */ 145 | /* new door thinker */ 146 | /* */ 147 | rtn = 1; 148 | ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); 149 | P_AddThinker (&ceiling->thinker); 150 | sec->specialdata = ceiling; 151 | ceiling->thinker.function = T_MoveCeiling; 152 | ceiling->sector = sec; 153 | ceiling->crush = false; 154 | switch(type) 155 | { 156 | case fastCrushAndRaise: 157 | ceiling->crush = true; 158 | ceiling->topheight = sec->ceilingheight; 159 | ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); 160 | ceiling->direction = -1; 161 | ceiling->speed = CEILSPEED * 2; 162 | break; 163 | case silentCrushAndRaise: 164 | case crushAndRaise: 165 | ceiling->crush = true; 166 | ceiling->topheight = sec->ceilingheight; 167 | case lowerAndCrush: 168 | case lowerToFloor: 169 | ceiling->bottomheight = sec->floorheight; 170 | if (type != lowerToFloor) 171 | ceiling->bottomheight += 8*FRACUNIT; 172 | ceiling->direction = -1; 173 | ceiling->speed = CEILSPEED; 174 | break; 175 | case raiseToHighest: 176 | ceiling->topheight = P_FindHighestCeilingSurrounding(sec); 177 | ceiling->direction = 1; 178 | ceiling->speed = CEILSPEED; 179 | break; 180 | } 181 | 182 | ceiling->tag = sec->tag; 183 | ceiling->type = type; 184 | P_AddActiveCeiling(ceiling); 185 | } 186 | return rtn; 187 | } 188 | 189 | /*================================================================== */ 190 | /* */ 191 | /* Add an active ceiling */ 192 | /* */ 193 | /*================================================================== */ 194 | void P_AddActiveCeiling(ceiling_t *c)//L800152EC() 195 | { 196 | int i; 197 | for (i = 0; i < MAXCEILINGS;i++) 198 | { 199 | if (activeceilings[i] == NULL) 200 | { 201 | activeceilings[i] = c; 202 | return; 203 | } 204 | } 205 | } 206 | 207 | /*================================================================== */ 208 | /* */ 209 | /* Remove a ceiling's thinker */ 210 | /* */ 211 | /*================================================================== */ 212 | void P_RemoveActiveCeiling(ceiling_t *c)//L80015328() 213 | { 214 | int i; 215 | 216 | for (i = 0;i < MAXCEILINGS;i++) 217 | { 218 | if (activeceilings[i] == c) 219 | { 220 | activeceilings[i]->sector->specialdata = NULL; 221 | P_RemoveThinker (&activeceilings[i]->thinker); 222 | activeceilings[i] = NULL; 223 | break; 224 | } 225 | } 226 | } 227 | 228 | /*================================================================== */ 229 | /* */ 230 | /* Restart a ceiling that's in-stasis */ 231 | /* */ 232 | /*================================================================== */ 233 | void P_ActivateInStasisCeiling(line_t *line)//L80015390() 234 | { 235 | int i; 236 | 237 | for (i = 0;i < MAXCEILINGS;i++) 238 | { 239 | if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && 240 | (activeceilings[i]->direction == 0)) 241 | { 242 | activeceilings[i]->direction = activeceilings[i]->olddirection; 243 | activeceilings[i]->thinker.function = T_MoveCeiling; 244 | } 245 | } 246 | } 247 | 248 | /*================================================================== */ 249 | /* */ 250 | /* EV_CeilingCrushStop */ 251 | /* Stop a ceiling from crushing! */ 252 | /* */ 253 | /*================================================================== */ 254 | int EV_CeilingCrushStop(line_t *line)//L80015404() 255 | { 256 | int i; 257 | int rtn; 258 | 259 | rtn = 0; 260 | for (i = 0;i < MAXCEILINGS;i++) 261 | { 262 | if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && 263 | (activeceilings[i]->direction != 0)) 264 | { 265 | activeceilings[i]->olddirection = activeceilings[i]->direction; 266 | activeceilings[i]->thinker.function = NULL; 267 | activeceilings[i]->direction = 0; /* in-stasis */ 268 | rtn = 1; 269 | } 270 | } 271 | 272 | return rtn; 273 | } 274 | -------------------------------------------------------------------------------- /PSXDOOM/p_change.c: -------------------------------------------------------------------------------- 1 | /* p_change.c */ 2 | 3 | #include "doomdef.h" 4 | #include "p_local.h" 5 | #include "st_main.h" 6 | 7 | //completo y revisado 8 | 9 | /* 10 | ============================================================================== 11 | 12 | SECTOR HEIGHT CHANGING 13 | 14 | = After modifying a sectors floor or ceiling height, call this 15 | = routine to adjust the positions of all things that touch the 16 | = sector. 17 | = 18 | = If anything doesn't fit anymore, true will be returned. 19 | = If crunch is true, they will take damage as they are being crushed 20 | = If Crunch is false, you should set the sector height back the way it 21 | = was and call P_ChangeSector again to undo the changes 22 | ============================================================================== 23 | */ 24 | 25 | boolean crushchange;//iGp000009bc 26 | boolean nofit; //uGp000008d8 27 | 28 | /* 29 | ================== 30 | = 31 | = P_ThingHeightClip 32 | = 33 | = Takes a valid thing and adjusts the thing->floorz, thing->ceilingz, 34 | = anf possibly thing->z 35 | = 36 | = This is called for all nearby monsters whenever a sector changes height 37 | = 38 | = If the thing doesn't fit, the z will be set to the lowest value and 39 | = false will be returned 40 | ================== 41 | */ 42 | //inline 43 | boolean P_ThingHeightClip (mobj_t *thing)//L80015478() 44 | { 45 | boolean onfloor; 46 | 47 | onfloor = (thing->z == thing->floorz); 48 | 49 | P_CheckPosition (thing, thing->x, thing->y); 50 | /* what about stranding a monster partially off an edge? */ 51 | 52 | thing->floorz = tmfloorz; 53 | thing->ceilingz = tmceilingz; 54 | 55 | if (onfloor) 56 | /* walking monsters rise and fall with the floor */ 57 | thing->z = thing->floorz; 58 | else 59 | { /* don't adjust a floating monster unless forced to */ 60 | if (thing->z+thing->height > thing->ceilingz) 61 | thing->z = thing->ceilingz - thing->height; 62 | } 63 | 64 | if (thing->ceilingz - thing->floorz < thing->height) 65 | return false; 66 | 67 | return true; 68 | } 69 | 70 | 71 | /* 72 | =============== 73 | = 74 | = PIT_ChangeSector 75 | = 76 | =============== 77 | */ 78 | 79 | boolean PIT_ChangeSector (mobj_t *thing)//L80015520() 80 | { 81 | mobj_t *mo; 82 | 83 | if (P_ThingHeightClip (thing)) 84 | return true; /* keep checking */ 85 | 86 | /* crunch bodies to giblets */ 87 | if (thing->health <= 0) 88 | { 89 | P_SetMobjState (thing, S_GIBS); 90 | S_StartSound(thing,sfx_slop); 91 | thing->height = 0; 92 | thing->radius = 0; 93 | 94 | if (thing->player == &players[consoleplayer]) 95 | stbar.gotgibbed = true; 96 | 97 | return true; /* keep checking */ 98 | } 99 | 100 | /* crunch dropped items */ 101 | if (thing->flags & MF_DROPPED) 102 | { 103 | P_RemoveMobj (thing); 104 | return true; /* keep checking */ 105 | } 106 | 107 | if (! (thing->flags & MF_SHOOTABLE) ) 108 | return true; /* assume it is bloody gibs or something */ 109 | 110 | nofit = true; 111 | if (crushchange && !(gametic&3) ) 112 | { 113 | P_DamageMobj(thing,NULL,NULL,10); 114 | /* spray blood in a random direction */ 115 | mo = P_SpawnMobj (thing->x, thing->y, thing->z + thing->height/2, MT_BLOOD); 116 | mo->momx = (P_Random() - P_Random ())<<12; 117 | mo->momy = (P_Random() - P_Random ())<<12; 118 | } 119 | 120 | return true; /* keep checking (crush other things) */ 121 | } 122 | 123 | /* 124 | =============== 125 | = 126 | = P_ChangeSector 127 | = 128 | =============== 129 | */ 130 | 131 | boolean P_ChangeSector (sector_t *sector, boolean crunch)//L8001570C() 132 | { 133 | int x,y; 134 | int i; 135 | 136 | /* force next sound to reflood */ 137 | //for (i=0 ; i= 0 ; i--) 139 | players[i].lastsoundsector = NULL; 140 | 141 | nofit = false; 142 | crushchange = crunch; 143 | 144 | /* recheck heights for all things near the moving sector */ 145 | for (x = sector->blockbox[BOXLEFT]; x <= sector->blockbox[BOXRIGHT]; x++) 146 | { 147 | for (y = sector->blockbox[BOXBOTTOM]; y <= sector->blockbox[BOXTOP]; y++) 148 | { 149 | P_BlockThingsIterator(x, y, PIT_ChangeSector); 150 | } 151 | } 152 | 153 | return nofit; 154 | } 155 | 156 | 157 | -------------------------------------------------------------------------------- /PSXDOOM/p_local.h: -------------------------------------------------------------------------------- 1 | /* P_local.h */ 2 | 3 | #ifndef __P_LOCAL__ 4 | #define __P_LOCAL__ 5 | 6 | #ifndef __R_LOCAL__ 7 | #include "r_local.h" 8 | #endif 9 | 10 | #define FLOATSPEED (FRACUNIT*8) 11 | 12 | #define GRAVITY (FRACUNIT*4) //like JagDoom 13 | #define MAXMOVE (16*FRACUNIT) 14 | 15 | 16 | #define MAXHEALTH 100 17 | #define VIEWHEIGHT (41*FRACUNIT) 18 | 19 | /* mapblocks are used to check movement against lines and things */ 20 | #define MAPBLOCKUNITS 128 21 | #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) 22 | #define MAPBLOCKSHIFT (FRACBITS+7) 23 | #define MAPBMASK (MAPBLOCKSIZE-1) 24 | #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) 25 | 26 | 27 | /* player radius for movement checking */ 28 | #define PLAYERRADIUS 16*FRACUNIT 29 | 30 | /* MAXRADIUS is for precalculated sector block boxes */ 31 | /* the spider demon is larger, but we don't have any moving sectors */ 32 | /* nearby */ 33 | #define MAXRADIUS 32*FRACUNIT 34 | 35 | 36 | #define USERANGE (70*FRACUNIT) 37 | #define MELEERANGE (70*FRACUNIT) 38 | #define MISSILERANGE (32*64*FRACUNIT) 39 | 40 | 41 | typedef enum 42 | { 43 | DI_EAST, 44 | DI_NORTHEAST, 45 | DI_NORTH, 46 | DI_NORTHWEST, 47 | DI_WEST, 48 | DI_SOUTHWEST, 49 | DI_SOUTH, 50 | DI_SOUTHEAST, 51 | DI_NODIR, 52 | NUMDIRS 53 | } dirtype_t; 54 | 55 | #define BASETHRESHOLD 100 /* follow a player exlusively for 3 seconds */ 56 | 57 | 58 | 59 | /* 60 | =============================================================================== 61 | 62 | P_TICK 63 | 64 | =============================================================================== 65 | */ 66 | 67 | extern thinker_t thinkercap; /* both the head and tail of the thinker list */ 68 | 69 | 70 | void P_InitThinkers (void); 71 | void P_AddThinker (thinker_t *thinker); 72 | void P_RemoveThinker (thinker_t *thinker); 73 | 74 | /* 75 | =============================================================================== 76 | 77 | P_PSPR 78 | 79 | =============================================================================== 80 | */ 81 | 82 | void P_SetupPsprites (int curplayer); //(player_t *curplayer); 83 | void P_MovePsprites (player_t *curplayer); 84 | 85 | void P_DropWeapon (player_t *player); 86 | 87 | /* 88 | =============================================================================== 89 | 90 | P_USER 91 | 92 | =============================================================================== 93 | */ 94 | 95 | void P_PlayerThink (player_t *player); 96 | 97 | 98 | /* 99 | =============================================================================== 100 | 101 | P_MOBJ 102 | 103 | =============================================================================== 104 | */ 105 | 106 | extern mobj_t mobjhead; 107 | 108 | extern int activethinkers; /* debug count */ 109 | extern int activemobjs; /* debug count */ 110 | 111 | #define ONFLOORZ MININT 112 | #define ONCEILINGZ MAXINT 113 | 114 | inline mobj_t *P_SpawnMobj (fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); 115 | 116 | void P_RemoveMobj (mobj_t *th); 117 | boolean P_SetMobjState (mobj_t *mobj, statenum_t state); 118 | void P_MobjThinker (mobj_t *mobj); 119 | 120 | void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); 121 | void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); 122 | mobj_t *P_SpawnMissile (mobj_t *source, mobj_t *dest, mobjtype_t type); 123 | void P_SpawnPlayerMissile (mobj_t *source, mobjtype_t type); 124 | 125 | void P_RunMobjBase (void);//P_RunMobjBase2 (void); 126 | void P_RunMobjExtra (void); 127 | 128 | void L_SkullBash (mobj_t *mo); 129 | void L_MissileHit (mobj_t *mo); 130 | void L_CrossSpecial (mobj_t *mo); 131 | 132 | void P_ExplodeMissile (mobj_t *mo); 133 | 134 | /* 135 | =============================================================================== 136 | 137 | P_ENEMY 138 | 139 | =============================================================================== 140 | */ 141 | 142 | void A_MissileExplode (mobj_t *mo); 143 | void A_SkullBash (mobj_t *mo); 144 | 145 | /* 146 | =============================================================================== 147 | 148 | P_MAPUTL 149 | 150 | =============================================================================== 151 | */ 152 | 153 | /*typedef struct 154 | { 155 | fixed_t x,y, dx, dy; 156 | } divline_t;*/ 157 | 158 | 159 | fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); 160 | int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line); 161 | int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line); 162 | void P_MakeDivline (line_t *li, divline_t *dl); 163 | inline fixed_t P_InterceptVector (divline_t *v2, divline_t *v1); 164 | int P_BoxOnLineSide (fixed_t *tmbox, line_t *ld); 165 | 166 | extern fixed_t opentop, openbottom, openrange;//,,800780A0 167 | extern fixed_t lowfloor; 168 | void P_LineOpening (line_t *linedef); 169 | 170 | boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ); 171 | boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) ); 172 | 173 | extern divline_t trace; 174 | 175 | void P_UnsetThingPosition (mobj_t *thing); 176 | void P_SetThingPosition (mobj_t *thing); 177 | 178 | void P_PlayerLand (mobj_t *mo); 179 | 180 | /* 181 | =============================================================================== 182 | 183 | P_MAP 184 | 185 | =============================================================================== 186 | */ 187 | 188 | extern boolean floatok; /* if true, move would be ok if */ //80077ea8 189 | extern fixed_t tmfloorz, tmceilingz; /* within tmfloorz - tmceilingz */ //80078010, 80077d30 190 | 191 | extern line_t *specialline;//80077dc8 192 | extern mobj_t *movething; 193 | 194 | 195 | boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); 196 | boolean P_TryMove (mobj_t *thing, fixed_t x, fixed_t y); 197 | boolean P_CheckSight (mobj_t *t1, mobj_t *t2); 198 | void P_UseLines (player_t *player); 199 | 200 | boolean P_ChangeSector (sector_t *sector, boolean crunch); 201 | 202 | extern mobj_t *linetarget; /* who got hit (or NULL) */ 203 | fixed_t P_AimLineAttack (mobj_t *t1, angle_t angle, fixed_t distance); 204 | 205 | void P_LineAttack (mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, int damage); 206 | 207 | void P_RadiusAttack (mobj_t *spot, mobj_t *source, int damage); 208 | 209 | /* 210 | =============================================================================== 211 | 212 | P_SETUP 213 | 214 | =============================================================================== 215 | */ 216 | 217 | extern byte *rejectmatrix; /* for fast sight rejection */ 218 | extern short *blockmaplump; /* offsets in blockmap are from here */ 219 | extern short *blockmap; 220 | extern int bmapwidth, bmapheight; /* in mapblocks */ 221 | extern fixed_t bmaporgx, bmaporgy; /* origin of block map */ 222 | extern mobj_t **blocklinks; /* for thing chains */ 223 | 224 | /* 225 | =============================================================================== 226 | 227 | P_INTER 228 | 229 | =============================================================================== 230 | */ 231 | 232 | extern int maxammo[NUMAMMO]; 233 | extern int clipammo[NUMAMMO]; 234 | 235 | void P_TouchSpecialThing (mobj_t *special, mobj_t *toucher); 236 | 237 | void P_DamageMobj (mobj_t *target, mobj_t *inflictor, mobj_t *source, int damage); 238 | 239 | #include "p_spec.h" 240 | 241 | extern int iquehead, iquetail; 242 | 243 | #define MAXTARGET 32 244 | extern mobj_t *playertarget[MAXTARGET]; //Psx Doom New 800A854C 245 | extern int playercounttarget; //Psx Doom New 80077E3C 246 | 247 | extern int playernum;//80078110, iGp00000d00 248 | 249 | void P_RespawnSpecials (void); 250 | 251 | 252 | /* 253 | =============================================================================== 254 | 255 | P_MOVE 256 | 257 | =============================================================================== 258 | */ 259 | 260 | //PSX NEW 261 | #define MAXTHINGSPEC 8 262 | extern line_t *thingspec[8]; 263 | extern int numthingspec;//80077ee8 264 | 265 | extern mobj_t *tmthing; 266 | extern fixed_t tmx, tmy; 267 | extern boolean checkposonly; 268 | 269 | void P_TryMove2(void); 270 | int PM_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); 271 | void PM_UnsetThingPosition(mobj_t *thing); 272 | void PM_SetThingPosition(mobj_t *thing); 273 | void PM_CheckPosition(void); 274 | boolean PM_BoxCrossLine(line_t *ld); 275 | 276 | boolean PIT_CheckLine(line_t *ld); 277 | boolean PIT_CheckThing(mobj_t *thing); 278 | boolean PM_BlockLinesIterator(int x, int y); 279 | boolean PM_BlockThingsIterator(int x, int y); 280 | 281 | 282 | /* 283 | =============================================================================== 284 | 285 | P_SHOOT 286 | 287 | =============================================================================== 288 | */ 289 | 290 | void P_Shoot2(void); 291 | boolean PA_DoIntercept(void *value, boolean isline, int frac); 292 | boolean PA_ShootLine(line_t *li, fixed_t interceptfrac); 293 | boolean PA_ShootThing(mobj_t *th, fixed_t interceptfrac); 294 | fixed_t PA_SightCrossLine(line_t *line); 295 | boolean PA_CrossSubsector(subsector_t *sub); 296 | int PA_DivlineSide(fixed_t x, fixed_t y, divline_t *line); 297 | boolean PA_CrossBSPNode(int bspnum); 298 | 299 | /* 300 | =============================================================================== 301 | 302 | P_SIGHT 303 | 304 | =============================================================================== 305 | */ 306 | 307 | void P_CheckSights(void); 308 | boolean P_CheckSight(mobj_t *t1, mobj_t *t2); 309 | boolean PS_CrossBSPNode(int bspnum); 310 | boolean PS_CrossSubsector(subsector_t *sub); 311 | fixed_t PS_SightCrossLine (line_t *line); 312 | 313 | #endif /* __P_LOCAL__ */ 314 | 315 | 316 | -------------------------------------------------------------------------------- /PSXDOOM/p_maputl.c: -------------------------------------------------------------------------------- 1 | 2 | /* P_maputl.c */ 3 | 4 | #include "doomdef.h" 5 | #include "p_local.h" 6 | 7 | 8 | /* 9 | =================== 10 | = 11 | = P_AproxDistance 12 | = 13 | = Gives an estimation of distance (not exact) 14 | = 15 | =================== 16 | */ 17 | 18 | fixed_t P_AproxDistance (fixed_t dx, fixed_t dy)//L8001C4A0() 19 | { 20 | dx = abs(dx); 21 | dy = abs(dy); 22 | if (dx < dy) 23 | return dx+dy-(dx>>1); 24 | return dx+dy-(dy>>1); 25 | } 26 | 27 | 28 | /* 29 | ================== 30 | = 31 | = P_PointOnLineSide 32 | = 33 | = Returns 0 or 1 34 | ================== 35 | */ 36 | 37 | int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line)//L8001C4D8() 38 | { 39 | fixed_t dx,dy; 40 | fixed_t left, right; 41 | 42 | if (!line->dx) 43 | { 44 | if (x <= line->v1->x) 45 | return line->dy > 0; 46 | return line->dy < 0; 47 | } 48 | if (!line->dy) 49 | { 50 | if (y <= line->v1->y) 51 | return line->dx < 0; 52 | return line->dx > 0; 53 | } 54 | 55 | dx = (x - line->v1->x); 56 | dy = (y - line->v1->y); 57 | 58 | left = (line->dy>>16) * (dx>>16); 59 | right = (dy>>16) * (line->dx>>16); 60 | 61 | if (right < left) 62 | return 0; /* front side */ 63 | return 1; /* back side */ 64 | } 65 | 66 | 67 | /* 68 | ================== 69 | = 70 | = P_PointOnDivlineSide 71 | = 72 | = Returns 0 or 1 73 | ================== 74 | */ 75 | 76 | int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line)//L8001C598() 77 | { 78 | fixed_t dx,dy; 79 | fixed_t left, right; 80 | 81 | if (!line->dx) 82 | { 83 | if (x <= line->x) 84 | return line->dy > 0; 85 | return line->dy < 0; 86 | } 87 | if (!line->dy) 88 | { 89 | if (y <= line->y) 90 | return line->dx < 0; 91 | return line->dx > 0; 92 | } 93 | 94 | dx = (x - line->x); 95 | dy = (y - line->y); 96 | 97 | /* try to quickly decide by looking at sign bits */ 98 | if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 ) 99 | { 100 | if ( (line->dy ^ dx) & 0x80000000 ) 101 | return 1; /* (left is negative) */ 102 | return 0; 103 | } 104 | 105 | left = FixedMul ( line->dy>>8, dx>>8 ); 106 | right = FixedMul ( dy>>8 , line->dx>>8 ); 107 | 108 | if (right < left) 109 | return 0; /* front side */ 110 | return 1; /* back side */ 111 | } 112 | 113 | 114 | 115 | /* 116 | ============== 117 | = 118 | = P_MakeDivline 119 | = 120 | ============== 121 | */ 122 | 123 | void P_MakeDivline (line_t *li, divline_t *dl)//L8001C68C() 124 | { 125 | dl->x = li->v1->x; 126 | dl->y = li->v1->y; 127 | dl->dx = li->dx; 128 | dl->dy = li->dy; 129 | } 130 | 131 | 132 | /* 133 | ================== 134 | = 135 | = P_LineOpening 136 | = 137 | = Sets opentop and openbottom to the window through a two sided line 138 | = OPTIMIZE: keep this precalculated 139 | ================== 140 | */ 141 | 142 | fixed_t opentop, openbottom, openrange;//80077EE4, 80077D5C, 800780A0 || iGp00000ad4,iGp0000094c,iGp00000c90 143 | fixed_t lowfloor;//80078004||fGp00000bf4 144 | 145 | void P_LineOpening (line_t *linedef)//L8001C6CC() 146 | { 147 | sector_t *front, *back; 148 | 149 | if (linedef->sidenum[1] == -1) 150 | { /* single sided line */ 151 | openrange = 0; 152 | return; 153 | } 154 | 155 | front = linedef->frontsector; 156 | back = linedef->backsector; 157 | 158 | if (front->ceilingheight < back->ceilingheight) 159 | opentop = front->ceilingheight; 160 | else 161 | opentop = back->ceilingheight; 162 | if (front->floorheight > back->floorheight) 163 | { 164 | openbottom = front->floorheight; 165 | lowfloor = back->floorheight; 166 | } 167 | else 168 | { 169 | openbottom = back->floorheight; 170 | lowfloor = front->floorheight; 171 | } 172 | 173 | openrange = opentop - openbottom; 174 | } 175 | 176 | /* 177 | =============================================================================== 178 | 179 | THING POSITION SETTING 180 | 181 | =============================================================================== 182 | */ 183 | 184 | /* 185 | =================== 186 | = 187 | = P_UnsetThingPosition 188 | = 189 | = Unlinks a thing from block map and sectors 190 | = 191 | =================== 192 | */ 193 | 194 | void P_UnsetThingPosition (mobj_t *thing)//L8001C768() 195 | { 196 | int blockx, blocky; 197 | 198 | if (!(thing->flags & MF_NOSECTOR)) 199 | { /* inert things don't need to be in blockmap */ 200 | /* unlink from subsector */ 201 | if (thing->snext) 202 | thing->snext->sprev = thing->sprev; 203 | if (thing->sprev) 204 | thing->sprev->snext = thing->snext; 205 | else 206 | thing->subsector->sector->thinglist = thing->snext; 207 | } 208 | 209 | if (!(thing->flags & MF_NOBLOCKMAP)) 210 | { /* inert things don't need to be in blockmap */ 211 | /* unlink from block map */ 212 | if (thing->bnext) 213 | thing->bnext->bprev = thing->bprev; 214 | if (thing->bprev) 215 | thing->bprev->bnext = thing->bnext; 216 | else 217 | { 218 | blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; 219 | blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; 220 | 221 | // Prevent buffer overflow if the map object is out of bounds. 222 | // This is part of the fix for the famous 'linedef deletion' bug. 223 | // From PsyDoom (StationDoom) by BodbDearg 224 | #if FIX_LINEDEFS_DELETION 225 | if (blockx>=0 && blockx < bmapwidth 226 | && blocky>=0 && blocky bnext; 229 | } 230 | #else 231 | blocklinks[blocky*bmapwidth+blockx] = thing->bnext; 232 | #endif 233 | } 234 | } 235 | } 236 | 237 | 238 | /* 239 | =================== 240 | = 241 | = P_SetThingPosition 242 | = 243 | = Links a thing into both a block and a subsector based on it's x y 244 | = Sets thing->subsector properly 245 | = 246 | =================== 247 | */ 248 | 249 | void P_SetThingPosition (mobj_t *thing)//L8001C878() 250 | { 251 | subsector_t *ss; 252 | sector_t *sec; 253 | int blockx, blocky; 254 | mobj_t **link; 255 | 256 | /* */ 257 | /* link into subsector */ 258 | /* */ 259 | ss = R_PointInSubsector (thing->x,thing->y); 260 | thing->subsector = ss; 261 | if(!(thing->flags & MF_NOSECTOR)) 262 | { 263 | /* invisible things don't go into the sector links */ 264 | sec = ss->sector; 265 | 266 | thing->sprev = NULL; 267 | thing->snext = sec->thinglist; 268 | if(sec->thinglist) 269 | sec->thinglist->sprev = thing; 270 | sec->thinglist = thing; 271 | } 272 | 273 | /* */ 274 | /* link into blockmap */ 275 | /* */ 276 | if(!(thing->flags & MF_NOBLOCKMAP)) 277 | { 278 | /* inert things don't need to be in blockmap */ 279 | blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; 280 | blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; 281 | if(blockx >= 0 && blockx < bmapwidth && blocky >= 0 && blocky < bmapheight) 282 | { 283 | link = &blocklinks[blocky*bmapwidth+blockx]; 284 | thing->bprev = NULL; 285 | thing->bnext = *link; 286 | if (*link) 287 | (*link)->bprev = thing; 288 | *link = thing; 289 | } 290 | else 291 | { 292 | /* thing is off the map */ 293 | thing->bnext = thing->bprev = NULL; 294 | } 295 | } 296 | } 297 | 298 | 299 | 300 | /* 301 | =============================================================================== 302 | 303 | BLOCK MAP ITERATORS 304 | 305 | For each line/thing in the given mapblock, call the passed function. 306 | If the function returns false, exit with false without checking anything else. 307 | 308 | =============================================================================== 309 | */ 310 | 311 | /* 312 | ================== 313 | = 314 | = P_BlockLinesIterator 315 | = 316 | = The validcount flags are used to avoid checking lines 317 | = that are marked in multiple mapblocks, so increment validcount before 318 | = the first call to P_BlockLinesIterator, then make one or more calls to it 319 | =================== 320 | */ 321 | 322 | boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) )//L8001C9B0() 323 | { 324 | int offset; 325 | short *list; 326 | line_t *ld; 327 | 328 | if (x<0 || y<0 || x>=bmapwidth || y>=bmapheight) 329 | return true; 330 | offset = y*bmapwidth+x; 331 | 332 | offset = *(blockmap+offset); 333 | 334 | for ( list = blockmaplump+offset ; *list != -1 ; list++) 335 | { 336 | ld = &lines[*list]; 337 | if (ld->validcount == validcount) 338 | continue; /* line has already been checked */ 339 | ld->validcount = validcount; 340 | 341 | if ( !func(ld) ) 342 | return false; 343 | } 344 | 345 | return true; /* everything was checked */ 346 | } 347 | 348 | 349 | /* 350 | ================== 351 | = 352 | = P_BlockThingsIterator 353 | = 354 | ================== 355 | */ 356 | 357 | boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) )//L8001CAD0() 358 | { 359 | mobj_t *mobj; 360 | 361 | if (x<0 || y<0 || x>=bmapwidth || y>=bmapheight) 362 | return true; 363 | 364 | for (mobj = blocklinks[y*bmapwidth+x] ; mobj ; mobj = mobj->bnext) 365 | { 366 | if (!func( mobj ) ) 367 | return false; 368 | } 369 | 370 | return true; 371 | } 372 | 373 | -------------------------------------------------------------------------------- /PSXDOOM/p_plats.c: -------------------------------------------------------------------------------- 1 | /*================================================================== */ 2 | /*================================================================== */ 3 | /* */ 4 | /* PLATFORM RAISING */ 5 | /* */ 6 | /*================================================================== */ 7 | /*================================================================== */ 8 | #include "doomdef.h" 9 | #include "p_local.h" 10 | 11 | plat_t *activeplats[MAXPLATS];//80097a24 12 | 13 | /*================================================================== */ 14 | /* */ 15 | /* Move a plat up and down */ 16 | /* */ 17 | /*================================================================== */ 18 | void T_PlatRaise(plat_t *plat)//L8001f6ECC() 19 | { 20 | result_e res; 21 | 22 | switch(plat->status) 23 | { 24 | case up: 25 | res = T_MovePlane(plat->sector,plat->speed, plat->high,plat->crush,0,1); 26 | 27 | if (plat->type == raiseAndChange || plat->type == raiseToNearestAndChange) 28 | { 29 | if (!(gametic&7)) 30 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_stnmov); 31 | } 32 | 33 | if (res == crushed && (!plat->crush)) 34 | { 35 | plat->count = plat->wait; 36 | plat->status = down; 37 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstart); 38 | } 39 | else 40 | { 41 | if (res == pastdest) 42 | { 43 | plat->count = plat->wait; 44 | plat->status = waiting; 45 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstop); 46 | switch(plat->type) 47 | { 48 | case downWaitUpStay: 49 | P_RemoveActivePlat(plat); 50 | break; 51 | case raiseAndChange: 52 | P_RemoveActivePlat(plat); 53 | break; 54 | case blazeDWUS: 55 | P_RemoveActivePlat(plat); 56 | break; 57 | default: 58 | break; 59 | } 60 | } 61 | } 62 | break; 63 | case down: 64 | res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); 65 | if (res == pastdest) 66 | { 67 | plat->count = plat->wait; 68 | plat->status = waiting; 69 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstop); 70 | } 71 | break; 72 | case waiting: 73 | if (!--plat->count) 74 | { 75 | if (plat->sector->floorheight == plat->low) 76 | plat->status = up; 77 | else 78 | plat->status = down; 79 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstart); 80 | } 81 | case in_stasis: 82 | break; 83 | } 84 | } 85 | 86 | /*================================================================== */ 87 | /* */ 88 | /* Do Platforms */ 89 | /* "amount" is only used for SOME platforms. */ 90 | /* */ 91 | /*================================================================== */ 92 | int EV_DoPlat(line_t *line,plattype_e type,int amount)//L8001f8D0() 93 | { 94 | plat_t *plat; 95 | int secnum; 96 | int rtn; 97 | sector_t *sec; 98 | 99 | secnum = -1; 100 | rtn = 0; 101 | 102 | /* */ 103 | /* Activate all plats that are in_stasis */ 104 | /* */ 105 | switch(type) 106 | { 107 | case perpetualRaise: 108 | P_ActivateInStasis(line->tag); 109 | break; 110 | default: 111 | break; 112 | } 113 | 114 | while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) 115 | { 116 | sec = §ors[secnum]; 117 | if (sec->specialdata) 118 | continue; 119 | 120 | /* */ 121 | /* Find lowest & highest floors around sector */ 122 | /* */ 123 | rtn = 1; 124 | plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); 125 | P_AddThinker(&plat->thinker); 126 | 127 | plat->type = type; 128 | plat->sector = sec; 129 | plat->sector->specialdata = plat; 130 | plat->thinker.function = T_PlatRaise; 131 | plat->crush = false; 132 | plat->tag = line->tag; 133 | switch(type) 134 | { 135 | case raiseToNearestAndChange: 136 | plat->speed = PLATSPEED/2; 137 | sec->floorpic = sides[line->sidenum[0]].sector->floorpic; 138 | plat->high = P_FindNextHighestFloor(sec,sec->floorheight); 139 | plat->wait = 0; 140 | plat->status = up; 141 | sec->special = 0; /* NO MORE DAMAGE, IF APPLICABLE */ 142 | S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); 143 | break; 144 | case raiseAndChange: 145 | plat->speed = PLATSPEED/2; 146 | sec->floorpic = sides[line->sidenum[0]].sector->floorpic; 147 | plat->high = sec->floorheight + amount*FRACUNIT; 148 | plat->wait = 0; 149 | plat->status = up; 150 | S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); 151 | break; 152 | case downWaitUpStay: 153 | plat->speed = PLATSPEED * 4; 154 | plat->low = P_FindLowestFloorSurrounding(sec); 155 | if (plat->low > sec->floorheight) 156 | plat->low = sec->floorheight; 157 | plat->high = sec->floorheight; 158 | plat->wait = 15*PLATWAIT; 159 | plat->status = down; 160 | S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); 161 | break; 162 | case blazeDWUS: 163 | plat->speed = PLATSPEED * 8; 164 | plat->low = P_FindLowestFloorSurrounding(sec); 165 | 166 | if (plat->low > sec->floorheight) 167 | plat->low = sec->floorheight; 168 | 169 | plat->high = sec->floorheight; 170 | plat->wait = 15 * PLATWAIT; 171 | plat->status = down; 172 | S_StartSound((mobj_t *)&sec->soundorg, sfx_pstart); 173 | break; 174 | case perpetualRaise: 175 | plat->speed = PLATSPEED; 176 | plat->low = P_FindLowestFloorSurrounding(sec); 177 | if (plat->low > sec->floorheight) 178 | plat->low = sec->floorheight; 179 | plat->high = P_FindHighestFloorSurrounding(sec); 180 | if (plat->high < sec->floorheight) 181 | plat->high = sec->floorheight; 182 | plat->wait = 15*PLATWAIT; 183 | plat->status = P_Random()&1; 184 | S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); 185 | break; 186 | } 187 | P_AddActivePlat(plat); 188 | } 189 | return rtn; 190 | } 191 | 192 | void P_ActivateInStasis(int tag)//L8001FBCC() 193 | { 194 | int i; 195 | 196 | for (i = 0;i < MAXPLATS;i++) 197 | if (activeplats[i] && 198 | (activeplats[i])->tag == tag && 199 | (activeplats[i])->status == in_stasis) 200 | { 201 | (activeplats[i])->status = (activeplats[i])->oldstatus; 202 | (activeplats[i])->thinker.function = T_PlatRaise; 203 | } 204 | } 205 | 206 | void EV_StopPlat(line_t *line)//L8001FC40() 207 | { 208 | int j; 209 | 210 | for (j = 0; j < MAXPLATS; j++) 211 | { 212 | if (activeplats[j] && ((activeplats[j])->status != in_stasis) && 213 | ((activeplats[j])->tag == line->tag)) 214 | { 215 | (activeplats[j])->oldstatus = (activeplats[j])->status; 216 | (activeplats[j])->status = in_stasis; 217 | (activeplats[j])->thinker.function = NULL; 218 | } 219 | } 220 | } 221 | 222 | void P_AddActivePlat(plat_t *plat)//L8001FCB4() 223 | { 224 | int i; 225 | for (i = 0;i < MAXPLATS;i++) 226 | { 227 | if (activeplats[i] == NULL) 228 | { 229 | activeplats[i] = plat; 230 | return; 231 | } 232 | } 233 | I_Error ("P_AddActivePlat: no more plats!"); 234 | } 235 | 236 | void P_RemoveActivePlat(plat_t *plat)//L8001FD0C() 237 | { 238 | int i; 239 | for (i = 0;i < MAXPLATS;i++) 240 | { 241 | if (plat == activeplats[i]) 242 | { 243 | (activeplats[i])->sector->specialdata = NULL; 244 | P_RemoveThinker(&(activeplats[i])->thinker); 245 | activeplats[i] = NULL; 246 | return; 247 | } 248 | } 249 | I_Error ("P_RemoveActivePlat: can't find plat!"); 250 | } 251 | -------------------------------------------------------------------------------- /PSXDOOM/p_sight.c: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | #include "p_local.h" 3 | 4 | //iGp00000a3c 5 | fixed_t sightzstart; //80077E4C // eye z of looker 6 | //iGp00000bf8, iGp00000a24 7 | fixed_t topslope, bottomslope; //80078008 ,80077E34 // slopes to top and bottom of target 8 | 9 | divline_t strace; //800979E0 // from t1 to t2 10 | fixed_t t2x, t2y; //80077F28,80077F2C || uGp00000b18, uGp00000b20 11 | 12 | //iGp00000c10,iGp00000c20,iGp00000c1c,iGp00000c28 13 | int t1xs,t1ys,t2xs,t2ys; //80078020,80078030,8007802C,80078038 14 | 15 | 16 | /* 17 | =============== 18 | = 19 | = P_CheckSights 20 | = 21 | = Check sights of all mobj thinkers that are going to change state this 22 | = tic and have MF_COUNTKILL set 23 | =============== 24 | */ 25 | 26 | void P_CheckSights(void)//L80024E18() 27 | { 28 | mobj_t *mobj; 29 | 30 | for (mobj = mobjhead.next; mobj != &mobjhead; mobj = mobj->next) 31 | { 32 | // must be killable 33 | if (!(mobj->flags & MF_COUNTKILL)) 34 | continue; 35 | 36 | // must be about to change states 37 | if (mobj->tics != 1) 38 | continue; 39 | 40 | mobj->flags &= ~MF_SEETARGET; 41 | 42 | // must have a target 43 | if (!mobj->target) 44 | continue; 45 | 46 | if (P_CheckSight(mobj, mobj->target)) 47 | mobj->flags |= MF_SEETARGET; 48 | } 49 | } 50 | 51 | 52 | /********************************** 53 | 54 | Returns true if a straight line between t1 and t2 is unobstructed 55 | 56 | **********************************/ 57 | 58 | boolean P_CheckSight(mobj_t *t1, mobj_t *t2)//L80024EC4() 59 | { 60 | int s1, s2; 61 | int pnum, bytenum, bitnum; 62 | 63 | // 64 | // check for trivial rejection 65 | // 66 | s1 = (t1->subsector->sector - sectors)/* * (int)0xE9BD37A7*/; 67 | s2 = (t2->subsector->sector - sectors)/* * (int)0xE9BD37A7*/; 68 | pnum = s1*numsectors + s2; 69 | bytenum = pnum >> 3; 70 | bitnum = 1 << (pnum & 7); 71 | 72 | if (rejectmatrix[bytenum] & bitnum) { 73 | return false; // can't possibly be connected 74 | } 75 | 76 | // look from eyes of t1 to any part of t2 77 | 78 | ++validcount; 79 | 80 | // make sure it never lies exactly on a vertex coordinate 81 | 82 | strace.x = (t1->x & ~0x1ffff) | 0x10000; 83 | strace.y = (t1->y & ~0x1ffff) | 0x10000; 84 | t2x = (t2->x & ~0x1ffff) | 0x10000; 85 | t2y = (t2->y & ~0x1ffff) | 0x10000; 86 | strace.dx = t2x - strace.x; 87 | strace.dy = t2y - strace.y; 88 | 89 | t1xs = strace.x >> FRACBITS; 90 | t1ys = strace.y >> FRACBITS; 91 | t2xs = t2x >> FRACBITS; 92 | t2ys = t2y >> FRACBITS; 93 | 94 | sightzstart = (t1->z + t1->height) - (t1->height >> 2); 95 | topslope = (t2->z + t2->height) - sightzstart; 96 | bottomslope = (t2->z) - sightzstart; 97 | 98 | return PS_CrossBSPNode(numnodes - 1); 99 | } 100 | 101 | /* 102 | ================= 103 | = 104 | = PS_SightCrossLine 105 | = 106 | = First checks the endpoints of the line to make sure that they cross the 107 | = sight trace treated as an infinite line. 108 | = 109 | = If so, it calculates the fractional distance along the sight trace that 110 | = the intersection occurs at. If 0 < intercept < 1.0, the line will block 111 | = the sight. 112 | ================= 113 | */ 114 | 115 | //inline 116 | fixed_t PS_SightCrossLine (line_t *line)//L8002504C() 117 | { 118 | int s1, s2; 119 | int p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y,dx,dy,ndx,ndy; 120 | 121 | // p1, p2 are line endpoints 122 | p1x = line->v1->x >> FRACBITS; 123 | p1y = line->v1->y >> FRACBITS; 124 | p2x = line->v2->x >> FRACBITS; 125 | p2y = line->v2->y >> FRACBITS; 126 | 127 | // p3, p4 are sight endpoints 128 | p3x = t1xs; 129 | p3y = t1ys; 130 | p4x = t2xs; 131 | p4y = t2ys; 132 | 133 | dx = p2x - p3x; 134 | dy = p2y - p3y; 135 | 136 | ndx = p4x - p3x; // this can be precomputed if worthwhile 137 | ndy = p4y - p3y; 138 | 139 | s1 = (ndy * dx) < (dy * ndx); 140 | 141 | dx = p1x - p3x; 142 | dy = p1y - p3y; 143 | 144 | s2 = (ndy * dx) < (dy * ndx); 145 | 146 | if (s1 == s2) 147 | return -1; // line isn't crossed 148 | 149 | ndx = p1y - p2y; // vector normal to world line 150 | ndy = p2x - p1x; 151 | 152 | s1 = ndx*dx + ndy*dy; // distance projected onto normal 153 | 154 | dx = p4x - p1x; 155 | dy = p4y - p1y; 156 | 157 | s2 = ndx*dx + ndy*dy; // distance projected onto normal 158 | 159 | s2 = FixedDiv(s1,(s1+s2)); 160 | 161 | return s2; 162 | } 163 | 164 | /* 165 | ================= 166 | = 167 | = PS_CrossSubsector 168 | = 169 | = Returns true if strace crosses the given subsector successfuly 170 | ================= 171 | */ 172 | 173 | boolean PS_CrossSubsector(subsector_t *sub)//L80025124() 174 | { 175 | seg_t *seg; 176 | line_t *line; 177 | int count; 178 | sector_t *front, *back; 179 | fixed_t opentop, openbottom; 180 | fixed_t frac, slope; 181 | 182 | // 183 | // check lines 184 | // 185 | count = sub->numlines; 186 | seg = &segs[sub->firstline]; 187 | 188 | for ( ; count ; seg++, count--) 189 | { 190 | line = seg->linedef; 191 | 192 | if (line->validcount == validcount) 193 | continue; // allready checked other side 194 | line->validcount = validcount; 195 | 196 | frac = PS_SightCrossLine (line); 197 | 198 | if (frac < 4 || frac > FRACUNIT) 199 | continue; 200 | 201 | // 202 | // crosses line 203 | // 204 | back = line->backsector; 205 | if (!back) 206 | return false; // one sided line 207 | front = line->frontsector; 208 | 209 | if (front->floorheight == back->floorheight 210 | && front->ceilingheight == back->ceilingheight) 211 | continue; // no wall to block sight with 212 | 213 | if (front->ceilingheight < back->ceilingheight) 214 | opentop = front->ceilingheight; 215 | else 216 | opentop = back->ceilingheight; 217 | if (front->floorheight > back->floorheight) 218 | openbottom = front->floorheight; 219 | else 220 | openbottom = back->floorheight; 221 | 222 | if (openbottom >= opentop) // quick test for totally closed doors 223 | return false; // stop 224 | 225 | frac >>= 2; 226 | 227 | if (front->floorheight != back->floorheight) 228 | { 229 | slope = (((openbottom - sightzstart)<<6) / frac) << 8; 230 | if (slope > bottomslope) 231 | bottomslope = slope; 232 | } 233 | 234 | if (front->ceilingheight != back->ceilingheight) 235 | { 236 | slope = (((opentop - sightzstart)<<6) / frac) << 8; 237 | if (slope < topslope) 238 | topslope = slope; 239 | } 240 | 241 | if (topslope <= bottomslope) 242 | return false; // stop 243 | } 244 | 245 | return true; // passed the subsector ok 246 | } 247 | 248 | /* 249 | ================= 250 | = 251 | = PS_CrossBSPNode 252 | = 253 | = Returns true if strace crosses the given node successfuly 254 | ================= 255 | */ 256 | 257 | boolean PS_CrossBSPNode(int bspnum)//L800253D0() 258 | { 259 | node_t *bsp; 260 | int side; 261 | int bsp_num; 262 | 263 | if (bspnum & NF_SUBSECTOR) 264 | { 265 | bsp_num = (bspnum & ~NF_SUBSECTOR); 266 | if (bsp_num >= numsubsectors) 267 | { 268 | I_Error("PS_CrossSubsector: ss %i with numss = %i", bsp_num, numsubsectors); 269 | } 270 | 271 | return PS_CrossSubsector(&subsectors[bsp_num]); 272 | } 273 | 274 | bsp = &nodes[bspnum]; 275 | 276 | // decide which side the start point is on 277 | // inline function ?? 278 | side = PA_DivlineSide(strace.x, strace.y, &bsp->line); 279 | 280 | // cross the starting side 281 | if (!PS_CrossBSPNode(bsp->children[side])) 282 | return false; 283 | 284 | // the partition plane is crossed here 285 | // inline function ?? 286 | if (side == PA_DivlineSide(t2x, t2y, &bsp->line)) 287 | return true; // the line doesn't touch the other side 288 | 289 | // cross the ending side 290 | return PS_CrossBSPNode(bsp->children[side ^ 1]); 291 | } 292 | -------------------------------------------------------------------------------- /PSXDOOM/p_telept.c: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | #include "p_local.h" 3 | 4 | /* 5 | ============== 6 | = 7 | = P_Telefrag 8 | = 9 | = Kill all monsters around the given spot 10 | = 11 | ============== 12 | */ 13 | //inline 14 | void P_Telefrag (mobj_t *thing, fixed_t x, fixed_t y)//L80028D30() 15 | { 16 | int delta; 17 | int size; 18 | mobj_t *m; 19 | 20 | for (m=mobjhead.next ; m != &mobjhead ; m=m->next) 21 | { 22 | if (!(m->flags & MF_SHOOTABLE) ) 23 | continue; /* not shootable */ 24 | size = m->radius + thing->radius + 4*FRACUNIT; 25 | delta = m->x - x; 26 | if (delta < - size || delta > size) 27 | continue; 28 | delta = m->y - y; 29 | if (delta < -size || delta > size) 30 | continue; 31 | P_DamageMobj (m, thing, thing, 10000); 32 | m->flags &= ~(MF_SOLID|MF_SHOOTABLE); 33 | } 34 | } 35 | 36 | 37 | /*================================================================== */ 38 | /* */ 39 | /* TELEPORTATION */ 40 | /* */ 41 | /*================================================================== */ 42 | int EV_Teleport( line_t *line,mobj_t *thing )//L80028E28() 43 | { 44 | int i; 45 | int tag; 46 | boolean flag; 47 | mobj_t *m,*fog; 48 | unsigned an; 49 | sector_t *sector; 50 | fixed_t oldx, oldy, oldz; 51 | int side; 52 | 53 | //printf("EV_Teleport\n"); 54 | 55 | side = !P_PointOnLineSide (thing->x, thing->y, line); 56 | 57 | if (thing->flags & MF_MISSILE) 58 | return 0; /* don't teleport missiles */ 59 | 60 | if (side == 1) /* don't teleport if hit back of line, */ 61 | return 0; /* so you can get out of teleporter */ 62 | 63 | tag = line->tag; 64 | for (i = 0; i < numsectors; i++) 65 | { 66 | if (sectors[ i ].tag == tag ) 67 | { 68 | for (m=mobjhead.next ; m != &mobjhead ; m=m->next) 69 | { 70 | if (m->type != MT_TELEPORTMAN ) 71 | continue; /* not a teleportman */ 72 | 73 | //sector = (m->subsector->sector - sectors) * (int)(0xE9BD37A7); 74 | //if ((sector >> 2) != i) 75 | //if((*(int *)m->subsector - (int)sectors) * -0x1642c859 >> 2 == i) 76 | sector = m->subsector->sector; 77 | if(sector-sectors != i ) 78 | continue; /* wrong sector */ 79 | 80 | oldx = thing->x; 81 | oldy = thing->y; 82 | oldz = thing->z; 83 | thing->flags |= MF_TELEPORT; 84 | numthingspec = 0; 85 | 86 | if (thing->player) 87 | P_Telefrag (thing, m->x, m->y); 88 | 89 | flag = P_TryMove (thing, m->x, m->y); 90 | thing->flags &= ~MF_TELEPORT; 91 | if (!flag) 92 | return 0; /* move is blocked */ 93 | thing->z = thing->floorz; 94 | 95 | /* spawn teleport fog at source and destination */ 96 | fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 97 | S_StartSound (fog, sfx_telept); 98 | an = m->angle >> ANGLETOFINESHIFT; 99 | fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] 100 | , thing->z, MT_TFOG); 101 | S_StartSound (fog, sfx_telept); 102 | if (thing->player) 103 | thing->reactiontime = 9; /* don't move for a bit */ //[psx] changed to 9 104 | thing->angle = m->angle; 105 | thing->momx = thing->momy = thing->momz = 0; 106 | return 1; 107 | } 108 | } 109 | } 110 | return 0; 111 | } 112 | 113 | -------------------------------------------------------------------------------- /PSXDOOM/pw_main.c: -------------------------------------------------------------------------------- 1 | /* pw_main.c -- password menu */ 2 | 3 | #include "doomdef.h" 4 | #include "p_local.h" 5 | #include "st_main.h" 6 | #include "r_local.h" 7 | 8 | 9 | char *passwordChar = "bcdfghjklmnpqrstvwxyz0123456789!";//80073B7C 10 | byte Passwordbuff[12];//0x80096388 11 | 12 | int CurPasswordSlot = 0;//80077A70 iGp00000660 13 | int PassInvalidTic;//80077E58 uGp00000a48 14 | int PassCodePos;//80077F9C uGp00000b8c 15 | 16 | boolean doPassword = false;//80077A6C 17 | 18 | /* 19 | ================= 20 | = 21 | = PW_Start 22 | = 23 | ================= 24 | */ 25 | 26 | void PW_Start(void)//L80037138() 27 | { 28 | S_StartSound(NULL, sfx_pistol); 29 | 30 | oldticbuttons[0] = ticbuttons[0]; 31 | oldticbuttons[1] = ticbuttons[1]; 32 | m_vframe1[0] = 0; 33 | PassInvalidTic = 0; 34 | PassCodePos = 0; 35 | } 36 | 37 | /* 38 | ================= 39 | = 40 | = PW_Stop 41 | = 42 | ================= 43 | */ 44 | 45 | void PW_Stop(int exit)//L80037188() 46 | { 47 | S_StartSound(NULL, 7);// SNDPSTOL.mid 48 | PassCodePos = 32; 49 | PW_Drawer(); 50 | } 51 | 52 | /* 53 | ================= 54 | = 55 | = PW_Ticker 56 | = 57 | ================= 58 | */ 59 | 60 | int PW_Ticker(void)//L800371BC() 61 | { 62 | int buttons, levelnum, skill; 63 | 64 | if(PassInvalidTic && (gamevbls < (int)gametic)) 65 | { 66 | PassInvalidTic--; 67 | if((PassInvalidTic & 7) == 4) 68 | S_StartSound(0,0x18); 69 | } 70 | 71 | buttons = Get_PadButtons(&ticbuttons[0]);//ticbuttons[0]; 72 | 73 | if (buttons & PAD_ARROWS) 74 | { 75 | m_vframe1[0] -= vblsinframe[0]; 76 | if (m_vframe1[0] <= 0) 77 | { 78 | m_vframe1[0] = TICRATE; 79 | 80 | if (buttons & PAD_DOWN) 81 | { 82 | if (PassCodePos < 32)//24 83 | { 84 | PassCodePos += 8; 85 | S_StartSound(NULL, sfx_pstop); 86 | } 87 | 88 | //new 89 | if (PassCodePos > 32) 90 | PassCodePos = 32; 91 | 92 | } 93 | else if (buttons & PAD_UP) 94 | { 95 | if (PassCodePos >= 8) 96 | { 97 | PassCodePos -= 8; 98 | S_StartSound(NULL, sfx_pstop); 99 | } 100 | } 101 | 102 | if (buttons & PAD_RIGHT) 103 | { 104 | PassCodePos += 1; 105 | if (PassCodePos >= 33) 106 | PassCodePos = 32; 107 | else 108 | S_StartSound(NULL, sfx_pstop); 109 | } 110 | else if (buttons & PAD_LEFT) 111 | { 112 | PassCodePos -= 1; 113 | if (PassCodePos < 0) 114 | PassCodePos = 0; 115 | else 116 | S_StartSound(NULL, sfx_pstop); 117 | } 118 | } 119 | } 120 | else 121 | { 122 | m_vframe1[0] = 0; 123 | } 124 | 125 | if (buttons & (PAD_START | PAD_SELECT)) 126 | return ga_exit;// exit 127 | 128 | if (buttons != (unsigned short)oldticbuttons[0]) 129 | { 130 | if ((PassCodePos == 32) && (buttons & PAD_ACTION)) 131 | return ga_exit;// exit 132 | 133 | if (buttons & (PAD_SQUARE | PAD_CROSS| PAD_CIRCLE)) 134 | { 135 | S_StartSound(NULL, sfx_swtchx); 136 | if (CurPasswordSlot < 10) 137 | { 138 | Passwordbuff[CurPasswordSlot] = PassCodePos; 139 | CurPasswordSlot++; 140 | if (CurPasswordSlot < 10) 141 | return ga_nothing; 142 | } 143 | 144 | if(Decode_Password(Passwordbuff, &levelnum, &skill, NULL)) 145 | { 146 | startskill = skill; 147 | startmap = levelnum; 148 | gamemap = levelnum; 149 | gameskill = skill; 150 | doPassword = true; //80077A6C 151 | 152 | //I_Error("startskill: %d\n startmap: %d", startskill, startmap); 153 | return ga_warped; 154 | } 155 | 156 | PassInvalidTic = 16; 157 | } 158 | else if(buttons & PAD_TRIANGLE) 159 | { 160 | S_StartSound(NULL, sfx_swtchx); 161 | CurPasswordSlot--; 162 | if (CurPasswordSlot < 0) 163 | CurPasswordSlot = 0; 164 | } 165 | 166 | Passwordbuff[CurPasswordSlot] = 0; 167 | } 168 | 169 | return ga_nothing; 170 | } 171 | 172 | /* 173 | ================= 174 | = 175 | = PW_Drawer 176 | = 177 | ================= 178 | */ 179 | 180 | void PW_Drawer(void) //L800374A8() 181 | { 182 | byte pass[2] = {0,0}; 183 | byte c; 184 | int texid, cnt; 185 | int xpos, ypos, pos1, pos2; 186 | 187 | DR_MODE *drawmode = (DR_MODE*) getScratchAddr(128);//1F800200 188 | SPRT *textsprite = (SPRT*) getScratchAddr(128);//1F800200 189 | 190 | NextTextureCacheIdx(); 191 | 192 | //Draw Backround MARB01 Pic 193 | for (ypos = 0; ypos < 4; ypos++) 194 | { 195 | for (xpos = 0; xpos < 4; xpos++) 196 | { 197 | DrawStaticImage(&marb01pic, xpos << 6, ypos << 6, palette[20]); 198 | } 199 | } 200 | 201 | SetDrawMode(drawmode, 0, 0, statuspic.vtpage, NULL); 202 | W_AddPrim(drawmode);// add to order table 203 | 204 | setSprt(textsprite); 205 | textsprite->clut = palette[16]; 206 | 207 | for (cnt = 0; cnt < 32; cnt++) 208 | { 209 | setRGB0(textsprite, 128, 128, 128); 210 | 211 | pos1 = cnt; 212 | if (cnt < 0) 213 | pos1 = cnt + 7; 214 | 215 | pos1 >>= 3; 216 | pos2 = cnt - (pos1 << 3); 217 | 218 | xpos = (pos2 * 20) + 48; 219 | ypos = (pos1 * 20) + 60; 220 | 221 | if (PassCodePos == cnt) 222 | { 223 | if (!(ticon & 8)) continue; 224 | setRGB0(textsprite, 255, 0, 0); 225 | } 226 | 227 | c = passwordChar[cnt]; 228 | if ((byte)(c - 'a') < 26) 229 | { 230 | texid = (byte)(c - 57); 231 | ypos = (pos1 * 20) + 63; 232 | } 233 | else 234 | { 235 | if ((byte)(c - '0') < 10) 236 | { 237 | texid = (byte)(c - '0'); 238 | } 239 | else if (c == '!') 240 | { 241 | texid = 12; 242 | } 243 | } 244 | 245 | setXY0(textsprite, xpos, ypos); 246 | setUV0(textsprite, symboldata[texid].x, symboldata[texid].y); 247 | setWH(textsprite, symboldata[texid].w, symboldata[texid].h); 248 | 249 | W_AddPrim(textsprite);// add to order table 250 | } 251 | 252 | ST_DrawText(-1,20,"Password"); 253 | 254 | if (PassInvalidTic & 4)//80077E58 255 | { 256 | ST_DrawText(-1, 160, "Invalid Password");//Draw Text 257 | } 258 | else 259 | { 260 | xpos = 58; 261 | for (cnt = 0; cnt < CurPasswordSlot; cnt++) 262 | { 263 | pass[0] = passwordChar[Passwordbuff[cnt]]; 264 | ST_DrawText(xpos, 160, pass);//Draw Text 265 | xpos += 14; 266 | } 267 | 268 | if (cnt < 10) 269 | { 270 | xpos = (cnt * 14) + 58; 271 | do 272 | { 273 | ST_DrawText(xpos, 160, ".");//Draw Text 274 | xpos += 14; 275 | cnt++; 276 | } while (cnt < 10); 277 | } 278 | } 279 | 280 | if ((PassCodePos != 32) || ((ticon & 8) == 0)) 281 | { 282 | ST_DrawText(-1,200,"Exit"); 283 | } 284 | 285 | UpdateDrawOTag(); 286 | DrawRender(); 287 | } 288 | -------------------------------------------------------------------------------- /PSXDOOM/r_data.c: -------------------------------------------------------------------------------- 1 | /* R_data.c */ 2 | 3 | #include "doomdef.h" 4 | #include "r_local.h" 5 | #include "p_local.h" 6 | 7 | int firstflat; //800780DC|iGp00000ccc 8 | int lastflat; //80077F98|iGp00000b88 9 | int numflats; //80077FE8|iGp00000bd8 10 | psxobj_t *texflats; //80077F4C|puGp00000b3c 11 | 12 | int firsttex; //80078104|iGp00000cf4 13 | int lasttex; //80077FC4|iGp00000bb4 14 | int numtextures; //80077FFC|iGp00000bec 15 | psxobj_t *textures; //80077F50|puGp00000b40 16 | 17 | int firstsprite; //80077E40|iGp00000a30 18 | int lastsprite; //80077D64|iGp00000954 19 | int numsprites; //80077D88|iGp00000978 20 | psxobj_t *texsprites; //80077CF0|puGp000008e0 21 | 22 | int *flattranslation; //80077D8C|puGp00000988 /* for global animation */ 23 | int *texturetranslation; //80077D98|puGp0000097c /* for global animation */ 24 | 25 | short skypalette; //800780F0 psx doom 26 | psxobj_t *skytexturep; //80077E7C 27 | 28 | void R_InitTextures(void); 29 | void R_InitFlats(void); 30 | void R_InitSprite(void); 31 | void R_InitPalettes(void); 32 | /*============================================================================ */ 33 | 34 | /* 35 | ================ 36 | = 37 | = R_InitData 38 | = 39 | = Locates all the lumps that will be used by all views 40 | = Must be called after W_Init 41 | ================= 42 | */ 43 | 44 | void R_InitData (void)//L8002BEE4() 45 | { 46 | //printf("\nR_InitData\n"); 47 | R_InitPalettes(); 48 | R_InitTextures(); 49 | R_InitFlats(); 50 | R_InitSprite(); 51 | } 52 | 53 | /* 54 | ================== 55 | = 56 | = R_InitTextures 57 | = 58 | = Initializes the texture list with the textures from the world map 59 | = 60 | ================== 61 | */ 62 | 63 | void R_InitTextures(void)//L8002BF1C() 64 | { 65 | maptexture_t *mtexture; 66 | psxobj_t *texture; 67 | byte *data; 68 | int width, height, lump, i; 69 | 70 | firsttex = W_GetNumForName("T_START") + 1; 71 | lasttex = W_GetNumForName("T_END") - 1; 72 | numtextures = (lasttex - firsttex) + 1; 73 | 74 | textures = Z_Malloc(numtextures * (sizeof(psxobj_t) + sizeof(int)), PU_STATIC, 0); 75 | texturetranslation = (int *) textures + (numtextures * (sizeof(psxobj_t)/4)); 76 | 77 | data = (byte *)W_CacheLumpName("TEXTURE1", PU_CACHE, true); 78 | texture = textures; 79 | 80 | mtexture = (maptexture_t *)data; 81 | for (lump = firsttex; lump <= lasttex; lump++) 82 | { 83 | texture->lump = lump; 84 | texture->vtpage = 0; 85 | 86 | texture->w = BIGSHORT(mtexture->width); 87 | texture->h = BIGSHORT(mtexture->height); 88 | 89 | width = texture->w + 15; 90 | if (width < 0) { width = texture->w + 30; } 91 | 92 | height = texture->h + 15; 93 | if (height < 0) { height = texture->h + 30; } 94 | 95 | texture->vbasex = width >> 4; 96 | texture->vbasey = height >> 4; 97 | 98 | mtexture++; 99 | texture++; 100 | } 101 | Z_Free(data); 102 | 103 | /* */ 104 | /* translation table for global animation */ 105 | /* */ 106 | for (i = 0; ilump = lump; 136 | flat->w = 64; 137 | flat->h = 64; 138 | flat->vtpage = 0; 139 | flat->vbasex = 4; 140 | flat->vbasey = 4; 141 | flat++; 142 | } 143 | 144 | /* translation table for global animation */ 145 | for (i = 0; ilump = lump; 178 | sprite->vtpage = 0; 179 | 180 | sprite->x = BIGSHORT(msprite->leftoffset); 181 | sprite->y = BIGSHORT(msprite->topoffset); 182 | 183 | sprite->w = BIGSHORT(msprite->width); 184 | sprite->h = BIGSHORT(msprite->height); 185 | 186 | width = sprite->w + 15; 187 | if (width < 0) { width = sprite->w + 30; } 188 | 189 | height = sprite->h + 15; 190 | if (height < 0) { height = sprite->h + 30; } 191 | 192 | sprite->vbasex = width >> 4; 193 | sprite->vbasey = height >> 4; 194 | 195 | msprite++; 196 | sprite++; 197 | } 198 | 199 | Z_Free(data); 200 | Z_FreeTags(mainzone, PU_CACHE); 201 | } 202 | 203 | /*============================================================================= */ 204 | 205 | #define HIBIT (1<<7) 206 | 207 | /* 208 | ================ 209 | = 210 | = R_TextureNumForName 211 | = 212 | ================ 213 | */ 214 | 215 | int R_TextureNumForName(char *name)//L8002C2E0() 216 | { 217 | #if 0 218 | int i; 219 | 220 | i = R_CheckTextureNumForName(name); 221 | if (i == -1) 222 | I_Error("R_TextureNumForName: %s not found", name); 223 | 224 | return i; 225 | #endif 226 | 227 | int i; 228 | lumpinfo_t *lump_p; 229 | char name8[8]; 230 | int v1, v2; 231 | int c; 232 | 233 | /* make the name into two integers for easy compares */ 234 | *(int *)&name8[0] = 0; 235 | *(int *)&name8[4] = 0; 236 | for (i = 0; i<8 && name[i]; i++) 237 | { 238 | c = name[i]; 239 | if (c >= 'a' && c <= 'z') 240 | c -= 'a' - 'A'; 241 | name8[i] = c; 242 | } 243 | 244 | v1 = *(int *)&name8[0]; 245 | v2 = *(int *)&name8[4]; 246 | 247 | lump_p = &lumpinfo[firsttex]; 248 | for (i = 0; iname[4] == v2) && 251 | ((*(int *)&lump_p->name[0] & ~HIBIT) == v1)) 252 | return i; 253 | } 254 | 255 | //I_Error("R_TextureNumForName: %s not found", name); 256 | return -1; 257 | } 258 | 259 | /* 260 | ================ 261 | = 262 | = R_FlatNumForName 263 | = 264 | ================ 265 | */ 266 | 267 | int R_FlatNumForName (char *name)//L8002C3A4() 268 | { 269 | int i; 270 | lumpinfo_t *lump_p; 271 | char name8[8]; 272 | int v1,v2; 273 | int c; 274 | 275 | /* make the name into two integers for easy compares */ 276 | *(int *)&name8[0] = 0; 277 | *(int *)&name8[4] = 0; 278 | for (i=0 ; i<8 && name[i] ; i++) 279 | { 280 | c = name[i]; 281 | if (c == 0) break; 282 | if (c >= 'a' && c <= 'z') 283 | c -= 'a'-'A'; 284 | name8[i] = c; 285 | } 286 | 287 | v1 = *(int *)&name8[0]; 288 | v2 = *(int *)&name8[4]; 289 | 290 | lump_p = &lumpinfo[firstflat]; 291 | for (i=0 ; iname[4] == v2) && 294 | ((*(int *)&lump_p->name[0] & ~HIBIT) == v1)) 295 | return i; 296 | } 297 | //I_Error ("R_FlatNumForName: %s not found",name); 298 | return 0; /* FIXME -1; */ 299 | } 300 | 301 | /* 302 | ================ 303 | = 304 | = R_InitPalettes 305 | = 306 | = Exclusive Psx Doom 307 | ================ 308 | */ 309 | 310 | void R_InitPalettes(void)//L8002C468() 311 | { 312 | int lump, i, x, y; 313 | byte *paldata; 314 | RECT rect; 315 | light_t *light; 316 | 317 | //printf("R_InitPalettes\n"); 318 | 319 | lights = (light_t*)W_CacheLumpName("LIGHTS", PU_STATIC, true); 320 | lights[0].r = 0xff; 321 | lights[0].g = 0xff; 322 | lights[0].b = 0xff; 323 | 324 | lump = W_GetNumForName("PLAYPAL"); 325 | 326 | paldata = (byte *)W_CacheLumpNum(lump, PU_CACHE, true); 327 | 328 | if ((W_LumpLength(lump) / 512) != MAX_PALETTES) 329 | { 330 | I_Error("R_InitPalettes: palette foulup\n"); 331 | } 332 | 333 | rect.w = 256; 334 | rect.h = 1; 335 | for (i = 0; i < MAX_PALETTES; i++) 336 | { 337 | y = i; 338 | if (y < 0) { y = i + 0xf; } 339 | 340 | y = y >> 4; 341 | x = y << 8; 342 | 343 | rect.x = x; 344 | rect.y = i - (y << 4) + 240; 345 | 346 | LoadImage(&rect, (unsigned long *)paldata); 347 | palette[i] = getClut(rect.x, rect.y); 348 | 349 | paldata += 512; 350 | } 351 | 352 | palettebase = palette[0]; 353 | 354 | Z_FreeTags(mainzone, PU_CACHE); 355 | } 356 | 357 | 358 | /* 359 | ================ 360 | = 361 | = R_CheckTextureNumForName 362 | = 363 | ================ 364 | */ 365 | 366 | #if 0 //dont use on Psx Doom 367 | int R_CheckTextureNumForName (char *name) 368 | { 369 | int i,c; 370 | char temp[8]; 371 | int v1, v2; 372 | texture_t *texture_p; 373 | 374 | if (name[0] == '-') /* no texture marker */ 375 | return 0; 376 | 377 | *(int *)&temp[0] = 0; 378 | *(int *)&temp[4] = 0; 379 | 380 | for (i=0 ; i<8 && name[i] ; i++) 381 | { 382 | c = name[i]; 383 | if (c >= 'a' && c<='z') 384 | c -= ('a'-'A'); 385 | temp[i] = c; 386 | } 387 | 388 | v1 = *(int *)temp; 389 | v2 = *(int *)&temp[4]; 390 | 391 | texture_p = textures; 392 | 393 | for (i=0 ; iname[4] == v2 395 | && (*(int *)texture_p->name) == v1) 396 | return i; 397 | 398 | return 0; /* FIXME -1; */ 399 | } 400 | #endif 401 | -------------------------------------------------------------------------------- /PSXDOOM/r_main.c: -------------------------------------------------------------------------------- 1 | /* r_main.c */ 2 | 3 | #include "doomdef.h" 4 | #include "r_local.h" 5 | 6 | /*===================================== */ 7 | 8 | /* */ 9 | /* subsectors */ 10 | /* */ 11 | //subsector_t *vissubsectors[MAXVISSSEC], **lastvissubsector; 12 | 13 | /* */ 14 | /* walls */ 15 | /* */ 16 | //viswall_t viswalls[MAXWALLCMDS], *lastwallcmd; 17 | 18 | /* */ 19 | /* planes */ 20 | /* */ 21 | //visplane_t visplanes[MAXVISPLANES], *lastvisplane; 22 | 23 | /* */ 24 | /* sprites */ 25 | /* */ 26 | //vissprite_t vissprites[MAXVISSPRITES], *lastsprite_p, *vissprite_p; 27 | 28 | /* */ 29 | /* openings / misc refresh memory */ 30 | /* */ 31 | //unsigned short openings[MAXOPENINGS], *lastopening; 32 | 33 | 34 | /*===================================== */ 35 | 36 | //boolean phase1completed; 37 | 38 | //pixel_t *workingscreen; 39 | 40 | 41 | fixed_t viewx, viewy, viewz; //80077D0C|uGp000008fc, 80077D10|uGp00000900, 80077D18|uGp00000908 42 | angle_t viewangle; //800780B8|uGp00000ca8 43 | fixed_t viewcos, viewsin; //80077EC8|iGp00000ab8, 80077EE0|iGp00000ad0 44 | player_t *viewplayer; //80077D60|ppGp00000950 45 | 46 | int validcount = 1; /* increment every time a check is made */ //800779F4 47 | //int framecount; /* incremented every frame */ 48 | 49 | /* */ 50 | /* sky mapping */ 51 | /* */ 52 | boolean rendersky;//8007801C|iGp00000c0c 53 | 54 | subsector_t *solidsubsectors[MAXSUBSECTORS]; //800A8F98 /* List of valid ranges to scan through */ 55 | subsector_t **endsubsector; //80077E90|ppsGp00000a80 /* Pointer to the first free entry */ 56 | int numdrawsubsectors; //80077F14|iGp00000b04 57 | 58 | byte solidcols[256]; //800A8D2C psxdoom 59 | 60 | /* */ 61 | /* precalculated math */ 62 | /* */ 63 | fixed_t *finecosine = &finesine[FINEANGLES/4];//80077A00 64 | 65 | 66 | /* */ 67 | /* News */ 68 | /* */ 69 | light_t *baselight; //pbGp00000a70 L80077E80 70 | unsigned int base_r; //iGp000008ac L80077CBC//r 71 | unsigned int base_g; //iGp00000a50 L80077E60//g 72 | unsigned int base_b; //iGp0000098c L80077D9C//b 73 | boolean viewlighting; //80078088|iGp00000c78 74 | sector_t *frontsector; //80077E38|psGp00000a28 75 | light_t *lights; //80077E94|pbGp00000a84 76 | short palette[MAX_PALETTES]; //800A8E68 77 | short palettebase; //80077DA8 78 | 79 | /*============================================================================= */ 80 | 81 | /* 82 | ============== 83 | = 84 | = R_Init 85 | = 86 | ============== 87 | */ 88 | 89 | static MATRIX R_Matrix;//80086358 90 | 91 | void R_Init (void) //L80030AFC() 92 | { 93 | R_InitData (); 94 | 95 | //Initialize Matrix 96 | R_Matrix.t[0] = 0; 97 | R_Matrix.t[1] = 0; 98 | R_Matrix.t[2] = 0; 99 | SetTransMatrix(&R_Matrix); 100 | 101 | R_Matrix.m[0][0] = 0; 102 | R_Matrix.m[0][1] = 0; 103 | R_Matrix.m[0][2] = 0; 104 | R_Matrix.m[1][0] = 0; 105 | R_Matrix.m[1][1] = 4096; 106 | R_Matrix.m[1][2] = 0; 107 | R_Matrix.m[2][0] = 0; 108 | R_Matrix.m[2][1] = 0; 109 | R_Matrix.m[2][2] = 0; 110 | SetRotMatrix(&R_Matrix); 111 | } 112 | 113 | /* 114 | ============== 115 | = 116 | = R_RenderView 117 | = 118 | ============== 119 | */ 120 | 121 | void R_RenderPlayerView(void)//L80030B80() 122 | { 123 | RECT area; 124 | angle_t angle; 125 | DR_TWIN *texwindow = (DR_TWIN*) getScratchAddr(128);//1F800200 126 | 127 | if (!viewlighting) 128 | { 129 | base_r = 128; 130 | base_g = 128; 131 | base_b = 128; 132 | baselight = &lights[0]; 133 | } 134 | 135 | viewplayer = &players[consoleplayer]; 136 | 137 | viewx = viewplayer->mo->x & (~FRACMASK); 138 | viewy = viewplayer->mo->y & (~FRACMASK); 139 | viewz = viewplayer->viewz & (~FRACMASK); 140 | 141 | viewangle = viewplayer->mo->angle; 142 | viewcos = finecosine[viewangle >> ANGLETOFINESHIFT]; 143 | viewsin = finesine[viewangle >> ANGLETOFINESHIFT]; 144 | 145 | R_Matrix.m[0][0] = viewsin >> 4; 146 | R_Matrix.m[0][2] = -viewcos >> 4; 147 | R_Matrix.m[2][0] = viewcos >> 4; 148 | R_Matrix.m[2][2] = viewsin >> 4; 149 | SetRotMatrix(&R_Matrix); 150 | 151 | R_BSP(); 152 | 153 | numdrawsubsectors = (endsubsector - solidsubsectors); 154 | 155 | DrawRender(); 156 | 157 | if (rendersky) 158 | R_RenderSKY(); 159 | 160 | while (endsubsector--, (solidsubsectors-1) < endsubsector) 161 | { 162 | frontsector = (*endsubsector)->sector; 163 | 164 | if (viewlighting) 165 | { 166 | baselight = &lights[frontsector->colorid]; 167 | 168 | base_r = (frontsector->lightlevel * baselight->r) >> 8; 169 | base_g = (frontsector->lightlevel * baselight->g) >> 8; 170 | base_b = (frontsector->lightlevel * baselight->b) >> 8; 171 | 172 | if (viewplayer->extralight != 0) 173 | { 174 | base_r += viewplayer->extralight; 175 | base_g += viewplayer->extralight; 176 | base_b += viewplayer->extralight; 177 | 178 | if (base_r > 255) { base_r = 255; } 179 | if (base_g > 255) { base_g = 255; } 180 | if (base_b > 255) { base_b = 255; } 181 | } 182 | } 183 | 184 | R_RenderAll(*endsubsector); 185 | } 186 | 187 | R_Render_Hud_Weapons(); 188 | 189 | setRECT(&area, 0, 0, 0, 0); 190 | SetTexWindow(texwindow, &area); 191 | W_AddPrim(texwindow); /* add to order table*/ 192 | } 193 | 194 | /*============================================================================= */ 195 | 196 | /* 197 | =============================================================================== 198 | = 199 | = R_PointToAngle 200 | = 201 | =============================================================================== 202 | */ 203 | 204 | extern int tantoangle[SLOPERANGE + 1]; 205 | 206 | inline int SlopeDiv(unsigned num, unsigned den)//L800310A4() 207 | { 208 | unsigned ans; 209 | if (den < 512) 210 | return SLOPERANGE; 211 | ans = (num << 3) / (den >> 8); 212 | return ans <= SLOPERANGE ? ans : SLOPERANGE; 213 | } 214 | 215 | angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2)//L800310EC() 216 | { 217 | int x; 218 | int y; 219 | 220 | x = x2 - x1; 221 | y = y2 - y1; 222 | 223 | if ((!x) && (!y)) 224 | return 0; 225 | 226 | if (x >= 0) 227 | { /* x >=0 */ 228 | if (y >= 0) 229 | { /* y>= 0 */ 230 | if (x>y) 231 | return tantoangle[SlopeDiv(y, x)]; /* octant 0 */ 232 | else 233 | return ANG90 - 1 - tantoangle[SlopeDiv(x, y)]; /* octant 1 */ 234 | } 235 | else 236 | { /* y<0 */ 237 | y = -y; 238 | if (x>y) 239 | return -tantoangle[SlopeDiv(y, x)]; /* octant 8 */ 240 | else 241 | return ANG270 + tantoangle[SlopeDiv(x, y)]; /* octant 7 */ 242 | } 243 | } 244 | else 245 | { /* x<0 */ 246 | x = -x; 247 | if (y >= 0) 248 | { /* y>= 0 */ 249 | if (x>y) 250 | return ANG180 - 1 - tantoangle[SlopeDiv(y, x)]; /* octant 3 */ 251 | else 252 | return ANG90 + tantoangle[SlopeDiv(x, y)]; /* octant 2 */ 253 | } 254 | else 255 | { /* y<0 */ 256 | y = -y; 257 | if (x>y) 258 | return ANG180 + tantoangle[SlopeDiv(y, x)]; /* octant 4 */ 259 | else 260 | return ANG270 - 1 - tantoangle[SlopeDiv(x, y)]; /* octant 5 */ 261 | } 262 | } 263 | } 264 | 265 | 266 | /* 267 | =============================================================================== 268 | = 269 | = R_PointOnSide 270 | = 271 | = Returns side 0 (front) or 1 (back) 272 | =============================================================================== 273 | */ 274 | inline int R_PointOnSide(int x, int y, node_t *node)//L80031400() 275 | { 276 | fixed_t dx, dy; 277 | fixed_t left, right; 278 | 279 | if (!node->line.dx) 280 | { 281 | if (x <= node->line.x) 282 | return node->line.dy > 0; 283 | return node->line.dy < 0; 284 | } 285 | if (!node->line.dy) 286 | { 287 | if (y <= node->line.y) 288 | return node->line.dx < 0; 289 | return node->line.dx > 0; 290 | } 291 | 292 | dx = (x - node->line.x); 293 | dy = (y - node->line.y); 294 | 295 | left = (node->line.dy >> 16) * (dx >> 16); 296 | right = (dy >> 16) * (node->line.dx >> 16); 297 | 298 | if (right < left) 299 | return 0; /* front side */ 300 | return 1; /* back side */ 301 | } 302 | 303 | 304 | 305 | /* 306 | ============== 307 | = 308 | = R_PointInSubsector 309 | = 310 | ============== 311 | */ 312 | struct subsector_s *R_PointInSubsector(fixed_t x, fixed_t y)//L800314A8() 313 | { 314 | node_t *node; 315 | int side, nodenum; 316 | 317 | if (!numnodes) /* single subsector is a special case */ 318 | return subsectors; 319 | 320 | nodenum = numnodes - 1; 321 | 322 | while (!(nodenum & NF_SUBSECTOR)) 323 | { 324 | node = &nodes[nodenum]; 325 | side = R_PointOnSide(x, y, node); 326 | nodenum = node->children[side]; 327 | } 328 | 329 | return &subsectors[nodenum & ~NF_SUBSECTOR]; 330 | } 331 | -------------------------------------------------------------------------------- /PSXDOOM/s_sound.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSXDOOM/s_sound.c -------------------------------------------------------------------------------- /PSXDOOM/snmain.s: -------------------------------------------------------------------------------- 1 | ; SN Systems replacement for main module 2 | ; in API lib 3 | 4 | opt c+ 5 | 6 | DIPSW equ $1F802040 ;byte, read only 7 | 8 | section .rdata 9 | section .text 10 | section .ctors 11 | section .dtors 12 | section .data 13 | section .sdata 14 | section .sbss 15 | section .bss 16 | 17 | xdef __SN_ENTRY_POINT,__main,__do_global_dtors 18 | xdef _stacksize,_ramsize,_bbsstart 19 | xdef __heapbase,__heapsize 20 | xdef __text,__textlen 21 | xdef __data,__datalen 22 | xdef __bss,__bsslen 23 | 24 | xref InitHeap,main 25 | 26 | section .text 27 | 28 | ;_stacksize dw $00008000 ; /* set 32K stack */ 29 | ;_ramsize dw $00200000 ; /* and 2MB CD ROM ram */ 30 | 31 | ; 32 | ; This is the program entry point. 33 | ; 1) Clear program BSS section to zero 34 | ; 2) Set stack and heap 35 | ; 3) Call user entry point i.e. main() 36 | ; 4) Jmp back to downloader stub (should be call exit() or something?) 37 | ; 38 | ; Note: default ram size is 8 Megabytes 39 | ; default stack size is 32K 40 | ; stack position is top of RAM 41 | ; heap is all of RAM from end of prog to lowest stack addr 42 | ; 43 | ; Use can override these settings by declaring suitable values 44 | ; for these variables in his C code module along with main(). 45 | ; e.g. 46 | ; _stacksize=0x00002000; /* set 8K stack */ 47 | ; _ramsize=0x00100000; /* and 1MB ram */ 48 | ; 49 | ; If user does not specify override valuse for these variables then 50 | ; the default values will be loaded from the SNDEF module in LIBSN.LIB 51 | ; 52 | __SN_ENTRY_POINT: 53 | 54 | la v0,sect(.sbss) 55 | la v1,sectend(.bss) 56 | @clrit: 57 | opt at- 58 | sw zero,0(v0) 59 | addiu v0,v0,4 60 | sltu at,v0,v1 61 | bne at,zero,@clrit 62 | nop 63 | opt at+ 64 | 65 | ; This was the old way to set ram-top. Read mem config from DIP switches. 66 | ; 67 | ; lui a0,DIPSW>>16 68 | ; lb v0,DIPSW&$FFFF(a0) ;read dip settings 69 | ; nop 70 | ; andi v0,v0,%00110000 ;mem size in bits 4 & 5 71 | ; srl v0,v0,2 72 | ; la a0,MemSizes 73 | ; addu a0,a0,v0 74 | ; lw v0,0(a0) ;put stack at top of RAM 75 | ; nop 76 | 77 | lw v0,_ramsize ;this is the new way; because there 78 | nop ; are no switches on new hardware. 79 | 80 | addi v0,v0,-8 ;but leave room for two parameters 81 | lui t0,$8000 ;(mem seg for kernel cached RAM) 82 | or sp,v0,t0 ;set stack in kseg0 83 | 84 | la a0,sectend(.bss) ; a0 = heap base 85 | sll a0,a0,3 86 | srl a0,a0,3 ;remove mem seg bits 87 | lw v1,_stacksize 88 | nop 89 | subu a1,v0,v1 ;calc a1 = top of heap 90 | subu a1,a1,a0 ; -heap base, => a1 = size of heap 91 | or a0,a0,t0 ;heap in kseg0 92 | 93 | sw ra,__ra_temp 94 | la gp,sect(.sdata) 95 | move fp,sp 96 | jal InitHeap 97 | addi a0,a0,4 ;don't know why they do this. 98 | 99 | lw ra,__ra_temp 100 | nop 101 | 102 | jal main 103 | nop 104 | 105 | ; Will fall through here if main() returns. Fall into debugger stub. 106 | break $1 ;for want of something better 107 | 108 | ;MemSizes dw $00100000 ; 1 Megabyte 109 | ; dw $00200000 ; 2 Megabytes 110 | ; dw $00800000 ; 8 Megabytes ** default for MW 3.0 111 | ; dw $01000000 ;16 Megabytes 112 | 113 | __main lw t0,__initialised 114 | 115 | addiu sp,sp,-16 116 | 117 | sw s0,4(sp) 118 | sw s1,8(sp) 119 | sw ra,12(sp) 120 | 121 | bne t0,zero,@exit 122 | li t0,1 123 | 124 | sw t0,__initialised 125 | 126 | la s0,sect(.ctors) 127 | la s1,(sectend(.ctors)-sect(.ctors))/4 128 | beq s1,zero,@exit 129 | nop 130 | 131 | @loop lw t0,0(s0) 132 | addiu s0,s0,4 133 | 134 | jalr t0 135 | addiu s1,s1,-1 136 | 137 | bne s1,zero,@loop 138 | nop 139 | 140 | @exit lw ra,12(sp) 141 | lw s1,8(sp) 142 | lw s0,4(sp) 143 | 144 | addiu sp,sp,16 145 | 146 | jr ra 147 | nop 148 | 149 | __do_global_dtors 150 | 151 | lw t0,__initialised 152 | 153 | addiu sp,sp,-16 154 | 155 | sw s0,4(sp) 156 | sw s1,8(sp) 157 | sw ra,12(sp) 158 | 159 | beq t0,zero,@exit 160 | nop 161 | 162 | la s0,sect(.dtors) 163 | la s1,(sectend(.dtors)-sect(.dtors))/4 164 | beq s1,zero,@exit 165 | nop 166 | 167 | @loop lw t0,0(s0) 168 | addiu s0,s0,4 169 | 170 | jalr t0 171 | addiu s1,s1,-1 172 | 173 | bne s1,zero,@loop 174 | nop 175 | 176 | @exit lw ra,12(sp) 177 | lw s1,8(sp) 178 | lw s0,4(sp) 179 | 180 | addiu sp,sp,16 181 | 182 | jr ra 183 | nop 184 | 185 | section .data 186 | 187 | cnop 0,4 ;longword align 188 | 189 | _ramsize dw $00200000 ; 2 Megabytes 190 | _stacksize dw $00008000 ; default stack is 32k 191 | _bbsstart dw sectend(.bss) 192 | _gpstart dw 0 193 | 194 | __heapbase dw 0 195 | __heapsize dw 0 196 | __text dw sect(.text) 197 | __textlen dw sectend(.text)-sect(.text) 198 | __data dw sect(.data) 199 | __datalen dw sectend(.data)-sect(.data) 200 | __bss dw sect(.bss) 201 | __bsslen dw sectend(.bss)-sect(.bss) 202 | 203 | __initialised dw 0 204 | 205 | section .sbss 206 | 207 | __ra_temp dsw 1 208 | 209 | end 210 | 211 | -------------------------------------------------------------------------------- /PSXDOOM/sounds.h: -------------------------------------------------------------------------------- 1 | #ifndef __SOUNDSH__ 2 | #define __SOUNDSH__ 3 | 4 | /* 5 | * Identifiers for all sfx in game. 6 | */ 7 | 8 | typedef enum 9 | { 10 | sfx_None, 11 | sfx_sgcock, 12 | sfx_punch, 13 | sfx_itmbk, 14 | sfx_firsht2, 15 | sfx_barexp, 16 | sfx_firxpl, 17 | sfx_pistol, 18 | sfx_shotgn, 19 | sfx_plasma, 20 | sfx_bfg, 21 | sfx_sawup, 22 | sfx_sawidl, 23 | sfx_sawful, 24 | sfx_sawhit, 25 | sfx_rlaunc, 26 | sfx_rxplod, 27 | sfx_pstart, 28 | sfx_pstop, 29 | sfx_doropn, 30 | sfx_dorcls, 31 | sfx_stnmov, 32 | sfx_swtchn, 33 | sfx_swtchx, 34 | sfx_itemup, 35 | sfx_wpnup, 36 | sfx_oof, 37 | sfx_telept, 38 | sfx_noway, 39 | sfx_dshtgn, 40 | sfx_dbopn, 41 | sfx_dbload, 42 | sfx_dbcls, 43 | sfx_plpain, 44 | sfx_pldeth, 45 | sfx_slop, 46 | sfx_posit1, 47 | sfx_posit2, 48 | sfx_posit3, 49 | sfx_podth1, 50 | sfx_podth2, 51 | sfx_podth3, 52 | sfx_posact, 53 | sfx_popain, 54 | sfx_dmpain, 55 | sfx_dmact, 56 | sfx_claw, 57 | sfx_bgsit1, 58 | sfx_bgsit2, 59 | sfx_bgdth1, 60 | sfx_bgdth2, 61 | sfx_bgact, 62 | sfx_sgtsit, 63 | sfx_sgtatk, 64 | sfx_sgtdth, 65 | sfx_brssit, 66 | sfx_brsdth, 67 | sfx_cacsit, 68 | sfx_cacdth, 69 | sfx_sklatk, 70 | sfx_skldth, 71 | sfx_kntsit, 72 | sfx_kntdth, 73 | sfx_pesit, 74 | sfx_pepain, 75 | sfx_pedth, 76 | sfx_bspsit, 77 | sfx_bspdth, 78 | sfx_bspact, 79 | sfx_bspwlk, 80 | sfx_manatk, 81 | sfx_mansit, 82 | sfx_mnpain, 83 | sfx_mandth, 84 | sfx_firsht, 85 | sfx_skesit, 86 | sfx_skedth, 87 | sfx_skeact, 88 | sfx_skeatk, 89 | sfx_skeswg, 90 | sfx_skepch, 91 | sfx_cybsit, 92 | sfx_cybdth, 93 | sfx_hoof, 94 | sfx_metal, 95 | sfx_spisit, 96 | sfx_spidth, 97 | sfx_bdopn, 98 | sfx_bdcls, 99 | sfx_getpow, 100 | NUMSFX 101 | } sfxenum_t; 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /PSXDOOM/soundst.h: -------------------------------------------------------------------------------- 1 | /* newsfx.h */ 2 | 3 | #if 0 4 | typedef struct 5 | { 6 | int samples; 7 | int loop_start; 8 | int loop_end; 9 | int info; 10 | int unity; 11 | int pitch_correction; 12 | int decay_step; 13 | unsigned char data[1]; 14 | } sfx_t; 15 | 16 | typedef struct sfxinfo_s 17 | { 18 | char *name; /* up to 6-character name */ 19 | boolean singularity; /* Sfx singularity (only one at a time) */ 20 | int priority; /* Sfx priority */ 21 | struct sfxinfo_s *link; /* referenced sound if a link */ 22 | int pitch; /* pitch if a link */ 23 | int volume; /* volume if a link */ 24 | sfx_t *md_data; /* machine-dependent sound data */ 25 | } sfxinfo_t; 26 | 27 | typedef struct 28 | { 29 | char *name; /* up to 6-character name */ 30 | void *md_data; /* machine-dependent music data */ 31 | } musicinfo_t; 32 | 33 | /*============================================================================ */ 34 | 35 | #define INTERNALQUADS 256 /* 4k / 16 bytes per quad (64 bits) */ 36 | #define EXTERNALQUADS 512 /* 16k / 32 bytes per quad (16 bits+music) */ 37 | #define SFXCHANNELS 4 38 | 39 | typedef struct 40 | { 41 | unsigned *source; /* work in groups of 4 8 bit samples */ 42 | int startquad; 43 | int stopquad; 44 | int volume; /* range from 0-32k */ 45 | sfxinfo_t *sfx; 46 | mobj_t *origin; 47 | } sfxchannel_t; 48 | 49 | extern sfxchannel_t sfxchannels[SFXCHANNELS]; 50 | 51 | extern int finalquad; /* the last quad mixed by update. */ 52 | 53 | extern int sfxvolume; /* range 0 - 255 */ 54 | extern int musicvolume; /* range 0 - 255 */ 55 | extern int oldsfxvolume; /* to detect transition to sound off */ 56 | 57 | extern int soundtics; /* time spent mixing sounds */ 58 | extern int soundstarttics; /* time S_Update started */ 59 | 60 | extern int sfxsample; /* the sample about to be output */ 61 | /* by S_WriteOutSamples */ 62 | 63 | /* external buffer for sfx and music */ 64 | extern int soundbuffer[EXTERNALQUADS*16]; 65 | 66 | extern int samplecount; /* 22khz sample counter in DSP memory */ 67 | 68 | #endif 69 | /*============================================================================ */ 70 | 71 | void S_Init(void); 72 | void S_Clear (void); 73 | void S_StartSound(mobj_t *origin, int sound_id); 74 | void S_UpdateSounds(void); 75 | 76 | -------------------------------------------------------------------------------- /PSXDOOM/st_main.h: -------------------------------------------------------------------------------- 1 | /* the status bar consists of two 8 bit color objects: */ 2 | /* the static background pic and a transparent foreground object that */ 3 | /* all the stats are drawn onto when they change */ 4 | /* coordinates are status bar relative (0 is first line of sbar) */ 5 | 6 | #define FLASHDELAY 4 /* # of tics delay (1/30 sec) */ 7 | #define FLASHTIMES 6 /* # of times to flash new frag amount (EVEN!) */ 8 | 9 | #define AMMOX 52 10 | #define AMMOY 14 11 | 12 | #define HEALTHX 104 13 | #define HEALTHY AMMOY 14 | 15 | #define KEYX 124 16 | #define REDKEYY 3 17 | #define BLUKEYY 15 18 | #define YELKEYY 27 19 | #define KEYW 16 20 | #define KEYH 11 21 | 22 | #define FACEX 144 23 | #define FACEY 5 24 | 25 | #define ARMORX 226 26 | #define ARMORY HEALTHY 27 | 28 | #define MAPX 316 29 | #define MAPY HEALTHY 30 | 31 | #define HISFRAGX MAPX 32 | #define HISFRAGY HEALTHY 33 | 34 | #define YOURFRAGX 278 35 | #define YOURFRAGY HEALTHY 36 | 37 | typedef enum 38 | { 39 | f_none, 40 | f_unk1, 41 | f_unk2, 42 | f_faceleft, /* turn face left */ 43 | f_faceright, /* turn face right */ 44 | f_hurtbad, /* surprised look when slammed hard */ 45 | f_gotgat, /* picked up a weapon smile */ 46 | f_mowdown, /* grimace while continuous firing */ 47 | NUMSPCLFACES 48 | } spclface_e; 49 | 50 | #define NUMFACES 47 //[PSX] Change 48 to 47 51 | #define EVILFACE 6 52 | #define GODFACE 40 53 | #define DEADFACE 41 54 | #define FIRSTSPLAT 42 55 | 56 | #define GIBTIME 2 //[PSX] Change 4 to 2 57 | #define NUMSPLATS 6 58 | #define NUMMICROS 8 /* amount of micro-sized #'s (weapon armed) */ 59 | 60 | typedef struct 61 | { 62 | byte xpos; 63 | byte ypos; 64 | byte x; 65 | byte y; 66 | byte w; 67 | byte h; 68 | } facedata_t; 69 | 70 | extern facedata_t facedata[NUMFACES];//0x80073c98 71 | 72 | typedef enum 73 | { 74 | sb_minus, 75 | sb_0, 76 | sb_percent = 11, 77 | sb_card_b, 78 | sb_card_y, 79 | sb_card_r, 80 | sb_skul_b, 81 | sb_skul_y, 82 | sb_skul_r, 83 | NUMSBOBJ 84 | } sbobj_e; 85 | 86 | typedef struct 87 | { 88 | short active; //* 89 | short doDraw; //2 90 | short delay; //4 91 | short times; //6 92 | } sbflash_t; 93 | 94 | typedef struct 95 | { 96 | int face; //800984F4 97 | /* Messaging */ 98 | spclface_e specialFace; //800984F8 /* Which type of special face to make */ 99 | boolean tryopen[NUMCARDS]; //800984FC /* Tried to open a card or skull door */ 100 | boolean gotgibbed; //80098514 /* Got gibbed */ 101 | int gibframe; //80098518 102 | int gibdelay; //8009851C 103 | char *message; //80098520 104 | int messagedelay; //80098524 105 | } stbar_t; 106 | 107 | extern stbar_t stbar; //800984F4 108 | extern psxobj_t statuspic; 109 | extern int weaponowned[NUMWEAPONS]; //80073ebc 110 | extern short micronums_x[NUMMICROS];//80073ee0 111 | extern short micronums_y[NUMMICROS];//80073ef0 112 | extern short card_y[NUMCARDS];//80073f00 113 | 114 | typedef struct { 115 | byte x; 116 | byte y; 117 | byte w; 118 | byte h; 119 | } symboldata_t; 120 | 121 | extern symboldata_t symboldata[];//80073e16 122 | 123 | void ST_Init (void); 124 | void ST_InitEveryLevel(void); 125 | void ST_Ticker (void); 126 | void ST_Drawer (void); 127 | void ST_DrawValue(int x, int y, int value); 128 | void ST_DrawMessage(int x, int y, char *text); 129 | void ST_CheatDraw(void); 130 | void ST_doPaletteStuff(void); 131 | int ST_GetTextCenterX(char *text); 132 | void ST_DrawText(int x, int y, char *text); 133 | 134 | 135 | -------------------------------------------------------------------------------- /PSXDOOM/t_main.c: -------------------------------------------------------------------------------- 1 | /* t_main.c -- title intro */ 2 | 3 | #include "doomdef.h" 4 | #include "p_spec.h" 5 | #include "r_local.h" 6 | 7 | int vframe1 = 0; //80077AB4 iGp000006a4 8 | int vframe2 = 0; //80077AB8 iGp000006a8 9 | 10 | int y_scroll;//80077FB8 uGp00000ba8 11 | int last_ticon;//80077D38 iGp00000928 12 | 13 | psxobj_t loadingpic;//0x80097870 14 | psxobj_t marb01pic;//0x80097890 15 | psxobj_t buttonspic;//0x800978B0 16 | psxobj_t neterrpic; //0x800978d0 17 | psxobj_t pausepic;//0x80097850 18 | psxobj_t titlepic;//0x80097810 19 | 20 | /* 21 | ======================= 22 | = 23 | = T_Start 24 | = 25 | ======================= 26 | */ 27 | 28 | void T_Start(void)//L800353E4() 29 | { 30 | int lump; 31 | 32 | Valloc_Init(); 33 | //Z_FreeTags(mainzone,PU_CACHE);//test 34 | 35 | W_CacheLumpName("LOADING", PU_STATIC, 0); 36 | ImageToVram(&loadingpic, "LOADING", 0); 37 | P_LoadingPlaque(&loadingpic, 95, 109, palette[20]); 38 | S_Lcd_Load(0); 39 | 40 | W_CacheLumpName("TILE", PU_STATIC, 0);//MARB01 41 | W_CacheLumpName("BUTTONS", PU_STATIC, 0); 42 | W_CacheLumpName("NETERR", PU_STATIC, 0); 43 | W_CacheLumpName("PAUSE", PU_STATIC, 0); 44 | 45 | ImageToVram(&marb01pic, "TILE", 0);//MARB01 46 | ImageToVram(&buttonspic, "BUTTONS", 0); 47 | ImageToVram(&neterrpic, "NETERR", 0); 48 | ImageToVram(&pausepic, "PAUSE", 0); 49 | ImageToVram(&titlepic, "TITLE", 0); 50 | 51 | lump = R_TextureNumForName("SKY09"); 52 | skytexturep = &textures[lump]; 53 | skypalette = palette[15]; 54 | 55 | W_CacheLumpNum(skytexturep->lump, PU_CACHE, true); 56 | 57 | TextureCache(skytexturep); 58 | 59 | y_scroll = 0; 60 | 61 | psxcd_play(CD_TRACK[cdmusic_title_screen], CDVolume); 62 | do {} while(psxcd_elapsed_sectors() == 0); 63 | } 64 | 65 | /* 66 | ======================= 67 | = 68 | = T_Stop 69 | = 70 | ======================= 71 | */ 72 | 73 | void T_Stop(int exit)//L800355B0() 74 | { 75 | S_StartSound(NULL, sfx_barexp); 76 | psxcd_stop(); 77 | } 78 | 79 | /* 80 | ======================= 81 | = 82 | = T_Ticker 83 | = 84 | ======================= 85 | */ 86 | 87 | int T_Ticker(void)//L800355DC() 88 | { 89 | byte *cache, *cachetmp; 90 | int exit, pixel, cnt, i; 91 | 92 | exit = ga_nothing; 93 | 94 | if (ticbuttons[0] != 0) 95 | { 96 | exit = ga_exit; 97 | } 98 | else 99 | { 100 | vframe1 -= vblsinframe[consoleplayer]; 101 | if ((vframe1 <= 0) && (y_scroll >= 128)) 102 | { 103 | vframe1 = 2; 104 | P_FireSky(skytexturep); 105 | } 106 | 107 | if (y_scroll < 129) 108 | y_scroll += 4; 109 | 110 | if (y_scroll >= 128) 111 | exit = -((unsigned int)(ticon - last_ticon < 1800) ^ 1) & 7; 112 | } 113 | 114 | return exit; 115 | } 116 | 117 | /* 118 | ======================= 119 | = 120 | = T_Draw 121 | = 122 | ======================= 123 | */ 124 | 125 | #if FIX_TITLE_FYRE_WITH == 1 126 | #define SKY_W 64 127 | #else 128 | #define SKY_W 63 129 | #endif // FIX_TITLE_FYRE_WITH 130 | 131 | void T_Draw(void)//L800356B8() 132 | { 133 | POLY_FT4 poly1; 134 | RECT rect; 135 | int i; 136 | byte *cache; 137 | 138 | NextTextureCacheIdx(); 139 | 140 | // Draw 4 Fire Textures 141 | if (skytexturep->index == -1) 142 | { 143 | rect.x = (skytexturep->vramx >> 1) + ((skytexturep->vtpage & 15) << 6); 144 | rect.y = (skytexturep->vramy) + ((skytexturep->vtpage & 16) << 4); 145 | rect.w = 32; 146 | rect.h = 128; 147 | cache = (byte *)(lumpcache[skytexturep->lump].cache) + 8; 148 | LoadImage(&rect, (unsigned long *)(byte*)(cache)); 149 | skytexturep->index = TextureCacheIdx; 150 | } 151 | 152 | setPolyFT4(&poly1); 153 | setRGB0(&poly1, 128, 128, 128); 154 | 155 | //setUV4(p,_u0,_v0,_u1,_v1,_u2,_v2,_u3,_v3) 156 | setUV4(&poly1, 157 | skytexturep->vramx , skytexturep->vramy, 158 | skytexturep->vramx + SKY_W, skytexturep->vramy, 159 | skytexturep->vramx , skytexturep->vramy + 127, 160 | skytexturep->vramx + SKY_W, skytexturep->vramy + 127); 161 | 162 | //setXY4(p,_x0,_y0,_x1,_y1,_x2,_y2,_x3,_y3) 163 | setXY4(&poly1, 164 | 0, 112, 165 | SKY_W, 112, 166 | 0, 239, 167 | SKY_W, 239); 168 | 169 | poly1.tpage = skytexturep->vtpage; 170 | poly1.clut = skypalette; 171 | 172 | for (i = 0; i < 4; i++) 173 | { 174 | W_AddPrim(&poly1);// add to order table 175 | poly1.x0 += SKY_W; 176 | poly1.x1 += SKY_W; 177 | poly1.x2 += SKY_W; 178 | poly1.x3 += SKY_W; 179 | } 180 | 181 | // Draw Title Textures 182 | setPolyFT4(&poly1); 183 | 184 | //setXY4(p,_x0,_y0,_x1,_y1,_x2,_y2,_x3,_y3) 185 | setXY4(&poly1, 186 | 0 , 0, 187 | 255, 0, 188 | 0 , 239, 189 | 255, 239); 190 | 191 | //setUV4(p,_u0,_v0,_u1,_v1,_u2,_v2,_u3,_v3) 192 | setUV4(&poly1, 193 | 0 , 0 , 194 | 255, 0 , 195 | 0 , 239, 196 | 255, 239); 197 | 198 | setRGB0(&poly1, y_scroll, y_scroll, y_scroll); 199 | 200 | poly1.tpage = titlepic.vtpage; 201 | poly1.clut = palette[17]; 202 | 203 | W_AddPrim(&poly1);// add to order table 204 | 205 | UpdateDrawOTag(); 206 | DrawRender(); 207 | } 208 | -------------------------------------------------------------------------------- /PSXDOOM/vsprintf.c: -------------------------------------------------------------------------------- 1 | 2 | //inline 3 | int mystrlen(char *string)//L800315D4() 4 | { 5 | int rc = 0; 6 | if (string) while (*(string++)) rc++; 7 | else rc = -1; 8 | return rc; 9 | } 10 | 11 | int D_vsprintf(char *string, const char *format, int *argptr)//L80031614() 12 | { 13 | int len, i, div, uselong; 14 | int fieldsize; 15 | unsigned long num; 16 | long snum; 17 | char padchar; 18 | char *str; 19 | char *origstring = string; 20 | 21 | while (*format) 22 | { 23 | if (*format != '%') *(string++) = *(format++); 24 | else 25 | { 26 | format++; 27 | 28 | /* set field pad character to 0 if necessary */ 29 | if (*format == '0') 30 | { 31 | padchar = '0'; 32 | format++; 33 | } 34 | else padchar = ' '; 35 | 36 | /* get the fieldwidth if any */ 37 | fieldsize = 0; 38 | while (*format >= '0' && *format <= '9') 39 | fieldsize = fieldsize * 10 + *(format++) - '0'; 40 | 41 | /* get rid of 'l' if present */ 42 | if (*format == 'l') 43 | { 44 | uselong = 1; 45 | format++; 46 | } else uselong = 0; 47 | 48 | div = 10; 49 | if (*format == 'c') 50 | { 51 | *(string++) = *argptr++; 52 | format++; 53 | } 54 | else if (*format == 's') 55 | { 56 | str = (char *)*argptr++; 57 | len = mystrlen(str); 58 | while (fieldsize-- > len) *(string++) = padchar; /* do field pad */ 59 | while (*str) *(string++) = *(str++); /* copy string */ 60 | format++; 61 | } 62 | else 63 | { 64 | if (*format == 'o') /* octal */ 65 | { 66 | div = 8; 67 | if (uselong) 68 | num = *argptr++; 69 | else 70 | num = *argptr++; 71 | /* printf("o=0%o\n", num); */ 72 | } 73 | else if (*format == 'x' || *format == 'X') /* hex */ 74 | { 75 | div = 16; 76 | if (uselong) 77 | num = *argptr++; 78 | else 79 | num = *argptr++; 80 | /* printf("x=%x\n", num); */ 81 | } 82 | else if (*format == 'i' || *format == 'd' || *format == 'u') /* decimal */ 83 | { 84 | div = 10; 85 | if (uselong) 86 | snum = *argptr++; 87 | else 88 | snum = *argptr++; 89 | if (snum < 0 && *format != 'u') /* handle negative %i or %d */ 90 | { 91 | *(string++) = '-'; 92 | num = -snum; 93 | if (fieldsize) fieldsize--; 94 | } else num = snum; 95 | } 96 | else return -1; /* unrecognized format specifier */ 97 | 98 | /* print any decimal or hex integer */ 99 | len = 0; 100 | while (num || fieldsize || !len) 101 | { 102 | for (i=len ; i ; i--) string[i] = string[i-1]; /* shift right */ 103 | if (len && fieldsize && !num) *string = padchar; /* pad out */ 104 | else 105 | { 106 | /* put in a hex or decimal digit */ 107 | *string = num % div; 108 | *string += *string > 9 ? 'A'-10 : '0'; 109 | /* printf("d = %c\n", *string); */ 110 | num /= div; 111 | } 112 | len++; 113 | if (fieldsize) fieldsize--; 114 | } 115 | string += len; 116 | format++; 117 | } 118 | } 119 | } 120 | *string = 0; 121 | 122 | return origstring - string; 123 | } 124 | -------------------------------------------------------------------------------- /PSYQ/CPE2X.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSYQ/CPE2X.EXE -------------------------------------------------------------------------------- /PSYQ/README.txt: -------------------------------------------------------------------------------- 1 | Replace these files once the PSYQ SDK is installed, copy them to the following address C:\psyq\bin 2 | 3 | CPE2X.EXE Originally from Orion http://onorisoft.free.fr/ 4 | cpe2x_gec.exe A modified version of Orion -------------------------------------------------------------------------------- /PSYQ/cpe2x_gec.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Erick194/PSXFINALDOOM-RE/270cb6ac6029bbdc65dcd7cd1226f1a5b5723c6f/PSYQ/cpe2x_gec.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSXFINALDOOM-RE 2 | 3 | Welcome to the complete reverse engineering of PSX Final Doom by [GEC], this effort took about 2 and a half years and 4 months after the release of the **[PSXDOOM-RE](https://github.com/Erick194/PSXDOOM-RE)** source code to complete, This is practically PsxDoom but updated for Final Doom, one of the great differences of both games was the mouse support that included Final Doom. 4 | 5 | This will be of great help to the project **[PsyDoom](https://github.com/BodbDearg/PsyDoom)** with the advantage of being updated soon with Psx Final Doom. 6 | 7 | You need to download and install the Psy-Q SDK http://www.psxdev.net/downloads.html 8 | 9 | It is necessary to visit this page for installation since it is a very old software, frequently presenting failures in modern Windows 10 | http://www.psxdev.net/help/psyq_install.html 11 | 12 | Once you have completed the installation process, go to copy the files in the PSYQ folder and it is necessary for the compilation. 13 | 14 | 15 | Now everything is complete, copy the PSXDOOM-RE folder to the root "C:" of your hard drive. 16 | 17 | You need to copy the PSXFINALDOOM SLUS_003.31 game files, with everything and their folders, the MOVIE.STR file is impossible to copy in Windows, it is the only file that is previously in the ABIN folder. 18 | 19 | You run the MAKEFILE.bat to compile and create the main.exe file, it will be automatically copied to the GAME folder. 20 | 21 | In the GAME folder, you run the MAKE_CD.bat file, it will create the CD image, and it will also create 2 necessary files that are "PSXCDABS.C and PSXCDABS.H" these are automatically copied to the previous folder, this is essential since if you modify the code or the files of the game these will change your LBA address and the file size, which requires compiling it again to avoid getting loading errors. 22 | 23 | 24 | Notes: 25 | The project is created with CodeBlocks, although it does not serve to compile, but to have the code in order and verification. 26 | 27 | The mkpsxiso.exe program is originally created by lameguy64, but the present version is modified by me, to create the files "PSXCDABS.C and PSXCDABS.H". 28 | https://github.com/Lameguy64/mkpsxiso by lameguy64 29 | 30 | 31 | Special thanks to my brothers for the help to the community in DoomWorld and Kaiser since he is the only one to see the progress of my work and helps me in several occasions. 32 | 33 | News: 34 | * No clip cheat code from PsyDoom. 35 | * VRAM Viewer added from Master Edition PsxDoom. 36 | * FPS Counter that can be deactivate/activate in the code itself. 37 | * Various bug fixes that have been included in **[PSXDOOM-RE](https://github.com/Erick194/PSXDOOM-RE)** 38 | --------------------------------------------------------------------------------