├── src ├── p │ ├── Interceptable.kt │ ├── bwhere_e.kt │ ├── result_e.kt │ ├── sd_e.kt │ ├── sdt_e.kt │ ├── plat_e.kt │ ├── slideframe_t.kt │ ├── stair_e.kt │ ├── plattype_e.kt │ ├── Resettable.kt │ ├── ceiling_e.kt │ ├── ISightChecker.kt │ ├── vldoor_e.kt │ ├── DoorDefines.kt │ ├── ThinkerList.kt │ ├── button_t.kt │ ├── slidedoor_t.kt │ ├── anim_t.kt │ ├── floor_e.kt │ ├── DoomPlayer.kt │ ├── slidename_t.kt │ ├── intercept_t.kt │ ├── pspdef_t.kt │ ├── switchlist_t.kt │ ├── Actions │ │ └── ActiveStates │ │ │ ├── Monsters.kt │ │ │ └── MonsterStates │ │ │ └── Spiders.kt │ ├── vldoor_t.kt │ ├── strobe_t.kt │ ├── ChaseDirections.kt │ ├── floormove_t.kt │ └── animdef_t.kt ├── f │ ├── point_t.kt │ ├── castinfo_t.kt │ ├── Wiper.kt │ └── anim_t.kt ├── rr │ ├── planefunction_t.kt │ ├── IDetailAware.kt │ ├── drawfuns │ │ ├── SpanFunction.kt │ │ ├── DcFlags.kt │ │ ├── ColumnFunction.kt │ │ ├── SpanVars.kt │ │ ├── ColFuncs.kt │ │ ├── DoomSpanFunction.kt │ │ ├── R_DrawColumnLow.kt │ │ └── ColVars.kt │ ├── IGetColumn.kt │ ├── IGetCachedColumn.kt │ ├── ILimitResettable.kt │ ├── cliprange_t.kt │ ├── BSPVars.kt │ ├── parallel │ │ ├── RWI.kt │ │ ├── IGetSmpColumn.kt │ │ └── RenderSegInstruction.kt │ ├── SimpleThings.kt │ ├── z_vertex_t.kt │ ├── base_ratio_t.kt │ ├── maskdraw_t.kt │ ├── texpatch_t.kt │ ├── SectorAction.kt │ ├── flat_t.kt │ ├── IVisSpriteManagement.kt │ ├── SegVars.kt │ ├── IMaskedDrawer.kt │ ├── vertex_t.kt │ ├── mappatch_t.kt │ ├── spritedef_t.kt │ ├── subsector_t.kt │ ├── vissprite_t.kt │ ├── texture_t.kt │ ├── spriteframe_t.kt │ ├── maptexture_t.kt │ └── ISpriteManager.kt ├── META-INF │ └── MANIFEST.MF ├── i │ ├── IDrawer.kt │ ├── DoomEventInterface.kt │ ├── IDiskDrawer.kt │ ├── IDoomSystem.kt │ ├── DiskDrawer.kt │ ├── DummySystem.kt │ └── Strings.kt ├── n │ ├── IDoomNet.kt │ ├── DummyNetworkHandler.kt │ ├── DoomSystemNetworking.kt │ └── DummyNetworkDriver.kt ├── doom │ ├── pic_t.kt │ ├── gameaction_t.kt │ ├── playerstate_t.kt │ ├── evtype_t.kt │ ├── th_class.kt │ ├── weapontype_t.kt │ ├── IDoom.kt │ ├── NetConsts.kt │ ├── KeyboardManager.kt │ ├── IDoomGameNetworking.kt │ ├── IDoomGame.kt │ ├── wbplayerstruct_t.kt │ ├── weaponinfo_t.kt │ ├── wbstartstruct_t.kt │ ├── DoomContext.kt │ ├── IDatagramSerializable.kt │ └── doomcom_t.kt ├── w │ ├── animenum_t.kt │ ├── IReadWriteDoomObject.kt │ ├── IPackableDoomObject.kt │ ├── statenum_t.kt │ ├── IWritableDoomObject.kt │ ├── li_namespace.kt │ ├── AidedReadableDoomObject.kt │ ├── IReadableDoomObject.kt │ ├── wad_source_t.kt │ ├── wadinfo_t.kt │ ├── wadfile_info_t.kt │ ├── wadheader_t.kt │ ├── CacheableDoomObjectContainer.kt │ ├── JadDecompress.kt │ ├── lumpinfo_t.kt │ ├── filelump_t.kt │ └── CacheableDoomObject.kt ├── automap │ ├── fpoint_t.kt │ ├── islope_t.kt │ ├── mpoint_t.kt │ ├── fline_t.kt │ ├── mline_t.kt │ └── IAutoMap.kt ├── defines │ ├── skill_t.kt │ ├── Language_t.kt │ ├── slopetype_t.kt │ ├── card_t.kt │ ├── GameMission_t.kt │ ├── gamestate_t.kt │ └── ammotype_t.kt ├── boom │ ├── prboom_comp_t.kt │ ├── mapsubsector_znod_t.kt │ ├── mapglvertex_t.kt │ ├── mapsubsector_v4_t.kt │ ├── mapseg_znod_t.kt │ ├── mapseg_v4_t.kt │ ├── ZNodeSegs.kt │ ├── DeepBSPNodesV4.kt │ ├── mapnode_znod_t.kt │ └── mapnode_v4_t.kt ├── st │ ├── st_chatstateenum_t.kt │ ├── st_stateenum_t.kt │ ├── AbstractStatusBar.kt │ ├── st_enumstatcodes_t.kt │ └── IDoomStatusBar.kt ├── pooling │ ├── RoguePatchMap.kt │ ├── AudioChunkPool.kt │ ├── ObjectQueuePool.kt │ ├── RoguePatchMap2.kt │ └── GenericIntMap.kt ├── s │ ├── ISoundOrigin.kt │ ├── AudioChunk.kt │ ├── degenmobj_t.kt │ ├── channel_t.kt │ ├── DMXSound.kt │ ├── DummyMusic.kt │ ├── DummySFX.kt │ ├── IMusic.kt │ ├── DoomSound.kt │ └── DummySoundDriver.kt ├── m │ ├── AbstractDoomMenu.kt │ ├── ISyncLogger.kt │ ├── default_t.kt │ ├── DrawRoutine.kt │ ├── MenuRoutine.kt │ ├── IRandom.kt │ ├── menu_t.kt │ ├── menuitem_t.kt │ ├── DummyMenu.kt │ ├── IDoomMenu.kt │ └── Swap.kt ├── savegame │ ├── ILoadSaveGame.kt │ ├── IDoomSaveGame.kt │ └── IDoomSaveGameHeader.kt ├── timing │ ├── FastTicker.kt │ ├── ITicker.kt │ ├── MilliTicker.kt │ ├── NanoTicker.kt │ └── DelegateTicker.kt ├── hu │ └── IHeadsUp.kt ├── data │ ├── musicinfo_t.kt │ ├── mapsubsector_t.kt │ ├── mobjinfo_t.kt │ ├── mapvertex_t.kt │ ├── maplinedef_t.kt │ ├── mapsector_t.kt │ ├── mapsidedef_t.kt │ ├── mapseg_t.kt │ ├── spritenum_t.kt │ ├── doomtype.kt │ ├── mapnode_t.kt │ ├── mobjtype_t.kt │ └── mapthing_t.kt ├── demo │ ├── IDemoTicCmd.kt │ └── IDoomDemo.kt ├── utils │ ├── OSValidator.kt │ └── QuoteType.kt ├── v │ ├── graphics │ │ ├── Horizontal.kt │ │ ├── Relocation.kt │ │ └── Points.kt │ ├── renderers │ │ └── DoomScreen.kt │ └── scale │ │ └── VideoScale.kt ├── com │ └── hiperbou │ │ └── lang │ │ └── LangExtensions.kt ├── g │ └── DoomGameInterface.kt └── awt │ └── DisplayModePicker.kt ├── .idea ├── .gitignore ├── encodings.xml ├── vcs.xml ├── misc.xml ├── modules.xml ├── artifacts │ └── kocoa-doom_jar.xml └── libraries │ └── KotlinJavaRuntime.xml ├── tranmap.dat ├── colors12.lmp ├── colors15.lmp ├── demos ├── crap.lmp ├── first.lmp ├── stuff.lmp ├── e1nm0646.lmp └── nuts.wad.lmp ├── pwads ├── easy.wad ├── grid.wad ├── web.wad ├── ABBEY.WAD ├── ZARNEK.WAD ├── cross.wad ├── easy2.wad ├── frugal.wad ├── masked.wad ├── orbit.wad ├── penta.wad ├── piano.wad ├── swdoor.wad ├── trigon.wad ├── weird.wad ├── onesquare.wad ├── sprites.wad ├── test272.wad ├── test272.wad.zip └── lotsofmonsters.wad ├── mm2-mochadoom.7z ├── kocoa-doom.iml ├── .gitignore ├── default.cfg ├── CHANGES.TXT └── README.md /src/p/Interceptable.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | interface Interceptable -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /src/f/point_t.kt: -------------------------------------------------------------------------------- 1 | package f 2 | 3 | 4 | class point_t(var x: Int, var y: Int) -------------------------------------------------------------------------------- /src/rr/planefunction_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | interface planefunction_t -------------------------------------------------------------------------------- /tranmap.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/tranmap.dat -------------------------------------------------------------------------------- /colors12.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/colors12.lmp -------------------------------------------------------------------------------- /colors15.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/colors15.lmp -------------------------------------------------------------------------------- /demos/crap.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/demos/crap.lmp -------------------------------------------------------------------------------- /pwads/easy.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/easy.wad -------------------------------------------------------------------------------- /pwads/grid.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/grid.wad -------------------------------------------------------------------------------- /pwads/web.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/web.wad -------------------------------------------------------------------------------- /demos/first.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/demos/first.lmp -------------------------------------------------------------------------------- /demos/stuff.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/demos/stuff.lmp -------------------------------------------------------------------------------- /mm2-mochadoom.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/mm2-mochadoom.7z -------------------------------------------------------------------------------- /pwads/ABBEY.WAD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/ABBEY.WAD -------------------------------------------------------------------------------- /pwads/ZARNEK.WAD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/ZARNEK.WAD -------------------------------------------------------------------------------- /pwads/cross.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/cross.wad -------------------------------------------------------------------------------- /pwads/easy2.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/easy2.wad -------------------------------------------------------------------------------- /pwads/frugal.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/frugal.wad -------------------------------------------------------------------------------- /pwads/masked.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/masked.wad -------------------------------------------------------------------------------- /pwads/orbit.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/orbit.wad -------------------------------------------------------------------------------- /pwads/penta.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/penta.wad -------------------------------------------------------------------------------- /pwads/piano.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/piano.wad -------------------------------------------------------------------------------- /pwads/swdoor.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/swdoor.wad -------------------------------------------------------------------------------- /pwads/trigon.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/trigon.wad -------------------------------------------------------------------------------- /pwads/weird.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/weird.wad -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: mochadoom.Engine 3 | 4 | -------------------------------------------------------------------------------- /src/i/IDrawer.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | interface IDrawer { 5 | fun Drawer() 6 | } -------------------------------------------------------------------------------- /demos/e1nm0646.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/demos/e1nm0646.lmp -------------------------------------------------------------------------------- /demos/nuts.wad.lmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/demos/nuts.wad.lmp -------------------------------------------------------------------------------- /pwads/onesquare.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/onesquare.wad -------------------------------------------------------------------------------- /pwads/sprites.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/sprites.wad -------------------------------------------------------------------------------- /pwads/test272.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/test272.wad -------------------------------------------------------------------------------- /src/n/IDoomNet.kt: -------------------------------------------------------------------------------- 1 | package n 2 | 3 | 4 | interface IDoomNet { 5 | fun NetUpdate() 6 | } -------------------------------------------------------------------------------- /pwads/test272.wad.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/test272.wad.zip -------------------------------------------------------------------------------- /src/p/bwhere_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class bwhere_e { 5 | top, middle, bottom 6 | } -------------------------------------------------------------------------------- /src/p/result_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class result_e { 5 | ok, crushed, pastdest 6 | } -------------------------------------------------------------------------------- /pwads/lotsofmonsters.wad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiperbou/kocoa-doom/HEAD/pwads/lotsofmonsters.wad -------------------------------------------------------------------------------- /src/p/sd_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class sd_e { 5 | sd_opening, sd_waiting, sd_closing 6 | } -------------------------------------------------------------------------------- /src/doom/pic_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | class pic_t(var width: Byte, var height: Byte, var data: Byte) -------------------------------------------------------------------------------- /src/w/animenum_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | enum class animenum_t { 4 | ANIM_ALWAYS, ANIM_RANDOM, ANIM_LEVEL 5 | } -------------------------------------------------------------------------------- /src/p/sdt_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class sdt_e { 5 | sdt_openOnly, sdt_closeOnly, sdt_openAndClose 6 | } -------------------------------------------------------------------------------- /src/w/IReadWriteDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | interface IReadWriteDoomObject : IReadableDoomObject, IWritableDoomObject -------------------------------------------------------------------------------- /src/automap/fpoint_t.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | 4 | class fpoint_t @JvmOverloads constructor(var x: Int = 0, var y: Int = 0) -------------------------------------------------------------------------------- /src/p/plat_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | // 5 | // P_PLATS 6 | // 7 | enum class plat_e { 8 | up, down, waiting, in_stasis 9 | } -------------------------------------------------------------------------------- /src/defines/skill_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | enum class skill_t { 5 | sk_baby, sk_easy, sk_medium, sk_hard, sk_nightmare 6 | } -------------------------------------------------------------------------------- /src/automap/islope_t.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | 4 | class islope_t { 5 | /** fixed_t */ 6 | var slp = 0 7 | var islp = 0 8 | } -------------------------------------------------------------------------------- /src/boom/prboom_comp_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | class prboom_comp_t(var minver: Int, var maxver: Int, var state: Boolean, var cmd: String) -------------------------------------------------------------------------------- /src/p/slideframe_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | class slideframe_t { 5 | var frontFrames = IntArray(4) 6 | var backFrames = IntArray(4) 7 | } -------------------------------------------------------------------------------- /src/p/stair_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class stair_e { 5 | build8, // slowly build by 8 6 | turbo16 // quickly build by 16 7 | } -------------------------------------------------------------------------------- /src/st/st_chatstateenum_t.kt: -------------------------------------------------------------------------------- 1 | package st 2 | 3 | 4 | internal enum class st_chatstateenum_t { 5 | StartChatState, WaitDestState, GetChatState 6 | } -------------------------------------------------------------------------------- /src/st/st_stateenum_t.kt: -------------------------------------------------------------------------------- 1 | package st 2 | 3 | 4 | //States for status bar code. 5 | enum class st_stateenum_t { 6 | AutomapState, FirstPersonState 7 | } -------------------------------------------------------------------------------- /src/p/plattype_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class plattype_e { 5 | perpetualRaise, downWaitUpStay, raiseAndChange, raiseToNearestAndChange, blazeDWUS 6 | } -------------------------------------------------------------------------------- /src/st/AbstractStatusBar.kt: -------------------------------------------------------------------------------- 1 | package st 2 | 3 | import doom.DoomMain 4 | 5 | abstract class AbstractStatusBar(protected val DOOM: DoomMain<*, *>) : IDoomStatusBar -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/defines/Language_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | /** Identify language to use, software localization. */ 5 | enum class Language_t { 6 | english, french, german, unknown 7 | } -------------------------------------------------------------------------------- /src/st/st_enumstatcodes_t.kt: -------------------------------------------------------------------------------- 1 | package st 2 | 3 | 4 | // States for the chat code. 5 | internal enum class st_enumstatcodes_t { 6 | StartChatState, WaitDestState, GetChatState 7 | } -------------------------------------------------------------------------------- /src/defines/slopetype_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | /** Move clipping aid for LineDefs. */ 5 | enum class slopetype_t { 6 | ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE 7 | } -------------------------------------------------------------------------------- /src/p/Resettable.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | /** For objects that needed to be memset to 0 in C, 5 | * rather than being reallocated. */ 6 | interface Resettable { 7 | fun reset() 8 | } -------------------------------------------------------------------------------- /src/pooling/RoguePatchMap.kt: -------------------------------------------------------------------------------- 1 | package pooling 2 | 3 | class RoguePatchMap : GenericIntMap?>() { 4 | init { 5 | patches = arrayOfNulls(DEFAULT_CAPACITY) 6 | } 7 | } -------------------------------------------------------------------------------- /src/s/ISoundOrigin.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | 4 | /** Use this instead of that degemobj_t crud */ 5 | interface ISoundOrigin { 6 | fun getX(): Int 7 | fun getY(): Int 8 | fun getZ(): Int 9 | } -------------------------------------------------------------------------------- /src/p/ceiling_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | // 5 | // P_CEILNG 6 | // 7 | enum class ceiling_e { 8 | lowerToFloor, raiseToHighest, lowerAndCrush, crushAndRaise, fastCrushAndRaise, silentCrushAndRaise 9 | } -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/defines/card_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | /** 5 | * Key cards. 6 | */ 7 | enum class card_t { 8 | it_bluecard, it_yellowcard, it_redcard, it_blueskull, it_yellowskull, it_redskull, NUMCARDS 9 | } -------------------------------------------------------------------------------- /src/m/AbstractDoomMenu.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import doom.DoomMain 5 | 6 | abstract class AbstractDoomMenu( ////////////////////// CONTEXT /////////////////// 7 | val DOOM: DoomMain 8 | ) : IDoomMenu -------------------------------------------------------------------------------- /src/w/IPackableDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.IOException 4 | import java.nio.ByteBuffer 5 | 6 | interface IPackableDoomObject { 7 | @Throws(IOException::class) 8 | fun pack(buf: ByteBuffer) 9 | } -------------------------------------------------------------------------------- /src/w/statenum_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | 4 | enum class statenum_t(private val value: Int) { 5 | NoState(-1), StatCount(0), ShowNextLoc(1); 6 | 7 | fun getValue(): Int { 8 | return value 9 | } 10 | } -------------------------------------------------------------------------------- /src/w/IWritableDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataOutputStream 4 | import java.io.IOException 5 | 6 | interface IWritableDoomObject { 7 | @Throws(IOException::class) 8 | fun write(dos: DataOutputStream) 9 | } -------------------------------------------------------------------------------- /src/rr/IDetailAware.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | interface IDetailAware { 5 | fun setDetail(detailshift: Int) 6 | 7 | companion object { 8 | const val HIGH_DETAIL = 0 9 | const val LOW_DETAIL = 1 10 | } 11 | } -------------------------------------------------------------------------------- /src/savegame/ILoadSaveGame.kt: -------------------------------------------------------------------------------- 1 | package savegame 2 | 3 | 4 | import p.ThinkerList 5 | 6 | interface ILoadSaveGame { 7 | fun setThinkerList(li: ThinkerList?) 8 | fun doSave(li: ThinkerList?) 9 | fun doLoad(li: ThinkerList?) 10 | } -------------------------------------------------------------------------------- /src/m/ISyncLogger.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import java.io.IOException 5 | 6 | interface ISyncLogger { 7 | @Throws(IOException::class) 8 | fun debugStart() 9 | fun debugEnd() 10 | fun sync(format: String?, vararg args: Any?) 11 | } -------------------------------------------------------------------------------- /src/doom/gameaction_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | enum class gameaction_t { 5 | ga_nothing, ga_loadlevel, ga_newgame, ga_loadgame, ga_savegame, ga_playdemo, ga_completed, ga_victory, ga_worlddone, ga_screenshot, ga_failure // HACK: communicate failures silently 6 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/SpanFunction.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | /** Either draws a column or a span 5 | * 6 | * @author velktron 7 | */ 8 | interface SpanFunction { 9 | operator fun invoke() 10 | operator fun invoke(dsvars: SpanVars) 11 | } -------------------------------------------------------------------------------- /src/p/ISightChecker.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import p.mobj_t 5 | 6 | interface ISightChecker { 7 | fun setZStartTopBOttom(zstart: Int, top: Int, bottom: Int) 8 | fun setSTrace(t1: mobj_t?, t2: mobj_t?) 9 | fun CrossBSPNode(bspnum: Int): Boolean 10 | } -------------------------------------------------------------------------------- /src/rr/IGetColumn.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | /** An interface used to ease the use of the GetCachedColumn by part 5 | * of parallelized renderers. 6 | * 7 | * @author Maes 8 | */ 9 | interface IGetColumn { 10 | fun GetColumn(tex: Int, col: Int): T 11 | } -------------------------------------------------------------------------------- /src/doom/playerstate_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | // Player states. 5 | // 6 | enum class playerstate_t { 7 | // Playing or camping. 8 | PST_LIVE, // Dead on the ground, view follows killer. 9 | PST_DEAD, // Ready to restart/respawn??? 10 | PST_REBORN 11 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/doom/evtype_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | /** The possible events according to Doom */ 5 | enum class evtype_t { 6 | ev_null, ev_keydown, ev_keyup, ev_mouse, ev_joystick, ev_mousewheel, // extension 7 | ev_clear // Forcibly clear all button input (e.g. when losing focus) 8 | } -------------------------------------------------------------------------------- /src/rr/IGetCachedColumn.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | /** An interface used to ease the use of the GetCachedColumn by part 5 | * of parallelized renderers. 6 | * 7 | * @author Maes 8 | */ 9 | interface IGetCachedColumn { 10 | fun GetCachedColumn(tex: Int, col: Int): T 11 | } -------------------------------------------------------------------------------- /src/p/vldoor_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | // 5 | // P_DOORS 6 | // 7 | enum class vldoor_e { 8 | normal, close30ThenOpen, close, open, raiseIn5Mins, blazeRaise, blazeOpen, blazeClose; 9 | 10 | companion object { 11 | val VALUES = vldoor_e.values().size 12 | } 13 | } -------------------------------------------------------------------------------- /src/w/li_namespace.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | 4 | /** killough 4/17/98: namespace tags, to prevent conflicts between resources */ 5 | enum class li_namespace { 6 | ns_global, ns_sprites, ns_flats, ns_colormaps, ns_prboom, ns_demos, ns_hires //e6y 7 | } // haleyjd 05/21/02: renamed from "namespace" 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/defines/GameMission_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | /** Mission packs - might be useful for TC stuff? 5 | * 6 | */ 7 | enum class GameMission_t { 8 | doom, // DOOM 1 9 | doom2, // DOOM 2 10 | pack_tnt, // TNT mission pack 11 | pack_plut, // Plutonia pack 12 | none 13 | } -------------------------------------------------------------------------------- /src/timing/FastTicker.kt: -------------------------------------------------------------------------------- 1 | package timing 2 | 3 | class FastTicker : ITicker { 4 | /** 5 | * I_GetTime 6 | * returns time in 1/70th second tics 7 | */ 8 | override fun GetTime(): Int { 9 | return fasttic++ 10 | } 11 | 12 | @Volatile 13 | var fasttic = 0 14 | } -------------------------------------------------------------------------------- /src/m/default_t.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | class default_t( 5 | var name: String, 6 | /** this is supposed to be a pointer */ 7 | var location: IntArray, var defaultvalue: Int 8 | ) { 9 | var scantranslate // PC scan code hack 10 | = 0 11 | var untranslated // lousy hack 12 | = 0 13 | } -------------------------------------------------------------------------------- /src/defines/gamestate_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | /** The current state of the game: whether we are 5 | * playing, gazing at the intermission screen, 6 | * the game final animation, or a demo. */ 7 | enum class gamestate_t { 8 | GS_LEVEL, GS_INTERMISSION, GS_FINALE, GS_DEMOSCREEN, GS_MINUS_ONE // hack used for the "-1" state 9 | } -------------------------------------------------------------------------------- /src/m/DrawRoutine.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | /** menu_t required a function pointer to a (routine)() that drew stuff. 5 | * So any class implementing them will implement this interface, and 6 | * we can have a single class type for all of them. 7 | * 8 | * @author Maes 9 | */ 10 | interface DrawRoutine { 11 | operator fun invoke() 12 | } -------------------------------------------------------------------------------- /src/m/MenuRoutine.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | /** menuitem_t required a function pointer to a (routine)(int choice) 5 | * So any class implementing them will implement this interface, and 6 | * we can have a single class type for all of them. 7 | * 8 | * @author Velktron 9 | */ 10 | interface MenuRoutine { 11 | operator fun invoke(choice: Int) 12 | } -------------------------------------------------------------------------------- /src/rr/ILimitResettable.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | /** Resets limit-removing stuff back to their initial values, 5 | * either for initialization reasons or to regain memory 6 | * e.g. playing MAP02 after nuts.wad should free up some vissprite buffers. 7 | * 8 | * @author admin 9 | */ 10 | interface ILimitResettable { 11 | fun resetLimits() 12 | } -------------------------------------------------------------------------------- /src/p/DoorDefines.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import m.fixed_t 5 | 6 | object DoorDefines { 7 | // Doors 8 | val VDOORSPEED: Int = fixed_t.MAPFRACUNIT * 2 9 | const val VDOORWAIT = 150 10 | 11 | // Lights 12 | const val GLOWSPEED = 5 13 | const val STROBEBRIGHT = 5 14 | const val FASTDARK = 15 15 | const val SLOWDARK = 35 16 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/DcFlags.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | /** Flags used to mark column functions according to type, 5 | * for quick type identification. 6 | * 7 | * @author velktron 8 | */ 9 | object DcFlags { 10 | const val FUZZY = 0x1 11 | const val TRANSLATED = 0x2 12 | const val TRANSPARENT = 0x4 13 | const val LOW_DETAIL = 0x8 14 | } -------------------------------------------------------------------------------- /src/defines/ammotype_t.kt: -------------------------------------------------------------------------------- 1 | package defines 2 | 3 | 4 | //Ammunition types defined. 5 | enum class ammotype_t { 6 | am_clip, // Pistol / chaingun ammo. 7 | am_shell, // Shotgun / double barreled shotgun. 8 | am_cell, // Plasma rifle, BFG. 9 | am_misl, // Missile launcher. 10 | NUMAMMO, 11 | am_noammo // Unlimited for chainsaw / fist. 12 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/ColumnFunction.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | /** Either draws a column or a span 5 | * 6 | * @author velktron 7 | */ 8 | interface ColumnFunction { 9 | operator fun invoke() 10 | operator fun invoke(dcvars: ColVars) 11 | 12 | /** A set of flags that help identifying the type of function */ 13 | fun getFlags(): Int 14 | } -------------------------------------------------------------------------------- /src/rr/cliprange_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | class cliprange_t { 5 | constructor(first: Int, last: Int) { 6 | this.first = first 7 | this.last = last 8 | } 9 | 10 | constructor() {} 11 | 12 | var first = 0 13 | var last = 0 14 | fun copy(from: cliprange_t) { 15 | first = from.first 16 | last = from.last 17 | } 18 | } -------------------------------------------------------------------------------- /src/rr/BSPVars.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | /** Stuff used to pass information between the BSP and the SegDrawer */ 5 | open class BSPVars { 6 | /** The sectors of the line currently being considered */ 7 | var frontsector: sector_t? = null 8 | var backsector: sector_t? = null 9 | var curline: seg_t? = null 10 | var sidedef: side_t? = null 11 | var linedef: line_t? = null 12 | } -------------------------------------------------------------------------------- /src/w/AidedReadableDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataInputStream 4 | import java.io.IOException 5 | 6 | /** This is for objects that can be read from disk, but cannot 7 | * self-determine their own length for some reason. 8 | * 9 | * @author Maes 10 | */ 11 | interface AidedReadableDoomObject { 12 | @Throws(IOException::class) 13 | fun read(f: DataInputStream?, len: Int) 14 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/SpanVars.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | class SpanVars { 5 | var ds_xfrac = 0 6 | var ds_yfrac = 0 7 | var ds_xstep = 0 8 | var ds_source: T? = null 9 | 10 | /** DrawSpan colormap. */ 11 | var ds_colormap: V? = null 12 | var ds_y = 0 13 | var ds_x2 = 0 14 | var ds_x1 = 0 15 | var ds_ystep = 0 16 | var spanfunc: DoomSpanFunction? = null 17 | } -------------------------------------------------------------------------------- /src/f/castinfo_t.kt: -------------------------------------------------------------------------------- 1 | package f 2 | 3 | 4 | import data.mobjtype_t 5 | 6 | /** 7 | * Final DOOM 2 animation Casting by id Software. in order of appearance 8 | */ 9 | class castinfo_t { 10 | var name: String? = null 11 | var type: mobjtype_t? = null 12 | 13 | constructor() {} 14 | constructor(name: String?, type: mobjtype_t?) { 15 | this.name = name 16 | this.type = type 17 | } 18 | } -------------------------------------------------------------------------------- /src/doom/th_class.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | /** killough 8/29/98: threads of thinkers, for more efficient searches 4 | * cph 2002/01/13: for consistency with the main thinker list, keep objects 5 | * pending deletion on a class list too 6 | */ 7 | enum class th_class { 8 | th_delete, th_misc, th_friends, th_enemies, th_all; 9 | 10 | companion object { 11 | val NUMTHCLASS = th_class.values().size 12 | } 13 | } -------------------------------------------------------------------------------- /src/s/AudioChunk.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | class AudioChunk { 4 | fun setStuff(chunk: Int, time: Int) { 5 | this.chunk = chunk 6 | this.time = time 7 | } 8 | 9 | var chunk = 0 10 | var time = 0 11 | var buffer: ByteArray 12 | var free: Boolean 13 | 14 | init { 15 | buffer = ByteArray(ISoundDriver.MIXBUFFERSIZE) 16 | setStuff(0, 0) 17 | free = true 18 | } 19 | } -------------------------------------------------------------------------------- /src/rr/parallel/RWI.kt: -------------------------------------------------------------------------------- 1 | package rr.parallel 2 | 3 | 4 | import rr.drawfuns.ColVars 5 | 6 | interface RWI { 7 | interface Init { 8 | fun InitRWIExecutors(num: Int, RWI: Array?>?): Array?>? 9 | } 10 | 11 | interface Get { 12 | fun getRWI(): Array> 13 | fun setExecutors(RWIExec: Array>) 14 | } 15 | } -------------------------------------------------------------------------------- /src/savegame/IDoomSaveGame.kt: -------------------------------------------------------------------------------- 1 | package savegame 2 | 3 | 4 | import p.ThinkerList 5 | import java.io.DataInputStream 6 | import java.io.DataOutputStream 7 | 8 | interface IDoomSaveGame { 9 | fun setThinkerList(li: ThinkerList?) 10 | fun doLoad(f: DataInputStream): Boolean 11 | fun getHeader(): IDoomSaveGameHeader? 12 | fun setHeader(header: IDoomSaveGameHeader?) 13 | fun doSave(f: DataOutputStream): Boolean 14 | } -------------------------------------------------------------------------------- /src/i/DoomEventInterface.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | /** Interface for Doom-to-System event handling methods 5 | * 6 | * @author Velktron 7 | */ 8 | interface DoomEventInterface { 9 | /** The implementation is windowing subsystem-specific 10 | * e.g. DOS, XServer, AWT or Swing or whatever. 11 | * 12 | */ 13 | fun GetEvent() 14 | fun mouseMoving(): Boolean 15 | fun setMouseMoving(mousMoving: Boolean) 16 | } -------------------------------------------------------------------------------- /src/doom/weapontype_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | /** The defined weapons, 5 | * including a marker indicating 6 | * user has not changed weapon. 7 | */ 8 | enum class weapontype_t { 9 | wp_fist, wp_pistol, wp_shotgun, wp_chaingun, wp_missile, wp_plasma, wp_bfg, wp_chainsaw, wp_supershotgun, NUMWEAPONS, // No pending weapon change. 10 | wp_nochange; 11 | 12 | override fun toString(): String { 13 | return name 14 | } 15 | } -------------------------------------------------------------------------------- /src/m/IRandom.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import data.mobjtype_t 5 | import p.ActiveStates 6 | 7 | interface IRandom { 8 | fun P_Random(): Int 9 | fun M_Random(): Int 10 | fun ClearRandom() 11 | val index: Int 12 | fun P_Random(caller: Int): Int 13 | fun P_Random(message: String?): Int 14 | fun P_Random(caller: ActiveStates?, sequence: Int): Int 15 | fun P_Random(caller: ActiveStates?, type: mobjtype_t?, sequence: Int): Int 16 | } -------------------------------------------------------------------------------- /src/p/ThinkerList.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import doom.SourceCode.P_Tick 5 | import doom.thinker_t 6 | 7 | interface ThinkerList { 8 | @P_Tick.C(P_Tick.P_AddThinker) 9 | fun AddThinker(thinker: thinker_t) 10 | 11 | @P_Tick.C(P_Tick.P_RemoveThinker) 12 | fun RemoveThinker(thinker: thinker_t) 13 | 14 | @P_Tick.C(P_Tick.P_InitThinkers) 15 | fun InitThinkers() 16 | fun getRandomThinker(): thinker_t 17 | fun getThinkerCap(): thinker_t 18 | } -------------------------------------------------------------------------------- /src/rr/SimpleThings.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import v.scale.VideoScale 4 | 5 | /** 6 | * A very "simple" things class which just does serial rendering and uses all 7 | * the base methods from AbstractThings. 8 | * 9 | * @author velktron 10 | * @param 11 | * @param 12 | */ 13 | class SimpleThings(vs: VideoScale, R: SceneRenderer) : AbstractThings(vs, R) { 14 | override fun completeColumn() { 15 | colfunc!!.invoke() 16 | } 17 | } -------------------------------------------------------------------------------- /src/doom/IDoom.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | import java.io.IOException 5 | 6 | /** Stuff that the "main" is supposed to do. DoomMain implements those. 7 | * 8 | * @author Maes 9 | */ 10 | interface IDoom { 11 | /** Called by IO functions when input is detected. */ 12 | fun PostEvent(ev: event_t) 13 | fun PageTicker() 14 | fun PageDrawer() 15 | fun AdvanceDemo() 16 | fun StartTitle() 17 | 18 | @Throws(IOException::class) 19 | fun QuitNetGame() 20 | } -------------------------------------------------------------------------------- /src/hu/IHeadsUp.kt: -------------------------------------------------------------------------------- 1 | package hu 2 | 3 | 4 | import doom.SourceCode.HU_Stuff 5 | import doom.event_t 6 | import rr.patch_t 7 | 8 | interface IHeadsUp { 9 | fun Ticker() 10 | fun Erase() 11 | fun Drawer() 12 | 13 | @HU_Stuff.C(HU_Stuff.HU_Responder) 14 | fun Responder(ev: event_t): Boolean 15 | fun getHUFonts(): Array 16 | fun dequeueChatChar(): Char 17 | fun Init() 18 | fun setChatMacro(i: Int, s: String) 19 | fun Start() 20 | fun Stop() 21 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/ColFuncs.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | class ColFuncs { 5 | var main: DoomColumnFunction? = null 6 | var base: DoomColumnFunction? = null 7 | var masked: DoomColumnFunction? = null 8 | var fuzz: DoomColumnFunction? = null 9 | var trans: DoomColumnFunction? = null 10 | var glass: DoomColumnFunction? = null 11 | var player: DoomColumnFunction? = null 12 | var sky: DoomColumnFunction? = null 13 | } -------------------------------------------------------------------------------- /src/pooling/AudioChunkPool.kt: -------------------------------------------------------------------------------- 1 | package pooling 2 | 3 | 4 | import s.AudioChunk 5 | 6 | // Referenced classes of package pooling: 7 | // ObjectPool 8 | class AudioChunkPool : ObjectQueuePool(10000L) { 9 | override fun create(): AudioChunk { 10 | return AudioChunk() 11 | } 12 | 13 | override fun expire(o: AudioChunk?) { 14 | o!!.free = true 15 | } 16 | 17 | override fun validate(o: AudioChunk?): Boolean { 18 | return o!!.free 19 | } 20 | } -------------------------------------------------------------------------------- /src/p/button_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import rr.line_t 5 | import s.degenmobj_t 6 | 7 | class button_t : Resettable { 8 | var line: line_t? = null 9 | var where: bwhere_e 10 | var btexture = 0 11 | var btimer = 0 12 | var soundorg: degenmobj_t? = null 13 | 14 | init { 15 | where = bwhere_e.top 16 | } 17 | 18 | override fun reset() { 19 | line = null 20 | where = bwhere_e.top 21 | btexture = 0 22 | btimer = 0 23 | soundorg = null 24 | } 25 | } -------------------------------------------------------------------------------- /src/rr/z_vertex_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import java.io.IOException 4 | import java.nio.ByteBuffer 5 | import java.nio.ByteOrder 6 | 7 | class z_vertex_t : vertex_t() { 8 | /** Notice how we auto-expand to fixed_t */ 9 | @Throws(IOException::class) 10 | override fun unpack(buf: ByteBuffer) { 11 | buf.order(ByteOrder.LITTLE_ENDIAN) 12 | x = buf.int 13 | y = buf.int 14 | } 15 | 16 | companion object { 17 | fun sizeOf(): Int { 18 | return 8 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/w/IReadableDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataInputStream 4 | import java.io.IOException 5 | 6 | /** This is an interface implemented by objects that must be read form disk. 7 | * Every object is supposed to do its own umarshalling. This way, 8 | * structured and hierchical reads are possible. Another superior innovation 9 | * of Mocha Doom ;-) Err....ok :-p 10 | * 11 | * @author Velktron 12 | */ 13 | interface IReadableDoomObject { 14 | @Throws(IOException::class) 15 | fun read(f: DataInputStream) 16 | } -------------------------------------------------------------------------------- /kocoa-doom.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/w/wad_source_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | 4 | // CPhipps - defined enum in wider scope 5 | // Ty 08/29/98 - add source field to identify where this lump came from 6 | enum class wad_source_t { 7 | // CPhipps - define elements in order of 'how new/unusual' 8 | source_iwad, // iwad file load 9 | source_pre, // predefined lump 10 | source_auto_load, // lump auto-loaded by config file 11 | source_pwad, // pwad file load 12 | source_lmp, // lmp file load 13 | source_net // CPhipps 14 | , 15 | source_deh, source_err 16 | } -------------------------------------------------------------------------------- /src/p/slidedoor_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import rr.SectorAction 5 | import rr.line_t 6 | import rr.sector_t 7 | 8 | class slidedoor_t : SectorAction() { 9 | var type: sdt_e 10 | var line: line_t? = null 11 | var frame = 0 12 | var whichDoorIndex = 0 13 | var timer = 0 14 | var frontsector: sector_t? = null 15 | var backsector: sector_t? = null 16 | var status: sd_e 17 | 18 | init { 19 | type = sdt_e.sdt_closeOnly 20 | status = sd_e.sd_closing 21 | thinkerFunction = ActiveStates.T_SlidingDoor 22 | } 23 | } -------------------------------------------------------------------------------- /src/rr/parallel/IGetSmpColumn.kt: -------------------------------------------------------------------------------- 1 | package rr.parallel 2 | 3 | 4 | import rr.column_t 5 | 6 | /** An interface used to ease the use of the GetCachedColumn by part 7 | * of parallelized renderers. 8 | * 9 | * @author Maes 10 | */ 11 | /** 12 | * Special version of GetColumn meant to be called concurrently by different 13 | * seg rendering threads, identfiex by index. This serves to avoid stomping 14 | * on mutual cached textures and causing crashes. 15 | * 16 | */ 17 | interface IGetSmpColumn { 18 | fun GetSmpColumn(tex: Int, col: Int, id: Int): column_t? 19 | } -------------------------------------------------------------------------------- /src/data/musicinfo_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | class musicinfo_t { 5 | constructor() {} 6 | constructor(name: String?) { 7 | this.name = name 8 | } 9 | 10 | constructor(name: String?, lumpnum: Int) { 11 | this.name = name 12 | this.lumpnum = lumpnum 13 | } 14 | 15 | // up to 6-character name 16 | var name: String? = null 17 | 18 | // lump number of music 19 | var lumpnum = 0 20 | 21 | // music data 22 | var data: ByteArray? = ByteArray(0) 23 | 24 | // music handle once registered 25 | var handle = 0 26 | } -------------------------------------------------------------------------------- /src/rr/base_ratio_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | class base_ratio_t(// Base width (unused) 5 | var base_width: Int, // Base height (used for wall visibility multiplier) 6 | var base_height: Int, // Psprite offset (needed for "tallscreen" modes) 7 | var psprite_offset: Int, 8 | // Width or height multiplier 9 | var multiplier: Int, gl_ratio: Float 10 | ) { 11 | var gl_ratio: Float 12 | 13 | init { 14 | this.gl_ratio = (base_ratio_t.RMUL * gl_ratio).toFloat() 15 | } 16 | 17 | companion object { 18 | const val RMUL = 1.6 / 1.333333 19 | } 20 | } -------------------------------------------------------------------------------- /src/rr/maskdraw_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | 4 | /** Purpose unknown, probably unused. 5 | * On a closer examination, it could have been part of a system to 6 | * "enqueue" masked draws, not much unlike the current parallel 7 | * rendering subsystem, but discarded because of simplifications. 8 | * In theory it could be brought back one day if parallel sprite 9 | * drawing comes back.. just a thought ;-) 10 | * 11 | * 12 | * @author Maes 13 | */ 14 | class maskdraw_t { 15 | var x1 = 0 16 | var x2 = 0 17 | var column = 0 18 | var topclip = 0 19 | var bottomclip = 0 20 | } -------------------------------------------------------------------------------- /src/rr/texpatch_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** 4 | * A single patch from a texture definition, 5 | * basically a rectangular area within 6 | * the texture rectangle. 7 | * @author admin 8 | */ 9 | class texpatch_t { 10 | // Block origin (allways UL), 11 | // which has allready accounted 12 | // for the internal origin of the patch. 13 | var originx = 0 14 | var originy = 0 15 | var patch = 0 16 | fun copyFromMapPatch(mpp: mappatch_t) { 17 | originx = mpp.originx.toInt() 18 | originy = mpp.originy.toInt() 19 | patch = mpp.patch.toInt() 20 | } 21 | } -------------------------------------------------------------------------------- /src/boom/mapsubsector_znod_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import utils.C2JUtils 5 | import w.CacheableDoomObject 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | class mapsubsector_znod_t : CacheableDoomObject { 11 | var numsegs: Long = 0 12 | @Throws(IOException::class) 13 | override fun unpack(buf: ByteBuffer) { 14 | buf.order(ByteOrder.LITTLE_ENDIAN) 15 | numsegs = C2JUtils.unsigned(buf.int) 16 | } 17 | 18 | companion object { 19 | fun sizeOf(): Int { 20 | return 4 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/rr/SectorAction.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import doom.thinker_t 4 | 5 | /** Used for special sector-based function for doors, ceilings 6 | * etc. that are treated as a thinker by the engine. The sector 7 | * is part of the spec, so extending classes don't need to override 8 | * it. Also, it extends thinker so futher extensions are thinkers too. 9 | * 10 | */ 11 | abstract class SectorAction : thinker_t() { 12 | var sector: sector_t? = null 13 | 14 | /** Special, only used when (un)archiving in order to re-link stuff 15 | * to their proper sector. 16 | */ 17 | var sectorid = 0 18 | } -------------------------------------------------------------------------------- /src/w/wadinfo_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataInputStream 4 | import java.io.IOException 5 | 6 | class wadinfo_t : IReadableDoomObject { 7 | // Should be "IWAD" or "PWAD". 8 | var identification: String? = null 9 | var numlumps: Long = 0 10 | var infotableofs: Long = 0 11 | 12 | /** Reads the wadinfo_t from the file. */ 13 | @Throws(IOException::class) 14 | override fun read(f: DataInputStream) { 15 | identification = DoomIO.readString(f, 4) 16 | numlumps = DoomIO.readUnsignedLEInt(f) 17 | infotableofs = DoomIO.readUnsignedLEInt(f) 18 | } 19 | } -------------------------------------------------------------------------------- /src/rr/flat_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import w.CacheableDoomObject 4 | import java.io.IOException 5 | import java.nio.ByteBuffer 6 | 7 | class flat_t : CacheableDoomObject { 8 | var data: ByteArray 9 | 10 | constructor() { 11 | data = ByteArray(flat_t.FLAT_SIZE) 12 | } 13 | 14 | constructor(size: Int) { 15 | data = ByteArray(size) 16 | } 17 | 18 | @Throws(IOException::class) 19 | override fun unpack(buf: ByteBuffer) { 20 | 21 | //buf.get(this.data); 22 | data = buf.array() 23 | } 24 | 25 | companion object { 26 | const val FLAT_SIZE = 4096 27 | } 28 | } -------------------------------------------------------------------------------- /src/s/degenmobj_t.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | class degenmobj_t : ISoundOrigin { 4 | private val x: Int 5 | private val y: Int 6 | private val z: Int 7 | 8 | constructor(x: Int, y: Int, z: Int) { 9 | this.x = x 10 | this.y = y 11 | this.z = z 12 | } 13 | 14 | constructor(x: Int, y: Int) { 15 | this.x = x 16 | this.y = y 17 | z = 0 18 | } 19 | 20 | override fun getX(): Int { 21 | return x 22 | } 23 | 24 | override fun getY(): Int { 25 | return y 26 | } 27 | 28 | override fun getZ(): Int { 29 | return z 30 | } 31 | } -------------------------------------------------------------------------------- /src/rr/IVisSpriteManagement.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** A sprite manager does everything but drawing the sprites. It creates lists 4 | * of sprites-per-sector, sorts them, and stuff like that. 5 | * that gory visibiliy 6 | * 7 | * @author velkton 8 | * 9 | * @param 10 | */ 11 | interface IVisSpriteManagement : ILimitResettable { 12 | fun AddSprites(sec: sector_t) 13 | 14 | /** Cache the sprite manager, if possible */ 15 | fun cacheSpriteManager(SM: ISpriteManager) 16 | fun SortVisSprites() 17 | fun getNumVisSprites(): Int 18 | fun getVisSprites(): Array> 19 | fun ClearSprites() 20 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings 2 | .classpath 3 | .project 4 | nbproject/private/ 5 | build/ 6 | dist/ 7 | *.wad 8 | *.dsg 9 | build.xml 10 | nbproject/ 11 | 12 | # Intellij 13 | out/ 14 | 15 | ### Generated by GitHub ### 16 | 17 | # Compiled class file 18 | *.class 19 | 20 | # Log file 21 | *.log 22 | 23 | # BlueJ files 24 | *.ctxt 25 | 26 | # Mobile Tools for Java (J2ME) 27 | .mtj.tmp/ 28 | 29 | # Package Files # 30 | *.jar 31 | *.war 32 | *.nar 33 | *.ear 34 | *.zip 35 | *.tar.gz 36 | *.rar 37 | 38 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 39 | hs_err_pid* 40 | -------------------------------------------------------------------------------- /src/doom/NetConsts.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | interface NetConsts { 5 | companion object { 6 | const val NCMD_EXIT = -0x80000000 7 | const val NCMD_RETRANSMIT = 0x40000000 8 | const val NCMD_SETUP = 0x20000000 9 | const val NCMD_KILL = 0x10000000 // kill game 10 | const val NCMD_CHECKSUM = 0x0fffffff 11 | const val DOOMCOM_ID = 0x12345678 12 | 13 | //Networking and tick handling related. Moved to DEFINES 14 | //protected static int BACKUPTICS = 12; 15 | // command_t 16 | const val CMD_SEND: Short = 1 17 | const val CMD_GET: Short = 2 18 | } 19 | } -------------------------------------------------------------------------------- /src/m/menu_t.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | /** General form for a classic, Doom-style menu with a bunch of 5 | * items and a drawing routine (menu_t's don't have action callbacks 6 | * proper, though). 7 | * 8 | * @author Maes 9 | */ 10 | class menu_t( 11 | /** # of menu items */ 12 | var numitems: Int, 13 | /** previous menu */ 14 | var prevMenu: menu_t?, 15 | /** menu items */ 16 | var menuitems: Array, 17 | /** draw routine */ 18 | var routine: DrawRoutine, 19 | /** x,y of menu */ 20 | var x: Int, var y: Int, 21 | /** last item user was on in menu */ 22 | var lastOn: Int 23 | ) -------------------------------------------------------------------------------- /src/timing/ITicker.kt: -------------------------------------------------------------------------------- 1 | package timing 2 | 3 | 4 | import doom.CVarManager 5 | import doom.CommandVariable 6 | import doom.SourceCode.I_IBM 7 | 8 | interface ITicker { 9 | @I_IBM.C(I_IBM.I_GetTime) 10 | fun GetTime(): Int 11 | 12 | companion object { 13 | fun createTicker(CVM: CVarManager): ITicker { 14 | return if (CVM.bool(CommandVariable.MILLIS)) { 15 | MilliTicker() 16 | } else if (CVM.bool(CommandVariable.FASTTIC) || CVM.bool(CommandVariable.FASTDEMO)) { 17 | DelegateTicker() 18 | } else { 19 | NanoTicker() 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/boom/mapglvertex_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** fixed 32 bit gl_vert format v2.0+ (glBsp 1.91) */ 10 | class mapglvertex_t : CacheableDoomObject { 11 | var x = 0 12 | var y // fixed_t 13 | = 0 14 | 15 | @Throws(IOException::class) 16 | override fun unpack(buf: ByteBuffer) { 17 | buf.order(ByteOrder.LITTLE_ENDIAN) 18 | x = buf.int 19 | y = buf.int 20 | } 21 | 22 | companion object { 23 | fun sizeOf(): Int { 24 | return 8 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/p/anim_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | /** Animating textures and planes 5 | * There is another anim_t used in wi_stuff, unrelated. 6 | * 7 | * @author admin 8 | */ 9 | class anim_t { 10 | constructor() {} 11 | constructor( 12 | istexture: Boolean, picnum: Int, basepic: Int, numpics: Int, 13 | speed: Int 14 | ) : super() { 15 | this.istexture = istexture 16 | this.picnum = picnum 17 | this.basepic = basepic 18 | this.numpics = numpics 19 | this.speed = speed 20 | } 21 | 22 | var istexture = false 23 | var picnum = 0 24 | var basepic = 0 25 | var numpics = 0 26 | var speed = 0 27 | } -------------------------------------------------------------------------------- /src/s/channel_t.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import data.sfxinfo_t 4 | import p.mobj_t 5 | import javax.sound.sampled.AudioFormat 6 | import javax.sound.sampled.SourceDataLine 7 | 8 | class channel_t { 9 | /** Currently playing sound. If null, then it's free */ 10 | private var currentSound: DoomSound? = null 11 | var sfxinfo: sfxinfo_t 12 | 13 | // origin of sound (usually a mobj_t). 14 | var origin: mobj_t? = null 15 | 16 | // handle of the sound being played 17 | var handle = 0 18 | var format: AudioFormat? = null 19 | var sfxVolume = 0 20 | var auline: SourceDataLine? = null 21 | 22 | init { 23 | sfxinfo = sfxinfo_t() 24 | } 25 | } -------------------------------------------------------------------------------- /src/boom/mapsubsector_v4_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | class mapsubsector_v4_t : CacheableDoomObject { 10 | var numsegs = 0.toChar() 11 | 12 | /** Index of first one, segs are stored sequentially. */ 13 | var firstseg = 0 14 | @Throws(IOException::class) 15 | override fun unpack(buf: ByteBuffer) { 16 | buf.order(ByteOrder.LITTLE_ENDIAN) 17 | numsegs = buf.char 18 | firstseg = buf.int 19 | } 20 | 21 | companion object { 22 | fun sizeOf(): Int { 23 | return 6 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/automap/mpoint_t.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | 4 | import m.fixed_t 5 | 6 | class mpoint_t { 7 | constructor(x: fixed_t, y: fixed_t) { 8 | this.x = x.`val` 9 | this.y = y.`val` 10 | } 11 | 12 | constructor(x: Int, y: Int) { 13 | this.x = x 14 | this.y = y 15 | } 16 | 17 | constructor(x: Double, y: Double) { 18 | this.x = x.toInt() 19 | this.y = y.toInt() 20 | } 21 | 22 | constructor() { 23 | x = 0 24 | y = 0 25 | } 26 | 27 | /** fixed_t */ 28 | var x: Int 29 | var y: Int 30 | override fun toString(): String { 31 | return Integer.toHexString(x) + " , " + Integer.toHexString(y) 32 | } 33 | } -------------------------------------------------------------------------------- /src/demo/IDemoTicCmd.kt: -------------------------------------------------------------------------------- 1 | package demo 2 | 3 | 4 | import doom.ticcmd_t 5 | import w.IWritableDoomObject 6 | 7 | /** Demo Tic Commands can be read/written to disk/buffers, 8 | * and are not necessarily equal to the in-game ticcmd_t. 9 | * Thus, it's necessary for them to implement some 10 | * adaptor method (both ways). 11 | * 12 | * @author admin 13 | */ 14 | interface IDemoTicCmd : IWritableDoomObject { 15 | /** Decode this IDemoTicCmd into a standard ticcmd_t. 16 | * 17 | * @param source 18 | */ 19 | fun decode(dest: ticcmd_t) 20 | 21 | /** Encode this IDemoTicCmd from a standard ticcmd_t. 22 | * 23 | * @param dest 24 | */ 25 | fun encode(source: ticcmd_t) 26 | } -------------------------------------------------------------------------------- /src/rr/SegVars.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import data.Limits 4 | import utils.C2JUtils 5 | 6 | class SegVars { 7 | // /// FROM BSP ///////// 8 | var MAXDRAWSEGS = Limits.MAXDRAWSEGS 9 | 10 | /** pointer to drawsegs */ 11 | var ds_p = 0 12 | lateinit var drawsegs: Array 13 | lateinit var maskedtexturecol: ShortArray 14 | var pmaskedtexturecol = 0 15 | 16 | /** 17 | * R_ClearDrawSegs 18 | * 19 | * The drawseg list is reset by pointing back at 0. 20 | * 21 | */ 22 | fun ClearDrawSegs() { 23 | ds_p = 0 24 | } 25 | 26 | fun ResizeDrawsegs() { 27 | drawsegs = C2JUtils.resize(drawsegs[0], drawsegs, drawsegs.size * 2) 28 | } 29 | } -------------------------------------------------------------------------------- /src/data/mapsubsector_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** SubSector, as generated by BSP. */ 10 | class mapsubsector_t : CacheableDoomObject { 11 | var numsegs = 0.toChar() 12 | 13 | /** Index of first one, segs are stored sequentially. */ 14 | var firstseg = 0.toChar() 15 | @Throws(IOException::class) 16 | override fun unpack(buf: ByteBuffer) { 17 | buf.order(ByteOrder.LITTLE_ENDIAN) 18 | numsegs = buf.char 19 | firstseg = buf.char 20 | } 21 | 22 | companion object { 23 | fun sizeOf(): Int { 24 | return 4 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/i/IDiskDrawer.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | interface IDiskDrawer : IDrawer { 5 | /** 6 | * Set a timeout (in tics) for displaying the disk icon 7 | * 8 | * @param timeout 9 | */ 10 | fun setReading(reading: Int) 11 | 12 | /** 13 | * Disk displayer is currently active 14 | * 15 | * @return 16 | */ 17 | fun isReading(): Boolean 18 | 19 | /** 20 | * Only call after the Wadloader is instantiated and initialized itself. 21 | * 22 | */ 23 | fun Init() 24 | 25 | /** 26 | * Status only valid after the last tic has been drawn. Use to know when to redraw status bar. 27 | * 28 | * @return 29 | */ 30 | fun justDoneReading(): Boolean 31 | } -------------------------------------------------------------------------------- /src/rr/IMaskedDrawer.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** Draws any masked stuff -sprites, textures, or special 3D floors */ 4 | interface IMaskedDrawer : IDetailAware { 5 | /** Cache the sprite manager, if possible */ 6 | fun cacheSpriteManager(SM: ISpriteManager) 7 | fun DrawMasked() 8 | fun setPspriteIscale(i: Int) 9 | fun setPspriteScale(i: Int) 10 | 11 | /** 12 | * For serial masked drawer, just complete the column function. For 13 | * parallel version, store rendering instructions and execute later on. 14 | * HINT: you need to discern between masked and non-masked draws. 15 | */ 16 | fun completeColumn() 17 | 18 | companion object { 19 | const val BASEYCENTER = 100 20 | } 21 | } -------------------------------------------------------------------------------- /src/timing/MilliTicker.kt: -------------------------------------------------------------------------------- 1 | package timing 2 | 3 | 4 | import data.Defines 5 | 6 | class MilliTicker : ITicker { 7 | /** 8 | * I_GetTime 9 | * returns time in 1/70th second tics 10 | */ 11 | override fun GetTime(): Int { 12 | val tp: Long 13 | //struct timezone tzp; 14 | val newtics: Int 15 | tp = System.currentTimeMillis() 16 | if (basetime == 0L) { 17 | basetime = tp 18 | } 19 | newtics = ((tp - basetime) * Defines.TICRATE / 1000).toInt() 20 | return newtics 21 | } 22 | 23 | @Volatile 24 | var basetime: Long = 0 25 | 26 | @Volatile 27 | var oldtics = 0 28 | 29 | @Volatile 30 | protected var discrepancies = 0 31 | } -------------------------------------------------------------------------------- /src/p/floor_e.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | enum class floor_e { 5 | // lower floor to highest surrounding floor 6 | lowerFloor, // lower floor to lowest surrounding floor 7 | lowerFloorToLowest, // lower floor to highest surrounding floor VERY FAST 8 | turboLower, // raise floor to lowest surrounding CEILING 9 | raiseFloor, // raise floor to next highest surrounding floor 10 | raiseFloorToNearest, // raise floor to shortest height texture around it 11 | raiseToTexture, // lower floor to lowest surrounding floor 12 | 13 | // and change floorpic 14 | lowerAndChange, raiseFloor24, raiseFloor24AndChange, raiseFloorCrush, // raise to next highest floor, turbo-speed 15 | raiseFloorTurbo, donutRaise, raiseFloor512 16 | } -------------------------------------------------------------------------------- /src/data/mobjinfo_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import data.sounds.sfxenum_t 5 | import defines.statenum_t 6 | 7 | class mobjinfo_t( 8 | var doomednum: Int, var spawnstate: statenum_t, var spawnhealth: Int, 9 | var seestate: statenum_t, var seesound: sfxenum_t, var reactiontime: Int, 10 | var attacksound: sfxenum_t, var painstate: statenum_t, 11 | var painchance: Int, var painsound: sfxenum_t, 12 | var meleestate: statenum_t, var missilestate: statenum_t, 13 | var deathstate: statenum_t, var xdeathstate: statenum_t, 14 | var deathsound: sfxenum_t, var speed: Int, var radius: Int, var height: Int, 15 | var mass: Int, var damage: Int, var activesound: sfxenum_t, var flags: Int, //TODO: was flags: Long 16 | var raisestate: statenum_t 17 | ) -------------------------------------------------------------------------------- /src/boom/mapseg_znod_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** ZDoom node? 10 | * 11 | */ 12 | class mapseg_znod_t : CacheableDoomObject { 13 | var v1 = 0 14 | var v2 // Those are unsigned :-/ 15 | = 0 16 | var linedef = 0.toChar() 17 | var side: Byte = 0 18 | @Throws(IOException::class) 19 | override fun unpack(buf: ByteBuffer) { 20 | buf.order(ByteOrder.LITTLE_ENDIAN) 21 | v1 = buf.int 22 | v2 = buf.int 23 | linedef = buf.char 24 | side = buf.get() 25 | } 26 | 27 | companion object { 28 | fun sizeOf(): Int { 29 | return 11 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/p/DoomPlayer.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | import m.fixed_t 4 | 5 | 6 | interface DoomPlayer { 7 | fun AimLineAttack( 8 | t1: mobj_t?, 9 | angle: Int, 10 | distance: fixed_t? 11 | ): fixed_t? 12 | 13 | fun LineAttack( 14 | t1: mobj_t?, 15 | angle: Int, 16 | distance: fixed_t?, 17 | slope: fixed_t?, 18 | damage: Int 19 | ) 20 | 21 | fun RadiusAttack( 22 | spot: mobj_t?, 23 | source: mobj_t?, 24 | damage: Int 25 | ) 26 | 27 | fun TouchSpecialThing( 28 | special: mobj_t?, 29 | toucher: mobj_t? 30 | ) 31 | 32 | fun DamageMobj( 33 | target: mobj_t?, 34 | inflictor: mobj_t?, 35 | source: mobj_t?, 36 | damage: Int 37 | ) 38 | } -------------------------------------------------------------------------------- /src/automap/fline_t.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | class fline_t { 4 | /* 5 | * public fline_t(){ 6 | a=new fpoint_t(); 7 | b=new fpoint_t(); 8 | } 9 | 10 | public fline_t(fpoint_t a, fpoint_t b){ 11 | this.a=a; 12 | this.b=b; 13 | } 14 | */ 15 | constructor(ax: Int, ay: Int, bx: Int, by: Int) { 16 | this.ay = ay 17 | this.ax = ax 18 | this.by = by 19 | this.bx = bx 20 | } 21 | 22 | constructor() { 23 | // TODO Auto-generated constructor stub 24 | } 25 | 26 | var ax = 0 27 | var ay = 0 28 | var bx = 0 29 | var by = 0 /* 30 | public fpoint_t a, b; 31 | 32 | public void reset() { 33 | this.a.x=0; 34 | this.a.y=0; 35 | this.b.x=0; 36 | this.b.y=0; 37 | 38 | }*/ 39 | } -------------------------------------------------------------------------------- /src/n/DummyNetworkHandler.kt: -------------------------------------------------------------------------------- 1 | package n 2 | 3 | 4 | import doom.IDoomGameNetworking 5 | import doom.doomcom_t 6 | 7 | class DummyNetworkHandler : IDoomGameNetworking { 8 | override fun NetUpdate() { 9 | // TODO Auto-generated method stub 10 | } 11 | 12 | override fun TryRunTics() { 13 | // TODO Auto-generated method stub 14 | } 15 | 16 | override fun getDoomCom(): doomcom_t? { 17 | // TODO Auto-generated method stub 18 | return null 19 | } 20 | 21 | override fun setDoomCom(doomcom: doomcom_t?) { 22 | // TODO Auto-generated method stub 23 | } 24 | 25 | override fun getTicdup(): Int { 26 | // TODO Auto-generated method stub 27 | return 0 28 | } 29 | 30 | override fun setTicdup(ticdup: Int) { 31 | // TODO Auto-generated method stub 32 | } 33 | } -------------------------------------------------------------------------------- /src/w/wadfile_info_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.InputStream 4 | import java.util.zip.ZipEntry 5 | 6 | // CPhipps - changed wad init 7 | // We _must_ have the wadfiles[] the same as those actually loaded, so there 8 | // is no point having these separate entities. This belongs here. 9 | class wadfile_info_t { 10 | var name // Also used as a resource identifier, so save with full path and all. 11 | : String? = null 12 | var entry // Secondary resource identifier e.g. files inside zip archives. 13 | : ZipEntry? = null 14 | var type // as per InputStreamSugar 15 | = 0 16 | var src: wad_source_t? = null 17 | var handle: InputStream? = null 18 | var cached // Whether we use local caching e.g. for URL or zips 19 | = false 20 | var maxsize: Long = -1 // Update when known for sure. Will speed up seeking. 21 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/DoomSpanFunction.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | import i.IDoomSystem 5 | 6 | abstract class DoomSpanFunction( 7 | protected val SCREENWIDTH: Int, 8 | protected val SCREENHEIGHT: Int, 9 | protected val ylookup: IntArray, 10 | protected val columnofs: IntArray, 11 | protected var dsvars: SpanVars, 12 | protected val screen: V, 13 | protected val I: IDoomSystem 14 | ) : SpanFunction { 15 | protected val RANGECHECK = false 16 | protected fun doRangeCheck() { 17 | if (dsvars.ds_x2 < dsvars.ds_x1 || dsvars.ds_x1 < 0 || dsvars.ds_x2 >= SCREENWIDTH || dsvars.ds_y > SCREENHEIGHT) { 18 | I.Error("R_DrawSpan: %d to %d at %d", dsvars.ds_x1, dsvars.ds_x2, dsvars.ds_y) 19 | } 20 | } 21 | 22 | override fun invoke(dsvars: SpanVars) { 23 | this.dsvars = dsvars 24 | invoke() 25 | } 26 | } -------------------------------------------------------------------------------- /src/data/mapvertex_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** 10 | * This is the structure of a map vertex ON DISK: in memory it gets shifted and 11 | * expanded to fixed_t. Also, on disk it only exists as part of the VERTEXES 12 | * lump: it is not individually cacheable, even though it implements 13 | * CacheableDoomObject. 14 | */ 15 | class mapvertex_t /*@JvmOverloads*/ constructor(var x: Short = 0.toShort(), var y: Short = 0.toShort()) : 16 | CacheableDoomObject { 17 | @Throws(IOException::class) 18 | override fun unpack(buf: ByteBuffer) { 19 | buf.order(ByteOrder.LITTLE_ENDIAN) 20 | x = buf.short 21 | y = buf.short 22 | } 23 | 24 | companion object { 25 | fun sizeOf(): Int { 26 | return 4 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/doom/KeyboardManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package doom 19 | 20 | 21 | /** 22 | * 23 | * @author Good Sign 24 | */ 25 | class KeyboardManager -------------------------------------------------------------------------------- /src/doom/IDoomGameNetworking.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | import java.io.IOException 5 | 6 | /** Doom is actually tied to its networking module. 7 | * Therefore, no matter where and how you implement it, these functions 8 | * need to be callable from within many modules. 9 | * 10 | * This is the so called "game networking" which is internal and game-specific, 11 | * and not system networking which deals with the low level sockets and packet 12 | * stuff. You'll need DoomSystemNetworking for that one. 13 | * 14 | * @author Velktron 15 | */ 16 | interface IDoomGameNetworking { 17 | @Throws(IOException::class) 18 | fun TryRunTics() 19 | 20 | /** 21 | * NetUpdate 22 | * Builds ticcmds for console player, 23 | * sends out a packet 24 | * @throws IOException 25 | */ 26 | fun NetUpdate() 27 | fun getDoomCom(): doomcom_t? 28 | fun setDoomCom(doomcom: doomcom_t?) 29 | fun getTicdup(): Int 30 | fun setTicdup(ticdup: Int) 31 | } -------------------------------------------------------------------------------- /src/p/slidename_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | class slidename_t { 5 | constructor() {} 6 | constructor( 7 | frontFrame1: String?, frontFrame2: String?, 8 | frontFrame3: String?, frontFrame4: String?, backFrame1: String?, 9 | backFrame2: String?, backFrame3: String?, backFrame4: String? 10 | ) { 11 | this.frontFrame1 = frontFrame1 12 | this.frontFrame2 = frontFrame2 13 | this.frontFrame3 = frontFrame3 14 | this.frontFrame4 = frontFrame4 15 | this.backFrame1 = backFrame1 16 | this.backFrame2 = backFrame2 17 | this.backFrame3 = backFrame3 18 | this.backFrame4 = backFrame4 19 | } 20 | 21 | var frontFrame1: String? = null 22 | var frontFrame2: String? = null 23 | var frontFrame3: String? = null 24 | var frontFrame4: String? = null 25 | var backFrame1: String? = null 26 | var backFrame2: String? = null 27 | var backFrame3: String? = null 28 | var backFrame4: String? = null 29 | } -------------------------------------------------------------------------------- /default.cfg: -------------------------------------------------------------------------------- 1 | mouse_sensitivity 5 2 | sfx_volume 8 3 | music_volume 8 4 | show_messages 1 5 | key_right 106 6 | key_left 105 7 | key_up 17 8 | key_down 31 9 | key_strafeleft 30 10 | key_straferight 32 11 | key_fire 29 12 | key_use 57 13 | key_strafe 56 14 | key_speed 54 15 | use_mouse 1 16 | mouseb_fire 0 17 | mouseb_strafe 1 18 | mouseb_forward 2 19 | use_joystick 0 20 | joyb_fire 0 21 | joyb_strafe 1 22 | joyb_use 3 23 | joyb_speed 2 24 | screenblocks 10 25 | detaillevel 0 26 | snd_channels 8 27 | snd_musicdevice 3 28 | snd_sfxdevice 3 29 | snd_sbport 0 30 | snd_sbirq 0 31 | snd_sbdma 0 32 | snd_mport 0 33 | usegamma 0 34 | chatmacro0 "No" 35 | chatmacro1 "I'm ready to kick butt!" 36 | chatmacro2 "I'm OK." 37 | chatmacro3 "I'm not looking too good!" 38 | chatmacro4 "Help!" 39 | chatmacro5 "You suck!" 40 | chatmacro6 "Next time, scumbag..." 41 | chatmacro7 "Come here!" 42 | chatmacro8 "I'll take care of it." 43 | chatmacro9 "Yes" 44 | -------------------------------------------------------------------------------- /src/s/DMXSound.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import w.CacheableDoomObject 4 | import java.io.IOException 5 | import java.nio.BufferUnderflowException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** An object representation of Doom's sound format */ 10 | class DMXSound : CacheableDoomObject { 11 | /** ushort, all Doom samples are "type 3". No idea how */ 12 | var type = 0 13 | 14 | /** ushort, speed in Hz. */ 15 | var speed = 0 16 | 17 | /** uint */ 18 | var datasize = 0 19 | lateinit var data: ByteArray 20 | @Throws(IOException::class) 21 | override fun unpack(buf: ByteBuffer) { 22 | buf.order(ByteOrder.LITTLE_ENDIAN) 23 | type = buf.char.code 24 | speed = buf.char.code 25 | datasize = try { 26 | buf.int 27 | } catch (e: BufferUnderflowException) { 28 | buf.capacity() - buf.position() 29 | } 30 | data = ByteArray(Math.min(buf.remaining(), datasize)) 31 | buf[data] 32 | } 33 | } -------------------------------------------------------------------------------- /src/i/IDoomSystem.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | import doom.ticcmd_t 5 | 6 | interface IDoomSystem { 7 | fun AllocLow(length: Int) 8 | fun BeginRead() 9 | fun EndRead() 10 | fun WaitVBL(count: Int) 11 | fun ZoneBase(size: Int): ByteArray? 12 | fun GetHeapSize(): Int 13 | fun Tactile(on: Int, off: Int, total: Int) 14 | fun Quit() 15 | fun BaseTiccmd(): ticcmd_t? 16 | fun Error(error: String?, vararg args: Any?) 17 | fun Error(error: String?) 18 | fun Init() 19 | 20 | /** Generate a blocking alert with the intention of continuing or aborting 21 | * a certain game-altering action. E.g. loading PWADs, or upon critical 22 | * level loading failures. This can be either a popup panel or console 23 | * message. 24 | * 25 | * @param cause Provide a clear string explaining why the alert was generated 26 | * @return true if we should continue, false if an alternate action should be taken. 27 | */ 28 | fun GenerateAlert(title: String?, cause: String?): Boolean 29 | } -------------------------------------------------------------------------------- /src/m/menuitem_t.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import g.Signals.ScanCode 5 | 6 | class menuitem_t { 7 | constructor(status: Int, name: String, routine: MenuRoutine, alphaKey: ScanCode?) { 8 | this.status = status 9 | this.name = name 10 | this.routine = routine 11 | this.alphaKey = alphaKey 12 | } 13 | 14 | constructor(status: Int, name: String, routine: MenuRoutine?) { 15 | this.status = status 16 | this.name = name 17 | this.routine = routine 18 | } 19 | 20 | /** 21 | * 0 = no cursor here, 1 = ok, 2 = arrows ok 22 | */ 23 | var status: Int 24 | var name: String 25 | 26 | // choice = menu item #. 27 | // if status = 2, 28 | // choice=0:leftarrow,1:rightarrow 29 | // MAES: OK... to probably we need some sort of "MenuRoutine" class for this one. 30 | // void (*routine)(int choice); 31 | var routine: MenuRoutine? = null 32 | 33 | /** 34 | * hotkey in menu 35 | */ 36 | var alphaKey: ScanCode? = null 37 | } -------------------------------------------------------------------------------- /src/i/DiskDrawer.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | import doom.DoomMain 5 | import rr.patch_t 6 | import v.renderers.DoomScreen 7 | 8 | class DiskDrawer(private val DOOM: DoomMain<*, *>, private val diskname: String) : IDiskDrawer { 9 | private var disk: patch_t? = null 10 | private var timer = 0 11 | override fun Init() { 12 | disk = DOOM.wadLoader.CachePatchName(diskname) 13 | } 14 | 15 | override fun Drawer() { 16 | if (timer > 0) { 17 | if (timer % 2 == 0) DOOM.graphicSystem.DrawPatchScaled(DoomScreen.FG, disk!!, DOOM.vs, 304, 184) 18 | } 19 | if (timer >= 0) timer-- 20 | } 21 | 22 | override fun setReading(reading: Int) { 23 | timer = reading 24 | } 25 | 26 | override fun isReading(): Boolean { 27 | return timer > 0 28 | } 29 | 30 | override fun justDoneReading(): Boolean { 31 | return timer == 0 32 | } 33 | 34 | companion object { 35 | const val STDISK = "STDISK" 36 | const val STCDROM = "STCDROM" 37 | } 38 | } -------------------------------------------------------------------------------- /src/boom/mapseg_v4_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** 10 | * LineSeg, generated by splitting LineDefs 11 | * using partition lines selected by BSP builder. 12 | * MAES: this is the ON-DISK structure. The corresponding memory structure, 13 | * segs_t, has fixed_t members. 14 | */ 15 | class mapseg_v4_t : CacheableDoomObject { 16 | var v1 = 0 17 | var v2 = 0 18 | var angle = 0.toChar() 19 | var linedef = 0.toChar() 20 | var side = 0.toChar() 21 | var offset = 0.toChar() 22 | @Throws(IOException::class) 23 | override fun unpack(buf: ByteBuffer) { 24 | buf.order(ByteOrder.LITTLE_ENDIAN) 25 | v1 = buf.int 26 | v2 = buf.int 27 | angle = buf.char 28 | linedef = buf.char 29 | side = buf.char 30 | offset = buf.char 31 | } 32 | 33 | companion object { 34 | fun sizeOf(): Int { 35 | return 16 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/savegame/IDoomSaveGameHeader.kt: -------------------------------------------------------------------------------- 1 | package savegame 2 | 3 | 4 | import defines.skill_t 5 | 6 | /** A Save Game Header should be able to be loaded quickly and return 7 | * some basic info about it (name, version, game time, etc.) in an unified 8 | * manner, no matter what actual format you use for saving. 9 | * 10 | * @author admin 11 | */ 12 | interface IDoomSaveGameHeader { 13 | fun getName(): String? 14 | fun setName(name: String?) 15 | fun getGameskill(): skill_t? 16 | fun setGameskill(gameskill: skill_t?) 17 | fun getVersion(): String? 18 | fun setVersion(vcheck: String?) 19 | fun getGameepisode(): Int 20 | fun setGameepisode(gameepisode: Int) 21 | fun isProperend(): Boolean 22 | fun setWrongversion(wrongversion: Boolean) 23 | fun isWrongversion(): Boolean 24 | fun setLeveltime(leveltime: Int) 25 | fun getLeveltime(): Int 26 | fun setPlayeringame(playeringame: BooleanArray) 27 | fun getPlayeringame(): BooleanArray 28 | fun setGamemap(gamemap: Int) 29 | fun getGamemap(): Int 30 | } -------------------------------------------------------------------------------- /src/rr/vertex_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import m.fixed_t.Companion.FRACBITS 4 | import p.Resettable 5 | import w.CacheableDoomObject 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** This is the vertex structure used IN MEMORY with fixed-point arithmetic. 11 | * It's DIFFERENT than the one used on disk, which has 16-bit signed shorts. 12 | * However, it must be parsed. 13 | * 14 | */ 15 | open class vertex_t : CacheableDoomObject, Resettable { 16 | /** treat as (fixed_t) */ 17 | var x = 0 18 | var y = 0 19 | 20 | /** Notice how we auto-expand to fixed_t */ 21 | @Throws(IOException::class) 22 | override fun unpack(buf: ByteBuffer) { 23 | buf.order(ByteOrder.LITTLE_ENDIAN) 24 | x = buf.short.toInt() shl FRACBITS 25 | y = buf.short.toInt() shl FRACBITS 26 | } 27 | 28 | override fun reset() { 29 | x = 0 30 | y = 0 31 | } 32 | 33 | companion object { 34 | fun sizeOf(): Int { 35 | return 4 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/rr/mappatch_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import w.CacheableDoomObject 4 | import java.io.IOException 5 | import java.nio.ByteBuffer 6 | import java.nio.ByteOrder 7 | 8 | /** 9 | * Texture definition. 10 | * Each texture is composed of one or more patches, 11 | * with patches being lumps stored in the WAD. 12 | * The lumps are referenced by number, and patched 13 | * into the rectangular texture space using origin 14 | * and possibly other attributes. 15 | */ 16 | class mappatch_t : CacheableDoomObject { 17 | var originx: Short = 0 18 | var originy: Short = 0 19 | var patch: Short = 0 20 | var stepdir: Short = 0 21 | var colormap: Short = 0 22 | @Throws(IOException::class) 23 | override fun unpack(buf: ByteBuffer) { 24 | buf.order(ByteOrder.LITTLE_ENDIAN) 25 | originx = buf.short 26 | originy = buf.short 27 | patch = buf.short 28 | stepdir = buf.short 29 | colormap = buf.short 30 | } 31 | 32 | companion object { 33 | fun size(): Int { 34 | return 10 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/s/DummyMusic.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | class DummyMusic : IMusic { 4 | override fun InitMusic() { 5 | // TODO Auto-generated method stub 6 | } 7 | 8 | override fun ShutdownMusic() { 9 | // TODO Auto-generated method stub 10 | } 11 | 12 | override fun SetMusicVolume(volume: Int) { 13 | // TODO Auto-generated method stub 14 | } 15 | 16 | override fun PauseSong(handle: Int) { 17 | // TODO Auto-generated method stub 18 | } 19 | 20 | override fun ResumeSong(handle: Int) { 21 | // TODO Auto-generated method stub 22 | } 23 | 24 | override fun RegisterSong(data: ByteArray?): Int { 25 | // TODO Auto-generated method stub 26 | return 0 27 | } 28 | 29 | override fun PlaySong(handle: Int, looping: Boolean) { 30 | // TODO Auto-generated method stub 31 | } 32 | 33 | override fun StopSong(handle: Int) { 34 | // TODO Auto-generated method stub 35 | } 36 | 37 | override fun UnRegisterSong(handle: Int) { 38 | // TODO Auto-generated method stub 39 | } 40 | } -------------------------------------------------------------------------------- /src/doom/IDoomGame.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | import defines.skill_t 5 | 6 | /** Groups functions formerly in d_game, 7 | * in case you want to provide a different implementation 8 | */ 9 | interface IDoomGame { 10 | fun ExitLevel() 11 | fun WorldDone() 12 | fun CheckDemoStatus(): Boolean 13 | 14 | /** Can be called by the startup code or M_Responder. 15 | * A normal game starts at map 1, 16 | * but a warp test can start elsewhere */ 17 | fun DeferedInitNew(skill: skill_t?, episode: Int, map: Int) 18 | 19 | /** Can be called by the startup code or M_Responder, 20 | * calls P_SetupLevel or W_EnterWorld. */ 21 | fun LoadGame(name: String?) 22 | 23 | /** Called by M_Responder. */ 24 | fun SaveGame(slot: Int, description: String) 25 | 26 | /** Takes a screenshot *NOW* 27 | * 28 | */ 29 | fun ScreenShot() 30 | fun StartTitle() 31 | fun getGameAction(): gameaction_t 32 | fun setGameAction(ga: gameaction_t) 33 | 34 | // public void PlayerReborn(int player); 35 | fun DeathMatchSpawnPlayer(playernum: Int) 36 | } -------------------------------------------------------------------------------- /.idea/artifacts/kocoa-doom_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/kocoa-doom_jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/data/maplinedef_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** 11 | * A LineDef, as used for editing, and as input to the BSP builder. 12 | */ 13 | class maplinedef_t : CacheableDoomObject { 14 | var v1 = 0.toChar() 15 | var v2 = 0.toChar() 16 | var flags: Short = 0 17 | var special: Short = 0 18 | var tag: Short = 0 19 | 20 | /** sidenum[1] will be 0xFFFF if one sided */ 21 | var sidenum: CharArray 22 | 23 | init { 24 | sidenum = CharArray(2) 25 | } 26 | 27 | @Throws(IOException::class) 28 | override fun unpack(buf: ByteBuffer) { 29 | buf.order(ByteOrder.LITTLE_ENDIAN) 30 | v1 = buf.char 31 | v2 = buf.char 32 | flags = buf.short 33 | special = buf.short 34 | tag = buf.short 35 | DoomBuffer.readCharArray(buf, sidenum, 2) 36 | } 37 | 38 | companion object { 39 | fun sizeOf(): Int { 40 | return 14 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/p/intercept_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import doom.SourceCode 5 | import p.mobj_t 6 | import rr.line_t 7 | 8 | /** 9 | * An object that carries...interception information, I guess...with either a line 10 | * or an object? 11 | * 12 | * @author Velktron 13 | */ 14 | class intercept_t { 15 | /** 16 | * most intercepts will belong to a static pool 17 | */ 18 | constructor() {} 19 | constructor(frac: Int, thing: mobj_t?) { 20 | this.frac = frac 21 | this.thing = thing 22 | isaline = false 23 | } 24 | 25 | constructor(frac: Int, line: line_t?) { 26 | this.frac = frac 27 | this.line = line 28 | isaline = true 29 | } 30 | 31 | /** 32 | * fixed_t, along trace line 33 | */ 34 | @SourceCode.fixed_t 35 | var frac = 0 36 | var isaline = false 37 | 38 | // MAES: this was an union of a mobj_t and a line_t, 39 | // returned as "d". 40 | var thing: mobj_t? = null 41 | var line: line_t? = null 42 | fun d(): Interceptable? { 43 | return if (isaline) line else thing 44 | } 45 | } -------------------------------------------------------------------------------- /src/rr/parallel/RenderSegInstruction.kt: -------------------------------------------------------------------------------- 1 | package rr.parallel 2 | 3 | 4 | /** This is all the information needed to draw a particular SEG. 5 | * It's quite a lot, actually, but much better than in testing 6 | * versions. 7 | * 8 | */ 9 | class RenderSegInstruction { 10 | var rw_x = 0 11 | var rw_stopx = 0 12 | var toptexture = 0 13 | var midtexture = 0 14 | var bottomtexture = 0 15 | var pixhigh = 0 16 | var pixlow = 0 17 | var pixhighstep = 0 18 | var pixlowstep = 0 19 | var topfrac = 0 20 | var topstep = 0 21 | var bottomfrac = 0 22 | var bottomstep = 0 23 | var segtextured = false 24 | var markfloor = false 25 | var markceiling = false 26 | var rw_centerangle // angle_t 27 | : Long = 0 28 | 29 | /** fixed_t */ 30 | var rw_offset = 0 31 | var rw_distance = 0 32 | var rw_scale = 0 33 | var rw_scalestep = 0 34 | var rw_midtexturemid = 0 35 | var rw_toptexturemid = 0 36 | var rw_bottomtexturemid = 0 37 | var viewheight = 0 38 | lateinit var walllights: Array 39 | var centery = 0 40 | } -------------------------------------------------------------------------------- /src/timing/NanoTicker.kt: -------------------------------------------------------------------------------- 1 | package timing 2 | 3 | 4 | import data.Defines 5 | 6 | class NanoTicker : ITicker { 7 | /** 8 | * I_GetTime 9 | * returns time in 1/70th second tics 10 | */ 11 | override fun GetTime(): Int { 12 | val tp: Long 13 | //struct timezone tzp; 14 | val newtics: Int 15 | 16 | // Attention: System.nanoTime() might not be consistent across multicore CPUs. 17 | // To avoid the core getting back to the past, 18 | tp = System.nanoTime() 19 | if (basetime == 0L) { 20 | basetime = tp 21 | } 22 | newtics = ((tp - basetime) * Defines.TICRATE / 1000000000).toInt() // + tp.tv_usec*TICRATE/1000000; 23 | if (newtics < oldtics) { 24 | System.err.printf("Timer discrepancies detected : %d", ++discrepancies) 25 | return oldtics 26 | } 27 | return newtics.also { oldtics = it } 28 | } 29 | 30 | @Volatile 31 | var basetime: Long = 0 32 | 33 | @Volatile 34 | var oldtics = 0 35 | 36 | @Volatile 37 | protected var discrepancies = 0 38 | } -------------------------------------------------------------------------------- /src/n/DoomSystemNetworking.kt: -------------------------------------------------------------------------------- 1 | package n 2 | 3 | 4 | //----------------------------------------------------------------------------- 5 | // 6 | // $Id: DoomSystemNetworking.java,v 1.1 2010/11/17 23:55:06 velktron Exp $ 7 | // 8 | // Copyright (C) 1993-1996 by id Software, Inc. 9 | // Copyright (C) 2022 hiperbou 10 | // 11 | // This program is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License 13 | // as published by the Free Software Foundation; either version 2 14 | // of the License, or (at your option) any later version. 15 | // 16 | // This program is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // DESCRIPTION: 22 | // System specific network interface stuff. 23 | // 24 | //----------------------------------------------------------------------------- 25 | interface DoomSystemNetworking { 26 | // Called by D_DoomMain. 27 | fun InitNetwork() 28 | fun NetCmd() 29 | } -------------------------------------------------------------------------------- /src/doom/wbplayerstruct_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | // 4 | // INTERMISSION 5 | // Structure passed e.g. to WI_Start(wb) 6 | // 7 | class wbplayerstruct_t : Cloneable { 8 | var `in` // whether the player is in game 9 | = false 10 | 11 | /** Player stats, kills, collected items etc. */ 12 | var skills = 0 13 | var sitems = 0 14 | var ssecret = 0 15 | var stime = 0 16 | var frags: IntArray 17 | 18 | /** current score on entry, modified on return */ 19 | var score = 0 20 | 21 | init { 22 | frags = IntArray(4) 23 | } 24 | 25 | public override fun clone(): wbplayerstruct_t { 26 | var r: wbplayerstruct_t? = null 27 | try { 28 | r = super.clone() as wbplayerstruct_t 29 | } catch (e: CloneNotSupportedException) { 30 | e.printStackTrace() 31 | } 32 | /*r.in=this.in; 33 | r.skills=this.skills; 34 | r.sitems=this.sitems; 35 | r.ssecret=this.ssecret; 36 | r.stime=this.stime; */System.arraycopy(frags, 0, r!!.frags, 0, r.frags.size) 37 | // r.score=this.score; 38 | return r 39 | } 40 | } -------------------------------------------------------------------------------- /src/p/pspdef_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import data.state_t 5 | import w.DoomIO 6 | import w.IPackableDoomObject 7 | import w.IReadableDoomObject 8 | import java.io.DataInputStream 9 | import java.io.IOException 10 | import java.nio.ByteBuffer 11 | 12 | class pspdef_t : IReadableDoomObject, IPackableDoomObject { 13 | /** a NULL state means not active */ 14 | var state: state_t? 15 | var tics = 0 16 | 17 | /** fixed_t */ 18 | var sx = 0 19 | var sy = 0 20 | 21 | // When read from disk. 22 | var readstate = 0 23 | 24 | init { 25 | state = state_t() 26 | } 27 | 28 | @Throws(IOException::class) 29 | override fun read(f: DataInputStream) { 30 | //state=data.info.states[f.readLEInt()]; 31 | readstate = DoomIO.readLEInt(f) 32 | tics = DoomIO.readLEInt(f) 33 | sx = DoomIO.readLEInt(f) 34 | sy = DoomIO.readLEInt(f) 35 | } 36 | 37 | @Throws(IOException::class) 38 | override fun pack(f: ByteBuffer) { 39 | if (state == null) f.putInt(0) else f.putInt(state!!.id) 40 | f.putInt(tics) 41 | f.putInt(sx) 42 | f.putInt(sy) 43 | } 44 | } -------------------------------------------------------------------------------- /src/n/DummyNetworkDriver.kt: -------------------------------------------------------------------------------- 1 | package n 2 | 3 | import doom.CommandVariable 4 | import doom.DoomMain 5 | import doom.NetConsts 6 | import doom.doomcom_t 7 | import mochadoom.Engine 8 | 9 | 10 | /** Does nothing. 11 | * Allows running single-player games without an actual network. 12 | * Hopefully, it will be replaced by a real UDP-based driver one day. 13 | * 14 | * @author Velktron 15 | */ 16 | class DummyNetworkDriver( ////////////// STATUS /////////// 17 | private val DOOM: DoomMain 18 | ) : NetConsts, DoomSystemNetworking { 19 | override fun InitNetwork() { 20 | val doomcom = doomcom_t() 21 | doomcom.id = NetConsts.DOOMCOM_ID 22 | doomcom.ticdup = 1 23 | 24 | // single player game 25 | DOOM.netgame = Engine.getCVM().present(CommandVariable.NET) 26 | doomcom.id = NetConsts.DOOMCOM_ID 27 | doomcom.numnodes = 1 28 | doomcom.numplayers = doomcom.numnodes 29 | doomcom.deathmatch = 0 30 | doomcom.consoleplayer = 0 31 | DOOM.gameNetworking.setDoomCom(doomcom) 32 | } 33 | 34 | override fun NetCmd() { 35 | // TODO Auto-generated method stub 36 | } 37 | } -------------------------------------------------------------------------------- /CHANGES.TXT: -------------------------------------------------------------------------------- 1 | Changes since 1.4a 2 | 3 | F Fixed an issue with TEXTURE2 lump loading which skipped the last entry. 4 | F Definitively fixed the retail/registered distinction 5 | F Fixed Ultimate Doom par times crash (finnw) 6 | F Fixed status bar "dirtying" by help screen 7 | F Fixed savegame name nulling 8 | F Fixed Quicksave string issue. 9 | F Fixed negative index objects crash 10 | F Fixed finale text centering error 11 | + Added MIDI/MUS compatible sound system ( by _D_, finnw). 12 | + Added PC speaker sound emulation (-speakersound) 13 | + Added Classic sound mixer (default) 14 | + Added Audioline-based sound mixer (-audiolines) (by _D_, Velktron) 15 | + Added Clip-based sound mixer (-clipsound) (By Velktron) 16 | + Added missing reject table safeguard 17 | + Added anti tutti-frutti safeguard 18 | + Added safeguards against certain mapping errors 19 | + Added an efficient object pooling system. 20 | + Added Gamma level settings. 21 | + Added patch_t load-time safeguard vs. broken columns. 22 | + Added Game Sound interface for channel/position/volume management. 23 | + Added graceful closing of open file handles. 24 | + Added always run option 25 | + Added pop-up message box on modified games -------------------------------------------------------------------------------- /src/data/mapsector_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | import java.util.* 10 | 11 | /** Sector definition, from editing. */ 12 | class mapsector_t : CacheableDoomObject { 13 | var floorheight: Short = 0 14 | var ceilingheight: Short = 0 15 | var floorpic: String? = null 16 | var ceilingpic: String? = null 17 | var lightlevel: Short = 0 18 | var special: Short = 0 19 | var tag: Short = 0 20 | @Throws(IOException::class) 21 | override fun unpack(buf: ByteBuffer) { 22 | buf.order(ByteOrder.LITTLE_ENDIAN) 23 | floorheight = buf.short 24 | ceilingheight = buf.short 25 | floorpic = DoomBuffer.getNullTerminatedString(buf, 8)!!.uppercase(Locale.getDefault()) 26 | ceilingpic = DoomBuffer.getNullTerminatedString(buf, 8)!!.uppercase(Locale.getDefault()) 27 | lightlevel = buf.short 28 | special = buf.short 29 | tag = buf.short 30 | } 31 | 32 | companion object { 33 | fun sizeOf(): Int { 34 | return 26 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/m/DummyMenu.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import doom.DoomMain 5 | import doom.event_t 6 | 7 | /** A dummy menu, useful for testers that do need a defined 8 | * menu object. 9 | * 10 | * @author Maes 11 | */ 12 | class DummyMenu(DOOM: DoomMain) : AbstractDoomMenu(DOOM!!) { 13 | override fun Responder(ev: event_t): Boolean { 14 | // TODO Auto-generated method stub 15 | return false 16 | } 17 | 18 | override fun Ticker() { 19 | // TODO Auto-generated method stub 20 | } 21 | 22 | override fun Drawer() { 23 | // TODO Auto-generated method stub 24 | } 25 | 26 | override fun Init() { 27 | // TODO Auto-generated method stub 28 | } 29 | 30 | override fun StartControlPanel() { 31 | // TODO Auto-generated method stub 32 | } 33 | 34 | override var showMessages: Boolean 35 | get() = false 36 | set(value) {} 37 | 38 | override var screenBlocks: Int 39 | get() = 0 40 | set(value) {} 41 | 42 | override val detailLevel: Int 43 | get() = 0 44 | 45 | override fun ClearMenus() { 46 | // TODO Auto-generated method stub 47 | } 48 | } -------------------------------------------------------------------------------- /src/doom/weaponinfo_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | import defines.ammotype_t 5 | import defines.statenum_t 6 | 7 | // 8 | // PSPRITE ACTIONS for waepons. 9 | // This struct controls the weapon animations. 10 | // 11 | // Each entry is: 12 | // ammo/amunition type 13 | // upstate 14 | // downstate 15 | // readystate 16 | // atkstate, i.e. attack/fire/hit frame 17 | // flashstate, muzzle flash 18 | // 19 | class weaponinfo_t(/* 20 | public weaponinfo_t(ammotype_t ammo, int upstate, int downstate, 21 | int readystate, int atkstate, int flashstate) { 22 | super(); 23 | this.ammo = ammo; 24 | this.upstate = upstate; 25 | this.downstate = downstate; 26 | this.readystate = readystate; 27 | this.atkstate = atkstate; 28 | this.flashstate = flashstate; 29 | }*/ 30 | var ammo: ammotype_t, var upstate: statenum_t, 31 | var downstate: statenum_t, var readystate: statenum_t, 32 | var atkstate: statenum_t, /* 33 | public int upstate; 34 | public int downstate; 35 | public int readystate; 36 | public int atkstate; 37 | public int flashstate; 38 | */var flashstate: statenum_t 39 | ) -------------------------------------------------------------------------------- /src/p/switchlist_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | // 11 | // P_SWITCH 12 | // 13 | class switchlist_t : CacheableDoomObject { 14 | constructor() {} 15 | 16 | // Were char[9] 17 | var name1: String? = null 18 | var name2: String? = null 19 | var episode: Short = 0 20 | 21 | constructor(name1: String?, name2: String?, episode: Int) : super() { 22 | this.name1 = name1 23 | this.name2 = name2 24 | this.episode = episode.toShort() 25 | } 26 | 27 | @Throws(IOException::class) 28 | override fun unpack(buf: ByteBuffer) { 29 | // Like most Doom structs... 30 | buf.order(ByteOrder.LITTLE_ENDIAN) 31 | name1 = DoomBuffer.getNullTerminatedString(buf, 9) 32 | name2 = DoomBuffer.getNullTerminatedString(buf, 9) 33 | episode = buf.short 34 | } 35 | 36 | override fun toString(): String { 37 | return String.format("%s %s %d", name1, name2, episode) 38 | } 39 | 40 | companion object { 41 | fun size(): Int { 42 | return 20 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/automap/mline_t.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | 4 | /** used only in automap */ 5 | class mline_t { 6 | var ax: Int 7 | var ay: Int 8 | var bx: Int 9 | var by: Int 10 | 11 | @JvmOverloads 12 | constructor(ax: Int = 0, ay: Int = 0, bx: Int = 0, by: Int = 0) { 13 | this.ax = ax 14 | this.ay = ay 15 | this.bx = bx 16 | this.by = by 17 | } 18 | 19 | constructor(ax: Double, ay: Double, bx: Double, by: Double) { 20 | this.ax = ax.toInt() 21 | this.ay = ay.toInt() 22 | this.bx = bx.toInt() 23 | this.by = by.toInt() 24 | } /* 25 | public mline_t(mpoint_t a, mpoint_t b) { 26 | this.a = a; 27 | this.b = b; 28 | } 29 | 30 | public mline_t(int ax,int ay,int bx,int by) { 31 | this.a = new mpoint_t(ax,ay); 32 | this.b = new mpoint_t(bx,by); 33 | } 34 | 35 | public mline_t(double ax,double ay,double bx,double by) { 36 | this.a = new mpoint_t(ax,ay); 37 | this.b = new mpoint_t(bx,by); 38 | } 39 | 40 | public mpoint_t a, b; 41 | public int ax; 42 | 43 | public String toString(){ 44 | return a.toString()+" - "+ b.toString(); 45 | } 46 | */ 47 | } -------------------------------------------------------------------------------- /src/rr/spritedef_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** 4 | * A sprite definition: 5 | * a number of animation frames. 6 | */ 7 | class spritedef_t { 8 | /** the very least, primitive fields won't bomb, 9 | * and copy constructors can do their job. 10 | */ 11 | constructor() {} 12 | constructor(numframes: Int) { 13 | this.numframes = numframes 14 | spriteframes = arrayOfNulls(numframes) 15 | } 16 | 17 | constructor(frames: Array) { 18 | numframes = frames.size 19 | spriteframes = arrayOfNulls(numframes) 20 | // copy shit over... 21 | for (i in 0 until numframes) { 22 | spriteframes[i] = frames[i].clone() 23 | } 24 | } 25 | 26 | /** Use this constructor, as we usually need less than 30 frames 27 | * It will actually clone the frames. 28 | */ 29 | fun copy(from: Array, maxframes: Int) { 30 | numframes = maxframes 31 | spriteframes = arrayOfNulls(maxframes) 32 | // copy shit over... 33 | for (i in 0 until maxframes) { 34 | spriteframes[i] = from[i].clone() 35 | } 36 | } 37 | 38 | var numframes = 0 39 | lateinit var spriteframes: Array 40 | } -------------------------------------------------------------------------------- /src/boom/ZNodeSegs.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import utils.GenericCopy 5 | import w.CacheableDoomObject 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.util.* 9 | 10 | class ZNodeSegs : CacheableDoomObject { 11 | lateinit var header: ByteArray 12 | lateinit var nodes: Array 13 | var numnodes = 0 14 | fun formatOK(): Boolean { 15 | return Arrays.equals(header, ZNodeSegs.DeepBSPHeader) 16 | } 17 | 18 | @Throws(IOException::class) 19 | override fun unpack(buf: ByteBuffer) { 20 | val length = buf.capacity() 21 | 22 | // Too short, not even header. 23 | if (length < 8) { 24 | return 25 | } 26 | numnodes = (length - 8) / mapnode_v4_t.sizeOf() 27 | if (length < 1) { 28 | return 29 | } 30 | buf[header] // read header 31 | nodes = GenericCopy.malloc({ mapseg_znod_t() }, length) 32 | for (i in 0 until length) { 33 | nodes[i].unpack(buf) 34 | } 35 | } 36 | 37 | companion object { 38 | private val DeepBSPHeader = byteArrayOf( 39 | 'x'.code.toByte(), 'N'.code.toByte(), 'd'.code.toByte(), '4'.code.toByte(), 0, 0, 0, 0 40 | ) 41 | } 42 | } -------------------------------------------------------------------------------- /src/w/wadheader_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataInputStream 4 | import java.io.DataOutputStream 5 | import java.io.IOException 6 | 7 | class wadheader_t : IReadableDoomObject, IWritableDoomObject { 8 | var type: String? = null 9 | var numentries = 0 10 | var tablepos = 0 11 | var big_endian = false 12 | @Throws(IOException::class) 13 | override fun read(f: DataInputStream) { 14 | type = DoomIO.readNullTerminatedString(f, 4) 15 | if (!big_endian) { 16 | numentries = DoomIO.readUnsignedLEInt(f).toInt() 17 | tablepos = DoomIO.readUnsignedLEInt(f).toInt() 18 | } else { 19 | numentries = f.readInt() 20 | tablepos = f.readInt() 21 | } 22 | } 23 | 24 | @Throws(IOException::class) 25 | override fun write(dos: DataOutputStream) { 26 | DoomIO.writeString(dos, type, 4) 27 | if (!big_endian) { 28 | DoomIO.writeLEInt(dos, numentries) 29 | DoomIO.writeLEInt(dos, tablepos) 30 | } else { 31 | dos.writeInt(numentries) 32 | dos.writeInt(tablepos) 33 | } 34 | } 35 | 36 | companion object { 37 | fun sizeof(): Int { 38 | return 16 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/pooling/ObjectQueuePool.kt: -------------------------------------------------------------------------------- 1 | package pooling 2 | 3 | 4 | import p.mobj_t 5 | import java.util.* 6 | 7 | /** A convenient object pooling class, derived from the stock ObjectPool. 8 | * 9 | * It's about 50% faster than calling new, and MUCH faster than ObjectPool 10 | * because it doesn't do that bullshit object cleanup every so often. 11 | * 12 | */ 13 | abstract class ObjectQueuePool(expirationTime: Long) { 14 | protected abstract fun create(): K 15 | abstract fun validate(obj: K): Boolean 16 | abstract fun expire(obj: K) 17 | fun drain() { 18 | locked.clear() 19 | } 20 | 21 | fun checkOut(): K { 22 | val t: K 23 | if (!locked.isEmpty()) { 24 | return locked.pop() 25 | } 26 | t = create() 27 | return t 28 | } 29 | 30 | fun checkIn(t: K) { 31 | if (ObjectQueuePool.D) if (t is mobj_t) System.out.printf( 32 | "Object %s returned to the pool\n", 33 | t.toString() 34 | ) 35 | locked.push(t) 36 | } 37 | 38 | protected var locked: Stack // private Hashtable unlocked; 39 | 40 | init { 41 | locked = Stack() 42 | } 43 | 44 | companion object { 45 | private const val D = false 46 | } 47 | } -------------------------------------------------------------------------------- /src/boom/DeepBSPNodesV4.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import utils.GenericCopy 5 | import utils.GenericCopy.malloc 6 | import w.CacheableDoomObject 7 | import java.io.IOException 8 | import java.nio.ByteBuffer 9 | import java.util.* 10 | 11 | class DeepBSPNodesV4 : CacheableDoomObject { 12 | var header = ByteArray(8) 13 | lateinit var nodes: Array 14 | var numnodes = 0 15 | fun formatOK(): Boolean { 16 | return Arrays.equals(header, DeepBSPNodesV4.DeepBSPHeader) 17 | } 18 | 19 | @Throws(IOException::class) 20 | override fun unpack(buf: ByteBuffer) { 21 | val length = buf.capacity() 22 | 23 | // Too short, not even header. 24 | if (length < 8) { 25 | return 26 | } 27 | numnodes = (length - 8) / mapnode_v4_t.sizeOf() 28 | if (length < 1) { 29 | return 30 | } 31 | buf[header] // read header 32 | nodes = malloc({ mapnode_v4_t() }, length) 33 | for (i in 0 until length) { 34 | nodes[i].unpack(buf) 35 | } 36 | } 37 | 38 | companion object { 39 | val DeepBSPHeader = byteArrayOf( 40 | 'x'.code.toByte(), 'N'.code.toByte(), 'd'.code.toByte(), '4'.code.toByte(), 0, 0, 0, 0 41 | ) 42 | } 43 | } -------------------------------------------------------------------------------- /src/boom/mapnode_znod_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | class mapnode_znod_t : CacheableDoomObject { 11 | var x // Partition line from (x,y) to x+dx,y+dy) 12 | : Short = 0 13 | var y: Short = 0 14 | var dx: Short = 0 15 | var dy: Short = 0 16 | 17 | // Bounding box for each child, clip against view frustum. 18 | var bbox: Array 19 | 20 | // If NF_SUBSECTOR its a subsector, else it's a node of another subtree. 21 | var children: IntArray 22 | 23 | init { 24 | bbox = Array(2) { ShortArray(4) } 25 | children = IntArray(2) 26 | } 27 | 28 | @Throws(IOException::class) 29 | override fun unpack(buf: ByteBuffer) { 30 | buf.order(ByteOrder.LITTLE_ENDIAN) 31 | x = buf.short 32 | y = buf.short 33 | dx = buf.short 34 | dy = buf.short 35 | DoomBuffer.readShortArray(buf, bbox[0], 4) 36 | DoomBuffer.readShortArray(buf, bbox[1], 4) 37 | DoomBuffer.readIntArray(buf, children, 2) 38 | } 39 | 40 | companion object { 41 | fun sizeOf(): Int { 42 | return 8 + 16 + 8 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/w/CacheableDoomObjectContainer.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.IOException 4 | import java.nio.ByteBuffer 5 | 6 | /** A container allowing for caching of arrays of CacheableDoomObjects 7 | * 8 | * It's a massive improvement over the older system, allowing for proper 9 | * caching and auto-unpacking of arrays of CacheableDoomObjects and much 10 | * cleaner code throughout. 11 | * 12 | * The container itself is a CacheableDoomObject....can you feel the 13 | * abuse? ;-) 14 | * 15 | */ 16 | class CacheableDoomObjectContainer(private val stuff: Array) : CacheableDoomObject { 17 | fun getStuff(): Array { 18 | return stuff 19 | } 20 | 21 | @Throws(IOException::class) 22 | override fun unpack(buf: ByteBuffer) { 23 | for (i in stuff.indices) { 24 | stuff[i]!!.unpack(buf) 25 | } 26 | } 27 | 28 | companion object { 29 | /** Statically usable method 30 | * 31 | * @param buf 32 | * @param stuff 33 | * @throws IOException 34 | */ 35 | @Throws(IOException::class) 36 | fun unpack(buf: ByteBuffer?, stuff: Array) { 37 | for (i in stuff.indices) { 38 | stuff[i].unpack(buf!!) 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/utils/OSValidator.kt: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | 4 | import java.util.* 5 | 6 | /** Half-assed way of finding the OS we're running under, shamelessly 7 | * ripped from: 8 | * 9 | * http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/ 10 | * . 11 | * This is required, as some things in AWT don't work exactly consistently cross-OS 12 | * (AWT frame size is the first thing that goes wrong, but also mouse grabbing 13 | * behavior). 14 | * 15 | * TODO: replace with Apache Commons library? 16 | * 17 | * @author velktron 18 | */ 19 | object OSValidator { 20 | fun isWindows(): Boolean { 21 | val os = System.getProperty("os.name").lowercase(Locale.getDefault()) 22 | //windows 23 | return os.indexOf("win") >= 0 24 | } 25 | 26 | fun isMac(): Boolean { 27 | val os = System.getProperty("os.name").lowercase(Locale.getDefault()) 28 | //Mac 29 | return os.indexOf("mac") >= 0 30 | } 31 | 32 | fun isUnix(): Boolean { 33 | val os = System.getProperty("os.name").lowercase(Locale.getDefault()) 34 | //linux or unix 35 | return os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 36 | } 37 | 38 | fun isUnknown(): Boolean { 39 | return !OSValidator.isWindows() && !OSValidator.isUnix() && !OSValidator.isMac() 40 | } 41 | } -------------------------------------------------------------------------------- /src/f/Wiper.kt: -------------------------------------------------------------------------------- 1 | package f 2 | 3 | 4 | import v.graphics.Wipers 5 | import v.graphics.Wipers.WipeFunc 6 | 7 | interface Wiper { 8 | fun ScreenWipe(type: Wipers.WipeType, x: Int, y: Int, width: Int, height: Int, ticks: Int): Boolean 9 | fun EndScreen(x: Int, y: Int, width: Int, height: Int): Boolean 10 | fun StartScreen(x: Int, y: Int, width: Int, height: Int): Boolean 11 | enum class Wipe(val _initFunc: WipeFunc, val _doFunc: WipeFunc, val _exitFunc: WipeFunc): Wipers.WipeType { 12 | // simple gradual pixel change for 8-bit only 13 | // MAES: this transition isn't guaranteed to always terminate 14 | // see Chocolate Strife develpment. Unused in Doom anyway. 15 | ColorXForm( 16 | WipeFunc.initColorXForm, 17 | WipeFunc.doColorXForm, 18 | WipeFunc.exitColorXForm 19 | ), // weird screen melt 20 | Melt( 21 | WipeFunc.initMelt, 22 | WipeFunc.doMelt, 23 | WipeFunc.exitMelt 24 | ), 25 | ScaledMelt( 26 | WipeFunc.initScaledMelt, 27 | WipeFunc.doScaledMelt, 28 | WipeFunc.exitMelt 29 | ); 30 | 31 | override fun getDoFunc() = _doFunc 32 | override fun getExitFunc() = _exitFunc 33 | 34 | override fun getInitFunc() = _initFunc 35 | } 36 | } -------------------------------------------------------------------------------- /src/p/Actions/ActiveStates/Monsters.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package p.Actions.ActiveStatesimportimport 19 | 20 | 21 | import p.Actions.ActiveStates.MonsterStatesimport.* 22 | import p.Actions.ActiveStates.MonsterStatesimportimport.Demonspawns 23 | import p.Actions.ActiveStates.MonsterStatesimportimport.Spiders 24 | import p.Actions.ActiveStates.MonsterStatesimportimport.Zombies 25 | 26 | /** 27 | * Include all from Monsters package 28 | * 29 | * @author Good Sign 30 | */ 31 | interface Monsters : Bosses, Demonspawns, HorrendousVisages, Mancubi, PainsSouls, Skels, Spiders, Viles, Zombies -------------------------------------------------------------------------------- /src/rr/subsector_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import p.Resettable 4 | 5 | /** 6 | * 7 | * A SubSector. References a Sector. Basically, this is a list of LineSegs, 8 | * indicating the visible walls that define (all or some) sides of a convex BSP 9 | * leaf. 10 | * 11 | * @author admin 12 | */ 13 | class subsector_t @JvmOverloads constructor(// Maes: single pointer 14 | var sector: sector_t? = null, // e6y: support for extended nodes 15 | // 'int' instead of 'short' 16 | var numlines: Int = 0, var firstline: Int = 0 17 | ) : Resettable { 18 | override fun toString(): String { 19 | subsector_t.sb.setLength(0) 20 | subsector_t.sb.append("Subsector") 21 | subsector_t.sb.append('\t') 22 | subsector_t.sb.append("Sector: ") 23 | subsector_t.sb.append(sector) 24 | subsector_t.sb.append('\t') 25 | subsector_t.sb.append("numlines ") 26 | subsector_t.sb.append(numlines) 27 | subsector_t.sb.append('\t') 28 | subsector_t.sb.append("firstline ") 29 | subsector_t.sb.append(firstline) 30 | return subsector_t.sb.toString() 31 | } 32 | 33 | override fun reset() { 34 | sector = null 35 | numlines = 0 36 | firstline = numlines 37 | } 38 | 39 | companion object { 40 | private val sb = StringBuilder() 41 | } 42 | } -------------------------------------------------------------------------------- /src/data/mapsidedef_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | import java.util.* 10 | 11 | /** 12 | * A SideDef, defining the visual appearance of a wall, by setting textures and 13 | * offsets. ON-DISK. 14 | */ 15 | class mapsidedef_t : CacheableDoomObject { 16 | var textureoffset: Short = 0 17 | var rowoffset: Short = 0 18 | 19 | // 8-char strings. 20 | var toptexture: String? = null 21 | var bottomtexture: String? = null 22 | var midtexture: String? = null 23 | 24 | /** Front sector, towards viewer. */ 25 | var sector: Short = 0 26 | @Throws(IOException::class) 27 | override fun unpack(buf: ByteBuffer) { 28 | buf.order(ByteOrder.LITTLE_ENDIAN) 29 | textureoffset = buf.short 30 | rowoffset = buf.short 31 | toptexture = DoomBuffer.getNullTerminatedString(buf, 8)!!.uppercase(Locale.getDefault()) 32 | bottomtexture = DoomBuffer.getNullTerminatedString(buf, 8)!!.uppercase(Locale.getDefault()) 33 | midtexture = DoomBuffer.getNullTerminatedString(buf, 8)!!.uppercase(Locale.getDefault()) 34 | sector = buf.short 35 | } 36 | 37 | companion object { 38 | fun sizeOf(): Int { 39 | return 30 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/s/DummySFX.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import data.sfxinfo_t 4 | 5 | class DummySFX : ISoundDriver { 6 | override fun InitSound(): Boolean { 7 | // Dummy is super-reliable ;-) 8 | return true 9 | } 10 | 11 | override fun UpdateSound() { 12 | // TODO Auto-generated method stub 13 | } 14 | 15 | override fun SubmitSound() { 16 | // TODO Auto-generated method stub 17 | } 18 | 19 | override fun ShutdownSound() { 20 | // TODO Auto-generated method stub 21 | } 22 | 23 | override fun GetSfxLumpNum(sfxinfo: sfxinfo_t): Int { 24 | // TODO Auto-generated method stub 25 | return 0 26 | } 27 | 28 | override fun StartSound(id: Int, vol: Int, sep: Int, pitch: Int, priority: Int): Int { 29 | // TODO Auto-generated method stub 30 | return 0 31 | } 32 | 33 | override fun StopSound(handle: Int) { 34 | // TODO Auto-generated method stub 35 | } 36 | 37 | override fun SoundIsPlaying(handle: Int): Boolean { 38 | // TODO Auto-generated method stub 39 | return false 40 | } 41 | 42 | override fun UpdateSoundParams(handle: Int, vol: Int, sep: Int, pitch: Int) { 43 | // TODO Auto-generated method stub 44 | } 45 | 46 | override fun SetChannels(numChannels: Int) { 47 | // TODO Auto-generated method stub 48 | } 49 | } -------------------------------------------------------------------------------- /src/v/graphics/Horizontal.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package v.graphics 19 | 20 | /** 21 | * Horizontal represents a range from a screen buffer (byte or short or int array) 22 | * 23 | * @author Good Sign 24 | */ 25 | class Horizontal { 26 | var start = 0 27 | var length = 0 28 | 29 | constructor() {} 30 | constructor(start: Int, length: Int) { 31 | this.start = start 32 | this.length = length 33 | } 34 | 35 | fun relocate(amount: Int): Relocation { 36 | return Relocation(start, start + amount, length) 37 | } 38 | 39 | fun shift(amount: Int) { 40 | start += amount 41 | } 42 | } -------------------------------------------------------------------------------- /src/data/mapseg_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import java.io.IOException 6 | import java.nio.ByteBuffer 7 | import java.nio.ByteOrder 8 | 9 | /** 10 | * LineSeg, generated by splitting LineDefs 11 | * using partition lines selected by BSP builder. 12 | * MAES: this is the ON-DISK structure. The corresponding memory structure, 13 | * segs_t, has fixed_t members. 14 | */ 15 | class mapseg_t : CacheableDoomObject { 16 | var v1 = 0.toChar() 17 | var v2 = 0.toChar() 18 | var angle = 0.toChar() 19 | var linedef = 0.toChar() 20 | var side = 0.toChar() 21 | var offset = 0.toChar() 22 | @Throws(IOException::class) 23 | override fun unpack(buf: ByteBuffer) { 24 | buf.order(ByteOrder.LITTLE_ENDIAN) 25 | v1 = buf.char 26 | v2 = buf.char 27 | angle = buf.char 28 | linedef = buf.char 29 | side = buf.char 30 | offset = buf.char 31 | } 32 | 33 | override fun toString(): String { 34 | return String.format( 35 | "mapseg_t v1,2: %d %d ang: %d ld: %d sd: %d off: %d", 36 | v1.code, 37 | v2.code, 38 | angle.code, 39 | linedef.code, 40 | side.code, 41 | offset.code 42 | ) 43 | } 44 | 45 | companion object { 46 | fun sizeOf(): Int { 47 | return 12 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/s/IMusic.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import doom.CVarManager 4 | import doom.CommandVariable 5 | 6 | 7 | 8 | // 9 | // MUSIC I/O 10 | // 11 | interface IMusic { 12 | fun InitMusic() 13 | fun ShutdownMusic() 14 | 15 | // Volume. 16 | fun SetMusicVolume(volume: Int) 17 | 18 | /** PAUSE game handling. */ 19 | fun PauseSong(handle: Int) 20 | fun ResumeSong(handle: Int) 21 | 22 | /** Registers a song handle to song data. 23 | * This should handle any conversions from MUS/MIDI/OPL/etc. 24 | * 25 | */ 26 | fun RegisterSong(data: ByteArray?): Int 27 | 28 | /** Called by anything that wishes to start music. 29 | * plays a song, and when the song is done, 30 | * starts playing it again in an endless loop. 31 | * Horrible thing to do, considering. */ 32 | fun PlaySong( 33 | handle: Int, 34 | looping: Boolean 35 | ) 36 | 37 | /** Stops a song over 3 seconds. */ 38 | fun StopSong(handle: Int) 39 | 40 | /** See above (register), then think backwards */ 41 | fun UnRegisterSong(handle: Int) 42 | 43 | companion object { 44 | fun chooseModule(CVM: CVarManager): IMusic { 45 | return if (CVM.bool(CommandVariable.NOMUSIC) || CVM.bool(CommandVariable.NOSOUND)) { 46 | DummyMusic() 47 | } else { 48 | DavidMusicModule() 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kocoa Doom 2 | 3 | ![Top Language](https://img.shields.io/github/languages/top/hiperbou/kocoa-doom.svg?style=flat) 4 | ![Code Size](https://img.shields.io/github/languages/code-size/hiperbou/kocoa-doom.svg?style=flat) 5 | ![License](https://img.shields.io/github/license/hiperbou/kocoa-doom.svg?style=flat&logo=gnu) 6 | 7 | Kocoa Doom is a pure Kotlin Doom source port. It is based on the Java port [Mocha Doom](https://github.com/AXDOOMER/mochadoom). 8 | 9 | # How to run 10 | 11 | 1. Open the project with IntelliJ 12 | 2. Build and run the project 13 | 14 | # License 15 | 16 | Kocoa Doom contains work from many contributors. Here are the main contributors, but it's no limited to this list. Others are listed in the copyright headers of the files where they own copyright. 17 | 18 | - Copyright (C) 1993-1996 [id Software, Inc.](http://www.idsoftware.com/) 19 | - Copyright (C) 2010-2013 [Victor Epitropou](https://sourceforge.net/projects/mochadoom/) 20 | - Copyright (C) 2016-2017 [Alexandre-Xavier Labonté-Lamoureux](https://github.com/AXDOOMER/) 21 | - Copyright (C) 2017 [Good Sign](https://github.com/GoodSign2017) 22 | - Copyright (C) 2022 [hiperbou](https://github.com/hiperbou) 23 | 24 | Kocoa Doom is distributed under the [GNU GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html). 25 | 26 | # Rip and Tear! 27 | 28 | Kocoa Doom in action: 29 | ![so_much_blood](https://cloud.githubusercontent.com/assets/6194072/18658610/94a326c2-7ed2-11e6-98af-4ed4c8b28510.png) 30 | -------------------------------------------------------------------------------- /src/data/spritenum_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | /** This is actually used as a data type */ 5 | enum class spritenum_t { 6 | SPR_TROO, SPR_SHTG, SPR_PUNG, SPR_PISG, SPR_PISF, SPR_SHTF, SPR_SHT2, SPR_CHGG, SPR_CHGF, SPR_MISG, SPR_MISF, SPR_SAWG, SPR_PLSG, SPR_PLSF, SPR_BFGG, SPR_BFGF, SPR_BLUD, SPR_PUFF, SPR_BAL1, SPR_BAL2, SPR_PLSS, SPR_PLSE, SPR_MISL, SPR_BFS1, SPR_BFE1, SPR_BFE2, SPR_TFOG, SPR_IFOG, SPR_PLAY, SPR_POSS, SPR_SPOS, SPR_VILE, SPR_FIRE, SPR_FATB, SPR_FBXP, SPR_SKEL, SPR_MANF, SPR_FATT, SPR_CPOS, SPR_SARG, SPR_HEAD, SPR_BAL7, SPR_BOSS, SPR_BOS2, SPR_SKUL, SPR_SPID, SPR_BSPI, SPR_APLS, SPR_APBX, SPR_CYBR, SPR_PAIN, SPR_SSWV, SPR_KEEN, SPR_BBRN, SPR_BOSF, SPR_ARM1, SPR_ARM2, SPR_BAR1, SPR_BEXP, SPR_FCAN, SPR_BON1, SPR_BON2, SPR_BKEY, SPR_RKEY, SPR_YKEY, SPR_BSKU, SPR_RSKU, SPR_YSKU, SPR_STIM, SPR_MEDI, SPR_SOUL, SPR_PINV, SPR_PSTR, SPR_PINS, SPR_MEGA, SPR_SUIT, SPR_PMAP, SPR_PVIS, SPR_CLIP, SPR_AMMO, SPR_ROCK, SPR_BROK, SPR_CELL, SPR_CELP, SPR_SHEL, SPR_SBOX, SPR_BPAK, SPR_BFUG, SPR_MGUN, SPR_CSAW, SPR_LAUN, SPR_PLAS, SPR_SHOT, SPR_SGN2, SPR_COLU, SPR_SMT2, SPR_GOR1, SPR_POL2, SPR_POL5, SPR_POL4, SPR_POL3, SPR_POL1, SPR_POL6, SPR_GOR2, SPR_GOR3, SPR_GOR4, SPR_GOR5, SPR_SMIT, SPR_COL1, SPR_COL2, SPR_COL3, SPR_COL4, SPR_CAND, SPR_CBRA, SPR_COL6, SPR_TRE1, SPR_TRE2, SPR_ELEC, SPR_CEYE, SPR_FSKU, SPR_COL5, SPR_TBLU, SPR_TGRN, SPR_TRED, SPR_SMBT, SPR_SMGT, SPR_SMRT, SPR_HDB1, SPR_HDB2, SPR_HDB3, SPR_HDB4, SPR_HDB5, SPR_HDB6, SPR_POB1, SPR_POB2, SPR_BRS1, SPR_TLMP, SPR_TLP2, NUMSPRITES 7 | } -------------------------------------------------------------------------------- /src/boom/mapnode_v4_t.kt: -------------------------------------------------------------------------------- 1 | package boom 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** BSP Node structure on-disk */ 11 | class mapnode_v4_t : CacheableDoomObject { 12 | /** Partition line from (x,y) to x+dx,y+dy) */ 13 | var x: Short = 0 14 | var y: Short = 0 15 | var dx: Short = 0 16 | var dy: Short = 0 17 | 18 | /** Bounding box for each child, clip against view frustum. */ 19 | var bbox: Array 20 | 21 | /** If NF_SUBSECTOR its a subsector, else it's a node of another subtree. 22 | * In simpler words: if the first bit is set, strip it and use the rest 23 | * as a subtree index. Else it's a node index. 24 | */ 25 | var children = IntArray(2) 26 | 27 | init { 28 | bbox = Array(2) { ShortArray(4) } 29 | children = IntArray(2) 30 | } 31 | 32 | @Throws(IOException::class) 33 | override fun unpack(buf: ByteBuffer) { 34 | buf.order(ByteOrder.LITTLE_ENDIAN) 35 | x = buf.short 36 | y = buf.short 37 | dx = buf.short 38 | dy = buf.short 39 | DoomBuffer.readShortArray(buf, bbox[0], 4) 40 | DoomBuffer.readShortArray(buf, bbox[1], 4) 41 | DoomBuffer.readIntArray(buf, children, 2) 42 | } 43 | 44 | companion object { 45 | fun sizeOf(): Int { 46 | return 8 + 16 + 8 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/data/doomtype.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | //----------------------------------------------------------------------------- 5 | // 6 | // $Id: doomtype.java,v 1.3 2011/02/11 00:11:13 velktron Exp $ 7 | // 8 | // Copyright (C) 1993-1996 by id Software, Inc. 9 | // Copyright (C) 2022 hiperbou 10 | // 11 | // This program is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License 13 | // as published by the Free Software Foundation; either version 2 14 | // of the License, or (at your option) any later version. 15 | // 16 | // This program is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // DESCRIPTION: 22 | // Simple basic typedefs, isolated here to make it easier 23 | // separating modules. 24 | // 25 | //----------------------------------------------------------------------------- 26 | object doomtype { 27 | // C's "chars" are actually Java signed bytes. 28 | var MAXCHAR = 0x7f.toByte() 29 | var MAXSHORT = 0x7fff.toShort() 30 | 31 | // Max pos 32-bit int. 32 | var MAXINT = 0x7fffffff 33 | var MAXLONG = 0x7fffffffL 34 | var MINCHAR = 0x80.toByte() 35 | var MINSHORT = 0x8000.toShort() 36 | 37 | // Max negative 32-bit integer. 38 | var MININT = -0x80000000 39 | var MINLONG = 0x80000000L 40 | } -------------------------------------------------------------------------------- /src/rr/vissprite_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** A vissprite_t is a thing 4 | * that will be drawn during a refresh. 5 | * I.e. a sprite object that is partly visible. 6 | */ 7 | class vissprite_t : Comparable> { 8 | // Doubly linked list. 9 | var prev: vissprite_t? = null 10 | var next: vissprite_t? = null 11 | var x1 = 0 12 | var x2 = 0 13 | 14 | // for line side calculation 15 | var gx = 0 16 | var gy = 0 17 | 18 | // global bottom / top for silhouette clipping 19 | var gz = 0 20 | var gzt = 0 21 | 22 | // horizontal position of x1 23 | var startfrac = 0 24 | var scale = 0 25 | 26 | // negative if flipped 27 | var xiscale = 0 28 | var texturemid = 0 29 | var patch = 0 30 | 31 | /** for color translation and shadow draw, 32 | * maxbright frames as well. 33 | * 34 | * Use paired with pcolormap; 35 | */ 36 | var colormap: V? = null 37 | 38 | /* pointer into colormap 39 | public int pcolormap; */ 40 | var mobjflags = 0 41 | 42 | /** visspites are sorted by scale */ 43 | override fun compareTo(o: vissprite_t): Int { 44 | // We only really care if it's drawn before. 45 | if (scale > o.scale) return 1 46 | return if (scale < o.scale) -1 else 0 47 | } 48 | 49 | override fun toString(): String { 50 | return "Effective drawing position x1: $x1 x2: $x2 scale ${scale / 65535.0}" + " iscale " + xiscale / 65535.0 51 | } 52 | } -------------------------------------------------------------------------------- /src/data/mapnode_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** BSP Node structure on-disk */ 11 | class mapnode_t : CacheableDoomObject { 12 | /** Partition line from (x,y) to x+dx,y+dy) */ 13 | var x: Short = 0 14 | var y: Short = 0 15 | var dx: Short = 0 16 | var dy: Short = 0 17 | 18 | /** Bounding box for each child, clip against view frustum. */ 19 | var bbox: Array 20 | 21 | /** If NF_SUBSECTOR its a subsector, else it's a node of another subtree. 22 | * In simpler words: if the first bit is set, strip it and use the rest 23 | * as a subtree index. Else it's a node index. 24 | */ 25 | var children = CharArray(2) // MAES: used to be unsigned short. 26 | 27 | init { 28 | bbox = Array(2) { ShortArray(4) } 29 | children = CharArray(2) 30 | } 31 | 32 | @Throws(IOException::class) 33 | override fun unpack(buf: ByteBuffer) { 34 | buf.order(ByteOrder.LITTLE_ENDIAN) 35 | x = buf.short 36 | y = buf.short 37 | dx = buf.short 38 | dy = buf.short 39 | DoomBuffer.readShortArray(buf, bbox[0], 4) 40 | DoomBuffer.readShortArray(buf, bbox[1], 4) 41 | DoomBuffer.readCharArray(buf, children, 2) 42 | } 43 | 44 | companion object { 45 | fun sizeOf(): Int { 46 | return 8 + 16 + 4 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/rr/texture_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** A maptexturedef_t describes a rectangular texture, 4 | * which is composed of one or more mappatch_t structures 5 | * that arrange graphic patches. 6 | * 7 | * This is the in-memory format, which is similar to maptexture_t (which is on-disk). 8 | * 9 | * @author Maes 10 | */ 11 | class texture_t { 12 | /** Keep name for switch changing, etc. */ 13 | var name: String? = null 14 | var width: Short = 0 15 | var height: Short = 0 16 | 17 | // All the patches[patchcount] 18 | // are drawn back to front into the cached texture. 19 | var patchcount: Short = 0 20 | lateinit var patches: Array 21 | 22 | /** Unmarshalling at its best! */ 23 | fun copyFromMapTexture(mt: maptexture_t) { 24 | name = "" + (mt.name) 25 | width = mt.width 26 | height = mt.height 27 | patchcount = mt.patchcount 28 | patches = arrayOfNulls(patchcount.toInt()) 29 | for (i in 0 until patchcount) { 30 | patches[i] = texpatch_t() 31 | patches[i]!!.copyFromMapPatch(mt.patches[i]) 32 | } 33 | } 34 | 35 | override fun toString(): String { 36 | val sb = StringBuilder() 37 | sb.append(name) 38 | sb.append(" Height ") 39 | sb.append(height.toInt()) 40 | sb.append(" Width ") 41 | sb.append(width.toInt()) 42 | sb.append(" Patchcount ") 43 | sb.append(patchcount.toInt()) 44 | return sb.toString() 45 | } 46 | } -------------------------------------------------------------------------------- /src/data/mobjtype_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | enum class mobjtype_t { 5 | MT_PLAYER, MT_POSSESSED, MT_SHOTGUY, MT_VILE, MT_FIRE, MT_UNDEAD, MT_TRACER, MT_SMOKE, MT_FATSO, MT_FATSHOT, MT_CHAINGUY, MT_TROOP, MT_SERGEANT, MT_SHADOWS, MT_HEAD, MT_BRUISER, MT_BRUISERSHOT, MT_KNIGHT, MT_SKULL, MT_SPIDER, MT_BABY, MT_CYBORG, MT_PAIN, MT_WOLFSS, MT_KEEN, MT_BOSSBRAIN, MT_BOSSSPIT, MT_BOSSTARGET, MT_SPAWNSHOT, MT_SPAWNFIRE, MT_BARREL, MT_TROOPSHOT, MT_HEADSHOT, MT_ROCKET, MT_PLASMA, MT_BFG, MT_ARACHPLAZ, MT_PUFF, MT_BLOOD, MT_TFOG, MT_IFOG, MT_TELEPORTMAN, MT_EXTRABFG, MT_MISC0, MT_MISC1, MT_MISC2, MT_MISC3, MT_MISC4, MT_MISC5, MT_MISC6, MT_MISC7, MT_MISC8, MT_MISC9, MT_MISC10, MT_MISC11, MT_MISC12, MT_INV, MT_MISC13, MT_INS, MT_MISC14, MT_MISC15, MT_MISC16, MT_MEGA, MT_CLIP, MT_MISC17, MT_MISC18, MT_MISC19, MT_MISC20, MT_MISC21, MT_MISC22, MT_MISC23, MT_MISC24, MT_MISC25, MT_CHAINGUN, MT_MISC26, MT_MISC27, MT_MISC28, MT_SHOTGUN, MT_SUPERSHOTGUN, MT_MISC29, MT_MISC30, MT_MISC31, MT_MISC32, MT_MISC33, MT_MISC34, MT_MISC35, MT_MISC36, MT_MISC37, MT_MISC38, MT_MISC39, MT_MISC40, MT_MISC41, MT_MISC42, MT_MISC43, MT_MISC44, MT_MISC45, MT_MISC46, MT_MISC47, MT_MISC48, MT_MISC49, MT_MISC50, MT_MISC51, MT_MISC52, MT_MISC53, MT_MISC54, MT_MISC55, MT_MISC56, MT_MISC57, MT_MISC58, MT_MISC59, MT_MISC60, MT_MISC61, MT_MISC62, MT_MISC63, MT_MISC64, MT_MISC65, MT_MISC66, MT_MISC67, MT_MISC68, MT_MISC69, MT_MISC70, MT_MISC71, MT_MISC72, MT_MISC73, MT_MISC74, MT_MISC75, MT_MISC76, MT_MISC77, MT_MISC78, MT_MISC79, MT_MISC80, MT_MISC81, MT_MISC82, MT_MISC83, MT_MISC84, MT_MISC85, MT_MISC86, NUMMOBJTYPES 6 | } -------------------------------------------------------------------------------- /src/demo/IDoomDemo.kt: -------------------------------------------------------------------------------- 1 | package demo 2 | 3 | 4 | import defines.skill_t 5 | import w.IWritableDoomObject 6 | 7 | interface IDoomDemo : IWritableDoomObject { 8 | /** Get next demo command, in its raw format. Use 9 | * its own adapters if you need it converted to a 10 | * standard ticcmd_t. 11 | * 12 | * @return 13 | */ 14 | fun getNextTic(): IDemoTicCmd? 15 | 16 | /** Record a demo command in the IDoomDemo's native format. 17 | * Use the IDemoTicCmd's objects adaptors to convert it. 18 | * 19 | * @param tic 20 | */ 21 | fun putTic(tic: IDemoTicCmd) 22 | fun getVersion(): Int 23 | fun setVersion(version: Int) 24 | fun getSkill(): skill_t? 25 | fun setSkill(skill: skill_t?) 26 | fun getEpisode(): Int 27 | fun setEpisode(episode: Int) 28 | fun getMap(): Int 29 | fun setMap(map: Int) 30 | fun isDeathmatch(): Boolean 31 | fun setDeathmatch(deathmatch: Boolean) 32 | fun isRespawnparm(): Boolean 33 | fun setRespawnparm(respawnparm: Boolean) 34 | fun isFastparm(): Boolean 35 | fun setFastparm(fastparm: Boolean) 36 | fun isNomonsters(): Boolean 37 | fun setNomonsters(nomonsters: Boolean) 38 | fun getConsoleplayer(): Int 39 | fun setConsoleplayer(consoleplayer: Int) 40 | fun getPlayeringame(): BooleanArray 41 | fun setPlayeringame(playeringame: BooleanArray) 42 | fun resetDemo() 43 | 44 | companion object { 45 | /** Vanilla end demo marker, to append at the end of recorded demos */ 46 | const val DEMOMARKER = 0x80 47 | } 48 | } -------------------------------------------------------------------------------- /src/p/vldoor_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import rr.SectorAction 5 | import w.DoomIO 6 | import w.IReadableDoomObject 7 | import java.io.DataInputStream 8 | import java.io.IOException 9 | import java.nio.ByteBuffer 10 | 11 | class vldoor_t : SectorAction(), IReadableDoomObject { 12 | var type: vldoor_e? = null 13 | 14 | /** fixed_t */ 15 | var topheight = 0 16 | var speed = 0 17 | 18 | /** 1 = up, 0 = waiting at top, -1 = down */ 19 | var direction = 0 20 | 21 | /** tics to wait at the top */ 22 | var topwait = 0 23 | 24 | /**(keep in case a door going down is reset) 25 | * when it reaches 0, start going down */ 26 | var topcountdown = 0 27 | @Throws(IOException::class) 28 | override fun read(f: DataInputStream) { 29 | super.read(f) // Call thinker reader first 30 | type = vldoor_e.values()[DoomIO.readLEInt(f)] 31 | super.sectorid = DoomIO.readLEInt(f) // Sector index (or pointer?) 32 | topheight = DoomIO.readLEInt(f) 33 | speed = DoomIO.readLEInt(f) 34 | direction = DoomIO.readLEInt(f) 35 | topwait = DoomIO.readLEInt(f) 36 | topcountdown = DoomIO.readLEInt(f) 37 | } 38 | 39 | @Throws(IOException::class) 40 | override fun pack(b: ByteBuffer) { 41 | super.pack(b) //12 42 | b.putInt(type!!.ordinal) // 16 43 | b.putInt(super.sectorid) // 20 44 | b.putInt(topheight) // 24 45 | b.putInt(speed) //28 46 | b.putInt(direction) // 32 47 | b.putInt(topwait) //36 48 | b.putInt(topcountdown) //40 49 | } 50 | } -------------------------------------------------------------------------------- /src/p/strobe_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import rr.SectorAction 5 | import w.DoomIO 6 | import java.io.DataInputStream 7 | import java.io.IOException 8 | import java.nio.ByteBuffer 9 | 10 | class strobe_t : SectorAction() { 11 | var count = 0 12 | var minlight = 0 13 | var maxlight = 0 14 | var darktime = 0 15 | var brighttime = 0 16 | 17 | // 18 | // T_StrobeFlash 19 | // 20 | fun StrobeFlash() { 21 | if (--count != 0) { 22 | return 23 | } 24 | val sector = sector!! 25 | if (sector.lightlevel.toInt() == minlight) { 26 | sector.lightlevel = maxlight.toShort() 27 | count = brighttime 28 | } else { 29 | sector.lightlevel = minlight.toShort() 30 | count = darktime 31 | } 32 | } 33 | 34 | @Throws(IOException::class) 35 | override fun read(f: DataInputStream) { 36 | super.read(f) // Call thinker reader first 37 | super.sectorid = DoomIO.readLEInt(f) // Sector index 38 | count = DoomIO.readLEInt(f) 39 | maxlight = DoomIO.readLEInt(f) 40 | minlight = DoomIO.readLEInt(f) 41 | darktime = DoomIO.readLEInt(f) 42 | brighttime = DoomIO.readLEInt(f) 43 | } 44 | 45 | @Throws(IOException::class) 46 | override fun pack(b: ByteBuffer) { 47 | super.pack(b) //12 48 | b.putInt(super.sectorid) // 16 49 | b.putInt(count) //20 50 | b.putInt(maxlight) //24 51 | b.putInt(minlight) //28 52 | b.putInt(darktime) //32 53 | b.putInt(brighttime) //36 54 | } 55 | } -------------------------------------------------------------------------------- /src/i/DummySystem.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | import doom.ticcmd_t 5 | 6 | class DummySystem : IDoomSystem { 7 | override fun AllocLow(length: Int) { 8 | // TODO Auto-generated method stub 9 | } 10 | 11 | override fun BeginRead() { 12 | // TODO Auto-generated method stub 13 | } 14 | 15 | override fun EndRead() { 16 | // TODO Auto-generated method stub 17 | } 18 | 19 | override fun WaitVBL(count: Int) { 20 | // TODO Auto-generated method stub 21 | } 22 | 23 | override fun ZoneBase(size: Int): ByteArray? { 24 | // TODO Auto-generated method stub 25 | return null 26 | } 27 | 28 | override fun GetHeapSize(): Int { 29 | // TODO Auto-generated method stub 30 | return 0 31 | } 32 | 33 | override fun Tactile(on: Int, off: Int, total: Int) { 34 | // TODO Auto-generated method stub 35 | } 36 | 37 | override fun Quit() { 38 | // TODO Auto-generated method stub 39 | } 40 | 41 | override fun BaseTiccmd(): ticcmd_t? { 42 | // TODO Auto-generated method stub 43 | return null 44 | } 45 | 46 | override fun Error(error: String?, vararg args: Any?) { 47 | // TODO Auto-generated method stub 48 | } 49 | 50 | override fun Error(error: String?) { 51 | // TODO Auto-generated method stub 52 | } 53 | 54 | override fun Init() { 55 | // TODO Auto-generated method stub 56 | } 57 | 58 | override fun GenerateAlert(title: String?, cause: String?): Boolean { 59 | // TODO Auto-generated method stub 60 | return false 61 | } 62 | } -------------------------------------------------------------------------------- /src/utils/QuoteType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package utils 19 | 20 | 21 | import java.util.* 22 | 23 | /** 24 | * @author Good Sign 25 | */ 26 | enum class QuoteType(val quoteChar: Char) { 27 | SINGLE('\''), DOUBLE('"'); 28 | 29 | fun isQuoted(s: String): Boolean { 30 | return C2JUtils.isQuoted(s, quoteChar) 31 | } 32 | 33 | fun unQuote(s: String): String? { 34 | return C2JUtils.unquote(s, quoteChar) 35 | } 36 | 37 | companion object { 38 | fun getQuoteType(stringSource: String): Optional { 39 | if (stringSource.length > 2) { 40 | for (type in QuoteType.values()) { 41 | if (type.isQuoted(stringSource)) { 42 | return Optional.of(type) 43 | } 44 | } 45 | } 46 | return Optional.empty() 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/rr/spriteframe_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** Sprites are patches with a special naming convention 4 | * so they can be recognized by R_InitSprites. 5 | * The base name is NNNNFx or NNNNFxFx, with 6 | * x indicating the rotation, x = 0, 1-7. 7 | * The sprite and frame specified by a thing_t 8 | * is range checked at run time. 9 | * A sprite is a patch_t that is assumed to represent 10 | * a three dimensional object and may have multiple 11 | * rotations pre drawn. 12 | * Horizontal flipping is used to save space, 13 | * thus NNNNF2F5 defines a mirrored patch. 14 | * Some sprites will only have one picture used 15 | * for all views: NNNNF0 16 | */ 17 | class spriteframe_t : Cloneable { 18 | /** If false use 0 for any position. 19 | * Note: as eight entries are available, 20 | * we might as well insert the same name eight times. 21 | * 22 | * FIXME: this is used as a tri-state. 23 | * 0= false 24 | * 1= true 25 | * -1= cleared/indeterminate, which should not evaluate to either true or false. 26 | */ 27 | var rotate = 0 28 | 29 | /** Lump to use for view angles 0-7. */ 30 | var lump: IntArray 31 | 32 | /** Flip bit (1 = flip) to use for view angles 0-7. */ 33 | var flip: ByteArray 34 | 35 | init { 36 | lump = IntArray(8) 37 | flip = ByteArray(8) 38 | } 39 | 40 | public override fun clone(): spriteframe_t { 41 | val response = spriteframe_t() 42 | response.rotate = rotate 43 | System.arraycopy(lump, 0, response.lump, 0, lump.size) 44 | System.arraycopy(flip, 0, response.flip, 0, flip.size) 45 | return response 46 | } 47 | } -------------------------------------------------------------------------------- /src/i/Strings.kt: -------------------------------------------------------------------------------- 1 | package i 2 | 3 | 4 | object Strings { 5 | const val MOCHA_DOOM_TITLE = "Kocoa Doom Alpha 1.7" 6 | const val MODIFIED_GAME = "===========================================================================\n" + 7 | "ATTENTION: This version of DOOM has been modified. If you would like to\n" + 8 | "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n" + 9 | " You will not receive technical support for modified games.\n" + 10 | " press enter to continue\n" + 11 | "===========================================================================\n" 12 | const val MODIFIED_GAME_TITLE = "Modified game alert" 13 | const val MODIFIED_GAME_DIALOG = "
" + 14 | "===========================================================================
" + 15 | "ATTENTION: This version of DOOM has been modified. If you would like to
" + 16 | "get a copy of the original game, call 1-800-IDGAMES or see the readme file.
" + 17 | " You will not receive technical support for modified games.
" + 18 | " press OK to continue
" + 19 | "===========================================================================
" + 20 | "
" 21 | const val LEVEL_FAILURE_TITLE = "Level loading failure" 22 | const val LEVEL_FAILURE_CAUSE = "
" + 23 | "Level loading failed!
" + 24 | "Press OK to end this game without exiting, or cancel to quit Doom." + 25 | "
" 26 | } -------------------------------------------------------------------------------- /src/v/graphics/Relocation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package v.graphics 19 | 20 | /** 21 | * Relocation represents a move of a fixed length of bytes/shorts/ints 22 | * from one range in screen buffer to another range of the same size 23 | * 24 | * @author Good Sign 25 | */ 26 | class Relocation { 27 | var source = 0 28 | var destination = 0 29 | var length = 0 30 | 31 | constructor() {} 32 | constructor(source: Int, destination: Int, length: Int) { 33 | this.source = source 34 | this.destination = destination 35 | this.length = length 36 | } 37 | 38 | fun shift(amount: Int): Relocation { 39 | source += amount 40 | destination += amount 41 | return this 42 | } 43 | 44 | fun retarget(source: Int, destination: Int): Relocation { 45 | this.source = source 46 | this.destination = destination 47 | return this 48 | } 49 | } -------------------------------------------------------------------------------- /src/v/renderers/DoomScreen.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package v.renderers 19 | 20 | import v.renderers.DoomScreen 21 | import java.util.* 22 | 23 | 24 | /** 25 | * 26 | * @author Good Sign 27 | */ 28 | enum class DoomScreen { 29 | FG, BG, WS, WE, SB; 30 | 31 | companion object { 32 | fun mapScreensToBuffers(bufferType: Class, bufferLen: Int): Map { 33 | return Arrays.stream(DoomScreen.values()) 34 | .collect({ EnumMap(DoomScreen::class.java) }, 35 | { map: EnumMap, screen: DoomScreen? -> 36 | map[screen] = java.lang.reflect.Array.newInstance(bufferType.componentType, bufferLen) as V 37 | }) { obj: EnumMap, m: EnumMap -> 38 | obj.putAll( 39 | m!! 40 | ) 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/timing/DelegateTicker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package timing 19 | 20 | /** 21 | * 22 | * @author Good Sign 23 | */ 24 | class DelegateTicker : ITicker { 25 | private val ft = FastTicker() 26 | private val mt = MilliTicker() 27 | private val nt = NanoTicker() 28 | private var currentTicker: ITicker = ft 29 | override fun GetTime(): Int { 30 | return currentTicker.GetTime() 31 | } 32 | 33 | fun changeTicker() { 34 | if (currentTicker === nt) { 35 | currentTicker = mt 36 | (currentTicker as MilliTicker).basetime = 0 37 | (currentTicker as MilliTicker).oldtics = 0 38 | } else if (currentTicker === mt) { 39 | currentTicker = ft 40 | (currentTicker as FastTicker).fasttic = 0 41 | } else { 42 | currentTicker = nt 43 | (currentTicker as NanoTicker).basetime = 0 44 | (currentTicker as NanoTicker).oldtics = 0 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/automap/IAutoMap.kt: -------------------------------------------------------------------------------- 1 | package automap 2 | 3 | 4 | 5 | import doom.SourceCode.AM_Map 6 | import doom.event_t 7 | 8 | interface IAutoMap { 9 | // Called by main loop. 10 | @AM_Map.C(AM_Map.AM_Responder) 11 | fun Responder(ev: event_t): Boolean 12 | 13 | // Called by main loop. 14 | fun Ticker() 15 | 16 | // Called by main loop, 17 | // called instead of view drawer if automap active. 18 | fun Drawer() 19 | 20 | // Added to be informed of gamma changes - Good Sign 2017/04/05 21 | fun Repalette() 22 | 23 | // Called to force the automap to quit 24 | // if the level is completed while it is up. 25 | @AM_Map.C(AM_Map.AM_Stop) 26 | fun Stop() 27 | fun Start() 28 | 29 | companion object { 30 | // Used by ST StatusBar stuff. 31 | const val AM_MSGHEADER = ('a'.code shl 24) + ('m'.code shl 16) 32 | val AM_MSGENTERED: Int = IAutoMap.AM_MSGHEADER or ('e'.code shl 8) 33 | val AM_MSGEXITED: Int = IAutoMap.AM_MSGHEADER or ('x'.code shl 8) 34 | 35 | // Color ranges for automap. Actual colors are bit-depth dependent. 36 | const val REDRANGE = 16 37 | const val BLUERANGE = 8 38 | const val GREENRANGE = 16 39 | const val GRAYSRANGE = 16 40 | const val BROWNRANGE = 16 41 | const val YELLOWRANGE = 1 42 | const val YOURRANGE = 0 43 | val WALLRANGE: Int = IAutoMap.REDRANGE 44 | val TSWALLRANGE: Int = IAutoMap.GRAYSRANGE 45 | val FDWALLRANGE: Int = IAutoMap.BROWNRANGE 46 | val CDWALLRANGE: Int = IAutoMap.YELLOWRANGE 47 | val THINGRANGE: Int = IAutoMap.GREENRANGE 48 | val SECRETWALLRANGE: Int = IAutoMap.WALLRANGE 49 | const val GRIDRANGE = 0 50 | } 51 | } -------------------------------------------------------------------------------- /src/w/JadDecompress.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import com.hiperbou.lang.times 4 | 5 | object JadDecompress { 6 | const val WINDOW_SIZE = 4096 7 | const val LOOKAHEAD_SIZE = 16 8 | const val LENSHIFT = 4 /* this must be log2(LOOKAHEAD_SIZE) */ 9 | fun decode(input: ByteArray, output: ByteArray) { 10 | /* 11 | * #ifdef JAGUAR decomp_input = input; decomp_output = output; 12 | * gpufinished = zero; gpucodestart = (int)&decomp_start; while 13 | * (!I_RefreshCompleted () ) ; #else 14 | */ 15 | var getidbyte = 0 16 | var len: Int 17 | var pos: Int 18 | var source_ptr: Int 19 | var input_ptr = 0 20 | var output_ptr = 0 21 | var idbyte = 0 22 | while (true) { 23 | 24 | /* get a new idbyte if necessary */ 25 | if (getidbyte == 0) idbyte = 0xFF and input[input_ptr++].toInt() 26 | getidbyte = getidbyte + 1 and 7 27 | if (idbyte and 1 != 0) { 28 | /* decompress */ 29 | pos = 0xFF and input[input_ptr++].toInt() shl JadDecompress.LENSHIFT 30 | pos = pos or (0xFF and input[input_ptr].toInt() shr JadDecompress.LENSHIFT) 31 | source_ptr = output_ptr - pos - 1 32 | len = (0xFF and input[input_ptr++].toInt() and 0xf) + 1 33 | if (len == 1) break 34 | len.times { 35 | output[output_ptr++] = output[source_ptr++] 36 | } 37 | } else { 38 | output[output_ptr++] = input[input_ptr++] 39 | } 40 | idbyte = idbyte shr 1 41 | } 42 | System.out.printf("Expanded %d to %d\n", input_ptr, output_ptr) 43 | } 44 | } -------------------------------------------------------------------------------- /src/p/ChaseDirections.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import data.Defines 5 | import m.fixed_t.Companion.MAPFRACUNIT 6 | 7 | object ChaseDirections { 8 | const val DI_EAST = 0 9 | const val DI_NORTHEAST = 1 10 | const val DI_NORTH = 2 11 | const val DI_NORTHWEST = 3 12 | const val DI_WEST = 4 13 | const val DI_SOUTHWEST = 5 14 | const val DI_SOUTH = 6 15 | const val DI_SOUTHEAST = 7 16 | const val DI_NODIR = 8 17 | const val NUMDIR = 9 18 | 19 | // 20 | // P_NewChaseDir related LUT. 21 | // 22 | val opposite = intArrayOf( 23 | ChaseDirections.DI_WEST, 24 | ChaseDirections.DI_SOUTHWEST, 25 | ChaseDirections.DI_SOUTH, 26 | ChaseDirections.DI_SOUTHEAST, 27 | ChaseDirections.DI_EAST, 28 | ChaseDirections.DI_NORTHEAST, 29 | ChaseDirections.DI_NORTH, 30 | ChaseDirections.DI_NORTHWEST, 31 | ChaseDirections.DI_NODIR 32 | ) 33 | val diags = intArrayOf( 34 | ChaseDirections.DI_NORTHWEST, 35 | ChaseDirections.DI_NORTHEAST, 36 | ChaseDirections.DI_SOUTHWEST, 37 | ChaseDirections.DI_SOUTHEAST 38 | ) 39 | val xspeed = intArrayOf( 40 | MAPFRACUNIT, 41 | 47000 / Defines.TIC_MUL, 42 | 0, 43 | -47000 / Defines.TIC_MUL, 44 | -MAPFRACUNIT, 45 | -47000 / Defines.TIC_MUL, 46 | 0, 47 | 47000 / Defines.TIC_MUL 48 | ) // all 49 | 50 | // fixed 51 | val yspeed = intArrayOf( 52 | 0, 53 | 47000 / Defines.TIC_MUL, 54 | MAPFRACUNIT, 55 | 47000 / Defines.TIC_MUL, 56 | 0, 57 | -47000 / Defines.TIC_MUL, 58 | -MAPFRACUNIT, 59 | -47000 / Defines.TIC_MUL 60 | ) // all 61 | // fixed 62 | } -------------------------------------------------------------------------------- /src/s/DoomSound.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import data.sfxinfo_t 4 | import javax.sound.sampled.AudioFormat 5 | import javax.sound.sampled.AudioFormat.Encoding 6 | 7 | /** A class representing a sample in memory 8 | * Convenient for wrapping/mirroring it regardless of what it represents. 9 | */ 10 | internal class DoomSound : sfxinfo_t { 11 | var format: AudioFormat 12 | 13 | constructor(format: AudioFormat) { 14 | this.format = format 15 | } 16 | 17 | constructor() { 18 | format = DoomSound.DEFAULT_DOOM_FORMAT 19 | } 20 | 21 | constructor(sfx: sfxinfo_t, format: AudioFormat) : this(format) { 22 | data = sfx.data 23 | pitch = sfx.pitch 24 | _link = sfx._link 25 | lumpnum = sfx.lumpnum 26 | name = sfx.name 27 | priority = sfx.priority 28 | singularity = sfx.singularity 29 | usefulness = sfx.usefulness 30 | volume = sfx.volume 31 | } 32 | 33 | companion object { 34 | /** This audio format is the one used by internal samples (16 bit, 11KHz, Stereo) 35 | * for Clips and AudioLines. Sure, it's not general enough... who cares though? 36 | */ 37 | val DEFAULT_SAMPLES_FORMAT = AudioFormat( 38 | Encoding.PCM_SIGNED, 39 | ISoundDriver.SAMPLERATE.toFloat(), 40 | 16, 41 | 2, 42 | 4, 43 | ISoundDriver.SAMPLERATE.toFloat(), 44 | true 45 | ) 46 | val DEFAULT_DOOM_FORMAT = AudioFormat( 47 | Encoding.PCM_UNSIGNED, 48 | ISoundDriver.SAMPLERATE.toFloat(), 49 | 8, 50 | 1, 51 | 1, 52 | ISoundDriver.SAMPLERATE.toFloat(), 53 | true 54 | ) 55 | } 56 | } -------------------------------------------------------------------------------- /src/doom/wbstartstruct_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | import data.Limits 5 | import utils.GenericCopy 6 | 7 | class wbstartstruct_t : Cloneable { 8 | var epsd // episode # (0-2) 9 | = 0 10 | 11 | // if true, splash the secret level 12 | var didsecret = false 13 | 14 | // previous and next levels, origin 0 15 | var last = 0 16 | var next = 0 17 | var maxkills = 0 18 | var maxitems = 0 19 | var maxsecret = 0 20 | var maxfrags = 0 21 | 22 | /** the par time */ 23 | var partime = 0 24 | 25 | /** index of this player in game */ 26 | var pnum = 0 27 | 28 | /** meant to be treated as a "struct", therefore assignments should be deep copies */ 29 | var plyr: Array 30 | 31 | init { 32 | plyr = GenericCopy.malloc({ wbplayerstruct_t() }, Limits.MAXPLAYERS) 33 | } 34 | 35 | public override fun clone(): wbstartstruct_t { 36 | var cl: wbstartstruct_t? = null 37 | try { 38 | cl = super.clone() as wbstartstruct_t 39 | } catch (e: CloneNotSupportedException) { 40 | // TODO Auto-generated catch block 41 | e.printStackTrace() 42 | } 43 | /*cl.epsd=this.epsd; 44 | cl.didsecret=this.didsecret; 45 | cl.last=this.last; 46 | cl.next=this.next; 47 | cl.maxfrags=this.maxfrags; 48 | cl.maxitems=this.maxitems; 49 | cl.maxsecret=this.maxsecret; 50 | cl.maxkills=this.maxkills; 51 | cl.partime=this.partime; 52 | cl.pnum=this.pnum;*/for (i in cl!!.plyr.indices) { 53 | cl.plyr[i] = plyr[i].clone() 54 | } 55 | //cl.plyr=this.plyr.clone(); 56 | return cl 57 | } 58 | } -------------------------------------------------------------------------------- /src/rr/maptexture_t.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | import utils.GenericCopy 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** Texture definition. 11 | * A DOOM wall texture is a list of patches which are to be combined in a predefined order. 12 | * This is the ON-DISK structure, to be read from the TEXTURES1 and TEXTURES2 lumps. 13 | * In memory, this becomes texture_t. 14 | * 15 | * @author MAES 16 | */ 17 | class maptexture_t : CacheableDoomObject { 18 | var name: String? = null 19 | var masked = false 20 | var width // was signed byte 21 | : Short = 0 22 | var height // was 23 | : Short = 0 24 | 25 | //void**t columndirectory; // OBSOLETE (yeah, but we must read a dummy integer here) 26 | var patchcount: Short = 0 27 | lateinit var patches: Array 28 | @Throws(IOException::class) 29 | override fun unpack(buf: ByteBuffer) { 30 | buf.order(ByteOrder.LITTLE_ENDIAN) 31 | name = DoomBuffer.getNullTerminatedString(buf, 8) 32 | masked = buf.int != 0 33 | width = buf.short 34 | height = buf.short 35 | buf.int // read a dummy integer for obsolete columndirectory. 36 | patchcount = buf.short 37 | 38 | // Simple sanity check. Do not attempt reading more patches than there 39 | // are left in the TEXTURE lump. 40 | patchcount = 41 | Math.min(patchcount.toInt(), (buf.capacity() - buf.position()) / mappatch_t.size()).toShort() 42 | patches = GenericCopy.malloc({ mappatch_t() }, patchcount.toInt()) 43 | DoomBuffer.readObjectArray(buf, patches as Array, patchcount.toInt()) 44 | } 45 | } -------------------------------------------------------------------------------- /src/p/floormove_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import rr.SectorAction 5 | import w.DoomIO 6 | import w.IReadableDoomObject 7 | import java.io.DataInputStream 8 | import java.io.IOException 9 | import java.nio.ByteBuffer 10 | 11 | class floormove_t : SectorAction(), IReadableDoomObject { 12 | var type: floor_e 13 | var crush = false 14 | var direction = 0 15 | var newspecial = 0 16 | var texture: Short = 0 17 | 18 | /** fixed_t */ 19 | var floordestheight = 0 20 | 21 | /** fixed_t */ 22 | var speed = 0 23 | 24 | init { 25 | // MAES HACK: floors are implied to be at least of "lowerFloor" type 26 | // unless set otherwise, due to implicit zero-enum value. 27 | type = floor_e.lowerFloor 28 | } 29 | 30 | @Throws(IOException::class) 31 | override fun read(f: DataInputStream) { 32 | super.read(f) // Call thinker reader first 33 | type = floor_e.values()[DoomIO.readLEInt(f)] 34 | crush = DoomIO.readIntBoolean(f) 35 | super.sectorid = DoomIO.readLEInt(f) // Sector index (or pointer?) 36 | direction = DoomIO.readLEInt(f) 37 | newspecial = DoomIO.readLEInt(f) 38 | texture = DoomIO.readLEShort(f) 39 | floordestheight = DoomIO.readLEInt(f) 40 | speed = DoomIO.readLEInt(f) 41 | } 42 | 43 | @Throws(IOException::class) 44 | override fun pack(b: ByteBuffer) { 45 | super.pack(b) //12 46 | b.putInt(type.ordinal) // 16 47 | b.putInt(if (crush) 1 else 0) //20 48 | b.putInt(super.sectorid) // 24 49 | b.putInt(direction) // 28 50 | b.putInt(newspecial) // 32 51 | b.putShort(texture) // 34 52 | b.putInt(floordestheight) // 38 53 | b.putInt(speed) // 42 54 | } 55 | } -------------------------------------------------------------------------------- /src/doom/DoomContext.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | /** Since a lot of stuff requires shared/global access to 5 | * the WadLoader, the Renderer, the Video system etc. and 6 | * we're trying to depart from the global/static mentality, 7 | * a common sharing is required. Ideally, this would be a perfect 8 | * example of where multiple inheritance could be adopted, since most 9 | * stuff needs to share this status anyway. The next best thing is 10 | * to have local references of any used fields in the classes that use them. 11 | * 12 | * About generics: T refers to the type of the graphics resources, and is 13 | * currently byte[], as all graphics resources are 8-bit indexed. There are 14 | * no plans that this will change anytime soon. Some classes should allow 15 | * different types in theory, but it would be too complex and pointless to 16 | * make everything fully compliant at the moment. 17 | * 18 | * V refers to the type of DISPLAY, and can be 8-bit (byte[]), 16-bit (short[] 19 | * for HiColor and lesser modes such as ARGB4444, etc.), and, in the future, 20 | * int[] (truecolor). 21 | * 22 | * The general approach is sharing as much code as possible between different 23 | * implementations (e.g. rendering code), and only specialize methods/classes when 24 | * the abstraction of generics isn't enough (typically, when you have to assign 25 | * directly to primitive arrays or deal with primitive method signatures). 26 | * 27 | * Classes that have specialized code for indexed and hicolor modes should be top-level 28 | * classes in their package, and contain two nested, static, extending classes called 29 | * Indexed and HiColor e.g. new MyClass.Indexed() and new MyClass.HiColor(), while any common 30 | * code should reside in MyClass. 31 | * 32 | * @author velktron 33 | */ 34 | class DoomContext -------------------------------------------------------------------------------- /src/p/Actions/ActiveStates/MonsterStates/Spiders.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1993-1996 by id Software, Inc. 3 | * Copyright (C) 2017 Good Sign 4 | * Copyright (C) 2022 hiperbou 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package p.Actions.ActiveStates.MonsterStatesimportimport 20 | 21 | 22 | import data.info 23 | import data.mobjtype_t 24 | import p.Actions.ActionTrait 25 | import p.mobj_t 26 | 27 | interface Spiders : ActionTrait { 28 | fun A_FaceTarget(actor: mobj_t?) 29 | fun A_SpidRefire(actor: mobj_t) { 30 | // keep firing unless target got out of sight 31 | A_FaceTarget(actor) 32 | if (P_Random() < 10) { 33 | return 34 | } 35 | if (actor.target == null || actor.target!!.health <= 0 || !enemies.CheckSight(actor, actor.target!!)) { 36 | actor.SetMobjState(actor.info!!.seestate) 37 | } 38 | } 39 | 40 | fun A_BspiAttack(actor: mobj_t) { 41 | if (actor.target == null) { 42 | return 43 | } 44 | A_FaceTarget(actor) 45 | 46 | // launch a missile 47 | attacks.SpawnMissile(actor, actor.target!!, mobjtype_t.MT_ARACHPLAZ) 48 | } 49 | } -------------------------------------------------------------------------------- /src/doom/IDatagramSerializable.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | /** Meant to provide a more lightweight alternative to Java's serialization model, 5 | * specifically for the purpose of sending 6 | * Objects implementing this can return references to one same byte array, with minimal 7 | * overhead. Since it's for send-only purposes, it won't matter if it's modified. 8 | * * 9 | * But don't use it in lieu of CacheableDoomObject! 10 | * 11 | * @author admin 12 | */ 13 | interface IDatagramSerializable { 14 | /** Packs object into a byte array suitable to send over 15 | * datagram networks. Typically, objects cache this array 16 | * for later use, and is availabe through cached() 17 | * 18 | * @return 19 | */ 20 | fun pack(): ByteArray 21 | 22 | /** Packs object into a byte array suitable to send over 23 | * datagram networks. The array is supplied externally 24 | * (good for daisy-chaining stuff into a single packet). 25 | * 26 | * @return 27 | */ 28 | fun pack(buf: ByteArray, offset: Int) 29 | 30 | /** Deserializes an object from a given byte buffer. 31 | * Only the first (sizeof) bytes will be used, dependant 32 | * on each object's implementation. Will NOT also copy 33 | * the byte[] caches. 34 | */ 35 | fun unpack(buf: ByteArray) 36 | 37 | /** Deserializes an object from a given byte buffer. 38 | * Only the first (sizeof) bytes will be used, starting 39 | * from a specified offset, dependant on each object's 40 | * implementation. 41 | */ 42 | fun unpack(buf: ByteArray, offset: Int) 43 | 44 | /** Only use this if you are 100% sure that the object's content 45 | * won't have changed since the last call of pack(). 46 | * 47 | * @return Should return the underlying byte[] array directly. 48 | */ 49 | fun cached(): ByteArray 50 | } -------------------------------------------------------------------------------- /src/doom/doomcom_t.kt: -------------------------------------------------------------------------------- 1 | package doom 2 | 3 | 4 | class doomcom_t { 5 | // Supposed to be DOOMCOM_ID? 6 | // Maes: was "long", but they intend 32-bit "int" here. Hurray for C's consistency! 7 | var id = 0 8 | 9 | // DOOM executes an int to execute commands. 10 | var intnum: Short = 0 11 | 12 | // Communication between DOOM and the driver. 13 | // Is CMD_SEND or CMD_GET. 14 | var command: Short = 0 15 | 16 | // Is dest for send, set by get (-1 = no packet). 17 | var remotenode: Short = 0 18 | 19 | // Number of bytes in doomdata to be sent 20 | var datalength: Short = 0 21 | 22 | // Info common to all nodes. 23 | // Console is allways node 0. 24 | var numnodes: Short = 0 25 | 26 | // Flag: 1 = no duplication, 2-5 = dup for slow nets. 27 | var ticdup: Short = 0 28 | 29 | // Flag: 1 = send a backup tic in every packet. 30 | var extratics: Short = 0 31 | 32 | // Flag: 1 = deathmatch. 33 | var deathmatch: Short = 0 34 | 35 | // Flag: -1 = new game, 0-5 = load savegame 36 | var savegame: Short = 0 37 | var episode // 1-3 38 | : Short = 0 39 | var map // 1-9 40 | : Short = 0 41 | var skill // 1-5 42 | : Short = 0 43 | 44 | // Info specific to this node. 45 | var consoleplayer: Short = 0 46 | var numplayers: Short = 0 47 | 48 | // These are related to the 3-display mode, 49 | // in which two drones looking left and right 50 | // were used to render two additional views 51 | // on two additional computers. 52 | // Probably not operational anymore. 53 | // 1 = left, 0 = center, -1 = right 54 | var angleoffset: Short = 0 55 | 56 | // 1 = drone 57 | var drone: Short = 0 58 | 59 | // The packet data to be sent. 60 | var data: doomdata_t 61 | 62 | init { 63 | data = doomdata_t() 64 | } 65 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/R_DrawColumnLow.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | import i.IDoomSystem 4 | import m.fixed_t.Companion.FRACBITS 5 | 6 | class R_DrawColumnLow( 7 | SCREENWIDTH: Int, SCREENHEIGHT: Int, 8 | ylookup: IntArray, columnofs: IntArray, dcvars: ColVars, 9 | screen: ShortArray?, I: IDoomSystem 10 | ) : DoomColumnFunction(SCREENWIDTH, SCREENHEIGHT, ylookup, columnofs, dcvars, screen, I) { 11 | init { 12 | _flags = DcFlags.LOW_DETAIL 13 | } 14 | 15 | override fun invoke() { 16 | var count: Int 17 | // MAES: were pointers. Of course... 18 | var dest: Int 19 | var dest2: Int 20 | val dc_source = dcvars.dc_source!! 21 | val dc_colormap = dcvars.dc_colormap!! 22 | val dc_source_ofs = dcvars.dc_source_ofs 23 | // Maes: fixed_t never used as such. 24 | var frac: Int 25 | val fracstep: Int 26 | count = dcvars.dc_yh - dcvars.dc_yl 27 | 28 | // Zero length. 29 | if (count < 0) return 30 | if (RANGECHECK) { 31 | performRangeCheck() 32 | } 33 | 34 | // The idea is to draw more than one pixel at a time. 35 | dest = blockyDest1() 36 | dest2 = blockyDest2() 37 | fracstep = dcvars.dc_iscale 38 | frac = dcvars.dc_texturemid + (dcvars.dc_yl - dcvars.centery) * fracstep 39 | // int spot=(frac >>> FRACBITS) & 127; 40 | do { 41 | 42 | // Hack. Does not work correctly. 43 | // MAES: that's good to know. 44 | screen!![dest2] = dc_colormap[0x00FF and dc_source[dc_source_ofs 45 | + (frac ushr FRACBITS and 127)].toInt()] 46 | screen[dest] = screen[dest2] 47 | dest += SCREENWIDTH 48 | dest2 += SCREENWIDTH 49 | frac += fracstep 50 | } while (count-- != 0) 51 | } 52 | } -------------------------------------------------------------------------------- /src/w/lumpinfo_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.InputStream 4 | 5 | /* 6 | typedef struct 7 | { 8 | // WARNING: order of some fields important (see info.c). 9 | 10 | char name[9]; 11 | int size; 12 | 13 | // killough 4/17/98: namespace tags, to prevent conflicts between resources 14 | enum { 15 | ns_global=0, 16 | ns_sprites, 17 | ns_flats, 18 | ns_colormaps, 19 | ns_prboom, 20 | ns_demos, 21 | ns_hires //e6y 22 | } li_namespace; // haleyjd 05/21/02: renamed from "namespace" 23 | 24 | wadfile_info_t *wadfile; 25 | int position; 26 | wad_source_t source; 27 | int flags; //e6y 28 | } lumpinfo_t; */ 29 | class lumpinfo_t : Cloneable { 30 | var name: String? = null 31 | var handle: InputStream? = null 32 | var position: Long = 0 33 | var size: Long = 0 34 | 35 | // A 32-bit hash which should be enough for searching through hashtables. 36 | var hash = 0 37 | 38 | // A 64-bit hash that just maps an 8-char string to a long num, good for hashing 39 | // or for direct comparisons. 40 | //public long stringhash; 41 | // Intepreting the first 32 bits of their name as an int. Used in initsprites. 42 | var intname = 0 43 | 44 | // public int next; 45 | //public int index; 46 | // For BOOM compatibility 47 | var namespace: li_namespace? = null 48 | var wadfile: wadfile_info_t? = null 49 | override fun hashCode(): Int { 50 | return hash 51 | } 52 | 53 | override fun toString(): String { 54 | return name + " " + Integer.toHexString(hash) 55 | } 56 | 57 | public override fun clone(): lumpinfo_t { 58 | val tmp = lumpinfo_t() 59 | tmp.name = name // Well... a reference will do. 60 | tmp.handle = handle 61 | tmp.position = position 62 | tmp.size = size 63 | tmp.hash = hash 64 | tmp.intname = intname 65 | tmp.namespace = namespace 66 | tmp.wadfile = wadfile 67 | return tmp 68 | } 69 | } -------------------------------------------------------------------------------- /src/pooling/RoguePatchMap2.kt: -------------------------------------------------------------------------------- 1 | package pooling 2 | 3 | 4 | import java.util.* 5 | 6 | class RoguePatchMap2 { 7 | fun containsKey(lump: Int): Boolean { 8 | return indexOf(lump) >= 0 9 | } 10 | 11 | operator fun get(lump: Int): Array? { 12 | val index = indexOf(lump) 13 | return if (index >= 0) { 14 | patches[index] 15 | } else { 16 | null 17 | } 18 | } 19 | 20 | fun put(lump: Int, patch: Array) { 21 | val index = indexOf(lump) 22 | if (index >= 0) { 23 | patches[index] = patch 24 | } else { 25 | ensureCapacity(numEntries + 1) 26 | val newIndex = index.inv() 27 | val moveCount = numEntries - newIndex 28 | if (moveCount > 0) { 29 | System.arraycopy(lumps, newIndex, lumps, newIndex + 1, moveCount) 30 | System.arraycopy(patches, newIndex, patches, newIndex + 1, moveCount) 31 | } 32 | lumps[newIndex] = lump 33 | patches[newIndex] = patch 34 | ++numEntries 35 | } 36 | } 37 | 38 | private fun ensureCapacity(cap: Int) { 39 | while (lumps.size <= cap) { 40 | lumps = Arrays.copyOf(lumps, Math.max(lumps.size * 2, RoguePatchMap2.DEFAULT_CAPACITY)) 41 | } 42 | while (patches.size <= cap) { 43 | patches = Arrays.copyOf(patches, Math.max(patches.size * 2, RoguePatchMap2.DEFAULT_CAPACITY)) 44 | } 45 | } 46 | 47 | private fun indexOf(lump: Int): Int { 48 | return Arrays.binarySearch(lumps, 0, numEntries, lump) 49 | } 50 | 51 | private var lumps: IntArray 52 | private var numEntries = 0 53 | private var patches: Array?> 54 | 55 | init { 56 | lumps = IntArray(DEFAULT_CAPACITY) 57 | patches = arrayOfNulls(DEFAULT_CAPACITY) 58 | } 59 | 60 | companion object { 61 | private const val DEFAULT_CAPACITY = 16 62 | } 63 | } -------------------------------------------------------------------------------- /src/data/mapthing_t.kt: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.IPackableDoomObject 6 | import w.IWritableDoomObject 7 | import java.io.DataOutputStream 8 | import java.io.IOException 9 | import java.nio.ByteBuffer 10 | import java.nio.ByteOrder 11 | 12 | /** mapthing_t ... same on disk AND in memory, wow?! */ 13 | class mapthing_t : CacheableDoomObject, IPackableDoomObject, IWritableDoomObject, Cloneable { 14 | var x: Short = 0 15 | var y: Short = 0 16 | var angle: Short = 0 17 | var type: Short = 0 18 | var options: Short = 0 19 | 20 | constructor() {} 21 | constructor(source: mapthing_t) { 22 | copyFrom(source) 23 | } 24 | 25 | @Throws(IOException::class) 26 | override fun unpack(buf: ByteBuffer) { 27 | buf.order(ByteOrder.LITTLE_ENDIAN) 28 | x = buf.short 29 | y = buf.short 30 | angle = buf.short 31 | type = buf.short 32 | options = buf.short 33 | } 34 | 35 | fun copyFrom(source: mapthing_t) { 36 | x = source.x 37 | y = source.y 38 | angle = source.angle 39 | options = source.options 40 | type = source.type 41 | } 42 | 43 | @Throws(IOException::class) 44 | override fun write(f: DataOutputStream) { 45 | 46 | // More efficient, avoids duplicating code and 47 | // handles little endian better. 48 | mapthing_t.iobuffer.position(0) 49 | mapthing_t.iobuffer.order(ByteOrder.LITTLE_ENDIAN) 50 | pack(mapthing_t.iobuffer) 51 | f.write(mapthing_t.iobuffer.array()) 52 | } 53 | 54 | override fun pack(b: ByteBuffer) { 55 | b.order(ByteOrder.LITTLE_ENDIAN) 56 | b.putShort(x) 57 | b.putShort(y) 58 | b.putShort(angle) 59 | b.putShort(type) 60 | b.putShort(options) 61 | } 62 | 63 | companion object { 64 | fun sizeOf(): Int { 65 | return 10 66 | } 67 | 68 | private val iobuffer = ByteBuffer.allocate(10) 69 | } 70 | } -------------------------------------------------------------------------------- /src/com/hiperbou/lang/LangExtensions.kt: -------------------------------------------------------------------------------- 1 | package com.hiperbou.lang 2 | 3 | 4 | //fun Boolean.toInt() = if (this) 1 else 0 5 | //fun Int.toBool() = if (this==0) false else true 6 | 7 | inline fun Array.apply(block: (T)->Unit, max:Int = this.size) { 8 | var i = 0 9 | while (i< max) { 10 | block(this[i]) 11 | i++ 12 | } 13 | } 14 | 15 | inline fun Array.transform(block: (T)->T, max:Int = this.size) { 16 | var i = 0 17 | while (i< max) { 18 | this[i] = block(this[i]) 19 | i++ 20 | } 21 | } 22 | 23 | inline fun BooleanArray.transform(block: (Boolean)->Boolean, max:Int = this.size) { 24 | var i = 0 25 | while (i< max) { 26 | this[i] = block(this[i]) 27 | i++ 28 | } 29 | } 30 | inline fun BooleanArray.transformIndexed(block: (Int)->Boolean, max:Int = this.size) { 31 | var i = 0 32 | while (i< max) { 33 | this[i] = block(i) 34 | i++ 35 | } 36 | } 37 | 38 | inline fun BooleanArray.transformIndexed(block: (Boolean, Int)->Boolean, max:Int = this.size) { 39 | var i = 0 40 | while (i< max) { 41 | this[i] = block(this[i], i) 42 | i++ 43 | } 44 | } 45 | 46 | inline fun IntArray.transform(block: (Int)->Int, max:Int = this.size) { 47 | var i = 0 48 | while (i< max) { 49 | this[i] = block(this[i]) 50 | i++ 51 | } 52 | } 53 | inline fun IntArray.multiply(times:Int, max:Int = this.size) { 54 | var i = 0 55 | while (i< max) { 56 | this[i] *= times 57 | i++ 58 | } 59 | } 60 | 61 | inline operator fun Int.times(block:(Int)->Unit) { 62 | var i = 0 63 | while (i < this) { 64 | block(i) 65 | i++ 66 | } 67 | } 68 | 69 | inline operator fun Short.times(block:(Int)->Unit) { 70 | var i = 0 71 | while (i < this) { 72 | block(i) 73 | i++ 74 | } 75 | } 76 | 77 | inline fun repeatFor(times:Int, block:(Int)->Unit) { 78 | var i = 0 79 | while (i < times) { 80 | block(i) 81 | i++ 82 | } 83 | } -------------------------------------------------------------------------------- /src/p/animdef_t.kt: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | 4 | import w.CacheableDoomObject 5 | import w.DoomBuffer 6 | import java.io.IOException 7 | import java.nio.ByteBuffer 8 | import java.nio.ByteOrder 9 | 10 | /** 11 | * Source animation definition. Made readable for compatibility with Boom's 12 | * SWANTBLS system. 13 | * 14 | * @author velktron 15 | */ 16 | class animdef_t : CacheableDoomObject { 17 | constructor() {} 18 | constructor( 19 | istexture: Boolean, endname: String?, startname: String?, 20 | speed: Int 21 | ) : super() { 22 | this.istexture = istexture 23 | this.endname = endname 24 | this.startname = startname 25 | this.speed = speed 26 | } 27 | 28 | /** if false, it is a flat, and will NOT be used as a texture. Unless you 29 | * use "flats on walls functionality of course. */ 30 | var istexture = false 31 | 32 | /** The END name and START name of a texture, given in this order when reading a lump 33 | * The animation system is agnostic to the actual names of of the "in-between" 34 | * frames, it's purely pointer based, and only the start/end are constant. It only 35 | * counts the actual number of existing textures during initialization time. 36 | * 37 | */ 38 | var endname: String? = null 39 | var startname: String? = null 40 | var speed = 0 41 | override fun toString(): String { 42 | return String.format( 43 | "%s %s %s %d", istexture, startname, endname, 44 | speed 45 | ) 46 | } 47 | 48 | @Throws(IOException::class) 49 | override fun unpack(buf: ByteBuffer) { 50 | // Like most Doom structs... 51 | buf.order(ByteOrder.LITTLE_ENDIAN) 52 | istexture = buf.get().toInt() != 0 53 | startname = DoomBuffer.getNullTerminatedString(buf, 9) 54 | endname = DoomBuffer.getNullTerminatedString(buf, 9) 55 | speed = buf.int 56 | } 57 | 58 | companion object { 59 | fun size(): Int { 60 | return 23 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/rr/drawfuns/ColVars.kt: -------------------------------------------------------------------------------- 1 | package rr.drawfuns 2 | 3 | 4 | /** This is all the information needed to draw a particular column. Really. 5 | * So if we store all of this crap somewhere instead of drawing, we can do the 6 | * drawing when it's more convenient, and since they are non-overlapping we can 7 | * parallelize them. Any questions? 8 | * 9 | */ 10 | class ColVars { 11 | /** when passing dc_source around, also set this */ 12 | var dc_source: T? = null 13 | var dc_source_ofs = 0 14 | var dc_translation: T? = null 15 | var viewheight = 0 16 | 17 | /** Used by functions that accept transparency or other special 18 | * remapping tables. 19 | * 20 | */ 21 | var tranmap: T? = null 22 | var centery = 0 23 | var dc_iscale = 0 24 | var dc_texturemid = 0 25 | var dc_texheight // Boom enhancement 26 | = 0 27 | var dc_x = 0 28 | var dc_yh = 0 29 | var dc_yl = 0 30 | var dc_flags = 0 31 | 32 | /** 33 | * MAES: this was a typedef for unsigned bytes, called "lighttable_t". It 34 | * makes more sense to make it generic and parametrize it to an array of 35 | * primitives since it's performance-critical in the renderer. 36 | * Now, whether this should be made bytes or shorts or chars or even ints 37 | * is debatable. 38 | */ 39 | var dc_colormap: V? = null 40 | 41 | /** Copies all BUT flags */ 42 | fun copyFrom(dcvars: ColVars) { 43 | dc_source = dcvars.dc_source 44 | dc_colormap = dcvars.dc_colormap 45 | dc_source_ofs = dcvars.dc_source_ofs 46 | viewheight = dcvars.viewheight 47 | centery = dcvars.centery 48 | dc_x = dcvars.dc_x 49 | dc_yh = dcvars.dc_yh 50 | dc_yl = dcvars.dc_yl 51 | dc_texturemid = dcvars.dc_texturemid 52 | dc_iscale = dcvars.dc_iscale 53 | dc_texheight = dcvars.dc_texheight 54 | } 55 | 56 | /** Assigns specific flags */ 57 | fun copyFrom(dcvars: ColVars, flags: Int) { 58 | this.copyFrom(dcvars) 59 | dc_flags = flags 60 | } 61 | } -------------------------------------------------------------------------------- /src/rr/ISpriteManager.kt: -------------------------------------------------------------------------------- 1 | package rr 2 | 3 | /** Interface for sprite managers. Handles loading sprites, fixing 4 | * rotations etc. and helping retrieving spritedefs when required. 5 | * 6 | * @author velktron. 7 | */ 8 | interface ISpriteManager { 9 | fun InitSpriteLumps() 10 | fun getNumSprites(): Int 11 | fun getFirstSpriteLump(): Int 12 | fun getSprites(): Array 13 | fun getSprite(index: Int): spritedef_t 14 | fun getSpriteWidth(): IntArray 15 | fun getSpriteOffset(): IntArray 16 | fun getSpriteTopOffset(): IntArray 17 | fun getSpriteWidth(index: Int): Int 18 | fun getSpriteOffset(index: Int): Int 19 | fun getSpriteTopOffset(index: Int): Int 20 | fun InitSprites(namelist: Array?) 21 | 22 | companion object { 23 | /** Default known sprite names for DOOM */ 24 | val doomsprnames = arrayOf( 25 | "TROO", "SHTG", "PUNG", "PISG", "PISF", "SHTF", "SHT2", "CHGG", "CHGF", "MISG", 26 | "MISF", "SAWG", "PLSG", "PLSF", "BFGG", "BFGF", "BLUD", "PUFF", "BAL1", "BAL2", 27 | "PLSS", "PLSE", "MISL", "BFS1", "BFE1", "BFE2", "TFOG", "IFOG", "PLAY", "POSS", 28 | "SPOS", "VILE", "FIRE", "FATB", "FBXP", "SKEL", "MANF", "FATT", "CPOS", "SARG", 29 | "HEAD", "BAL7", "BOSS", "BOS2", "SKUL", "SPID", "BSPI", "APLS", "APBX", "CYBR", 30 | "PAIN", "SSWV", "KEEN", "BBRN", "BOSF", "ARM1", "ARM2", "BAR1", "BEXP", "FCAN", 31 | "BON1", "BON2", "BKEY", "RKEY", "YKEY", "BSKU", "RSKU", "YSKU", "STIM", "MEDI", 32 | "SOUL", "PINV", "PSTR", "PINS", "MEGA", "SUIT", "PMAP", "PVIS", "CLIP", "AMMO", 33 | "ROCK", "BROK", "CELL", "CELP", "SHEL", "SBOX", "BPAK", "BFUG", "MGUN", "CSAW", 34 | "LAUN", "PLAS", "SHOT", "SGN2", "COLU", "SMT2", "GOR1", "POL2", "POL5", "POL4", 35 | "POL3", "POL1", "POL6", "GOR2", "GOR3", "GOR4", "GOR5", "SMIT", "COL1", "COL2", 36 | "COL3", "COL4", "CAND", "CBRA", "COL6", "TRE1", "TRE2", "ELEC", "CEYE", "FSKU", 37 | "COL5", "TBLU", "TGRN", "TRED", "SMBT", "SMGT", "SMRT", "HDB1", "HDB2", "HDB3", 38 | "HDB4", "HDB5", "HDB6", "POB1", "POB2", "BRS1", "TLMP", "TLP2" 39 | ) 40 | } 41 | } -------------------------------------------------------------------------------- /src/pooling/GenericIntMap.kt: -------------------------------------------------------------------------------- 1 | package pooling 2 | 3 | 4 | import java.util.* 5 | 6 | abstract class GenericIntMap internal constructor() { 7 | fun containsKey(lump: Int): Boolean { 8 | return indexOf(lump) >= 0 9 | } 10 | 11 | operator fun get(lump: Int): K? { 12 | val index = indexOf(lump) 13 | return if (index >= 0) { 14 | patches[index] 15 | } else { 16 | null 17 | } 18 | } 19 | 20 | fun put(lump: Int, patch: K) { 21 | val index = indexOf(lump) 22 | if (index >= 0) { 23 | patches[index] = patch 24 | } else { 25 | ensureCapacity(numEntries + 1) 26 | val newIndex = index.inv() 27 | val moveCount = numEntries - newIndex 28 | if (moveCount > 0) { 29 | System.arraycopy(lumps, newIndex, lumps, newIndex + 1, moveCount) 30 | System.arraycopy(patches, newIndex, patches, newIndex + 1, moveCount) 31 | } 32 | lumps[newIndex] = lump 33 | patches[newIndex] = patch 34 | ++numEntries 35 | } 36 | } 37 | 38 | protected fun ensureCapacity(cap: Int) { 39 | while (lumps.size <= cap) { 40 | lumps = Arrays.copyOf(lumps, Math.max(lumps.size * 2, GenericIntMap.DEFAULT_CAPACITY)) 41 | } 42 | while (patches.size <= cap) { 43 | patches = Arrays.copyOf(patches, Math.max(patches.size * 2, GenericIntMap.DEFAULT_CAPACITY)) 44 | } 45 | } 46 | 47 | protected fun indexOf(lump: Int): Int { 48 | return Arrays.binarySearch(lumps, 0, numEntries, lump) 49 | //for (int i=0;i 58 | 59 | /** Concrete implementations must allocate patches 60 | * 61 | */ 62 | init { 63 | lumps = IntArray(GenericIntMap.DEFAULT_CAPACITY) 64 | // patches = new K[DEFAULT_CAPACITY]; 65 | } 66 | 67 | companion object { 68 | const val DEFAULT_CAPACITY = 16 69 | } 70 | } -------------------------------------------------------------------------------- /.idea/libraries/KotlinJavaRuntime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/g/DoomGameInterface.kt: -------------------------------------------------------------------------------- 1 | package g 2 | 3 | 4 | import defines.skill_t 5 | import doom.event_t 6 | import doom.gameaction_t 7 | 8 | //----------------------------------------------------------------------------- 9 | // 10 | // $Id: DoomGameInterface.java,v 1.4 2010/12/20 17:15:08 velktron Exp $ 11 | // 12 | // Copyright (C) 1993-1996 by id Software, Inc. 13 | // Copyright (C) 2022 hiperbou 14 | // 15 | // This program is free software; you can redistribute it and/or 16 | // modify it under the terms of the GNU General Public License 17 | // as published by the Free Software Foundation; either version 2 18 | // of the License, or (at your option) any later version. 19 | // 20 | // This program is distributed in the hope that it will be useful, 21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | // GNU General Public License for more details. 24 | // 25 | // DESCRIPTION: 26 | // Duh. 27 | // 28 | //----------------------------------------------------------------------------- 29 | interface DoomGameInterface { 30 | // 31 | // GAME 32 | // 33 | fun DeathMatchSpawnPlayer(playernum: Int) 34 | fun InitNew(skill: skill_t?, episode: Int, map: Int) 35 | 36 | /** Can be called by the startup code or M_Responder. 37 | * A normal game starts at map 1, 38 | * but a warp test can start elsewhere */ 39 | fun DeferedInitNew(skill: skill_t?, episode: Int, map: Int) 40 | fun DeferedPlayDemo(demo: String?) 41 | 42 | /** Can be called by the startup code or M_Responder, 43 | * calls P_SetupLevel or W_EnterWorld. */ 44 | fun LoadGame(name: String?) 45 | fun DoLoadGame() 46 | 47 | /** Called by M_Responder. */ 48 | fun SaveGame(slot: Int, description: String?) 49 | 50 | /** Only called by startup code. */ 51 | fun RecordDemo(name: String?) 52 | fun BeginRecording() 53 | fun PlayDemo(name: String?) 54 | fun TimeDemo(name: String?) 55 | fun CheckDemoStatus(): Boolean 56 | fun ExitLevel() 57 | fun SecretExitLevel() 58 | fun WorldDone() 59 | fun Ticker() 60 | fun Responder(ev: event_t?): Boolean 61 | fun ScreenShot() 62 | var gameAction: gameaction_t? 63 | var paused: Boolean 64 | } -------------------------------------------------------------------------------- /src/st/IDoomStatusBar.kt: -------------------------------------------------------------------------------- 1 | package st 2 | 3 | import doom.SourceCode.ST_Stuff 4 | import doom.event_t 5 | 6 | //----------------------------------------------------------------------------- 7 | // 8 | // $Id: IDoomStatusBar.java,v 1.4 2012/09/24 17:16:23 velktron Exp $ 9 | // 10 | // Copyright (C) 1993-1996 by id Software, Inc. 11 | // Copyright (C) 2022 hiperbou 12 | // 13 | // This program is free software; you can redistribute it and/or 14 | // modify it under the terms of the GNU General Public License 15 | // as published by the Free Software Foundation; either version 2 16 | // of the License, or (at your option) any later version. 17 | // 18 | // This program is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU General Public License for more details. 22 | // 23 | // DESCRIPTION: 24 | // Status bar code. 25 | // Does the face/direction indicator animatin. 26 | // Does palette indicators as well (red pain/berserk, bright pickup) 27 | // 28 | //----------------------------------------------------------------------------- 29 | interface IDoomStatusBar { 30 | // 31 | // STATUS BAR 32 | // 33 | fun NotifyAMEnter() 34 | fun NotifyAMExit() 35 | 36 | /** Called by main loop. */ 37 | @ST_Stuff.C(ST_Stuff.ST_Responder) 38 | fun Responder(ev: event_t): Boolean 39 | 40 | /** Called by main loop. */ 41 | fun Ticker() 42 | 43 | /** Called by main loop. */ 44 | fun Drawer(fullscreen: Boolean, refresh: Boolean) 45 | 46 | /** Called when the console player is spawned on each level. */ 47 | fun Start() 48 | 49 | /** Called by startup code. */ 50 | fun Init() 51 | 52 | /** Used externally to determine window scaling. 53 | * This means that drawing transparent status bars is possible, but 54 | * it will look fugly because of the solid windowing (and possibly 55 | * HOMS). 56 | */ 57 | fun getHeight(): Int 58 | 59 | /** Forces a full refresh for reasons not handled otherwise, e.g. after full-page 60 | * draws of help screens, which normally don't trigger a complete redraw even if 61 | * they should, really. 62 | */ 63 | fun forceRefresh() 64 | } -------------------------------------------------------------------------------- /src/s/DummySoundDriver.kt: -------------------------------------------------------------------------------- 1 | package s 2 | 3 | import data.sounds.musicenum_t 4 | import data.sounds.sfxenum_t 5 | import p.mobj_t 6 | 7 | /** Does nothing. Just allows me to code without 8 | * commenting out ALL sound-related code. Hopefully 9 | * it will be superseded by a real sound driver one day. 10 | * 11 | * @author Velktron 12 | */ 13 | class DummySoundDriver : IDoomSound { 14 | override fun Init(sfxVolume: Int, musicVolume: Int) { 15 | // TODO Auto-generated method stub 16 | } 17 | 18 | override fun Start() { 19 | // TODO Auto-generated method stub 20 | } 21 | 22 | override fun StartSound(origin: ISoundOrigin?, sound_id: Int) { 23 | // TODO Auto-generated method stub 24 | } 25 | 26 | override fun StartSound(origin: ISoundOrigin?, sound_id: sfxenum_t?) { 27 | // TODO Auto-generated method stub 28 | } 29 | 30 | override fun StartSoundAtVolume(origin: ISoundOrigin?, sound_id: Int, volume: Int) { 31 | // TODO Auto-generated method stub 32 | } 33 | 34 | override fun StopSound(origin: ISoundOrigin?) { 35 | // TODO Auto-generated method stub 36 | } 37 | 38 | override fun ChangeMusic(musicnum: Int, looping: Boolean) { 39 | // TODO Auto-generated method stub 40 | } 41 | 42 | override fun StopMusic() { 43 | // TODO Auto-generated method stub 44 | } 45 | 46 | override fun PauseSound() { 47 | // TODO Auto-generated method stub 48 | } 49 | 50 | override fun ResumeSound() { 51 | // TODO Auto-generated method stub 52 | } 53 | 54 | override fun UpdateSounds(listener: mobj_t) { 55 | // TODO Auto-generated method stub 56 | } 57 | 58 | override fun SetMusicVolume(volume: Int) { 59 | // TODO Auto-generated method stub 60 | } 61 | 62 | override fun SetSfxVolume(volume: Int) { 63 | // TODO Auto-generated method stub 64 | } 65 | 66 | override fun StartMusic(music_id: Int) { 67 | // TODO Auto-generated method stub 68 | } 69 | 70 | override fun StartMusic(music_id: musicenum_t) { 71 | // TODO Auto-generated method stub 72 | } 73 | 74 | override fun ChangeMusic(musicnum: musicenum_t, looping: Boolean) { 75 | // TODO Auto-generated method stub 76 | } 77 | } -------------------------------------------------------------------------------- /src/w/filelump_t.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.DataInputStream 4 | import java.io.DataOutputStream 5 | import java.io.IOException 6 | import java.util.* 7 | 8 | /** filelumps are on-disk structures. lumpinfos are almost the same, but are memory only. 9 | * 10 | * @author Maes 11 | */ 12 | class filelump_t : IReadableDoomObject, IWritableDoomObject { 13 | var filepos: Long = 0 14 | var size // Is INT 32-bit in file! 15 | : Long = 0 16 | var name // Whatever appears inside the wadfile 17 | : String? = null 18 | var actualname // Sanitized name, e.g. after compression markers 19 | : String? = null 20 | var big_endian = false // E.g. Jaguar 21 | var compressed = false // Compressed lump 22 | @Throws(IOException::class) 23 | override fun read(f: DataInputStream) { 24 | // MAES: Byte Buffers actually make it convenient changing byte order on-the-fly. 25 | // But RandomAccessFiles (and inputsteams) don't :-S 26 | if (!big_endian) { 27 | filepos = DoomIO.readUnsignedLEInt(f) 28 | size = DoomIO.readUnsignedLEInt(f) 29 | } else { 30 | filepos = f.readInt().toLong() 31 | size = f.readInt().toLong() 32 | } 33 | 34 | // Names used in the reading subsystem should be upper case, 35 | // but check for compressed status first 36 | name = DoomIO.readNullTerminatedString(f, 8) 37 | val stuff = name!!.toCharArray() 38 | 39 | // It's a compressed lump 40 | if (stuff[0].code > 0x7F) { 41 | compressed = true 42 | stuff[0] = (stuff[0].code and 0x7F).toChar() 43 | } 44 | actualname = String(stuff).uppercase(Locale.getDefault()) 45 | } 46 | 47 | @Throws(IOException::class) 48 | override fun write(dos: DataOutputStream) { 49 | if (!big_endian) { 50 | DoomIO.writeLEInt(dos, filepos.toInt()) 51 | DoomIO.writeLEInt(dos, size.toInt()) 52 | } else { 53 | dos.writeInt(filepos.toInt()) 54 | dos.writeInt(size.toInt()) 55 | } 56 | DoomIO.writeString(dos, name, 8) 57 | } 58 | 59 | companion object { 60 | fun sizeof(): Int { 61 | return 4 + 4 + 8 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/m/IDoomMenu.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | import doom.SourceCode.M_Menu 5 | import doom.event_t 6 | 7 | 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // $Id: IDoomMenu.java,v 1.5 2011/09/29 15:16:23 velktron Exp $ 11 | // 12 | // Copyright (C) 1993-1996 by id Software, Inc. 13 | // Copyright (C) 2022 hiperbou 14 | // 15 | // This program is free software; you can redistribute it and/or 16 | // modify it under the terms of the GNU General Public License 17 | // as published by the Free Software Foundation; either version 2 18 | // of the License, or (at your option) any later version. 19 | // 20 | // This program is distributed in the hope that it will be useful, 21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | // GNU General Public License for more details. 24 | // 25 | // DESCRIPTION: 26 | // Menu widget stuff, episode selection and such. 27 | // 28 | // ----------------------------------------------------------------------------- 29 | /** 30 | * 31 | */ 32 | interface IDoomMenu { 33 | // 34 | // MENUS 35 | // 36 | /** 37 | * Called by main loop, saves config file and calls I_Quit when user exits. 38 | * Even when the menu is not displayed, this can resize the view and change 39 | * game parameters. Does all the real work of the menu interaction. 40 | */ 41 | @M_Menu.C(M_Menu.M_Responder) 42 | fun Responder(ev: event_t): Boolean 43 | 44 | /** 45 | * Called by main loop, only used for menu (skull cursor) animation. 46 | */ 47 | @M_Menu.C(M_Menu.M_Ticker) 48 | fun Ticker() 49 | 50 | /** 51 | * Called by main loop, draws the menus directly into the screen buffer. 52 | */ 53 | @M_Menu.C(M_Menu.M_Drawer) 54 | fun Drawer() 55 | 56 | /** 57 | * Called by D_DoomMain, loads the config file. 58 | */ 59 | @M_Menu.C(M_Menu.M_Init) 60 | fun Init() 61 | 62 | /** 63 | * Called by intro code to force menu up upon a keypress, does nothing if 64 | * menu is already up. 65 | */ 66 | @M_Menu.C(M_Menu.M_StartControlPanel) 67 | fun StartControlPanel() 68 | var showMessages: Boolean 69 | var screenBlocks: Int 70 | val detailLevel: Int 71 | fun ClearMenus() 72 | } -------------------------------------------------------------------------------- /src/v/scale/VideoScale.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see //www.gnu.org/licenses/>. 17 | */ 18 | package v.scale 19 | 20 | /** 21 | * Interface for an object that conveys screen resolution/scaling information, meant to replace the static declarations 22 | * in Defines. 23 | * 24 | * @author velktron 25 | */ 26 | interface VideoScale { 27 | fun getScreenWidth(): Int 28 | fun getScreenHeight(): Int 29 | fun getScalingX(): Int 30 | fun getScalingY(): Int 31 | 32 | /** 33 | * Safest global scaling for fixed stuff like menus, titlepic etc 34 | */ 35 | fun getSafeScaling(): Int 36 | 37 | /** 38 | * Get floating point screen multiplier. Not recommended, as it causes visual glitches. Replace with safe scale, 39 | * whenever possible 40 | */ 41 | fun getScreenMul(): Float 42 | 43 | /** 44 | * Future, should signal aware objects that they should refresh their resolution-dependent state, structures, 45 | * variables etc. 46 | * 47 | * @return 48 | */ 49 | fun changed(): Boolean 50 | 51 | companion object { 52 | //It is educational but futile to change this 53 | //scaling e.g. to 2. Drawing of status bar, 54 | //menues etc. is tied to the scale implied 55 | //by the graphics. 56 | const val INV_ASPECT_RATIO = 0.625 // 0.75, ideally 57 | 58 | // 59 | // For resize of screen, at start of game. 60 | // It will not work dynamically, see visplanes. 61 | // 62 | const val BASE_WIDTH = 320 63 | val BASE_HEIGHT: Int = (VideoScale.INV_ASPECT_RATIO * 320).toInt() // 200 64 | } 65 | } -------------------------------------------------------------------------------- /src/f/anim_t.kt: -------------------------------------------------------------------------------- 1 | package f 2 | 3 | 4 | import rr.patch_t 5 | import w.animenum_t 6 | 7 | // 8 | //Animation. 9 | //There is another anim_t used in p_spec. 10 | // 11 | class anim_t { 12 | constructor( 13 | type: animenum_t, period: Int, nanims: Int, loc: point_t, 14 | data1: Int, data2: Int, p: Array, nexttic: Int, lastdrawn: Int, 15 | ctr: Int, state: Int 16 | ) { 17 | this.type = type 18 | this.period = period 19 | this.nanims = nanims 20 | this.loc = loc 21 | this.data1 = data1 22 | this.data2 = data2 23 | this.p = p 24 | this.nexttic = nexttic 25 | this.lastdrawn = lastdrawn 26 | this.ctr = ctr 27 | this.state = state 28 | } 29 | 30 | // Partial constructor, only 4 first fields. 31 | constructor( 32 | animAlways: animenum_t, period: Int, nanims: Int, loc: point_t 33 | ) { 34 | type = animAlways 35 | this.period = period 36 | this.nanims = nanims 37 | this.loc = loc 38 | } 39 | 40 | // Partial constructor, only 5 first fields. 41 | constructor( 42 | type: animenum_t, period: Int, nanims: Int, loc: point_t, data1: Int 43 | ) { 44 | this.type = type 45 | this.period = period 46 | this.nanims = nanims 47 | this.loc = loc 48 | this.data1 = data1 49 | } 50 | 51 | var type: animenum_t 52 | 53 | // period in tics between animations 54 | var period: Int 55 | 56 | // number of animation frames 57 | var nanims: Int 58 | 59 | // location of animation 60 | var loc: point_t 61 | 62 | // ALWAYS: n/a, 63 | // RANDOM: period deviation (<256), 64 | // LEVEL: level 65 | var data1 = 0 66 | 67 | // ALWAYS: n/a, 68 | // RANDOM: random base period, 69 | // LEVEL: n/a 70 | var data2 = 0 71 | 72 | // actual graphics for frames of animations 73 | //Maes: was pointer to array 74 | var p = arrayOfNulls(3) 75 | 76 | // following must be initialized to zero before use! 77 | // next value of bcnt (used in conjunction with period) 78 | var nexttic = 0 79 | 80 | // last drawn animation frame 81 | var lastdrawn = 0 82 | 83 | // next frame number to animate 84 | var ctr = 0 85 | 86 | // used by RANDOM and LEVEL when animating 87 | var state = 0 88 | } -------------------------------------------------------------------------------- /src/m/Swap.kt: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | 4 | //----------------------------------------------------------------------------- 5 | // 6 | // $Id: Swap.java,v 1.2 2011/07/27 20:48:20 velktron Exp $ 7 | // 8 | // Copyright (C) 1993-1996 by id Software, Inc. 9 | // Copyright (C) 2022 hiperbou 10 | // 11 | // This program is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License 13 | // as published by the Free Software Foundation; either version 2 14 | // of the License, or (at your option) any later version. 15 | // 16 | // This program is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // DESCRIPTION: 22 | // Endianess handling, swapping 16bit and 32bit. 23 | // It's role is much less important than in C-based ports (because of stream 24 | // built-in endianness settings), but they are still used occasionally. 25 | // 26 | //----------------------------------------------------------------------------- 27 | object Swap { 28 | // Swap 16bit, that is, MSB and LSB byte. 29 | fun SHORT(x: Short): Short { 30 | // No masking with 0xFF should be necessary. 31 | // MAES: necessary with java due to sign trailing. 32 | return ((x.toInt() ushr 8 and 0xFF).toShort().toInt() or (x.toInt() shl 8)).toShort() 33 | } 34 | 35 | //Swap 16bit, that is, MSB and LSB byte. 36 | fun SHORT(x: Char): Short { 37 | // No masking with 0xFF should be necessary. 38 | // MAES: necessary with java due to sign trailing. 39 | return ((x.code ushr 8 and 0xFF).toShort().toInt() or (x.code shl 8)).toShort() 40 | } 41 | 42 | //Swap 16bit, that is, MSB and LSB byte. 43 | fun USHORT(x: Char): Char { 44 | // No masking with 0xFF should be necessary. 45 | // MAES: necessary with java due to sign trailing. 46 | return ((x.code ushr 8 and 0xFF).toChar().code or (x.code shl 8)).toChar() 47 | } 48 | 49 | // Swapping 32bit. 50 | // Maes: the "long" here is really 32-bit. 51 | fun LONG(x: Int): Int { 52 | return (x ushr 24 53 | or (x ushr 8 and 0xff00) 54 | or (x shl 8 and 0xff0000) 55 | or (x shl 24)) 56 | } 57 | } -------------------------------------------------------------------------------- /src/w/CacheableDoomObject.kt: -------------------------------------------------------------------------------- 1 | package w 2 | 3 | import java.io.IOException 4 | import java.nio.ByteBuffer 5 | 6 | /** All objects that can be deserialized from raw byte buffers such as those 7 | * read from WAD lumps should implement this method, so that the WadLoader 8 | * can cache them, and recursive calls to sub-objects can be made. 9 | * 10 | * E.g. an object of type A consists of a header and a list of objects of type B. 11 | * Calling A.unpack(buf) will cause A to unmarshal its own header, set the list of 12 | * B objects, and then call B.unpack() for each of them, by passing the same buffer 13 | * along. 14 | * 15 | * This system works cleanly, and allows to simulate Doom's "cached memory" while 16 | * returning proper objects of the correct type and keeping close to Java's 17 | * "correct" way of doing things. 18 | * * 19 | * For example, if a patch_t is read from disk, the WadLoader uses its unpack() method 20 | * to read it from a lump read from disk, and creates a new patch_t object, which is placed 21 | * in the lump cache (which holds CacheableDoomObject, incidentally). The next time this 22 | * same patch_t is requested, the reference to the already cached patch_t will be returned, 23 | * if it hasn't been forcedly flushed from the cache. Voila', lump caching! 24 | * 25 | * The principle can be applied to ARRAYS of similar objects too: using the same buffer, 26 | * iterative serial unpacking is possible, while still mantaining a "cached" reference 27 | * to their array (TODO: actually, this needs to be implemented more efficiently. Look in 28 | * WadLoader) 29 | * 30 | * The opposite would be a "PackableDoomObject", aka objects that can pack themselves into 31 | * a byte buffer for transmission purposes, although Doom doesn't really need to write as 32 | * much as it needs reading. 33 | * 34 | * For the purpose of saving/loading games, which need to read/write to variable disk 35 | * structures ALL the time, use the ReadableDoomObject/WritableDoomObject interfaces. 36 | * Their difference is that they are highly mutable and supposed to be read from files 37 | * or input/output streams, and that a continuous reference to them as deserialized 38 | * objects (e.g. in the caching mechanism) is not needed. 39 | * 40 | * 41 | * @author Velktron 42 | */ 43 | interface CacheableDoomObject { 44 | @Throws(IOException::class) 45 | fun unpack(buf: ByteBuffer) 46 | } -------------------------------------------------------------------------------- /src/v/graphics/Points.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Good Sign 3 | * Copyright (C) 2022 hiperbou 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package v.graphics 19 | 20 | import rr.patch_t 21 | import v.graphics.Screens.BadRangeException 22 | 23 | /** 24 | * 25 | * @author Good Sign 26 | */ 27 | interface Points> : Screens { 28 | @Throws(BadRangeException::class) 29 | fun doRangeCheck(x: Int, y: Int, width: Int, height: Int) { 30 | if (x >= 0 && y >= 0) { 31 | val scrWidth = this.getScreenWidth() 32 | val scrHeight = this.getScreenHeight() 33 | if (x + width > scrWidth || y + height > scrWidth) { 34 | throw BadRangeException( 35 | String.format( 36 | "Coordinates overflow screen space: (%d, %d, %d, %d) on screen %dx%d", 37 | x, y, x + width, y + height, scrWidth, scrHeight 38 | ) 39 | ) 40 | } 41 | } else { 42 | throw IllegalArgumentException(String.format("Invalid coordinates: (%d, %d)", x, y)) 43 | } 44 | } 45 | 46 | @Throws(BadRangeException::class) 47 | fun doRangeCheck(x: Int, y: Int, patch: patch_t) { 48 | doRangeCheck(x, y, patch.width.toInt(), patch.height.toInt()) 49 | } 50 | 51 | @Throws(BadRangeException::class) 52 | fun doRangeCheck(x: Int, y: Int, patch: patch_t, dupx: Int, dupy: Int) { 53 | doRangeCheck(x, y, patch.width * dupx, patch.height * dupy) 54 | } 55 | 56 | fun point(x: Int, y: Int): Int { 57 | return y * getScreenWidth() + x 58 | } 59 | 60 | fun point(x: Int, y: Int, width: Int): Int { 61 | return y * width + x 62 | } 63 | } -------------------------------------------------------------------------------- /src/awt/DisplayModePicker.kt: -------------------------------------------------------------------------------- 1 | package awt 2 | 3 | 4 | import java.awt.DisplayMode 5 | import java.awt.GraphicsDevice 6 | import java.util.* 7 | 8 | class DisplayModePicker(protected var device: GraphicsDevice) { 9 | protected var default_mode: DisplayMode 10 | 11 | init { 12 | default_mode = device.displayMode 13 | } 14 | 15 | fun pickClosest(width: Int, height: Int): DisplayMode? { 16 | val modes = device.displayModes 17 | val picks: MutableList = ArrayList() 18 | val wc = WidthComparator() 19 | val hc = HeightComparator() 20 | 21 | // Filter out those with too small dimensions. 22 | for (dm in modes) { 23 | if (dm.width >= width && dm.height >= height) { 24 | picks.add(dm) 25 | } 26 | } 27 | if (picks.size > 0) { 28 | Collections.sort(picks, wc.thenComparing(hc)) 29 | } 30 | 31 | // First one is the minimum that satisfies the desired criteria. 32 | return picks[0] 33 | } 34 | 35 | /** 36 | * Return offsets to center rasters too oddly shaped to fit entirely into 37 | * a standard display mode (unfortunately, this means most stuff > 640 x 400), 38 | * with doom's standard 8:5 ratio. 39 | * 40 | * @param width 41 | * @param height 42 | * @param dm 43 | * @return array, x-offset and y-offset. 44 | */ 45 | fun getCentering(width: Int, height: Int, dm: DisplayMode): IntArray { 46 | val xy = IntArray(2) 47 | xy[0] = (dm.width - width) / 2 48 | xy[1] = (dm.height - height) / 2 49 | return xy 50 | } 51 | 52 | internal inner class WidthComparator : Comparator { 53 | override fun compare(arg0: DisplayMode, arg1: DisplayMode): Int { 54 | if (arg0.width > arg1.width) { 55 | return 1 56 | } 57 | return if (arg0.width < arg1.width) { 58 | -1 59 | } else 0 60 | } 61 | } 62 | 63 | internal inner class HeightComparator : Comparator { 64 | override fun compare(arg0: DisplayMode, arg1: DisplayMode): Int { 65 | if (arg0.height > arg1.height) { 66 | return 1 67 | } 68 | return if (arg0.height < arg1.height) { 69 | -1 70 | } else 0 71 | } 72 | } 73 | } --------------------------------------------------------------------------------