commit e20e553baff54cbd8ba828291a7c3e477b06e669 Author: Travis Bradshaw Date: Tue Jan 31 16:46:52 2012 -0600 Source release of Wolfenstein 3D Classic Platinum for iOS, 1.0 diff --git a/Carmack_iPhone_development.doc b/Carmack_iPhone_development.doc new file mode 100644 index 0000000..6563d34 Binary files /dev/null and b/Carmack_iPhone_development.doc differ diff --git a/wolf3d/base/iphone/GOLDKEYPIC.tga b/wolf3d/base/iphone/GOLDKEYPIC.tga new file mode 100644 index 0000000..c43d175 Binary files /dev/null and b/wolf3d/base/iphone/GOLDKEYPIC.tga differ diff --git a/wolf3d/base/iphone/L_damage.tga b/wolf3d/base/iphone/L_damage.tga new file mode 100644 index 0000000..f5a1842 Binary files /dev/null and b/wolf3d/base/iphone/L_damage.tga differ diff --git a/wolf3d/base/iphone/R_damage.tga b/wolf3d/base/iphone/R_damage.tga new file mode 100644 index 0000000..4153724 Binary files /dev/null and b/wolf3d/base/iphone/R_damage.tga differ diff --git a/wolf3d/base/iphone/SILVERKEYPIC.tga b/wolf3d/base/iphone/SILVERKEYPIC.tga new file mode 100644 index 0000000..ab6f39a Binary files /dev/null and b/wolf3d/base/iphone/SILVERKEYPIC.tga differ diff --git a/wolf3d/base/iphone/baborted_01.wav b/wolf3d/base/iphone/baborted_01.wav new file mode 100644 index 0000000..bba0110 Binary files /dev/null and b/wolf3d/base/iphone/baborted_01.wav differ diff --git a/wolf3d/base/iphone/background_1.jpg b/wolf3d/base/iphone/background_1.jpg new file mode 100644 index 0000000..76611f2 Binary files /dev/null and b/wolf3d/base/iphone/background_1.jpg differ diff --git a/wolf3d/base/iphone/baction_01.wav b/wolf3d/base/iphone/baction_01.wav new file mode 100644 index 0000000..2f8e147 Binary files /dev/null and b/wolf3d/base/iphone/baction_01.wav differ diff --git a/wolf3d/base/iphone/bdown_01.wav b/wolf3d/base/iphone/bdown_01.wav new file mode 100644 index 0000000..7a9d541 Binary files /dev/null and b/wolf3d/base/iphone/bdown_01.wav differ diff --git a/wolf3d/base/iphone/button_back.tga b/wolf3d/base/iphone/button_back.tga new file mode 100644 index 0000000..b104913 Binary files /dev/null and b/wolf3d/base/iphone/button_back.tga differ diff --git a/wolf3d/base/iphone/button_control.tga b/wolf3d/base/iphone/button_control.tga new file mode 100644 index 0000000..6deeeaf Binary files /dev/null and b/wolf3d/base/iphone/button_control.tga differ diff --git a/wolf3d/base/iphone/button_ep1.tga b/wolf3d/base/iphone/button_ep1.tga new file mode 100644 index 0000000..e528af1 Binary files /dev/null and b/wolf3d/base/iphone/button_ep1.tga differ diff --git a/wolf3d/base/iphone/button_ep2.tga b/wolf3d/base/iphone/button_ep2.tga new file mode 100644 index 0000000..9e79fdc Binary files /dev/null and b/wolf3d/base/iphone/button_ep2.tga differ diff --git a/wolf3d/base/iphone/button_ep3.tga b/wolf3d/base/iphone/button_ep3.tga new file mode 100644 index 0000000..db1164e Binary files /dev/null and b/wolf3d/base/iphone/button_ep3.tga differ diff --git a/wolf3d/base/iphone/button_ep4.tga b/wolf3d/base/iphone/button_ep4.tga new file mode 100644 index 0000000..77b1d0c Binary files /dev/null and b/wolf3d/base/iphone/button_ep4.tga differ diff --git a/wolf3d/base/iphone/button_ep5.tga b/wolf3d/base/iphone/button_ep5.tga new file mode 100644 index 0000000..8a258ae Binary files /dev/null and b/wolf3d/base/iphone/button_ep5.tga differ diff --git a/wolf3d/base/iphone/button_ep6.tga b/wolf3d/base/iphone/button_ep6.tga new file mode 100644 index 0000000..965e4c3 Binary files /dev/null and b/wolf3d/base/iphone/button_ep6.tga differ diff --git a/wolf3d/base/iphone/button_levels.tga b/wolf3d/base/iphone/button_levels.tga new file mode 100644 index 0000000..2efd868 Binary files /dev/null and b/wolf3d/base/iphone/button_levels.tga differ diff --git a/wolf3d/base/iphone/button_new.tga b/wolf3d/base/iphone/button_new.tga new file mode 100644 index 0000000..6fd6e45 Binary files /dev/null and b/wolf3d/base/iphone/button_new.tga differ diff --git a/wolf3d/base/iphone/button_resume.tga b/wolf3d/base/iphone/button_resume.tga new file mode 100644 index 0000000..f2f2d2f Binary files /dev/null and b/wolf3d/base/iphone/button_resume.tga differ diff --git a/wolf3d/base/iphone/button_skill1.tga b/wolf3d/base/iphone/button_skill1.tga new file mode 100644 index 0000000..5a2eb38 Binary files /dev/null and b/wolf3d/base/iphone/button_skill1.tga differ diff --git a/wolf3d/base/iphone/button_skill2.tga b/wolf3d/base/iphone/button_skill2.tga new file mode 100644 index 0000000..79e9f19 Binary files /dev/null and b/wolf3d/base/iphone/button_skill2.tga differ diff --git a/wolf3d/base/iphone/button_skill3.tga b/wolf3d/base/iphone/button_skill3.tga new file mode 100644 index 0000000..eb7f995 Binary files /dev/null and b/wolf3d/base/iphone/button_skill3.tga differ diff --git a/wolf3d/base/iphone/button_skill4.tga b/wolf3d/base/iphone/button_skill4.tga new file mode 100644 index 0000000..cda8f11 Binary files /dev/null and b/wolf3d/base/iphone/button_skill4.tga differ diff --git a/wolf3d/base/iphone/button_web.tga b/wolf3d/base/iphone/button_web.tga new file mode 100644 index 0000000..650070c Binary files /dev/null and b/wolf3d/base/iphone/button_web.tga differ diff --git a/wolf3d/base/iphone/diractional_01.tga b/wolf3d/base/iphone/diractional_01.tga new file mode 100644 index 0000000..bdbc461 Binary files /dev/null and b/wolf3d/base/iphone/diractional_01.tga differ diff --git a/wolf3d/base/iphone/diractional_02.tga b/wolf3d/base/iphone/diractional_02.tga new file mode 100644 index 0000000..c36cdb2 Binary files /dev/null and b/wolf3d/base/iphone/diractional_02.tga differ diff --git a/wolf3d/base/iphone/diractional_03.tga b/wolf3d/base/iphone/diractional_03.tga new file mode 100644 index 0000000..a707f8a Binary files /dev/null and b/wolf3d/base/iphone/diractional_03.tga differ diff --git a/wolf3d/base/iphone/door.tga b/wolf3d/base/iphone/door.tga new file mode 100644 index 0000000..462c16d Binary files /dev/null and b/wolf3d/base/iphone/door.tga differ diff --git a/wolf3d/base/iphone/ep_1.tga b/wolf3d/base/iphone/ep_1.tga new file mode 100644 index 0000000..604662d Binary files /dev/null and b/wolf3d/base/iphone/ep_1.tga differ diff --git a/wolf3d/base/iphone/ep_1_6.tga b/wolf3d/base/iphone/ep_1_6.tga new file mode 100644 index 0000000..02f2b4b Binary files /dev/null and b/wolf3d/base/iphone/ep_1_6.tga differ diff --git a/wolf3d/base/iphone/font/0.tga b/wolf3d/base/iphone/font/0.tga new file mode 100644 index 0000000..d80c1c5 Binary files /dev/null and b/wolf3d/base/iphone/font/0.tga differ diff --git a/wolf3d/base/iphone/font/1.tga b/wolf3d/base/iphone/font/1.tga new file mode 100644 index 0000000..2c0d381 Binary files /dev/null and b/wolf3d/base/iphone/font/1.tga differ diff --git a/wolf3d/base/iphone/font/2.tga b/wolf3d/base/iphone/font/2.tga new file mode 100644 index 0000000..394db19 Binary files /dev/null and b/wolf3d/base/iphone/font/2.tga differ diff --git a/wolf3d/base/iphone/font/3.tga b/wolf3d/base/iphone/font/3.tga new file mode 100644 index 0000000..f5e55f0 Binary files /dev/null and b/wolf3d/base/iphone/font/3.tga differ diff --git a/wolf3d/base/iphone/font/4.tga b/wolf3d/base/iphone/font/4.tga new file mode 100644 index 0000000..1af6b8d Binary files /dev/null and b/wolf3d/base/iphone/font/4.tga differ diff --git a/wolf3d/base/iphone/font/5.tga b/wolf3d/base/iphone/font/5.tga new file mode 100644 index 0000000..f418df8 Binary files /dev/null and b/wolf3d/base/iphone/font/5.tga differ diff --git a/wolf3d/base/iphone/font/6.tga b/wolf3d/base/iphone/font/6.tga new file mode 100644 index 0000000..f55af93 Binary files /dev/null and b/wolf3d/base/iphone/font/6.tga differ diff --git a/wolf3d/base/iphone/font/7.tga b/wolf3d/base/iphone/font/7.tga new file mode 100644 index 0000000..665d285 Binary files /dev/null and b/wolf3d/base/iphone/font/7.tga differ diff --git a/wolf3d/base/iphone/font/8.tga b/wolf3d/base/iphone/font/8.tga new file mode 100644 index 0000000..049687f Binary files /dev/null and b/wolf3d/base/iphone/font/8.tga differ diff --git a/wolf3d/base/iphone/font/9.tga b/wolf3d/base/iphone/font/9.tga new file mode 100644 index 0000000..d9273f6 Binary files /dev/null and b/wolf3d/base/iphone/font/9.tga differ diff --git a/wolf3d/base/iphone/font1.dat b/wolf3d/base/iphone/font1.dat new file mode 100644 index 0000000..b823c9e Binary files /dev/null and b/wolf3d/base/iphone/font1.dat differ diff --git a/wolf3d/base/iphone/font1.tga b/wolf3d/base/iphone/font1.tga new file mode 100644 index 0000000..411c22f Binary files /dev/null and b/wolf3d/base/iphone/font1.tga differ diff --git a/wolf3d/base/iphone/id_logo.tga b/wolf3d/base/iphone/id_logo.tga new file mode 100644 index 0000000..f682884 Binary files /dev/null and b/wolf3d/base/iphone/id_logo.tga differ diff --git a/wolf3d/base/iphone/intermission.jpg b/wolf3d/base/iphone/intermission.jpg new file mode 100644 index 0000000..45ebce4 Binary files /dev/null and b/wolf3d/base/iphone/intermission.jpg differ diff --git a/wolf3d/base/iphone/kills.tga b/wolf3d/base/iphone/kills.tga new file mode 100644 index 0000000..1748d4a Binary files /dev/null and b/wolf3d/base/iphone/kills.tga differ diff --git a/wolf3d/base/iphone/layout_1.tga b/wolf3d/base/iphone/layout_1.tga new file mode 100644 index 0000000..8c881ba Binary files /dev/null and b/wolf3d/base/iphone/layout_1.tga differ diff --git a/wolf3d/base/iphone/layout_2.tga b/wolf3d/base/iphone/layout_2.tga new file mode 100644 index 0000000..f48d80f Binary files /dev/null and b/wolf3d/base/iphone/layout_2.tga differ diff --git a/wolf3d/base/iphone/layout_3.tga b/wolf3d/base/iphone/layout_3.tga new file mode 100644 index 0000000..f2a1612 Binary files /dev/null and b/wolf3d/base/iphone/layout_3.tga differ diff --git a/wolf3d/base/iphone/layout_4.tga b/wolf3d/base/iphone/layout_4.tga new file mode 100644 index 0000000..c20b482 Binary files /dev/null and b/wolf3d/base/iphone/layout_4.tga differ diff --git a/wolf3d/base/iphone/map.tga b/wolf3d/base/iphone/map.tga new file mode 100644 index 0000000..39bf0d3 Binary files /dev/null and b/wolf3d/base/iphone/map.tga differ diff --git a/wolf3d/base/iphone/menu.tga b/wolf3d/base/iphone/menu.tga new file mode 100644 index 0000000..bf84bff Binary files /dev/null and b/wolf3d/base/iphone/menu.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE1APIC.tga b/wolf3d/base/iphone/newhead/FACE1APIC.tga new file mode 100644 index 0000000..e8be37e Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE1APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE1BPIC.tga b/wolf3d/base/iphone/newhead/FACE1BPIC.tga new file mode 100644 index 0000000..28245e8 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE1BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE1CPIC.tga b/wolf3d/base/iphone/newhead/FACE1CPIC.tga new file mode 100644 index 0000000..d6fad3d Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE1CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE2APIC.tga b/wolf3d/base/iphone/newhead/FACE2APIC.tga new file mode 100644 index 0000000..3bfddbf Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE2APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE2BPIC.tga b/wolf3d/base/iphone/newhead/FACE2BPIC.tga new file mode 100644 index 0000000..eecc9ac Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE2BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE2CPIC.tga b/wolf3d/base/iphone/newhead/FACE2CPIC.tga new file mode 100644 index 0000000..6e97496 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE2CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE3APIC.tga b/wolf3d/base/iphone/newhead/FACE3APIC.tga new file mode 100644 index 0000000..472e1d7 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE3APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE3BPIC.tga b/wolf3d/base/iphone/newhead/FACE3BPIC.tga new file mode 100644 index 0000000..ebb86f8 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE3BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE3CPIC.tga b/wolf3d/base/iphone/newhead/FACE3CPIC.tga new file mode 100644 index 0000000..a212b89 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE3CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE4APIC.tga b/wolf3d/base/iphone/newhead/FACE4APIC.tga new file mode 100644 index 0000000..81a6c2d Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE4APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE4BPIC.tga b/wolf3d/base/iphone/newhead/FACE4BPIC.tga new file mode 100644 index 0000000..5ea9a44 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE4BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE4CPIC.tga b/wolf3d/base/iphone/newhead/FACE4CPIC.tga new file mode 100644 index 0000000..efedbe2 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE4CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE5APIC.tga b/wolf3d/base/iphone/newhead/FACE5APIC.tga new file mode 100644 index 0000000..b5be8f8 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE5APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE5BPIC.tga b/wolf3d/base/iphone/newhead/FACE5BPIC.tga new file mode 100644 index 0000000..1c00bc5 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE5BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE5CPIC.tga b/wolf3d/base/iphone/newhead/FACE5CPIC.tga new file mode 100644 index 0000000..696d276 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE5CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE6APIC.tga b/wolf3d/base/iphone/newhead/FACE6APIC.tga new file mode 100644 index 0000000..8965073 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE6APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE6BPIC.tga b/wolf3d/base/iphone/newhead/FACE6BPIC.tga new file mode 100644 index 0000000..c6bb1be Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE6BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE6CPIC.tga b/wolf3d/base/iphone/newhead/FACE6CPIC.tga new file mode 100644 index 0000000..f97cc98 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE6CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE7APIC.tga b/wolf3d/base/iphone/newhead/FACE7APIC.tga new file mode 100644 index 0000000..2fec011 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE7APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE7BPIC.tga b/wolf3d/base/iphone/newhead/FACE7BPIC.tga new file mode 100644 index 0000000..114b610 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE7BPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE7CPIC.tga b/wolf3d/base/iphone/newhead/FACE7CPIC.tga new file mode 100644 index 0000000..8f238a2 Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE7CPIC.tga differ diff --git a/wolf3d/base/iphone/newhead/FACE8APIC.tga b/wolf3d/base/iphone/newhead/FACE8APIC.tga new file mode 100644 index 0000000..3d9b1fe Binary files /dev/null and b/wolf3d/base/iphone/newhead/FACE8APIC.tga differ diff --git a/wolf3d/base/iphone/newhead/GOTGATLINGPIC.tga b/wolf3d/base/iphone/newhead/GOTGATLINGPIC.tga new file mode 100644 index 0000000..cfd0834 Binary files /dev/null and b/wolf3d/base/iphone/newhead/GOTGATLINGPIC.tga differ diff --git a/wolf3d/base/iphone/partime.tga b/wolf3d/base/iphone/partime.tga new file mode 100644 index 0000000..52df1b3 Binary files /dev/null and b/wolf3d/base/iphone/partime.tga differ diff --git a/wolf3d/base/iphone/secrets.tga b/wolf3d/base/iphone/secrets.tga new file mode 100644 index 0000000..c37375b Binary files /dev/null and b/wolf3d/base/iphone/secrets.tga differ diff --git a/wolf3d/base/iphone/shoot.tga b/wolf3d/base/iphone/shoot.tga new file mode 100644 index 0000000..fe705c1 Binary files /dev/null and b/wolf3d/base/iphone/shoot.tga differ diff --git a/wolf3d/base/iphone/slide_01.wav b/wolf3d/base/iphone/slide_01.wav new file mode 100644 index 0000000..116d83e Binary files /dev/null and b/wolf3d/base/iphone/slide_01.wav differ diff --git a/wolf3d/base/iphone/status_hud.tga b/wolf3d/base/iphone/status_hud.tga new file mode 100644 index 0000000..adf1243 Binary files /dev/null and b/wolf3d/base/iphone/status_hud.tga differ diff --git a/wolf3d/base/iphone/treasure.tga b/wolf3d/base/iphone/treasure.tga new file mode 100644 index 0000000..46ab048 Binary files /dev/null and b/wolf3d/base/iphone/treasure.tga differ diff --git a/wolf3d/base/iphone/victory.jpg b/wolf3d/base/iphone/victory.jpg new file mode 100644 index 0000000..5df8b01 Binary files /dev/null and b/wolf3d/base/iphone/victory.jpg differ diff --git a/wolf3d/base/iphone/wolf_logo.tga b/wolf3d/base/iphone/wolf_logo.tga new file mode 100644 index 0000000..57341b1 Binary files /dev/null and b/wolf3d/base/iphone/wolf_logo.tga differ diff --git a/wolf3d/base/lsfx/001.ogg b/wolf3d/base/lsfx/001.ogg new file mode 100644 index 0000000..45d5882 Binary files /dev/null and b/wolf3d/base/lsfx/001.ogg differ diff --git a/wolf3d/base/lsfx/003.ogg b/wolf3d/base/lsfx/003.ogg new file mode 100644 index 0000000..2af07dc Binary files /dev/null and b/wolf3d/base/lsfx/003.ogg differ diff --git a/wolf3d/base/lsfx/008.ogg b/wolf3d/base/lsfx/008.ogg new file mode 100644 index 0000000..0e69b7e Binary files /dev/null and b/wolf3d/base/lsfx/008.ogg differ diff --git a/wolf3d/base/lsfx/009.ogg b/wolf3d/base/lsfx/009.ogg new file mode 100644 index 0000000..e2700f7 Binary files /dev/null and b/wolf3d/base/lsfx/009.ogg differ diff --git a/wolf3d/base/lsfx/012.ogg b/wolf3d/base/lsfx/012.ogg new file mode 100644 index 0000000..61cb109 Binary files /dev/null and b/wolf3d/base/lsfx/012.ogg differ diff --git a/wolf3d/base/lsfx/023.ogg b/wolf3d/base/lsfx/023.ogg new file mode 100644 index 0000000..93930c8 Binary files /dev/null and b/wolf3d/base/lsfx/023.ogg differ diff --git a/wolf3d/base/lsfx/028.ogg b/wolf3d/base/lsfx/028.ogg new file mode 100644 index 0000000..00d59e6 Binary files /dev/null and b/wolf3d/base/lsfx/028.ogg differ diff --git a/wolf3d/base/lsfx/030.ogg b/wolf3d/base/lsfx/030.ogg new file mode 100644 index 0000000..baafbd3 Binary files /dev/null and b/wolf3d/base/lsfx/030.ogg differ diff --git a/wolf3d/base/lsfx/031.ogg b/wolf3d/base/lsfx/031.ogg new file mode 100644 index 0000000..3d1ba81 Binary files /dev/null and b/wolf3d/base/lsfx/031.ogg differ diff --git a/wolf3d/base/lsfx/033.ogg b/wolf3d/base/lsfx/033.ogg new file mode 100644 index 0000000..176d710 Binary files /dev/null and b/wolf3d/base/lsfx/033.ogg differ diff --git a/wolf3d/base/lsfx/034.ogg b/wolf3d/base/lsfx/034.ogg new file mode 100644 index 0000000..1fbdf25 Binary files /dev/null and b/wolf3d/base/lsfx/034.ogg differ diff --git a/wolf3d/base/lsfx/035.ogg b/wolf3d/base/lsfx/035.ogg new file mode 100644 index 0000000..50a5250 Binary files /dev/null and b/wolf3d/base/lsfx/035.ogg differ diff --git a/wolf3d/base/lsfx/036.ogg b/wolf3d/base/lsfx/036.ogg new file mode 100644 index 0000000..32d2da8 Binary files /dev/null and b/wolf3d/base/lsfx/036.ogg differ diff --git a/wolf3d/base/lsfx/037.ogg b/wolf3d/base/lsfx/037.ogg new file mode 100644 index 0000000..af973f4 Binary files /dev/null and b/wolf3d/base/lsfx/037.ogg differ diff --git a/wolf3d/base/lsfx/038.ogg b/wolf3d/base/lsfx/038.ogg new file mode 100644 index 0000000..1e9a6b5 Binary files /dev/null and b/wolf3d/base/lsfx/038.ogg differ diff --git a/wolf3d/base/lsfx/040.ogg b/wolf3d/base/lsfx/040.ogg new file mode 100644 index 0000000..a985ded Binary files /dev/null and b/wolf3d/base/lsfx/040.ogg differ diff --git a/wolf3d/base/lsfx/044.ogg b/wolf3d/base/lsfx/044.ogg new file mode 100644 index 0000000..2a1c0d4 Binary files /dev/null and b/wolf3d/base/lsfx/044.ogg differ diff --git a/wolf3d/base/lsfx/045.ogg b/wolf3d/base/lsfx/045.ogg new file mode 100644 index 0000000..abba9bd Binary files /dev/null and b/wolf3d/base/lsfx/045.ogg differ diff --git a/wolf3d/base/lsfx/061.ogg b/wolf3d/base/lsfx/061.ogg new file mode 100644 index 0000000..a1efdfe Binary files /dev/null and b/wolf3d/base/lsfx/061.ogg differ diff --git a/wolf3d/base/lsfx/062.ogg b/wolf3d/base/lsfx/062.ogg new file mode 100644 index 0000000..2ca850b Binary files /dev/null and b/wolf3d/base/lsfx/062.ogg differ diff --git a/wolf3d/base/lsfx/064.ogg b/wolf3d/base/lsfx/064.ogg new file mode 100644 index 0000000..4bd9afd Binary files /dev/null and b/wolf3d/base/lsfx/064.ogg differ diff --git a/wolf3d/base/lsfx/069.ogg b/wolf3d/base/lsfx/069.ogg new file mode 100644 index 0000000..0c32eab Binary files /dev/null and b/wolf3d/base/lsfx/069.ogg differ diff --git a/wolf3d/base/lsfx/076.ogg b/wolf3d/base/lsfx/076.ogg new file mode 100644 index 0000000..4bb9f9f Binary files /dev/null and b/wolf3d/base/lsfx/076.ogg differ diff --git a/wolf3d/base/lsfx/078.ogg b/wolf3d/base/lsfx/078.ogg new file mode 100644 index 0000000..f5d185e Binary files /dev/null and b/wolf3d/base/lsfx/078.ogg differ diff --git a/wolf3d/base/lsfx/080.ogg b/wolf3d/base/lsfx/080.ogg new file mode 100644 index 0000000..9c450cc Binary files /dev/null and b/wolf3d/base/lsfx/080.ogg differ diff --git a/wolf3d/base/lsfx/085.ogg b/wolf3d/base/lsfx/085.ogg new file mode 100644 index 0000000..168310a Binary files /dev/null and b/wolf3d/base/lsfx/085.ogg differ diff --git a/wolf3d/base/lsfx/086.ogg b/wolf3d/base/lsfx/086.ogg new file mode 100644 index 0000000..05de25c Binary files /dev/null and b/wolf3d/base/lsfx/086.ogg differ diff --git a/wolf3d/base/maps/w00.map b/wolf3d/base/maps/w00.map new file mode 100644 index 0000000..7d8b349 Binary files /dev/null and b/wolf3d/base/maps/w00.map differ diff --git a/wolf3d/base/maps/w01.map b/wolf3d/base/maps/w01.map new file mode 100644 index 0000000..77f4d9d Binary files /dev/null and b/wolf3d/base/maps/w01.map differ diff --git a/wolf3d/base/maps/w02.map b/wolf3d/base/maps/w02.map new file mode 100644 index 0000000..0310c5b Binary files /dev/null and b/wolf3d/base/maps/w02.map differ diff --git a/wolf3d/base/maps/w03.map b/wolf3d/base/maps/w03.map new file mode 100644 index 0000000..e2293e2 Binary files /dev/null and b/wolf3d/base/maps/w03.map differ diff --git a/wolf3d/base/maps/w04.map b/wolf3d/base/maps/w04.map new file mode 100644 index 0000000..fb8cffe Binary files /dev/null and b/wolf3d/base/maps/w04.map differ diff --git a/wolf3d/base/maps/w05.map b/wolf3d/base/maps/w05.map new file mode 100644 index 0000000..c19af56 Binary files /dev/null and b/wolf3d/base/maps/w05.map differ diff --git a/wolf3d/base/maps/w06.map b/wolf3d/base/maps/w06.map new file mode 100644 index 0000000..6c6c6c8 Binary files /dev/null and b/wolf3d/base/maps/w06.map differ diff --git a/wolf3d/base/maps/w07.map b/wolf3d/base/maps/w07.map new file mode 100644 index 0000000..cbc8b26 Binary files /dev/null and b/wolf3d/base/maps/w07.map differ diff --git a/wolf3d/base/maps/w08.map b/wolf3d/base/maps/w08.map new file mode 100644 index 0000000..89bf0ec Binary files /dev/null and b/wolf3d/base/maps/w08.map differ diff --git a/wolf3d/base/maps/w09.map b/wolf3d/base/maps/w09.map new file mode 100644 index 0000000..d9dadcd Binary files /dev/null and b/wolf3d/base/maps/w09.map differ diff --git a/wolf3d/base/maps/w10.map b/wolf3d/base/maps/w10.map new file mode 100644 index 0000000..5ccc227 Binary files /dev/null and b/wolf3d/base/maps/w10.map differ diff --git a/wolf3d/base/maps/w11.map b/wolf3d/base/maps/w11.map new file mode 100644 index 0000000..26226e6 Binary files /dev/null and b/wolf3d/base/maps/w11.map differ diff --git a/wolf3d/base/maps/w12.map b/wolf3d/base/maps/w12.map new file mode 100644 index 0000000..5c40cd1 Binary files /dev/null and b/wolf3d/base/maps/w12.map differ diff --git a/wolf3d/base/maps/w13.map b/wolf3d/base/maps/w13.map new file mode 100644 index 0000000..3d40a2f Binary files /dev/null and b/wolf3d/base/maps/w13.map differ diff --git a/wolf3d/base/maps/w14.map b/wolf3d/base/maps/w14.map new file mode 100644 index 0000000..efdfe11 Binary files /dev/null and b/wolf3d/base/maps/w14.map differ diff --git a/wolf3d/base/maps/w15.map b/wolf3d/base/maps/w15.map new file mode 100644 index 0000000..9049b30 Binary files /dev/null and b/wolf3d/base/maps/w15.map differ diff --git a/wolf3d/base/maps/w16.map b/wolf3d/base/maps/w16.map new file mode 100644 index 0000000..6bdfd94 Binary files /dev/null and b/wolf3d/base/maps/w16.map differ diff --git a/wolf3d/base/maps/w17.map b/wolf3d/base/maps/w17.map new file mode 100644 index 0000000..d71726b Binary files /dev/null and b/wolf3d/base/maps/w17.map differ diff --git a/wolf3d/base/maps/w18.map b/wolf3d/base/maps/w18.map new file mode 100644 index 0000000..abfcf34 Binary files /dev/null and b/wolf3d/base/maps/w18.map differ diff --git a/wolf3d/base/maps/w19.map b/wolf3d/base/maps/w19.map new file mode 100644 index 0000000..32d6ab4 Binary files /dev/null and b/wolf3d/base/maps/w19.map differ diff --git a/wolf3d/base/maps/w20.map b/wolf3d/base/maps/w20.map new file mode 100644 index 0000000..1cc6bc9 Binary files /dev/null and b/wolf3d/base/maps/w20.map differ diff --git a/wolf3d/base/maps/w21.map b/wolf3d/base/maps/w21.map new file mode 100644 index 0000000..3fe2b4f Binary files /dev/null and b/wolf3d/base/maps/w21.map differ diff --git a/wolf3d/base/maps/w22.map b/wolf3d/base/maps/w22.map new file mode 100644 index 0000000..c290d12 Binary files /dev/null and b/wolf3d/base/maps/w22.map differ diff --git a/wolf3d/base/maps/w23.map b/wolf3d/base/maps/w23.map new file mode 100644 index 0000000..ffec9ea Binary files /dev/null and b/wolf3d/base/maps/w23.map differ diff --git a/wolf3d/base/maps/w24.map b/wolf3d/base/maps/w24.map new file mode 100644 index 0000000..b0a1466 Binary files /dev/null and b/wolf3d/base/maps/w24.map differ diff --git a/wolf3d/base/maps/w25.map b/wolf3d/base/maps/w25.map new file mode 100644 index 0000000..8a6ead7 Binary files /dev/null and b/wolf3d/base/maps/w25.map differ diff --git a/wolf3d/base/maps/w26.map b/wolf3d/base/maps/w26.map new file mode 100644 index 0000000..ee7416a Binary files /dev/null and b/wolf3d/base/maps/w26.map differ diff --git a/wolf3d/base/maps/w27.map b/wolf3d/base/maps/w27.map new file mode 100644 index 0000000..8f8a2c7 Binary files /dev/null and b/wolf3d/base/maps/w27.map differ diff --git a/wolf3d/base/maps/w28.map b/wolf3d/base/maps/w28.map new file mode 100644 index 0000000..84d348e Binary files /dev/null and b/wolf3d/base/maps/w28.map differ diff --git a/wolf3d/base/maps/w29.map b/wolf3d/base/maps/w29.map new file mode 100644 index 0000000..e8c7e30 Binary files /dev/null and b/wolf3d/base/maps/w29.map differ diff --git a/wolf3d/base/maps/w30.map b/wolf3d/base/maps/w30.map new file mode 100644 index 0000000..ffeaa24 Binary files /dev/null and b/wolf3d/base/maps/w30.map differ diff --git a/wolf3d/base/maps/w31.map b/wolf3d/base/maps/w31.map new file mode 100644 index 0000000..df0385b Binary files /dev/null and b/wolf3d/base/maps/w31.map differ diff --git a/wolf3d/base/maps/w32.map b/wolf3d/base/maps/w32.map new file mode 100644 index 0000000..4656e7f Binary files /dev/null and b/wolf3d/base/maps/w32.map differ diff --git a/wolf3d/base/maps/w33.map b/wolf3d/base/maps/w33.map new file mode 100644 index 0000000..e8c11e5 Binary files /dev/null and b/wolf3d/base/maps/w33.map differ diff --git a/wolf3d/base/maps/w34.map b/wolf3d/base/maps/w34.map new file mode 100644 index 0000000..aa765b7 Binary files /dev/null and b/wolf3d/base/maps/w34.map differ diff --git a/wolf3d/base/maps/w35.map b/wolf3d/base/maps/w35.map new file mode 100644 index 0000000..ffe6302 Binary files /dev/null and b/wolf3d/base/maps/w35.map differ diff --git a/wolf3d/base/maps/w36.map b/wolf3d/base/maps/w36.map new file mode 100644 index 0000000..715b591 Binary files /dev/null and b/wolf3d/base/maps/w36.map differ diff --git a/wolf3d/base/maps/w37.map b/wolf3d/base/maps/w37.map new file mode 100644 index 0000000..f835b06 Binary files /dev/null and b/wolf3d/base/maps/w37.map differ diff --git a/wolf3d/base/maps/w38.map b/wolf3d/base/maps/w38.map new file mode 100644 index 0000000..6d3f1dd Binary files /dev/null and b/wolf3d/base/maps/w38.map differ diff --git a/wolf3d/base/maps/w39.map b/wolf3d/base/maps/w39.map new file mode 100644 index 0000000..d49df96 Binary files /dev/null and b/wolf3d/base/maps/w39.map differ diff --git a/wolf3d/base/maps/w40.map b/wolf3d/base/maps/w40.map new file mode 100644 index 0000000..c0af824 Binary files /dev/null and b/wolf3d/base/maps/w40.map differ diff --git a/wolf3d/base/maps/w41.map b/wolf3d/base/maps/w41.map new file mode 100644 index 0000000..b0505f5 Binary files /dev/null and b/wolf3d/base/maps/w41.map differ diff --git a/wolf3d/base/maps/w42.map b/wolf3d/base/maps/w42.map new file mode 100644 index 0000000..67f0b53 Binary files /dev/null and b/wolf3d/base/maps/w42.map differ diff --git a/wolf3d/base/maps/w43.map b/wolf3d/base/maps/w43.map new file mode 100644 index 0000000..ed94eb2 Binary files /dev/null and b/wolf3d/base/maps/w43.map differ diff --git a/wolf3d/base/maps/w44.map b/wolf3d/base/maps/w44.map new file mode 100644 index 0000000..633df7e Binary files /dev/null and b/wolf3d/base/maps/w44.map differ diff --git a/wolf3d/base/maps/w45.map b/wolf3d/base/maps/w45.map new file mode 100644 index 0000000..12c9fd3 Binary files /dev/null and b/wolf3d/base/maps/w45.map differ diff --git a/wolf3d/base/maps/w46.map b/wolf3d/base/maps/w46.map new file mode 100644 index 0000000..4751c5e Binary files /dev/null and b/wolf3d/base/maps/w46.map differ diff --git a/wolf3d/base/maps/w47.map b/wolf3d/base/maps/w47.map new file mode 100644 index 0000000..e31a790 Binary files /dev/null and b/wolf3d/base/maps/w47.map differ diff --git a/wolf3d/base/maps/w48.map b/wolf3d/base/maps/w48.map new file mode 100644 index 0000000..e1a633e Binary files /dev/null and b/wolf3d/base/maps/w48.map differ diff --git a/wolf3d/base/maps/w49.map b/wolf3d/base/maps/w49.map new file mode 100644 index 0000000..debe203 Binary files /dev/null and b/wolf3d/base/maps/w49.map differ diff --git a/wolf3d/base/maps/w50.map b/wolf3d/base/maps/w50.map new file mode 100644 index 0000000..ddb69cc Binary files /dev/null and b/wolf3d/base/maps/w50.map differ diff --git a/wolf3d/base/maps/w51.map b/wolf3d/base/maps/w51.map new file mode 100644 index 0000000..1a304b5 Binary files /dev/null and b/wolf3d/base/maps/w51.map differ diff --git a/wolf3d/base/maps/w52.map b/wolf3d/base/maps/w52.map new file mode 100644 index 0000000..f853629 Binary files /dev/null and b/wolf3d/base/maps/w52.map differ diff --git a/wolf3d/base/maps/w53.map b/wolf3d/base/maps/w53.map new file mode 100644 index 0000000..766b62b Binary files /dev/null and b/wolf3d/base/maps/w53.map differ diff --git a/wolf3d/base/maps/w54.map b/wolf3d/base/maps/w54.map new file mode 100644 index 0000000..8d5b5f4 Binary files /dev/null and b/wolf3d/base/maps/w54.map differ diff --git a/wolf3d/base/maps/w55.map b/wolf3d/base/maps/w55.map new file mode 100644 index 0000000..f76f0f6 Binary files /dev/null and b/wolf3d/base/maps/w55.map differ diff --git a/wolf3d/base/maps/w56.map b/wolf3d/base/maps/w56.map new file mode 100644 index 0000000..d201194 Binary files /dev/null and b/wolf3d/base/maps/w56.map differ diff --git a/wolf3d/base/maps/w57.map b/wolf3d/base/maps/w57.map new file mode 100644 index 0000000..af5c4bd Binary files /dev/null and b/wolf3d/base/maps/w57.map differ diff --git a/wolf3d/base/maps/w58.map b/wolf3d/base/maps/w58.map new file mode 100644 index 0000000..c8a5a7b Binary files /dev/null and b/wolf3d/base/maps/w58.map differ diff --git a/wolf3d/base/maps/w59.map b/wolf3d/base/maps/w59.map new file mode 100644 index 0000000..ad8fe6e Binary files /dev/null and b/wolf3d/base/maps/w59.map differ diff --git a/wolf3d/base/music/CORNER.ogg b/wolf3d/base/music/CORNER.ogg new file mode 100644 index 0000000..311f29c Binary files /dev/null and b/wolf3d/base/music/CORNER.ogg differ diff --git a/wolf3d/base/music/DUNGEON.ogg b/wolf3d/base/music/DUNGEON.ogg new file mode 100644 index 0000000..42da5be Binary files /dev/null and b/wolf3d/base/music/DUNGEON.ogg differ diff --git a/wolf3d/base/music/ENDLEVEL.ogg b/wolf3d/base/music/ENDLEVEL.ogg new file mode 100644 index 0000000..1345118 Binary files /dev/null and b/wolf3d/base/music/ENDLEVEL.ogg differ diff --git a/wolf3d/base/music/FUNKYOU.ogg b/wolf3d/base/music/FUNKYOU.ogg new file mode 100644 index 0000000..fa485a5 Binary files /dev/null and b/wolf3d/base/music/FUNKYOU.ogg differ diff --git a/wolf3d/base/music/GETTHEM.ogg b/wolf3d/base/music/GETTHEM.ogg new file mode 100644 index 0000000..3182e17 Binary files /dev/null and b/wolf3d/base/music/GETTHEM.ogg differ diff --git a/wolf3d/base/music/GOINGAFT.ogg b/wolf3d/base/music/GOINGAFT.ogg new file mode 100644 index 0000000..8509011 Binary files /dev/null and b/wolf3d/base/music/GOINGAFT.ogg differ diff --git a/wolf3d/base/music/HEADACHE.ogg b/wolf3d/base/music/HEADACHE.ogg new file mode 100644 index 0000000..4b294e3 Binary files /dev/null and b/wolf3d/base/music/HEADACHE.ogg differ diff --git a/wolf3d/base/music/HITLWLTZ.ogg b/wolf3d/base/music/HITLWLTZ.ogg new file mode 100644 index 0000000..62cebed Binary files /dev/null and b/wolf3d/base/music/HITLWLTZ.ogg differ diff --git a/wolf3d/base/music/INTROCW3.ogg b/wolf3d/base/music/INTROCW3.ogg new file mode 100644 index 0000000..ea34b9f Binary files /dev/null and b/wolf3d/base/music/INTROCW3.ogg differ diff --git a/wolf3d/base/music/NAZI_NOR.ogg b/wolf3d/base/music/NAZI_NOR.ogg new file mode 100644 index 0000000..db0f9b7 Binary files /dev/null and b/wolf3d/base/music/NAZI_NOR.ogg differ diff --git a/wolf3d/base/music/NAZI_OMI.ogg b/wolf3d/base/music/NAZI_OMI.ogg new file mode 100644 index 0000000..1dfd100 Binary files /dev/null and b/wolf3d/base/music/NAZI_OMI.ogg differ diff --git a/wolf3d/base/music/NAZI_RAP.ogg b/wolf3d/base/music/NAZI_RAP.ogg new file mode 100644 index 0000000..35c337b Binary files /dev/null and b/wolf3d/base/music/NAZI_RAP.ogg differ diff --git a/wolf3d/base/music/PACMAN.ogg b/wolf3d/base/music/PACMAN.ogg new file mode 100644 index 0000000..35a33e6 Binary files /dev/null and b/wolf3d/base/music/PACMAN.ogg differ diff --git a/wolf3d/base/music/POW.ogg b/wolf3d/base/music/POW.ogg new file mode 100644 index 0000000..8e85bd8 Binary files /dev/null and b/wolf3d/base/music/POW.ogg differ diff --git a/wolf3d/base/music/PREGNANT.ogg b/wolf3d/base/music/PREGNANT.ogg new file mode 100644 index 0000000..9ba2c7a Binary files /dev/null and b/wolf3d/base/music/PREGNANT.ogg differ diff --git a/wolf3d/base/music/ROSTER.ogg b/wolf3d/base/music/ROSTER.ogg new file mode 100644 index 0000000..ed954dd Binary files /dev/null and b/wolf3d/base/music/ROSTER.ogg differ diff --git a/wolf3d/base/music/SALUTE.ogg b/wolf3d/base/music/SALUTE.ogg new file mode 100644 index 0000000..07f4d2b Binary files /dev/null and b/wolf3d/base/music/SALUTE.ogg differ diff --git a/wolf3d/base/music/SEARCHN.ogg b/wolf3d/base/music/SEARCHN.ogg new file mode 100644 index 0000000..4a3b56e Binary files /dev/null and b/wolf3d/base/music/SEARCHN.ogg differ diff --git a/wolf3d/base/music/SUSPENSE.ogg b/wolf3d/base/music/SUSPENSE.ogg new file mode 100644 index 0000000..2052349 Binary files /dev/null and b/wolf3d/base/music/SUSPENSE.ogg differ diff --git a/wolf3d/base/music/TWELFTH.ogg b/wolf3d/base/music/TWELFTH.ogg new file mode 100644 index 0000000..b408782 Binary files /dev/null and b/wolf3d/base/music/TWELFTH.ogg differ diff --git a/wolf3d/base/music/ULTIMATE.ogg b/wolf3d/base/music/ULTIMATE.ogg new file mode 100644 index 0000000..511c5d5 Binary files /dev/null and b/wolf3d/base/music/ULTIMATE.ogg differ diff --git a/wolf3d/base/music/URAHERO.ogg b/wolf3d/base/music/URAHERO.ogg new file mode 100644 index 0000000..097418d Binary files /dev/null and b/wolf3d/base/music/URAHERO.ogg differ diff --git a/wolf3d/base/music/VICMARCH.ogg b/wolf3d/base/music/VICMARCH.ogg new file mode 100644 index 0000000..0e9d2a6 Binary files /dev/null and b/wolf3d/base/music/VICMARCH.ogg differ diff --git a/wolf3d/base/music/VICTORS.ogg b/wolf3d/base/music/VICTORS.ogg new file mode 100644 index 0000000..b4c1253 Binary files /dev/null and b/wolf3d/base/music/VICTORS.ogg differ diff --git a/wolf3d/base/music/WARMARCH.ogg b/wolf3d/base/music/WARMARCH.ogg new file mode 100644 index 0000000..36f9cdf Binary files /dev/null and b/wolf3d/base/music/WARMARCH.ogg differ diff --git a/wolf3d/base/music/WONDERIN.ogg b/wolf3d/base/music/WONDERIN.ogg new file mode 100644 index 0000000..50e7916 Binary files /dev/null and b/wolf3d/base/music/WONDERIN.ogg differ diff --git a/wolf3d/base/music/ZEROHOUR.ogg b/wolf3d/base/music/ZEROHOUR.ogg new file mode 100644 index 0000000..8fd7618 Binary files /dev/null and b/wolf3d/base/music/ZEROHOUR.ogg differ diff --git a/wolf3d/base/sfx/001.wav b/wolf3d/base/sfx/001.wav new file mode 100644 index 0000000..561b50e Binary files /dev/null and b/wolf3d/base/sfx/001.wav differ diff --git a/wolf3d/base/sfx/002.wav b/wolf3d/base/sfx/002.wav new file mode 100644 index 0000000..3b54119 Binary files /dev/null and b/wolf3d/base/sfx/002.wav differ diff --git a/wolf3d/base/sfx/007.wav b/wolf3d/base/sfx/007.wav new file mode 100644 index 0000000..caebe87 Binary files /dev/null and b/wolf3d/base/sfx/007.wav differ diff --git a/wolf3d/base/sfx/010.wav b/wolf3d/base/sfx/010.wav new file mode 100644 index 0000000..89ec52c Binary files /dev/null and b/wolf3d/base/sfx/010.wav differ diff --git a/wolf3d/base/sfx/011.wav b/wolf3d/base/sfx/011.wav new file mode 100644 index 0000000..5dc5893 Binary files /dev/null and b/wolf3d/base/sfx/011.wav differ diff --git a/wolf3d/base/sfx/012.wav b/wolf3d/base/sfx/012.wav new file mode 100644 index 0000000..2b929b7 Binary files /dev/null and b/wolf3d/base/sfx/012.wav differ diff --git a/wolf3d/base/sfx/013.wav b/wolf3d/base/sfx/013.wav new file mode 100644 index 0000000..f97865c Binary files /dev/null and b/wolf3d/base/sfx/013.wav differ diff --git a/wolf3d/base/sfx/015.wav b/wolf3d/base/sfx/015.wav new file mode 100644 index 0000000..c381dc4 Binary files /dev/null and b/wolf3d/base/sfx/015.wav differ diff --git a/wolf3d/base/sfx/017.wav b/wolf3d/base/sfx/017.wav new file mode 100644 index 0000000..0d29d30 Binary files /dev/null and b/wolf3d/base/sfx/017.wav differ diff --git a/wolf3d/base/sfx/019.wav b/wolf3d/base/sfx/019.wav new file mode 100644 index 0000000..678942a Binary files /dev/null and b/wolf3d/base/sfx/019.wav differ diff --git a/wolf3d/base/sfx/022.wav b/wolf3d/base/sfx/022.wav new file mode 100644 index 0000000..0da2e81 Binary files /dev/null and b/wolf3d/base/sfx/022.wav differ diff --git a/wolf3d/base/sfx/024.wav b/wolf3d/base/sfx/024.wav new file mode 100644 index 0000000..68b2fcf Binary files /dev/null and b/wolf3d/base/sfx/024.wav differ diff --git a/wolf3d/base/sfx/025.wav b/wolf3d/base/sfx/025.wav new file mode 100644 index 0000000..ed9c061 Binary files /dev/null and b/wolf3d/base/sfx/025.wav differ diff --git a/wolf3d/base/sfx/026.wav b/wolf3d/base/sfx/026.wav new file mode 100644 index 0000000..edbfe43 Binary files /dev/null and b/wolf3d/base/sfx/026.wav differ diff --git a/wolf3d/base/sfx/027.wav b/wolf3d/base/sfx/027.wav new file mode 100644 index 0000000..3b57d24 Binary files /dev/null and b/wolf3d/base/sfx/027.wav differ diff --git a/wolf3d/base/sfx/034.wav b/wolf3d/base/sfx/034.wav new file mode 100644 index 0000000..176deec Binary files /dev/null and b/wolf3d/base/sfx/034.wav differ diff --git a/wolf3d/base/sfx/035.wav b/wolf3d/base/sfx/035.wav new file mode 100644 index 0000000..a905362 Binary files /dev/null and b/wolf3d/base/sfx/035.wav differ diff --git a/wolf3d/base/sfx/037.wav b/wolf3d/base/sfx/037.wav new file mode 100644 index 0000000..e56691a Binary files /dev/null and b/wolf3d/base/sfx/037.wav differ diff --git a/wolf3d/base/sfx/040.wav b/wolf3d/base/sfx/040.wav new file mode 100644 index 0000000..1e99ae6 Binary files /dev/null and b/wolf3d/base/sfx/040.wav differ diff --git a/wolf3d/base/sfx/044.wav b/wolf3d/base/sfx/044.wav new file mode 100644 index 0000000..74ff993 Binary files /dev/null and b/wolf3d/base/sfx/044.wav differ diff --git a/wolf3d/base/sfx/046.wav b/wolf3d/base/sfx/046.wav new file mode 100644 index 0000000..a72dd7c Binary files /dev/null and b/wolf3d/base/sfx/046.wav differ diff --git a/wolf3d/base/sfx/049.wav b/wolf3d/base/sfx/049.wav new file mode 100644 index 0000000..c1d4d6e Binary files /dev/null and b/wolf3d/base/sfx/049.wav differ diff --git a/wolf3d/base/sfx/052.wav b/wolf3d/base/sfx/052.wav new file mode 100644 index 0000000..cee1e25 Binary files /dev/null and b/wolf3d/base/sfx/052.wav differ diff --git a/wolf3d/base/sfx/054.wav b/wolf3d/base/sfx/054.wav new file mode 100644 index 0000000..004a2dc Binary files /dev/null and b/wolf3d/base/sfx/054.wav differ diff --git a/wolf3d/base/sfx/061.wav b/wolf3d/base/sfx/061.wav new file mode 100644 index 0000000..cbbd342 Binary files /dev/null and b/wolf3d/base/sfx/061.wav differ diff --git a/wolf3d/base/sfx/065.wav b/wolf3d/base/sfx/065.wav new file mode 100644 index 0000000..04673ee Binary files /dev/null and b/wolf3d/base/sfx/065.wav differ diff --git a/wolf3d/base/sfx/069.wav b/wolf3d/base/sfx/069.wav new file mode 100644 index 0000000..7e5f8f6 Binary files /dev/null and b/wolf3d/base/sfx/069.wav differ diff --git a/wolf3d/base/sfx/071.wav b/wolf3d/base/sfx/071.wav new file mode 100644 index 0000000..c7b8ea7 Binary files /dev/null and b/wolf3d/base/sfx/071.wav differ diff --git a/wolf3d/base/sfx/074.wav b/wolf3d/base/sfx/074.wav new file mode 100644 index 0000000..a1067fb Binary files /dev/null and b/wolf3d/base/sfx/074.wav differ diff --git a/wolf3d/base/sfx/076.wav b/wolf3d/base/sfx/076.wav new file mode 100644 index 0000000..308c4e3 Binary files /dev/null and b/wolf3d/base/sfx/076.wav differ diff --git a/wolf3d/base/sfx/078.wav b/wolf3d/base/sfx/078.wav new file mode 100644 index 0000000..1b914f9 Binary files /dev/null and b/wolf3d/base/sfx/078.wav differ diff --git a/wolf3d/base/sfx/080.wav b/wolf3d/base/sfx/080.wav new file mode 100644 index 0000000..8a5c1cd Binary files /dev/null and b/wolf3d/base/sfx/080.wav differ diff --git a/wolf3d/base/sfx/082.wav b/wolf3d/base/sfx/082.wav new file mode 100644 index 0000000..1945f65 Binary files /dev/null and b/wolf3d/base/sfx/082.wav differ diff --git a/wolf3d/base/sfx/084.wav b/wolf3d/base/sfx/084.wav new file mode 100644 index 0000000..b390590 Binary files /dev/null and b/wolf3d/base/sfx/084.wav differ diff --git a/wolf3d/base/sfx/086.wav b/wolf3d/base/sfx/086.wav new file mode 100644 index 0000000..7ec7956 Binary files /dev/null and b/wolf3d/base/sfx/086.wav differ diff --git a/wolf3d/base/sfx/088.wav b/wolf3d/base/sfx/088.wav new file mode 100644 index 0000000..883ecb8 Binary files /dev/null and b/wolf3d/base/sfx/088.wav differ diff --git a/wolf3d/base/sfx/091.wav b/wolf3d/base/sfx/091.wav new file mode 100644 index 0000000..051d55a Binary files /dev/null and b/wolf3d/base/sfx/091.wav differ diff --git a/wolf3d/base/sfx/096.wav b/wolf3d/base/sfx/096.wav new file mode 100644 index 0000000..d3c3d8e Binary files /dev/null and b/wolf3d/base/sfx/096.wav differ diff --git a/wolf3d/base/sfx/102.wav b/wolf3d/base/sfx/102.wav new file mode 100644 index 0000000..8d73e43 Binary files /dev/null and b/wolf3d/base/sfx/102.wav differ diff --git a/wolf3d/base/sfx/103.wav b/wolf3d/base/sfx/103.wav new file mode 100644 index 0000000..418c881 Binary files /dev/null and b/wolf3d/base/sfx/103.wav differ diff --git a/wolf3d/base/sfx/105.wav b/wolf3d/base/sfx/105.wav new file mode 100644 index 0000000..206aa88 Binary files /dev/null and b/wolf3d/base/sfx/105.wav differ diff --git a/wolf3d/base/sfx/107.wav b/wolf3d/base/sfx/107.wav new file mode 100644 index 0000000..2c676c9 Binary files /dev/null and b/wolf3d/base/sfx/107.wav differ diff --git a/wolf3d/base/sfx/109.wav b/wolf3d/base/sfx/109.wav new file mode 100644 index 0000000..8e18743 Binary files /dev/null and b/wolf3d/base/sfx/109.wav differ diff --git a/wolf3d/base/sfx/112.wav b/wolf3d/base/sfx/112.wav new file mode 100644 index 0000000..c0d291c Binary files /dev/null and b/wolf3d/base/sfx/112.wav differ diff --git a/wolf3d/base/sfx/115.wav b/wolf3d/base/sfx/115.wav new file mode 100644 index 0000000..0f3aa3e Binary files /dev/null and b/wolf3d/base/sfx/115.wav differ diff --git a/wolf3d/base/sfx/119.wav b/wolf3d/base/sfx/119.wav new file mode 100644 index 0000000..3651189 Binary files /dev/null and b/wolf3d/base/sfx/119.wav differ diff --git a/wolf3d/base/sprites/000.5551 b/wolf3d/base/sprites/000.5551 new file mode 100644 index 0000000..10b2cfb Binary files /dev/null and b/wolf3d/base/sprites/000.5551 differ diff --git a/wolf3d/base/sprites/001.5551 b/wolf3d/base/sprites/001.5551 new file mode 100644 index 0000000..33e410f Binary files /dev/null and b/wolf3d/base/sprites/001.5551 differ diff --git a/wolf3d/base/sprites/002.5551 b/wolf3d/base/sprites/002.5551 new file mode 100644 index 0000000..dd36835 Binary files /dev/null and b/wolf3d/base/sprites/002.5551 differ diff --git a/wolf3d/base/sprites/003.5551 b/wolf3d/base/sprites/003.5551 new file mode 100644 index 0000000..222dc5b Binary files /dev/null and b/wolf3d/base/sprites/003.5551 differ diff --git a/wolf3d/base/sprites/004.5551 b/wolf3d/base/sprites/004.5551 new file mode 100644 index 0000000..de6cd59 Binary files /dev/null and b/wolf3d/base/sprites/004.5551 differ diff --git a/wolf3d/base/sprites/005.5551 b/wolf3d/base/sprites/005.5551 new file mode 100644 index 0000000..97db7c3 Binary files /dev/null and b/wolf3d/base/sprites/005.5551 differ diff --git a/wolf3d/base/sprites/006.5551 b/wolf3d/base/sprites/006.5551 new file mode 100644 index 0000000..fe4e549 Binary files /dev/null and b/wolf3d/base/sprites/006.5551 differ diff --git a/wolf3d/base/sprites/007.5551 b/wolf3d/base/sprites/007.5551 new file mode 100644 index 0000000..b1bd310 Binary files /dev/null and b/wolf3d/base/sprites/007.5551 differ diff --git a/wolf3d/base/sprites/008.5551 b/wolf3d/base/sprites/008.5551 new file mode 100644 index 0000000..b616457 Binary files /dev/null and b/wolf3d/base/sprites/008.5551 differ diff --git a/wolf3d/base/sprites/009.5551 b/wolf3d/base/sprites/009.5551 new file mode 100644 index 0000000..578bcba Binary files /dev/null and b/wolf3d/base/sprites/009.5551 differ diff --git a/wolf3d/base/sprites/010.5551 b/wolf3d/base/sprites/010.5551 new file mode 100644 index 0000000..a6524dd Binary files /dev/null and b/wolf3d/base/sprites/010.5551 differ diff --git a/wolf3d/base/sprites/011.5551 b/wolf3d/base/sprites/011.5551 new file mode 100644 index 0000000..24b65d4 Binary files /dev/null and b/wolf3d/base/sprites/011.5551 differ diff --git a/wolf3d/base/sprites/012.5551 b/wolf3d/base/sprites/012.5551 new file mode 100644 index 0000000..c780f8e Binary files /dev/null and b/wolf3d/base/sprites/012.5551 differ diff --git a/wolf3d/base/sprites/013.5551 b/wolf3d/base/sprites/013.5551 new file mode 100644 index 0000000..153091d Binary files /dev/null and b/wolf3d/base/sprites/013.5551 differ diff --git a/wolf3d/base/sprites/014.5551 b/wolf3d/base/sprites/014.5551 new file mode 100644 index 0000000..fa9e356 Binary files /dev/null and b/wolf3d/base/sprites/014.5551 differ diff --git a/wolf3d/base/sprites/015.5551 b/wolf3d/base/sprites/015.5551 new file mode 100644 index 0000000..c1eddb8 Binary files /dev/null and b/wolf3d/base/sprites/015.5551 differ diff --git a/wolf3d/base/sprites/016.5551 b/wolf3d/base/sprites/016.5551 new file mode 100644 index 0000000..6d568b7 Binary files /dev/null and b/wolf3d/base/sprites/016.5551 differ diff --git a/wolf3d/base/sprites/017.5551 b/wolf3d/base/sprites/017.5551 new file mode 100644 index 0000000..3e1a7a3 Binary files /dev/null and b/wolf3d/base/sprites/017.5551 differ diff --git a/wolf3d/base/sprites/018.5551 b/wolf3d/base/sprites/018.5551 new file mode 100644 index 0000000..e6a25a4 Binary files /dev/null and b/wolf3d/base/sprites/018.5551 differ diff --git a/wolf3d/base/sprites/019.5551 b/wolf3d/base/sprites/019.5551 new file mode 100644 index 0000000..a1977d0 Binary files /dev/null and b/wolf3d/base/sprites/019.5551 differ diff --git a/wolf3d/base/sprites/020.5551 b/wolf3d/base/sprites/020.5551 new file mode 100644 index 0000000..52a4080 Binary files /dev/null and b/wolf3d/base/sprites/020.5551 differ diff --git a/wolf3d/base/sprites/021.5551 b/wolf3d/base/sprites/021.5551 new file mode 100644 index 0000000..245544a Binary files /dev/null and b/wolf3d/base/sprites/021.5551 differ diff --git a/wolf3d/base/sprites/022.5551 b/wolf3d/base/sprites/022.5551 new file mode 100644 index 0000000..5b7b15d Binary files /dev/null and b/wolf3d/base/sprites/022.5551 differ diff --git a/wolf3d/base/sprites/023.5551 b/wolf3d/base/sprites/023.5551 new file mode 100644 index 0000000..cfc475d Binary files /dev/null and b/wolf3d/base/sprites/023.5551 differ diff --git a/wolf3d/base/sprites/024.5551 b/wolf3d/base/sprites/024.5551 new file mode 100644 index 0000000..3ac9062 Binary files /dev/null and b/wolf3d/base/sprites/024.5551 differ diff --git a/wolf3d/base/sprites/025.5551 b/wolf3d/base/sprites/025.5551 new file mode 100644 index 0000000..8ebad7c Binary files /dev/null and b/wolf3d/base/sprites/025.5551 differ diff --git a/wolf3d/base/sprites/026.5551 b/wolf3d/base/sprites/026.5551 new file mode 100644 index 0000000..6b45aea Binary files /dev/null and b/wolf3d/base/sprites/026.5551 differ diff --git a/wolf3d/base/sprites/027.5551 b/wolf3d/base/sprites/027.5551 new file mode 100644 index 0000000..9fa4914 Binary files /dev/null and b/wolf3d/base/sprites/027.5551 differ diff --git a/wolf3d/base/sprites/028.5551 b/wolf3d/base/sprites/028.5551 new file mode 100644 index 0000000..a32bd00 Binary files /dev/null and b/wolf3d/base/sprites/028.5551 differ diff --git a/wolf3d/base/sprites/029.5551 b/wolf3d/base/sprites/029.5551 new file mode 100644 index 0000000..f3b4428 Binary files /dev/null and b/wolf3d/base/sprites/029.5551 differ diff --git a/wolf3d/base/sprites/030.5551 b/wolf3d/base/sprites/030.5551 new file mode 100644 index 0000000..216853b Binary files /dev/null and b/wolf3d/base/sprites/030.5551 differ diff --git a/wolf3d/base/sprites/031.5551 b/wolf3d/base/sprites/031.5551 new file mode 100644 index 0000000..bd6272b Binary files /dev/null and b/wolf3d/base/sprites/031.5551 differ diff --git a/wolf3d/base/sprites/032.5551 b/wolf3d/base/sprites/032.5551 new file mode 100644 index 0000000..240d76c Binary files /dev/null and b/wolf3d/base/sprites/032.5551 differ diff --git a/wolf3d/base/sprites/033.5551 b/wolf3d/base/sprites/033.5551 new file mode 100644 index 0000000..a5c9ef9 Binary files /dev/null and b/wolf3d/base/sprites/033.5551 differ diff --git a/wolf3d/base/sprites/034.5551 b/wolf3d/base/sprites/034.5551 new file mode 100644 index 0000000..b7fa952 Binary files /dev/null and b/wolf3d/base/sprites/034.5551 differ diff --git a/wolf3d/base/sprites/035.5551 b/wolf3d/base/sprites/035.5551 new file mode 100644 index 0000000..a2e0993 Binary files /dev/null and b/wolf3d/base/sprites/035.5551 differ diff --git a/wolf3d/base/sprites/036.5551 b/wolf3d/base/sprites/036.5551 new file mode 100644 index 0000000..c6f816f Binary files /dev/null and b/wolf3d/base/sprites/036.5551 differ diff --git a/wolf3d/base/sprites/037.5551 b/wolf3d/base/sprites/037.5551 new file mode 100644 index 0000000..19f2360 Binary files /dev/null and b/wolf3d/base/sprites/037.5551 differ diff --git a/wolf3d/base/sprites/038.5551 b/wolf3d/base/sprites/038.5551 new file mode 100644 index 0000000..3e44f54 Binary files /dev/null and b/wolf3d/base/sprites/038.5551 differ diff --git a/wolf3d/base/sprites/039.5551 b/wolf3d/base/sprites/039.5551 new file mode 100644 index 0000000..56b6ccc Binary files /dev/null and b/wolf3d/base/sprites/039.5551 differ diff --git a/wolf3d/base/sprites/040.5551 b/wolf3d/base/sprites/040.5551 new file mode 100644 index 0000000..9b53a7f Binary files /dev/null and b/wolf3d/base/sprites/040.5551 differ diff --git a/wolf3d/base/sprites/041.5551 b/wolf3d/base/sprites/041.5551 new file mode 100644 index 0000000..0cc89da Binary files /dev/null and b/wolf3d/base/sprites/041.5551 differ diff --git a/wolf3d/base/sprites/042.5551 b/wolf3d/base/sprites/042.5551 new file mode 100644 index 0000000..86b3c9e Binary files /dev/null and b/wolf3d/base/sprites/042.5551 differ diff --git a/wolf3d/base/sprites/043.5551 b/wolf3d/base/sprites/043.5551 new file mode 100644 index 0000000..6c52cbf Binary files /dev/null and b/wolf3d/base/sprites/043.5551 differ diff --git a/wolf3d/base/sprites/044.5551 b/wolf3d/base/sprites/044.5551 new file mode 100644 index 0000000..db2c09a Binary files /dev/null and b/wolf3d/base/sprites/044.5551 differ diff --git a/wolf3d/base/sprites/045.5551 b/wolf3d/base/sprites/045.5551 new file mode 100644 index 0000000..5c56a88 Binary files /dev/null and b/wolf3d/base/sprites/045.5551 differ diff --git a/wolf3d/base/sprites/046.5551 b/wolf3d/base/sprites/046.5551 new file mode 100644 index 0000000..9f90b64 Binary files /dev/null and b/wolf3d/base/sprites/046.5551 differ diff --git a/wolf3d/base/sprites/047.5551 b/wolf3d/base/sprites/047.5551 new file mode 100644 index 0000000..dd769c2 Binary files /dev/null and b/wolf3d/base/sprites/047.5551 differ diff --git a/wolf3d/base/sprites/048.5551 b/wolf3d/base/sprites/048.5551 new file mode 100644 index 0000000..e112f5f Binary files /dev/null and b/wolf3d/base/sprites/048.5551 differ diff --git a/wolf3d/base/sprites/049.5551 b/wolf3d/base/sprites/049.5551 new file mode 100644 index 0000000..ad5e451 Binary files /dev/null and b/wolf3d/base/sprites/049.5551 differ diff --git a/wolf3d/base/sprites/054.5551 b/wolf3d/base/sprites/054.5551 new file mode 100644 index 0000000..14bc09a Binary files /dev/null and b/wolf3d/base/sprites/054.5551 differ diff --git a/wolf3d/base/sprites/055.5551 b/wolf3d/base/sprites/055.5551 new file mode 100644 index 0000000..d2b6418 Binary files /dev/null and b/wolf3d/base/sprites/055.5551 differ diff --git a/wolf3d/base/sprites/056.5551 b/wolf3d/base/sprites/056.5551 new file mode 100644 index 0000000..6538116 Binary files /dev/null and b/wolf3d/base/sprites/056.5551 differ diff --git a/wolf3d/base/sprites/057.5551 b/wolf3d/base/sprites/057.5551 new file mode 100644 index 0000000..070f9a1 Binary files /dev/null and b/wolf3d/base/sprites/057.5551 differ diff --git a/wolf3d/base/sprites/058.5551 b/wolf3d/base/sprites/058.5551 new file mode 100644 index 0000000..97d0fff Binary files /dev/null and b/wolf3d/base/sprites/058.5551 differ diff --git a/wolf3d/base/sprites/059.5551 b/wolf3d/base/sprites/059.5551 new file mode 100644 index 0000000..277477c Binary files /dev/null and b/wolf3d/base/sprites/059.5551 differ diff --git a/wolf3d/base/sprites/060.5551 b/wolf3d/base/sprites/060.5551 new file mode 100644 index 0000000..aeeb0b5 Binary files /dev/null and b/wolf3d/base/sprites/060.5551 differ diff --git a/wolf3d/base/sprites/061.5551 b/wolf3d/base/sprites/061.5551 new file mode 100644 index 0000000..240005c Binary files /dev/null and b/wolf3d/base/sprites/061.5551 differ diff --git a/wolf3d/base/sprites/062.5551 b/wolf3d/base/sprites/062.5551 new file mode 100644 index 0000000..4a0df39 Binary files /dev/null and b/wolf3d/base/sprites/062.5551 differ diff --git a/wolf3d/base/sprites/063.5551 b/wolf3d/base/sprites/063.5551 new file mode 100644 index 0000000..691e0c1 Binary files /dev/null and b/wolf3d/base/sprites/063.5551 differ diff --git a/wolf3d/base/sprites/064.5551 b/wolf3d/base/sprites/064.5551 new file mode 100644 index 0000000..b8d3f6c Binary files /dev/null and b/wolf3d/base/sprites/064.5551 differ diff --git a/wolf3d/base/sprites/065.5551 b/wolf3d/base/sprites/065.5551 new file mode 100644 index 0000000..f0b382b Binary files /dev/null and b/wolf3d/base/sprites/065.5551 differ diff --git a/wolf3d/base/sprites/066.5551 b/wolf3d/base/sprites/066.5551 new file mode 100644 index 0000000..80b045d Binary files /dev/null and b/wolf3d/base/sprites/066.5551 differ diff --git a/wolf3d/base/sprites/067.5551 b/wolf3d/base/sprites/067.5551 new file mode 100644 index 0000000..8d247c7 Binary files /dev/null and b/wolf3d/base/sprites/067.5551 differ diff --git a/wolf3d/base/sprites/068.5551 b/wolf3d/base/sprites/068.5551 new file mode 100644 index 0000000..c3ca20f Binary files /dev/null and b/wolf3d/base/sprites/068.5551 differ diff --git a/wolf3d/base/sprites/069.5551 b/wolf3d/base/sprites/069.5551 new file mode 100644 index 0000000..bff5229 Binary files /dev/null and b/wolf3d/base/sprites/069.5551 differ diff --git a/wolf3d/base/sprites/070.5551 b/wolf3d/base/sprites/070.5551 new file mode 100644 index 0000000..84e2f64 Binary files /dev/null and b/wolf3d/base/sprites/070.5551 differ diff --git a/wolf3d/base/sprites/071.5551 b/wolf3d/base/sprites/071.5551 new file mode 100644 index 0000000..1efc07c Binary files /dev/null and b/wolf3d/base/sprites/071.5551 differ diff --git a/wolf3d/base/sprites/072.5551 b/wolf3d/base/sprites/072.5551 new file mode 100644 index 0000000..091c2c8 Binary files /dev/null and b/wolf3d/base/sprites/072.5551 differ diff --git a/wolf3d/base/sprites/073.5551 b/wolf3d/base/sprites/073.5551 new file mode 100644 index 0000000..deaffe8 Binary files /dev/null and b/wolf3d/base/sprites/073.5551 differ diff --git a/wolf3d/base/sprites/074.5551 b/wolf3d/base/sprites/074.5551 new file mode 100644 index 0000000..1de7c9a Binary files /dev/null and b/wolf3d/base/sprites/074.5551 differ diff --git a/wolf3d/base/sprites/075.5551 b/wolf3d/base/sprites/075.5551 new file mode 100644 index 0000000..53dd27f Binary files /dev/null and b/wolf3d/base/sprites/075.5551 differ diff --git a/wolf3d/base/sprites/076.5551 b/wolf3d/base/sprites/076.5551 new file mode 100644 index 0000000..371b238 Binary files /dev/null and b/wolf3d/base/sprites/076.5551 differ diff --git a/wolf3d/base/sprites/077.5551 b/wolf3d/base/sprites/077.5551 new file mode 100644 index 0000000..12d2eb5 Binary files /dev/null and b/wolf3d/base/sprites/077.5551 differ diff --git a/wolf3d/base/sprites/078.5551 b/wolf3d/base/sprites/078.5551 new file mode 100644 index 0000000..0032fa8 Binary files /dev/null and b/wolf3d/base/sprites/078.5551 differ diff --git a/wolf3d/base/sprites/079.5551 b/wolf3d/base/sprites/079.5551 new file mode 100644 index 0000000..44ba2b6 Binary files /dev/null and b/wolf3d/base/sprites/079.5551 differ diff --git a/wolf3d/base/sprites/080.5551 b/wolf3d/base/sprites/080.5551 new file mode 100644 index 0000000..33c484e Binary files /dev/null and b/wolf3d/base/sprites/080.5551 differ diff --git a/wolf3d/base/sprites/081.5551 b/wolf3d/base/sprites/081.5551 new file mode 100644 index 0000000..a23cc52 Binary files /dev/null and b/wolf3d/base/sprites/081.5551 differ diff --git a/wolf3d/base/sprites/082.5551 b/wolf3d/base/sprites/082.5551 new file mode 100644 index 0000000..8a4659d Binary files /dev/null and b/wolf3d/base/sprites/082.5551 differ diff --git a/wolf3d/base/sprites/083.5551 b/wolf3d/base/sprites/083.5551 new file mode 100644 index 0000000..4fac962 Binary files /dev/null and b/wolf3d/base/sprites/083.5551 differ diff --git a/wolf3d/base/sprites/084.5551 b/wolf3d/base/sprites/084.5551 new file mode 100644 index 0000000..2061f3d Binary files /dev/null and b/wolf3d/base/sprites/084.5551 differ diff --git a/wolf3d/base/sprites/085.5551 b/wolf3d/base/sprites/085.5551 new file mode 100644 index 0000000..5d38b34 Binary files /dev/null and b/wolf3d/base/sprites/085.5551 differ diff --git a/wolf3d/base/sprites/086.5551 b/wolf3d/base/sprites/086.5551 new file mode 100644 index 0000000..0034cb2 Binary files /dev/null and b/wolf3d/base/sprites/086.5551 differ diff --git a/wolf3d/base/sprites/087.5551 b/wolf3d/base/sprites/087.5551 new file mode 100644 index 0000000..092be17 Binary files /dev/null and b/wolf3d/base/sprites/087.5551 differ diff --git a/wolf3d/base/sprites/088.5551 b/wolf3d/base/sprites/088.5551 new file mode 100644 index 0000000..9f6a951 Binary files /dev/null and b/wolf3d/base/sprites/088.5551 differ diff --git a/wolf3d/base/sprites/089.5551 b/wolf3d/base/sprites/089.5551 new file mode 100644 index 0000000..a46fbb8 Binary files /dev/null and b/wolf3d/base/sprites/089.5551 differ diff --git a/wolf3d/base/sprites/090.5551 b/wolf3d/base/sprites/090.5551 new file mode 100644 index 0000000..53ba0eb Binary files /dev/null and b/wolf3d/base/sprites/090.5551 differ diff --git a/wolf3d/base/sprites/091.5551 b/wolf3d/base/sprites/091.5551 new file mode 100644 index 0000000..c098695 Binary files /dev/null and b/wolf3d/base/sprites/091.5551 differ diff --git a/wolf3d/base/sprites/092.5551 b/wolf3d/base/sprites/092.5551 new file mode 100644 index 0000000..8c6c111 Binary files /dev/null and b/wolf3d/base/sprites/092.5551 differ diff --git a/wolf3d/base/sprites/093.5551 b/wolf3d/base/sprites/093.5551 new file mode 100644 index 0000000..cd075bf Binary files /dev/null and b/wolf3d/base/sprites/093.5551 differ diff --git a/wolf3d/base/sprites/094.5551 b/wolf3d/base/sprites/094.5551 new file mode 100644 index 0000000..274b15f Binary files /dev/null and b/wolf3d/base/sprites/094.5551 differ diff --git a/wolf3d/base/sprites/095.5551 b/wolf3d/base/sprites/095.5551 new file mode 100644 index 0000000..6d98513 Binary files /dev/null and b/wolf3d/base/sprites/095.5551 differ diff --git a/wolf3d/base/sprites/096.5551 b/wolf3d/base/sprites/096.5551 new file mode 100644 index 0000000..0ff7cbb Binary files /dev/null and b/wolf3d/base/sprites/096.5551 differ diff --git a/wolf3d/base/sprites/097.5551 b/wolf3d/base/sprites/097.5551 new file mode 100644 index 0000000..9bda348 Binary files /dev/null and b/wolf3d/base/sprites/097.5551 differ diff --git a/wolf3d/base/sprites/098.5551 b/wolf3d/base/sprites/098.5551 new file mode 100644 index 0000000..354d058 Binary files /dev/null and b/wolf3d/base/sprites/098.5551 differ diff --git a/wolf3d/base/sprites/099.5551 b/wolf3d/base/sprites/099.5551 new file mode 100644 index 0000000..be5a5da Binary files /dev/null and b/wolf3d/base/sprites/099.5551 differ diff --git a/wolf3d/base/sprites/100.5551 b/wolf3d/base/sprites/100.5551 new file mode 100644 index 0000000..fd64dd9 Binary files /dev/null and b/wolf3d/base/sprites/100.5551 differ diff --git a/wolf3d/base/sprites/101.5551 b/wolf3d/base/sprites/101.5551 new file mode 100644 index 0000000..5962982 Binary files /dev/null and b/wolf3d/base/sprites/101.5551 differ diff --git a/wolf3d/base/sprites/102.5551 b/wolf3d/base/sprites/102.5551 new file mode 100644 index 0000000..e2a167e Binary files /dev/null and b/wolf3d/base/sprites/102.5551 differ diff --git a/wolf3d/base/sprites/103.5551 b/wolf3d/base/sprites/103.5551 new file mode 100644 index 0000000..f6251ba Binary files /dev/null and b/wolf3d/base/sprites/103.5551 differ diff --git a/wolf3d/base/sprites/104.5551 b/wolf3d/base/sprites/104.5551 new file mode 100644 index 0000000..161643f Binary files /dev/null and b/wolf3d/base/sprites/104.5551 differ diff --git a/wolf3d/base/sprites/105.5551 b/wolf3d/base/sprites/105.5551 new file mode 100644 index 0000000..0f8f735 Binary files /dev/null and b/wolf3d/base/sprites/105.5551 differ diff --git a/wolf3d/base/sprites/106.5551 b/wolf3d/base/sprites/106.5551 new file mode 100644 index 0000000..f4c773c Binary files /dev/null and b/wolf3d/base/sprites/106.5551 differ diff --git a/wolf3d/base/sprites/107.5551 b/wolf3d/base/sprites/107.5551 new file mode 100644 index 0000000..1f484f9 Binary files /dev/null and b/wolf3d/base/sprites/107.5551 differ diff --git a/wolf3d/base/sprites/108.5551 b/wolf3d/base/sprites/108.5551 new file mode 100644 index 0000000..ed5ad57 Binary files /dev/null and b/wolf3d/base/sprites/108.5551 differ diff --git a/wolf3d/base/sprites/109.5551 b/wolf3d/base/sprites/109.5551 new file mode 100644 index 0000000..4c59d17 Binary files /dev/null and b/wolf3d/base/sprites/109.5551 differ diff --git a/wolf3d/base/sprites/110.5551 b/wolf3d/base/sprites/110.5551 new file mode 100644 index 0000000..b2679aa Binary files /dev/null and b/wolf3d/base/sprites/110.5551 differ diff --git a/wolf3d/base/sprites/111.5551 b/wolf3d/base/sprites/111.5551 new file mode 100644 index 0000000..5f26193 Binary files /dev/null and b/wolf3d/base/sprites/111.5551 differ diff --git a/wolf3d/base/sprites/112.5551 b/wolf3d/base/sprites/112.5551 new file mode 100644 index 0000000..4d73c28 Binary files /dev/null and b/wolf3d/base/sprites/112.5551 differ diff --git a/wolf3d/base/sprites/113.5551 b/wolf3d/base/sprites/113.5551 new file mode 100644 index 0000000..f073df3 Binary files /dev/null and b/wolf3d/base/sprites/113.5551 differ diff --git a/wolf3d/base/sprites/114.5551 b/wolf3d/base/sprites/114.5551 new file mode 100644 index 0000000..dd95b1d Binary files /dev/null and b/wolf3d/base/sprites/114.5551 differ diff --git a/wolf3d/base/sprites/115.5551 b/wolf3d/base/sprites/115.5551 new file mode 100644 index 0000000..23086de Binary files /dev/null and b/wolf3d/base/sprites/115.5551 differ diff --git a/wolf3d/base/sprites/116.5551 b/wolf3d/base/sprites/116.5551 new file mode 100644 index 0000000..3dadeb3 Binary files /dev/null and b/wolf3d/base/sprites/116.5551 differ diff --git a/wolf3d/base/sprites/117.5551 b/wolf3d/base/sprites/117.5551 new file mode 100644 index 0000000..df491db Binary files /dev/null and b/wolf3d/base/sprites/117.5551 differ diff --git a/wolf3d/base/sprites/118.5551 b/wolf3d/base/sprites/118.5551 new file mode 100644 index 0000000..6884683 Binary files /dev/null and b/wolf3d/base/sprites/118.5551 differ diff --git a/wolf3d/base/sprites/119.5551 b/wolf3d/base/sprites/119.5551 new file mode 100644 index 0000000..b755b4d Binary files /dev/null and b/wolf3d/base/sprites/119.5551 differ diff --git a/wolf3d/base/sprites/120.5551 b/wolf3d/base/sprites/120.5551 new file mode 100644 index 0000000..6d93ccf Binary files /dev/null and b/wolf3d/base/sprites/120.5551 differ diff --git a/wolf3d/base/sprites/121.5551 b/wolf3d/base/sprites/121.5551 new file mode 100644 index 0000000..dfaca72 Binary files /dev/null and b/wolf3d/base/sprites/121.5551 differ diff --git a/wolf3d/base/sprites/122.5551 b/wolf3d/base/sprites/122.5551 new file mode 100644 index 0000000..68a34b8 Binary files /dev/null and b/wolf3d/base/sprites/122.5551 differ diff --git a/wolf3d/base/sprites/123.5551 b/wolf3d/base/sprites/123.5551 new file mode 100644 index 0000000..f7ddbd3 Binary files /dev/null and b/wolf3d/base/sprites/123.5551 differ diff --git a/wolf3d/base/sprites/124.5551 b/wolf3d/base/sprites/124.5551 new file mode 100644 index 0000000..caeb12a Binary files /dev/null and b/wolf3d/base/sprites/124.5551 differ diff --git a/wolf3d/base/sprites/125.5551 b/wolf3d/base/sprites/125.5551 new file mode 100644 index 0000000..53c248e Binary files /dev/null and b/wolf3d/base/sprites/125.5551 differ diff --git a/wolf3d/base/sprites/126.5551 b/wolf3d/base/sprites/126.5551 new file mode 100644 index 0000000..62d939d Binary files /dev/null and b/wolf3d/base/sprites/126.5551 differ diff --git a/wolf3d/base/sprites/127.5551 b/wolf3d/base/sprites/127.5551 new file mode 100644 index 0000000..d87f63d Binary files /dev/null and b/wolf3d/base/sprites/127.5551 differ diff --git a/wolf3d/base/sprites/128.5551 b/wolf3d/base/sprites/128.5551 new file mode 100644 index 0000000..193f341 Binary files /dev/null and b/wolf3d/base/sprites/128.5551 differ diff --git a/wolf3d/base/sprites/129.5551 b/wolf3d/base/sprites/129.5551 new file mode 100644 index 0000000..dd68741 Binary files /dev/null and b/wolf3d/base/sprites/129.5551 differ diff --git a/wolf3d/base/sprites/130.5551 b/wolf3d/base/sprites/130.5551 new file mode 100644 index 0000000..98c8bfc Binary files /dev/null and b/wolf3d/base/sprites/130.5551 differ diff --git a/wolf3d/base/sprites/131.5551 b/wolf3d/base/sprites/131.5551 new file mode 100644 index 0000000..fba497c Binary files /dev/null and b/wolf3d/base/sprites/131.5551 differ diff --git a/wolf3d/base/sprites/132.5551 b/wolf3d/base/sprites/132.5551 new file mode 100644 index 0000000..1569164 Binary files /dev/null and b/wolf3d/base/sprites/132.5551 differ diff --git a/wolf3d/base/sprites/133.5551 b/wolf3d/base/sprites/133.5551 new file mode 100644 index 0000000..0e97299 Binary files /dev/null and b/wolf3d/base/sprites/133.5551 differ diff --git a/wolf3d/base/sprites/134.5551 b/wolf3d/base/sprites/134.5551 new file mode 100644 index 0000000..62825fa Binary files /dev/null and b/wolf3d/base/sprites/134.5551 differ diff --git a/wolf3d/base/sprites/135.5551 b/wolf3d/base/sprites/135.5551 new file mode 100644 index 0000000..0087a5c Binary files /dev/null and b/wolf3d/base/sprites/135.5551 differ diff --git a/wolf3d/base/sprites/136.5551 b/wolf3d/base/sprites/136.5551 new file mode 100644 index 0000000..5a64f44 Binary files /dev/null and b/wolf3d/base/sprites/136.5551 differ diff --git a/wolf3d/base/sprites/137.5551 b/wolf3d/base/sprites/137.5551 new file mode 100644 index 0000000..8c25f20 Binary files /dev/null and b/wolf3d/base/sprites/137.5551 differ diff --git a/wolf3d/base/sprites/138.5551 b/wolf3d/base/sprites/138.5551 new file mode 100644 index 0000000..c984d44 Binary files /dev/null and b/wolf3d/base/sprites/138.5551 differ diff --git a/wolf3d/base/sprites/139.5551 b/wolf3d/base/sprites/139.5551 new file mode 100644 index 0000000..896bff9 Binary files /dev/null and b/wolf3d/base/sprites/139.5551 differ diff --git a/wolf3d/base/sprites/140.5551 b/wolf3d/base/sprites/140.5551 new file mode 100644 index 0000000..139e98f Binary files /dev/null and b/wolf3d/base/sprites/140.5551 differ diff --git a/wolf3d/base/sprites/141.5551 b/wolf3d/base/sprites/141.5551 new file mode 100644 index 0000000..f30af53 Binary files /dev/null and b/wolf3d/base/sprites/141.5551 differ diff --git a/wolf3d/base/sprites/142.5551 b/wolf3d/base/sprites/142.5551 new file mode 100644 index 0000000..9cc59b5 Binary files /dev/null and b/wolf3d/base/sprites/142.5551 differ diff --git a/wolf3d/base/sprites/143.5551 b/wolf3d/base/sprites/143.5551 new file mode 100644 index 0000000..e60dbff Binary files /dev/null and b/wolf3d/base/sprites/143.5551 differ diff --git a/wolf3d/base/sprites/144.5551 b/wolf3d/base/sprites/144.5551 new file mode 100644 index 0000000..99af0df Binary files /dev/null and b/wolf3d/base/sprites/144.5551 differ diff --git a/wolf3d/base/sprites/145.5551 b/wolf3d/base/sprites/145.5551 new file mode 100644 index 0000000..64e4670 Binary files /dev/null and b/wolf3d/base/sprites/145.5551 differ diff --git a/wolf3d/base/sprites/146.5551 b/wolf3d/base/sprites/146.5551 new file mode 100644 index 0000000..1b9bd5b Binary files /dev/null and b/wolf3d/base/sprites/146.5551 differ diff --git a/wolf3d/base/sprites/147.5551 b/wolf3d/base/sprites/147.5551 new file mode 100644 index 0000000..8293ef6 Binary files /dev/null and b/wolf3d/base/sprites/147.5551 differ diff --git a/wolf3d/base/sprites/148.5551 b/wolf3d/base/sprites/148.5551 new file mode 100644 index 0000000..ea84391 Binary files /dev/null and b/wolf3d/base/sprites/148.5551 differ diff --git a/wolf3d/base/sprites/149.5551 b/wolf3d/base/sprites/149.5551 new file mode 100644 index 0000000..1d7cfeb Binary files /dev/null and b/wolf3d/base/sprites/149.5551 differ diff --git a/wolf3d/base/sprites/150.5551 b/wolf3d/base/sprites/150.5551 new file mode 100644 index 0000000..38ca817 Binary files /dev/null and b/wolf3d/base/sprites/150.5551 differ diff --git a/wolf3d/base/sprites/151.5551 b/wolf3d/base/sprites/151.5551 new file mode 100644 index 0000000..c27ba88 Binary files /dev/null and b/wolf3d/base/sprites/151.5551 differ diff --git a/wolf3d/base/sprites/152.5551 b/wolf3d/base/sprites/152.5551 new file mode 100644 index 0000000..1ac6378 Binary files /dev/null and b/wolf3d/base/sprites/152.5551 differ diff --git a/wolf3d/base/sprites/153.5551 b/wolf3d/base/sprites/153.5551 new file mode 100644 index 0000000..a5a0e88 Binary files /dev/null and b/wolf3d/base/sprites/153.5551 differ diff --git a/wolf3d/base/sprites/154.5551 b/wolf3d/base/sprites/154.5551 new file mode 100644 index 0000000..7c29061 Binary files /dev/null and b/wolf3d/base/sprites/154.5551 differ diff --git a/wolf3d/base/sprites/155.5551 b/wolf3d/base/sprites/155.5551 new file mode 100644 index 0000000..6a010d7 Binary files /dev/null and b/wolf3d/base/sprites/155.5551 differ diff --git a/wolf3d/base/sprites/156.5551 b/wolf3d/base/sprites/156.5551 new file mode 100644 index 0000000..3e16a28 Binary files /dev/null and b/wolf3d/base/sprites/156.5551 differ diff --git a/wolf3d/base/sprites/157.5551 b/wolf3d/base/sprites/157.5551 new file mode 100644 index 0000000..751bd64 Binary files /dev/null and b/wolf3d/base/sprites/157.5551 differ diff --git a/wolf3d/base/sprites/158.5551 b/wolf3d/base/sprites/158.5551 new file mode 100644 index 0000000..e376772 Binary files /dev/null and b/wolf3d/base/sprites/158.5551 differ diff --git a/wolf3d/base/sprites/159.5551 b/wolf3d/base/sprites/159.5551 new file mode 100644 index 0000000..84e0e10 Binary files /dev/null and b/wolf3d/base/sprites/159.5551 differ diff --git a/wolf3d/base/sprites/160.5551 b/wolf3d/base/sprites/160.5551 new file mode 100644 index 0000000..62b7117 Binary files /dev/null and b/wolf3d/base/sprites/160.5551 differ diff --git a/wolf3d/base/sprites/161.5551 b/wolf3d/base/sprites/161.5551 new file mode 100644 index 0000000..3718d29 Binary files /dev/null and b/wolf3d/base/sprites/161.5551 differ diff --git a/wolf3d/base/sprites/162.5551 b/wolf3d/base/sprites/162.5551 new file mode 100644 index 0000000..b895354 Binary files /dev/null and b/wolf3d/base/sprites/162.5551 differ diff --git a/wolf3d/base/sprites/163.5551 b/wolf3d/base/sprites/163.5551 new file mode 100644 index 0000000..5ab5b46 Binary files /dev/null and b/wolf3d/base/sprites/163.5551 differ diff --git a/wolf3d/base/sprites/164.5551 b/wolf3d/base/sprites/164.5551 new file mode 100644 index 0000000..56f9637 Binary files /dev/null and b/wolf3d/base/sprites/164.5551 differ diff --git a/wolf3d/base/sprites/165.5551 b/wolf3d/base/sprites/165.5551 new file mode 100644 index 0000000..8e982ea Binary files /dev/null and b/wolf3d/base/sprites/165.5551 differ diff --git a/wolf3d/base/sprites/166.5551 b/wolf3d/base/sprites/166.5551 new file mode 100644 index 0000000..76884d6 Binary files /dev/null and b/wolf3d/base/sprites/166.5551 differ diff --git a/wolf3d/base/sprites/167.5551 b/wolf3d/base/sprites/167.5551 new file mode 100644 index 0000000..be816b2 Binary files /dev/null and b/wolf3d/base/sprites/167.5551 differ diff --git a/wolf3d/base/sprites/168.5551 b/wolf3d/base/sprites/168.5551 new file mode 100644 index 0000000..303828b Binary files /dev/null and b/wolf3d/base/sprites/168.5551 differ diff --git a/wolf3d/base/sprites/169.5551 b/wolf3d/base/sprites/169.5551 new file mode 100644 index 0000000..07e5cd7 Binary files /dev/null and b/wolf3d/base/sprites/169.5551 differ diff --git a/wolf3d/base/sprites/170.5551 b/wolf3d/base/sprites/170.5551 new file mode 100644 index 0000000..0702421 Binary files /dev/null and b/wolf3d/base/sprites/170.5551 differ diff --git a/wolf3d/base/sprites/171.5551 b/wolf3d/base/sprites/171.5551 new file mode 100644 index 0000000..e66f9a5 Binary files /dev/null and b/wolf3d/base/sprites/171.5551 differ diff --git a/wolf3d/base/sprites/172.5551 b/wolf3d/base/sprites/172.5551 new file mode 100644 index 0000000..1e46505 Binary files /dev/null and b/wolf3d/base/sprites/172.5551 differ diff --git a/wolf3d/base/sprites/173.5551 b/wolf3d/base/sprites/173.5551 new file mode 100644 index 0000000..af8523f Binary files /dev/null and b/wolf3d/base/sprites/173.5551 differ diff --git a/wolf3d/base/sprites/174.5551 b/wolf3d/base/sprites/174.5551 new file mode 100644 index 0000000..d274dff Binary files /dev/null and b/wolf3d/base/sprites/174.5551 differ diff --git a/wolf3d/base/sprites/175.5551 b/wolf3d/base/sprites/175.5551 new file mode 100644 index 0000000..668f360 Binary files /dev/null and b/wolf3d/base/sprites/175.5551 differ diff --git a/wolf3d/base/sprites/176.5551 b/wolf3d/base/sprites/176.5551 new file mode 100644 index 0000000..fb0c7b4 Binary files /dev/null and b/wolf3d/base/sprites/176.5551 differ diff --git a/wolf3d/base/sprites/177.5551 b/wolf3d/base/sprites/177.5551 new file mode 100644 index 0000000..276928a Binary files /dev/null and b/wolf3d/base/sprites/177.5551 differ diff --git a/wolf3d/base/sprites/178.5551 b/wolf3d/base/sprites/178.5551 new file mode 100644 index 0000000..da03992 Binary files /dev/null and b/wolf3d/base/sprites/178.5551 differ diff --git a/wolf3d/base/sprites/179.5551 b/wolf3d/base/sprites/179.5551 new file mode 100644 index 0000000..d4f5f66 Binary files /dev/null and b/wolf3d/base/sprites/179.5551 differ diff --git a/wolf3d/base/sprites/180.5551 b/wolf3d/base/sprites/180.5551 new file mode 100644 index 0000000..3aec5e0 Binary files /dev/null and b/wolf3d/base/sprites/180.5551 differ diff --git a/wolf3d/base/sprites/181.5551 b/wolf3d/base/sprites/181.5551 new file mode 100644 index 0000000..fb4d869 Binary files /dev/null and b/wolf3d/base/sprites/181.5551 differ diff --git a/wolf3d/base/sprites/182.5551 b/wolf3d/base/sprites/182.5551 new file mode 100644 index 0000000..b6c7388 Binary files /dev/null and b/wolf3d/base/sprites/182.5551 differ diff --git a/wolf3d/base/sprites/183.5551 b/wolf3d/base/sprites/183.5551 new file mode 100644 index 0000000..3d2b4c7 Binary files /dev/null and b/wolf3d/base/sprites/183.5551 differ diff --git a/wolf3d/base/sprites/184.5551 b/wolf3d/base/sprites/184.5551 new file mode 100644 index 0000000..24ce9cd Binary files /dev/null and b/wolf3d/base/sprites/184.5551 differ diff --git a/wolf3d/base/sprites/185.5551 b/wolf3d/base/sprites/185.5551 new file mode 100644 index 0000000..12085c2 Binary files /dev/null and b/wolf3d/base/sprites/185.5551 differ diff --git a/wolf3d/base/sprites/186.5551 b/wolf3d/base/sprites/186.5551 new file mode 100644 index 0000000..676c575 Binary files /dev/null and b/wolf3d/base/sprites/186.5551 differ diff --git a/wolf3d/base/sprites/187.5551 b/wolf3d/base/sprites/187.5551 new file mode 100644 index 0000000..823fda3 Binary files /dev/null and b/wolf3d/base/sprites/187.5551 differ diff --git a/wolf3d/base/sprites/188.5551 b/wolf3d/base/sprites/188.5551 new file mode 100644 index 0000000..7d8db1a Binary files /dev/null and b/wolf3d/base/sprites/188.5551 differ diff --git a/wolf3d/base/sprites/189.5551 b/wolf3d/base/sprites/189.5551 new file mode 100644 index 0000000..446ffe6 Binary files /dev/null and b/wolf3d/base/sprites/189.5551 differ diff --git a/wolf3d/base/sprites/190.5551 b/wolf3d/base/sprites/190.5551 new file mode 100644 index 0000000..e11aa3e Binary files /dev/null and b/wolf3d/base/sprites/190.5551 differ diff --git a/wolf3d/base/sprites/191.5551 b/wolf3d/base/sprites/191.5551 new file mode 100644 index 0000000..11d2010 Binary files /dev/null and b/wolf3d/base/sprites/191.5551 differ diff --git a/wolf3d/base/sprites/192.5551 b/wolf3d/base/sprites/192.5551 new file mode 100644 index 0000000..d5b2102 Binary files /dev/null and b/wolf3d/base/sprites/192.5551 differ diff --git a/wolf3d/base/sprites/193.5551 b/wolf3d/base/sprites/193.5551 new file mode 100644 index 0000000..7b1d709 Binary files /dev/null and b/wolf3d/base/sprites/193.5551 differ diff --git a/wolf3d/base/sprites/194.5551 b/wolf3d/base/sprites/194.5551 new file mode 100644 index 0000000..6c59c6a Binary files /dev/null and b/wolf3d/base/sprites/194.5551 differ diff --git a/wolf3d/base/sprites/195.5551 b/wolf3d/base/sprites/195.5551 new file mode 100644 index 0000000..83e172b Binary files /dev/null and b/wolf3d/base/sprites/195.5551 differ diff --git a/wolf3d/base/sprites/196.5551 b/wolf3d/base/sprites/196.5551 new file mode 100644 index 0000000..144ccf1 Binary files /dev/null and b/wolf3d/base/sprites/196.5551 differ diff --git a/wolf3d/base/sprites/197.5551 b/wolf3d/base/sprites/197.5551 new file mode 100644 index 0000000..1783a4a Binary files /dev/null and b/wolf3d/base/sprites/197.5551 differ diff --git a/wolf3d/base/sprites/198.5551 b/wolf3d/base/sprites/198.5551 new file mode 100644 index 0000000..1dd12fd Binary files /dev/null and b/wolf3d/base/sprites/198.5551 differ diff --git a/wolf3d/base/sprites/199.5551 b/wolf3d/base/sprites/199.5551 new file mode 100644 index 0000000..9a977d0 Binary files /dev/null and b/wolf3d/base/sprites/199.5551 differ diff --git a/wolf3d/base/sprites/200.5551 b/wolf3d/base/sprites/200.5551 new file mode 100644 index 0000000..4cf4da5 Binary files /dev/null and b/wolf3d/base/sprites/200.5551 differ diff --git a/wolf3d/base/sprites/201.5551 b/wolf3d/base/sprites/201.5551 new file mode 100644 index 0000000..f72022e Binary files /dev/null and b/wolf3d/base/sprites/201.5551 differ diff --git a/wolf3d/base/sprites/202.5551 b/wolf3d/base/sprites/202.5551 new file mode 100644 index 0000000..853c022 Binary files /dev/null and b/wolf3d/base/sprites/202.5551 differ diff --git a/wolf3d/base/sprites/203.5551 b/wolf3d/base/sprites/203.5551 new file mode 100644 index 0000000..118d187 Binary files /dev/null and b/wolf3d/base/sprites/203.5551 differ diff --git a/wolf3d/base/sprites/204.5551 b/wolf3d/base/sprites/204.5551 new file mode 100644 index 0000000..a84d63f Binary files /dev/null and b/wolf3d/base/sprites/204.5551 differ diff --git a/wolf3d/base/sprites/205.5551 b/wolf3d/base/sprites/205.5551 new file mode 100644 index 0000000..b6bcda4 Binary files /dev/null and b/wolf3d/base/sprites/205.5551 differ diff --git a/wolf3d/base/sprites/206.5551 b/wolf3d/base/sprites/206.5551 new file mode 100644 index 0000000..404979f Binary files /dev/null and b/wolf3d/base/sprites/206.5551 differ diff --git a/wolf3d/base/sprites/207.5551 b/wolf3d/base/sprites/207.5551 new file mode 100644 index 0000000..5f340f2 Binary files /dev/null and b/wolf3d/base/sprites/207.5551 differ diff --git a/wolf3d/base/sprites/208.5551 b/wolf3d/base/sprites/208.5551 new file mode 100644 index 0000000..b3341f1 Binary files /dev/null and b/wolf3d/base/sprites/208.5551 differ diff --git a/wolf3d/base/sprites/209.5551 b/wolf3d/base/sprites/209.5551 new file mode 100644 index 0000000..f7e8a31 Binary files /dev/null and b/wolf3d/base/sprites/209.5551 differ diff --git a/wolf3d/base/sprites/210.5551 b/wolf3d/base/sprites/210.5551 new file mode 100644 index 0000000..99477c3 Binary files /dev/null and b/wolf3d/base/sprites/210.5551 differ diff --git a/wolf3d/base/sprites/211.5551 b/wolf3d/base/sprites/211.5551 new file mode 100644 index 0000000..c7badbe Binary files /dev/null and b/wolf3d/base/sprites/211.5551 differ diff --git a/wolf3d/base/sprites/212.5551 b/wolf3d/base/sprites/212.5551 new file mode 100644 index 0000000..c3b16a0 Binary files /dev/null and b/wolf3d/base/sprites/212.5551 differ diff --git a/wolf3d/base/sprites/213.5551 b/wolf3d/base/sprites/213.5551 new file mode 100644 index 0000000..0a09c35 Binary files /dev/null and b/wolf3d/base/sprites/213.5551 differ diff --git a/wolf3d/base/sprites/214.5551 b/wolf3d/base/sprites/214.5551 new file mode 100644 index 0000000..c781c80 Binary files /dev/null and b/wolf3d/base/sprites/214.5551 differ diff --git a/wolf3d/base/sprites/215.5551 b/wolf3d/base/sprites/215.5551 new file mode 100644 index 0000000..2e70b34 Binary files /dev/null and b/wolf3d/base/sprites/215.5551 differ diff --git a/wolf3d/base/sprites/216.5551 b/wolf3d/base/sprites/216.5551 new file mode 100644 index 0000000..272b3b9 Binary files /dev/null and b/wolf3d/base/sprites/216.5551 differ diff --git a/wolf3d/base/sprites/217.5551 b/wolf3d/base/sprites/217.5551 new file mode 100644 index 0000000..ee3f9b8 Binary files /dev/null and b/wolf3d/base/sprites/217.5551 differ diff --git a/wolf3d/base/sprites/218.5551 b/wolf3d/base/sprites/218.5551 new file mode 100644 index 0000000..0f0c6f1 Binary files /dev/null and b/wolf3d/base/sprites/218.5551 differ diff --git a/wolf3d/base/sprites/219.5551 b/wolf3d/base/sprites/219.5551 new file mode 100644 index 0000000..fc4cc43 Binary files /dev/null and b/wolf3d/base/sprites/219.5551 differ diff --git a/wolf3d/base/sprites/220.5551 b/wolf3d/base/sprites/220.5551 new file mode 100644 index 0000000..62595fb Binary files /dev/null and b/wolf3d/base/sprites/220.5551 differ diff --git a/wolf3d/base/sprites/221.5551 b/wolf3d/base/sprites/221.5551 new file mode 100644 index 0000000..36717ea Binary files /dev/null and b/wolf3d/base/sprites/221.5551 differ diff --git a/wolf3d/base/sprites/222.5551 b/wolf3d/base/sprites/222.5551 new file mode 100644 index 0000000..60725e9 Binary files /dev/null and b/wolf3d/base/sprites/222.5551 differ diff --git a/wolf3d/base/sprites/223.5551 b/wolf3d/base/sprites/223.5551 new file mode 100644 index 0000000..f4f8024 Binary files /dev/null and b/wolf3d/base/sprites/223.5551 differ diff --git a/wolf3d/base/sprites/224.5551 b/wolf3d/base/sprites/224.5551 new file mode 100644 index 0000000..464b9ba Binary files /dev/null and b/wolf3d/base/sprites/224.5551 differ diff --git a/wolf3d/base/sprites/225.5551 b/wolf3d/base/sprites/225.5551 new file mode 100644 index 0000000..4ba4586 Binary files /dev/null and b/wolf3d/base/sprites/225.5551 differ diff --git a/wolf3d/base/sprites/226.5551 b/wolf3d/base/sprites/226.5551 new file mode 100644 index 0000000..dca1083 Binary files /dev/null and b/wolf3d/base/sprites/226.5551 differ diff --git a/wolf3d/base/sprites/227.5551 b/wolf3d/base/sprites/227.5551 new file mode 100644 index 0000000..cfa8c68 Binary files /dev/null and b/wolf3d/base/sprites/227.5551 differ diff --git a/wolf3d/base/sprites/228.5551 b/wolf3d/base/sprites/228.5551 new file mode 100644 index 0000000..84f7af6 Binary files /dev/null and b/wolf3d/base/sprites/228.5551 differ diff --git a/wolf3d/base/sprites/229.5551 b/wolf3d/base/sprites/229.5551 new file mode 100644 index 0000000..cf512f0 Binary files /dev/null and b/wolf3d/base/sprites/229.5551 differ diff --git a/wolf3d/base/sprites/230.5551 b/wolf3d/base/sprites/230.5551 new file mode 100644 index 0000000..40785e5 Binary files /dev/null and b/wolf3d/base/sprites/230.5551 differ diff --git a/wolf3d/base/sprites/231.5551 b/wolf3d/base/sprites/231.5551 new file mode 100644 index 0000000..1dcb526 Binary files /dev/null and b/wolf3d/base/sprites/231.5551 differ diff --git a/wolf3d/base/sprites/232.5551 b/wolf3d/base/sprites/232.5551 new file mode 100644 index 0000000..9299399 Binary files /dev/null and b/wolf3d/base/sprites/232.5551 differ diff --git a/wolf3d/base/sprites/233.5551 b/wolf3d/base/sprites/233.5551 new file mode 100644 index 0000000..db6a6a7 Binary files /dev/null and b/wolf3d/base/sprites/233.5551 differ diff --git a/wolf3d/base/sprites/234.5551 b/wolf3d/base/sprites/234.5551 new file mode 100644 index 0000000..16a6a77 Binary files /dev/null and b/wolf3d/base/sprites/234.5551 differ diff --git a/wolf3d/base/sprites/235.5551 b/wolf3d/base/sprites/235.5551 new file mode 100644 index 0000000..1dcb526 Binary files /dev/null and b/wolf3d/base/sprites/235.5551 differ diff --git a/wolf3d/base/sprites/236.5551 b/wolf3d/base/sprites/236.5551 new file mode 100644 index 0000000..b225287 Binary files /dev/null and b/wolf3d/base/sprites/236.5551 differ diff --git a/wolf3d/base/sprites/237.5551 b/wolf3d/base/sprites/237.5551 new file mode 100644 index 0000000..ffb383b Binary files /dev/null and b/wolf3d/base/sprites/237.5551 differ diff --git a/wolf3d/base/sprites/238.5551 b/wolf3d/base/sprites/238.5551 new file mode 100644 index 0000000..303ba64 Binary files /dev/null and b/wolf3d/base/sprites/238.5551 differ diff --git a/wolf3d/base/sprites/239.5551 b/wolf3d/base/sprites/239.5551 new file mode 100644 index 0000000..14d685a Binary files /dev/null and b/wolf3d/base/sprites/239.5551 differ diff --git a/wolf3d/base/sprites/240.5551 b/wolf3d/base/sprites/240.5551 new file mode 100644 index 0000000..303ba64 Binary files /dev/null and b/wolf3d/base/sprites/240.5551 differ diff --git a/wolf3d/base/sprites/241.5551 b/wolf3d/base/sprites/241.5551 new file mode 100644 index 0000000..ef927f0 Binary files /dev/null and b/wolf3d/base/sprites/241.5551 differ diff --git a/wolf3d/base/sprites/242.5551 b/wolf3d/base/sprites/242.5551 new file mode 100644 index 0000000..3382d92 Binary files /dev/null and b/wolf3d/base/sprites/242.5551 differ diff --git a/wolf3d/base/sprites/243.5551 b/wolf3d/base/sprites/243.5551 new file mode 100644 index 0000000..ebff3f9 Binary files /dev/null and b/wolf3d/base/sprites/243.5551 differ diff --git a/wolf3d/base/sprites/244.5551 b/wolf3d/base/sprites/244.5551 new file mode 100644 index 0000000..23d5995 Binary files /dev/null and b/wolf3d/base/sprites/244.5551 differ diff --git a/wolf3d/base/sprites/245.5551 b/wolf3d/base/sprites/245.5551 new file mode 100644 index 0000000..1bbb524 Binary files /dev/null and b/wolf3d/base/sprites/245.5551 differ diff --git a/wolf3d/base/sprites/246.5551 b/wolf3d/base/sprites/246.5551 new file mode 100644 index 0000000..6fc4491 Binary files /dev/null and b/wolf3d/base/sprites/246.5551 differ diff --git a/wolf3d/base/sprites/247.5551 b/wolf3d/base/sprites/247.5551 new file mode 100644 index 0000000..b35f4fe Binary files /dev/null and b/wolf3d/base/sprites/247.5551 differ diff --git a/wolf3d/base/sprites/248.5551 b/wolf3d/base/sprites/248.5551 new file mode 100644 index 0000000..3003cf5 Binary files /dev/null and b/wolf3d/base/sprites/248.5551 differ diff --git a/wolf3d/base/sprites/249.5551 b/wolf3d/base/sprites/249.5551 new file mode 100644 index 0000000..60c0735 Binary files /dev/null and b/wolf3d/base/sprites/249.5551 differ diff --git a/wolf3d/base/sprites/250.5551 b/wolf3d/base/sprites/250.5551 new file mode 100644 index 0000000..5584931 Binary files /dev/null and b/wolf3d/base/sprites/250.5551 differ diff --git a/wolf3d/base/sprites/251.5551 b/wolf3d/base/sprites/251.5551 new file mode 100644 index 0000000..f6fdf54 Binary files /dev/null and b/wolf3d/base/sprites/251.5551 differ diff --git a/wolf3d/base/sprites/252.5551 b/wolf3d/base/sprites/252.5551 new file mode 100644 index 0000000..51924e3 Binary files /dev/null and b/wolf3d/base/sprites/252.5551 differ diff --git a/wolf3d/base/sprites/253.5551 b/wolf3d/base/sprites/253.5551 new file mode 100644 index 0000000..2265402 Binary files /dev/null and b/wolf3d/base/sprites/253.5551 differ diff --git a/wolf3d/base/sprites/254.5551 b/wolf3d/base/sprites/254.5551 new file mode 100644 index 0000000..4b85d06 Binary files /dev/null and b/wolf3d/base/sprites/254.5551 differ diff --git a/wolf3d/base/sprites/255.5551 b/wolf3d/base/sprites/255.5551 new file mode 100644 index 0000000..2f554af Binary files /dev/null and b/wolf3d/base/sprites/255.5551 differ diff --git a/wolf3d/base/sprites/256.5551 b/wolf3d/base/sprites/256.5551 new file mode 100644 index 0000000..27c0e10 Binary files /dev/null and b/wolf3d/base/sprites/256.5551 differ diff --git a/wolf3d/base/sprites/257.5551 b/wolf3d/base/sprites/257.5551 new file mode 100644 index 0000000..dc5c355 Binary files /dev/null and b/wolf3d/base/sprites/257.5551 differ diff --git a/wolf3d/base/sprites/258.5551 b/wolf3d/base/sprites/258.5551 new file mode 100644 index 0000000..f7d25d4 Binary files /dev/null and b/wolf3d/base/sprites/258.5551 differ diff --git a/wolf3d/base/sprites/259.5551 b/wolf3d/base/sprites/259.5551 new file mode 100644 index 0000000..1a31a40 Binary files /dev/null and b/wolf3d/base/sprites/259.5551 differ diff --git a/wolf3d/base/sprites/260.5551 b/wolf3d/base/sprites/260.5551 new file mode 100644 index 0000000..997e825 Binary files /dev/null and b/wolf3d/base/sprites/260.5551 differ diff --git a/wolf3d/base/sprites/261.5551 b/wolf3d/base/sprites/261.5551 new file mode 100644 index 0000000..3c607f9 Binary files /dev/null and b/wolf3d/base/sprites/261.5551 differ diff --git a/wolf3d/base/sprites/262.5551 b/wolf3d/base/sprites/262.5551 new file mode 100644 index 0000000..a618908 Binary files /dev/null and b/wolf3d/base/sprites/262.5551 differ diff --git a/wolf3d/base/sprites/263.5551 b/wolf3d/base/sprites/263.5551 new file mode 100644 index 0000000..1126224 Binary files /dev/null and b/wolf3d/base/sprites/263.5551 differ diff --git a/wolf3d/base/sprites/264.5551 b/wolf3d/base/sprites/264.5551 new file mode 100644 index 0000000..6de71af Binary files /dev/null and b/wolf3d/base/sprites/264.5551 differ diff --git a/wolf3d/base/sprites/265.5551 b/wolf3d/base/sprites/265.5551 new file mode 100644 index 0000000..f6dbe20 Binary files /dev/null and b/wolf3d/base/sprites/265.5551 differ diff --git a/wolf3d/base/sprites/266.5551 b/wolf3d/base/sprites/266.5551 new file mode 100644 index 0000000..9761287 Binary files /dev/null and b/wolf3d/base/sprites/266.5551 differ diff --git a/wolf3d/base/sprites/267.5551 b/wolf3d/base/sprites/267.5551 new file mode 100644 index 0000000..79d0f25 Binary files /dev/null and b/wolf3d/base/sprites/267.5551 differ diff --git a/wolf3d/base/sprites/268.5551 b/wolf3d/base/sprites/268.5551 new file mode 100644 index 0000000..1d5b80d Binary files /dev/null and b/wolf3d/base/sprites/268.5551 differ diff --git a/wolf3d/base/sprites/269.5551 b/wolf3d/base/sprites/269.5551 new file mode 100644 index 0000000..74165ea Binary files /dev/null and b/wolf3d/base/sprites/269.5551 differ diff --git a/wolf3d/base/sprites/270.5551 b/wolf3d/base/sprites/270.5551 new file mode 100644 index 0000000..b7506db Binary files /dev/null and b/wolf3d/base/sprites/270.5551 differ diff --git a/wolf3d/base/sprites/271.5551 b/wolf3d/base/sprites/271.5551 new file mode 100644 index 0000000..6062741 Binary files /dev/null and b/wolf3d/base/sprites/271.5551 differ diff --git a/wolf3d/base/sprites/272.5551 b/wolf3d/base/sprites/272.5551 new file mode 100644 index 0000000..b530aec Binary files /dev/null and b/wolf3d/base/sprites/272.5551 differ diff --git a/wolf3d/base/sprites/273.5551 b/wolf3d/base/sprites/273.5551 new file mode 100644 index 0000000..4db2aeb Binary files /dev/null and b/wolf3d/base/sprites/273.5551 differ diff --git a/wolf3d/base/sprites/274.5551 b/wolf3d/base/sprites/274.5551 new file mode 100644 index 0000000..d6e935f Binary files /dev/null and b/wolf3d/base/sprites/274.5551 differ diff --git a/wolf3d/base/sprites/275.5551 b/wolf3d/base/sprites/275.5551 new file mode 100644 index 0000000..03a922e Binary files /dev/null and b/wolf3d/base/sprites/275.5551 differ diff --git a/wolf3d/base/sprites/276.5551 b/wolf3d/base/sprites/276.5551 new file mode 100644 index 0000000..a5d9260 Binary files /dev/null and b/wolf3d/base/sprites/276.5551 differ diff --git a/wolf3d/base/sprites/277.5551 b/wolf3d/base/sprites/277.5551 new file mode 100644 index 0000000..381662e Binary files /dev/null and b/wolf3d/base/sprites/277.5551 differ diff --git a/wolf3d/base/sprites/278.5551 b/wolf3d/base/sprites/278.5551 new file mode 100644 index 0000000..29d830d Binary files /dev/null and b/wolf3d/base/sprites/278.5551 differ diff --git a/wolf3d/base/sprites/279.5551 b/wolf3d/base/sprites/279.5551 new file mode 100644 index 0000000..b6afd9a Binary files /dev/null and b/wolf3d/base/sprites/279.5551 differ diff --git a/wolf3d/base/sprites/280.5551 b/wolf3d/base/sprites/280.5551 new file mode 100644 index 0000000..b891f3e Binary files /dev/null and b/wolf3d/base/sprites/280.5551 differ diff --git a/wolf3d/base/sprites/281.5551 b/wolf3d/base/sprites/281.5551 new file mode 100644 index 0000000..15ede16 Binary files /dev/null and b/wolf3d/base/sprites/281.5551 differ diff --git a/wolf3d/base/sprites/282.5551 b/wolf3d/base/sprites/282.5551 new file mode 100644 index 0000000..c121c68 Binary files /dev/null and b/wolf3d/base/sprites/282.5551 differ diff --git a/wolf3d/base/sprites/283.5551 b/wolf3d/base/sprites/283.5551 new file mode 100644 index 0000000..96d11b9 Binary files /dev/null and b/wolf3d/base/sprites/283.5551 differ diff --git a/wolf3d/base/sprites/284.5551 b/wolf3d/base/sprites/284.5551 new file mode 100644 index 0000000..d69680a Binary files /dev/null and b/wolf3d/base/sprites/284.5551 differ diff --git a/wolf3d/base/sprites/285.5551 b/wolf3d/base/sprites/285.5551 new file mode 100644 index 0000000..123c382 Binary files /dev/null and b/wolf3d/base/sprites/285.5551 differ diff --git a/wolf3d/base/sprites/286.5551 b/wolf3d/base/sprites/286.5551 new file mode 100644 index 0000000..cbf8063 Binary files /dev/null and b/wolf3d/base/sprites/286.5551 differ diff --git a/wolf3d/base/sprites/287.5551 b/wolf3d/base/sprites/287.5551 new file mode 100644 index 0000000..79ae359 Binary files /dev/null and b/wolf3d/base/sprites/287.5551 differ diff --git a/wolf3d/base/sprites/288.5551 b/wolf3d/base/sprites/288.5551 new file mode 100644 index 0000000..d5c6f17 Binary files /dev/null and b/wolf3d/base/sprites/288.5551 differ diff --git a/wolf3d/base/sprites/289.5551 b/wolf3d/base/sprites/289.5551 new file mode 100644 index 0000000..1dad4a5 Binary files /dev/null and b/wolf3d/base/sprites/289.5551 differ diff --git a/wolf3d/base/sprites/290.5551 b/wolf3d/base/sprites/290.5551 new file mode 100644 index 0000000..5aeaf94 Binary files /dev/null and b/wolf3d/base/sprites/290.5551 differ diff --git a/wolf3d/base/sprites/291.5551 b/wolf3d/base/sprites/291.5551 new file mode 100644 index 0000000..0453e0a Binary files /dev/null and b/wolf3d/base/sprites/291.5551 differ diff --git a/wolf3d/base/sprites/292.5551 b/wolf3d/base/sprites/292.5551 new file mode 100644 index 0000000..69dd45d Binary files /dev/null and b/wolf3d/base/sprites/292.5551 differ diff --git a/wolf3d/base/sprites/293.5551 b/wolf3d/base/sprites/293.5551 new file mode 100644 index 0000000..c774fda Binary files /dev/null and b/wolf3d/base/sprites/293.5551 differ diff --git a/wolf3d/base/sprites/294.5551 b/wolf3d/base/sprites/294.5551 new file mode 100644 index 0000000..c018c41 Binary files /dev/null and b/wolf3d/base/sprites/294.5551 differ diff --git a/wolf3d/base/sprites/295.5551 b/wolf3d/base/sprites/295.5551 new file mode 100644 index 0000000..71f422b Binary files /dev/null and b/wolf3d/base/sprites/295.5551 differ diff --git a/wolf3d/base/sprites/296.5551 b/wolf3d/base/sprites/296.5551 new file mode 100644 index 0000000..cd3bf27 Binary files /dev/null and b/wolf3d/base/sprites/296.5551 differ diff --git a/wolf3d/base/sprites/297.5551 b/wolf3d/base/sprites/297.5551 new file mode 100644 index 0000000..84d1481 Binary files /dev/null and b/wolf3d/base/sprites/297.5551 differ diff --git a/wolf3d/base/sprites/298.5551 b/wolf3d/base/sprites/298.5551 new file mode 100644 index 0000000..6ae5db5 Binary files /dev/null and b/wolf3d/base/sprites/298.5551 differ diff --git a/wolf3d/base/sprites/299.5551 b/wolf3d/base/sprites/299.5551 new file mode 100644 index 0000000..3f5827d Binary files /dev/null and b/wolf3d/base/sprites/299.5551 differ diff --git a/wolf3d/base/sprites/300.5551 b/wolf3d/base/sprites/300.5551 new file mode 100644 index 0000000..9cb7776 Binary files /dev/null and b/wolf3d/base/sprites/300.5551 differ diff --git a/wolf3d/base/sprites/301.5551 b/wolf3d/base/sprites/301.5551 new file mode 100644 index 0000000..24906aa Binary files /dev/null and b/wolf3d/base/sprites/301.5551 differ diff --git a/wolf3d/base/sprites/302.5551 b/wolf3d/base/sprites/302.5551 new file mode 100644 index 0000000..7bfa388 Binary files /dev/null and b/wolf3d/base/sprites/302.5551 differ diff --git a/wolf3d/base/sprites/303.5551 b/wolf3d/base/sprites/303.5551 new file mode 100644 index 0000000..1e4db23 Binary files /dev/null and b/wolf3d/base/sprites/303.5551 differ diff --git a/wolf3d/base/sprites/304.5551 b/wolf3d/base/sprites/304.5551 new file mode 100644 index 0000000..7462287 Binary files /dev/null and b/wolf3d/base/sprites/304.5551 differ diff --git a/wolf3d/base/sprites/305.5551 b/wolf3d/base/sprites/305.5551 new file mode 100644 index 0000000..1dabec0 Binary files /dev/null and b/wolf3d/base/sprites/305.5551 differ diff --git a/wolf3d/base/sprites/306.5551 b/wolf3d/base/sprites/306.5551 new file mode 100644 index 0000000..a752f6d Binary files /dev/null and b/wolf3d/base/sprites/306.5551 differ diff --git a/wolf3d/base/sprites/307.5551 b/wolf3d/base/sprites/307.5551 new file mode 100644 index 0000000..ca3a7ed Binary files /dev/null and b/wolf3d/base/sprites/307.5551 differ diff --git a/wolf3d/base/sprites/308.5551 b/wolf3d/base/sprites/308.5551 new file mode 100644 index 0000000..8a250b3 Binary files /dev/null and b/wolf3d/base/sprites/308.5551 differ diff --git a/wolf3d/base/sprites/309.5551 b/wolf3d/base/sprites/309.5551 new file mode 100644 index 0000000..2167866 Binary files /dev/null and b/wolf3d/base/sprites/309.5551 differ diff --git a/wolf3d/base/sprites/310.5551 b/wolf3d/base/sprites/310.5551 new file mode 100644 index 0000000..870b934 Binary files /dev/null and b/wolf3d/base/sprites/310.5551 differ diff --git a/wolf3d/base/sprites/311.5551 b/wolf3d/base/sprites/311.5551 new file mode 100644 index 0000000..ec8dcff Binary files /dev/null and b/wolf3d/base/sprites/311.5551 differ diff --git a/wolf3d/base/sprites/312.5551 b/wolf3d/base/sprites/312.5551 new file mode 100644 index 0000000..aea971b Binary files /dev/null and b/wolf3d/base/sprites/312.5551 differ diff --git a/wolf3d/base/sprites/313.5551 b/wolf3d/base/sprites/313.5551 new file mode 100644 index 0000000..af2c27b Binary files /dev/null and b/wolf3d/base/sprites/313.5551 differ diff --git a/wolf3d/base/sprites/314.5551 b/wolf3d/base/sprites/314.5551 new file mode 100644 index 0000000..e2276e6 Binary files /dev/null and b/wolf3d/base/sprites/314.5551 differ diff --git a/wolf3d/base/sprites/315.5551 b/wolf3d/base/sprites/315.5551 new file mode 100644 index 0000000..7834e0e Binary files /dev/null and b/wolf3d/base/sprites/315.5551 differ diff --git a/wolf3d/base/sprites/316.5551 b/wolf3d/base/sprites/316.5551 new file mode 100644 index 0000000..836cfdd Binary files /dev/null and b/wolf3d/base/sprites/316.5551 differ diff --git a/wolf3d/base/sprites/317.5551 b/wolf3d/base/sprites/317.5551 new file mode 100644 index 0000000..3078acd Binary files /dev/null and b/wolf3d/base/sprites/317.5551 differ diff --git a/wolf3d/base/sprites/318.5551 b/wolf3d/base/sprites/318.5551 new file mode 100644 index 0000000..f384fed Binary files /dev/null and b/wolf3d/base/sprites/318.5551 differ diff --git a/wolf3d/base/sprites/319.5551 b/wolf3d/base/sprites/319.5551 new file mode 100644 index 0000000..f68d3fc Binary files /dev/null and b/wolf3d/base/sprites/319.5551 differ diff --git a/wolf3d/base/sprites/320.5551 b/wolf3d/base/sprites/320.5551 new file mode 100644 index 0000000..2144b10 Binary files /dev/null and b/wolf3d/base/sprites/320.5551 differ diff --git a/wolf3d/base/sprites/321.5551 b/wolf3d/base/sprites/321.5551 new file mode 100644 index 0000000..fe465a9 Binary files /dev/null and b/wolf3d/base/sprites/321.5551 differ diff --git a/wolf3d/base/sprites/322.5551 b/wolf3d/base/sprites/322.5551 new file mode 100644 index 0000000..1e21474 Binary files /dev/null and b/wolf3d/base/sprites/322.5551 differ diff --git a/wolf3d/base/sprites/323.5551 b/wolf3d/base/sprites/323.5551 new file mode 100644 index 0000000..7b19047 Binary files /dev/null and b/wolf3d/base/sprites/323.5551 differ diff --git a/wolf3d/base/sprites/324.5551 b/wolf3d/base/sprites/324.5551 new file mode 100644 index 0000000..0f99965 Binary files /dev/null and b/wolf3d/base/sprites/324.5551 differ diff --git a/wolf3d/base/sprites/325.5551 b/wolf3d/base/sprites/325.5551 new file mode 100644 index 0000000..687ffab Binary files /dev/null and b/wolf3d/base/sprites/325.5551 differ diff --git a/wolf3d/base/sprites/326.5551 b/wolf3d/base/sprites/326.5551 new file mode 100644 index 0000000..741794d Binary files /dev/null and b/wolf3d/base/sprites/326.5551 differ diff --git a/wolf3d/base/sprites/327.5551 b/wolf3d/base/sprites/327.5551 new file mode 100644 index 0000000..7d6bf75 Binary files /dev/null and b/wolf3d/base/sprites/327.5551 differ diff --git a/wolf3d/base/sprites/328.5551 b/wolf3d/base/sprites/328.5551 new file mode 100644 index 0000000..741794d Binary files /dev/null and b/wolf3d/base/sprites/328.5551 differ diff --git a/wolf3d/base/sprites/329.5551 b/wolf3d/base/sprites/329.5551 new file mode 100644 index 0000000..a8501b9 Binary files /dev/null and b/wolf3d/base/sprites/329.5551 differ diff --git a/wolf3d/base/sprites/330.5551 b/wolf3d/base/sprites/330.5551 new file mode 100644 index 0000000..a003f44 Binary files /dev/null and b/wolf3d/base/sprites/330.5551 differ diff --git a/wolf3d/base/sprites/331.5551 b/wolf3d/base/sprites/331.5551 new file mode 100644 index 0000000..5ee58ea Binary files /dev/null and b/wolf3d/base/sprites/331.5551 differ diff --git a/wolf3d/base/sprites/332.5551 b/wolf3d/base/sprites/332.5551 new file mode 100644 index 0000000..96e2bff Binary files /dev/null and b/wolf3d/base/sprites/332.5551 differ diff --git a/wolf3d/base/sprites/333.5551 b/wolf3d/base/sprites/333.5551 new file mode 100644 index 0000000..d8793ae Binary files /dev/null and b/wolf3d/base/sprites/333.5551 differ diff --git a/wolf3d/base/sprites/334.5551 b/wolf3d/base/sprites/334.5551 new file mode 100644 index 0000000..1fde418 Binary files /dev/null and b/wolf3d/base/sprites/334.5551 differ diff --git a/wolf3d/base/sprites/335.5551 b/wolf3d/base/sprites/335.5551 new file mode 100644 index 0000000..8f92258 Binary files /dev/null and b/wolf3d/base/sprites/335.5551 differ diff --git a/wolf3d/base/sprites/336.5551 b/wolf3d/base/sprites/336.5551 new file mode 100644 index 0000000..0d1b821 Binary files /dev/null and b/wolf3d/base/sprites/336.5551 differ diff --git a/wolf3d/base/sprites/337.5551 b/wolf3d/base/sprites/337.5551 new file mode 100644 index 0000000..1a20a37 Binary files /dev/null and b/wolf3d/base/sprites/337.5551 differ diff --git a/wolf3d/base/sprites/338.5551 b/wolf3d/base/sprites/338.5551 new file mode 100644 index 0000000..124ce1b Binary files /dev/null and b/wolf3d/base/sprites/338.5551 differ diff --git a/wolf3d/base/sprites/339.5551 b/wolf3d/base/sprites/339.5551 new file mode 100644 index 0000000..0ccbe1d Binary files /dev/null and b/wolf3d/base/sprites/339.5551 differ diff --git a/wolf3d/base/sprites/340.5551 b/wolf3d/base/sprites/340.5551 new file mode 100644 index 0000000..e741550 Binary files /dev/null and b/wolf3d/base/sprites/340.5551 differ diff --git a/wolf3d/base/sprites/341.5551 b/wolf3d/base/sprites/341.5551 new file mode 100644 index 0000000..caf10de Binary files /dev/null and b/wolf3d/base/sprites/341.5551 differ diff --git a/wolf3d/base/sprites/342.5551 b/wolf3d/base/sprites/342.5551 new file mode 100644 index 0000000..11dfb66 Binary files /dev/null and b/wolf3d/base/sprites/342.5551 differ diff --git a/wolf3d/base/sprites/343.5551 b/wolf3d/base/sprites/343.5551 new file mode 100644 index 0000000..450f186 Binary files /dev/null and b/wolf3d/base/sprites/343.5551 differ diff --git a/wolf3d/base/sprites/344.5551 b/wolf3d/base/sprites/344.5551 new file mode 100644 index 0000000..633cdf4 Binary files /dev/null and b/wolf3d/base/sprites/344.5551 differ diff --git a/wolf3d/base/sprites/345.5551 b/wolf3d/base/sprites/345.5551 new file mode 100644 index 0000000..714270c Binary files /dev/null and b/wolf3d/base/sprites/345.5551 differ diff --git a/wolf3d/base/sprites/346.5551 b/wolf3d/base/sprites/346.5551 new file mode 100644 index 0000000..4a1ff92 Binary files /dev/null and b/wolf3d/base/sprites/346.5551 differ diff --git a/wolf3d/base/sprites/347.5551 b/wolf3d/base/sprites/347.5551 new file mode 100644 index 0000000..dfb4e2e Binary files /dev/null and b/wolf3d/base/sprites/347.5551 differ diff --git a/wolf3d/base/sprites/348.5551 b/wolf3d/base/sprites/348.5551 new file mode 100644 index 0000000..4532bac Binary files /dev/null and b/wolf3d/base/sprites/348.5551 differ diff --git a/wolf3d/base/sprites/349.5551 b/wolf3d/base/sprites/349.5551 new file mode 100644 index 0000000..6481089 Binary files /dev/null and b/wolf3d/base/sprites/349.5551 differ diff --git a/wolf3d/base/sprites/350.5551 b/wolf3d/base/sprites/350.5551 new file mode 100644 index 0000000..ee3a40b Binary files /dev/null and b/wolf3d/base/sprites/350.5551 differ diff --git a/wolf3d/base/sprites/351.5551 b/wolf3d/base/sprites/351.5551 new file mode 100644 index 0000000..1bb2bce Binary files /dev/null and b/wolf3d/base/sprites/351.5551 differ diff --git a/wolf3d/base/sprites/352.5551 b/wolf3d/base/sprites/352.5551 new file mode 100644 index 0000000..a61bed2 Binary files /dev/null and b/wolf3d/base/sprites/352.5551 differ diff --git a/wolf3d/base/sprites/353.5551 b/wolf3d/base/sprites/353.5551 new file mode 100644 index 0000000..99d5b7c Binary files /dev/null and b/wolf3d/base/sprites/353.5551 differ diff --git a/wolf3d/base/sprites/354.5551 b/wolf3d/base/sprites/354.5551 new file mode 100644 index 0000000..b0c2025 Binary files /dev/null and b/wolf3d/base/sprites/354.5551 differ diff --git a/wolf3d/base/sprites/355.5551 b/wolf3d/base/sprites/355.5551 new file mode 100644 index 0000000..e3604cf Binary files /dev/null and b/wolf3d/base/sprites/355.5551 differ diff --git a/wolf3d/base/sprites/356.5551 b/wolf3d/base/sprites/356.5551 new file mode 100644 index 0000000..22928a2 Binary files /dev/null and b/wolf3d/base/sprites/356.5551 differ diff --git a/wolf3d/base/sprites/357.5551 b/wolf3d/base/sprites/357.5551 new file mode 100644 index 0000000..e3dfc9a Binary files /dev/null and b/wolf3d/base/sprites/357.5551 differ diff --git a/wolf3d/base/sprites/358.5551 b/wolf3d/base/sprites/358.5551 new file mode 100644 index 0000000..02bcf97 Binary files /dev/null and b/wolf3d/base/sprites/358.5551 differ diff --git a/wolf3d/base/sprites/359.5551 b/wolf3d/base/sprites/359.5551 new file mode 100644 index 0000000..4e41c24 Binary files /dev/null and b/wolf3d/base/sprites/359.5551 differ diff --git a/wolf3d/base/sprites/360.5551 b/wolf3d/base/sprites/360.5551 new file mode 100644 index 0000000..f2a5744 Binary files /dev/null and b/wolf3d/base/sprites/360.5551 differ diff --git a/wolf3d/base/sprites/361.5551 b/wolf3d/base/sprites/361.5551 new file mode 100644 index 0000000..c20bbcd Binary files /dev/null and b/wolf3d/base/sprites/361.5551 differ diff --git a/wolf3d/base/sprites/362.5551 b/wolf3d/base/sprites/362.5551 new file mode 100644 index 0000000..1554c96 Binary files /dev/null and b/wolf3d/base/sprites/362.5551 differ diff --git a/wolf3d/base/sprites/363.5551 b/wolf3d/base/sprites/363.5551 new file mode 100644 index 0000000..9666db3 Binary files /dev/null and b/wolf3d/base/sprites/363.5551 differ diff --git a/wolf3d/base/sprites/364.5551 b/wolf3d/base/sprites/364.5551 new file mode 100644 index 0000000..802e36f Binary files /dev/null and b/wolf3d/base/sprites/364.5551 differ diff --git a/wolf3d/base/sprites/365.5551 b/wolf3d/base/sprites/365.5551 new file mode 100644 index 0000000..cf06d62 Binary files /dev/null and b/wolf3d/base/sprites/365.5551 differ diff --git a/wolf3d/base/sprites/366.5551 b/wolf3d/base/sprites/366.5551 new file mode 100644 index 0000000..e91fab6 Binary files /dev/null and b/wolf3d/base/sprites/366.5551 differ diff --git a/wolf3d/base/sprites/367.5551 b/wolf3d/base/sprites/367.5551 new file mode 100644 index 0000000..f289ac1 Binary files /dev/null and b/wolf3d/base/sprites/367.5551 differ diff --git a/wolf3d/base/sprites/368.5551 b/wolf3d/base/sprites/368.5551 new file mode 100644 index 0000000..4a006a3 Binary files /dev/null and b/wolf3d/base/sprites/368.5551 differ diff --git a/wolf3d/base/sprites/369.5551 b/wolf3d/base/sprites/369.5551 new file mode 100644 index 0000000..228fa68 Binary files /dev/null and b/wolf3d/base/sprites/369.5551 differ diff --git a/wolf3d/base/sprites/370.5551 b/wolf3d/base/sprites/370.5551 new file mode 100644 index 0000000..1f5918d Binary files /dev/null and b/wolf3d/base/sprites/370.5551 differ diff --git a/wolf3d/base/sprites/371.5551 b/wolf3d/base/sprites/371.5551 new file mode 100644 index 0000000..3cd07a6 Binary files /dev/null and b/wolf3d/base/sprites/371.5551 differ diff --git a/wolf3d/base/sprites/372.5551 b/wolf3d/base/sprites/372.5551 new file mode 100644 index 0000000..9974167 Binary files /dev/null and b/wolf3d/base/sprites/372.5551 differ diff --git a/wolf3d/base/sprites/373.5551 b/wolf3d/base/sprites/373.5551 new file mode 100644 index 0000000..db56de9 Binary files /dev/null and b/wolf3d/base/sprites/373.5551 differ diff --git a/wolf3d/base/sprites/374.5551 b/wolf3d/base/sprites/374.5551 new file mode 100644 index 0000000..660207f Binary files /dev/null and b/wolf3d/base/sprites/374.5551 differ diff --git a/wolf3d/base/sprites/375.5551 b/wolf3d/base/sprites/375.5551 new file mode 100644 index 0000000..0b6556a Binary files /dev/null and b/wolf3d/base/sprites/375.5551 differ diff --git a/wolf3d/base/sprites/376.5551 b/wolf3d/base/sprites/376.5551 new file mode 100644 index 0000000..305e94a Binary files /dev/null and b/wolf3d/base/sprites/376.5551 differ diff --git a/wolf3d/base/sprites/377.5551 b/wolf3d/base/sprites/377.5551 new file mode 100644 index 0000000..2db0c09 Binary files /dev/null and b/wolf3d/base/sprites/377.5551 differ diff --git a/wolf3d/base/sprites/378.5551 b/wolf3d/base/sprites/378.5551 new file mode 100644 index 0000000..2b61416 Binary files /dev/null and b/wolf3d/base/sprites/378.5551 differ diff --git a/wolf3d/base/sprites/379.5551 b/wolf3d/base/sprites/379.5551 new file mode 100644 index 0000000..28e204b Binary files /dev/null and b/wolf3d/base/sprites/379.5551 differ diff --git a/wolf3d/base/sprites/380.5551 b/wolf3d/base/sprites/380.5551 new file mode 100644 index 0000000..f18bacd Binary files /dev/null and b/wolf3d/base/sprites/380.5551 differ diff --git a/wolf3d/base/sprites/381.5551 b/wolf3d/base/sprites/381.5551 new file mode 100644 index 0000000..0fb5615 Binary files /dev/null and b/wolf3d/base/sprites/381.5551 differ diff --git a/wolf3d/base/sprites/382.5551 b/wolf3d/base/sprites/382.5551 new file mode 100644 index 0000000..3d0593c Binary files /dev/null and b/wolf3d/base/sprites/382.5551 differ diff --git a/wolf3d/base/sprites/383.5551 b/wolf3d/base/sprites/383.5551 new file mode 100644 index 0000000..93afe73 Binary files /dev/null and b/wolf3d/base/sprites/383.5551 differ diff --git a/wolf3d/base/sprites/384.5551 b/wolf3d/base/sprites/384.5551 new file mode 100644 index 0000000..74f3818 Binary files /dev/null and b/wolf3d/base/sprites/384.5551 differ diff --git a/wolf3d/base/sprites/385.5551 b/wolf3d/base/sprites/385.5551 new file mode 100644 index 0000000..74ede7e Binary files /dev/null and b/wolf3d/base/sprites/385.5551 differ diff --git a/wolf3d/base/sprites/386.5551 b/wolf3d/base/sprites/386.5551 new file mode 100644 index 0000000..c17c8b8 Binary files /dev/null and b/wolf3d/base/sprites/386.5551 differ diff --git a/wolf3d/base/sprites/387.5551 b/wolf3d/base/sprites/387.5551 new file mode 100644 index 0000000..197bf6a Binary files /dev/null and b/wolf3d/base/sprites/387.5551 differ diff --git a/wolf3d/base/sprites/388.5551 b/wolf3d/base/sprites/388.5551 new file mode 100644 index 0000000..5244ff6 Binary files /dev/null and b/wolf3d/base/sprites/388.5551 differ diff --git a/wolf3d/base/sprites/408.5551 b/wolf3d/base/sprites/408.5551 new file mode 100644 index 0000000..463c276 Binary files /dev/null and b/wolf3d/base/sprites/408.5551 differ diff --git a/wolf3d/base/sprites/409.5551 b/wolf3d/base/sprites/409.5551 new file mode 100644 index 0000000..6c7f13e Binary files /dev/null and b/wolf3d/base/sprites/409.5551 differ diff --git a/wolf3d/base/sprites/410.5551 b/wolf3d/base/sprites/410.5551 new file mode 100644 index 0000000..380b83d Binary files /dev/null and b/wolf3d/base/sprites/410.5551 differ diff --git a/wolf3d/base/sprites/411.5551 b/wolf3d/base/sprites/411.5551 new file mode 100644 index 0000000..3120879 Binary files /dev/null and b/wolf3d/base/sprites/411.5551 differ diff --git a/wolf3d/base/sprites/412.5551 b/wolf3d/base/sprites/412.5551 new file mode 100644 index 0000000..fad5b7b Binary files /dev/null and b/wolf3d/base/sprites/412.5551 differ diff --git a/wolf3d/base/sprites/413.5551 b/wolf3d/base/sprites/413.5551 new file mode 100644 index 0000000..caf2753 Binary files /dev/null and b/wolf3d/base/sprites/413.5551 differ diff --git a/wolf3d/base/sprites/414.5551 b/wolf3d/base/sprites/414.5551 new file mode 100644 index 0000000..828ffad Binary files /dev/null and b/wolf3d/base/sprites/414.5551 differ diff --git a/wolf3d/base/sprites/415.5551 b/wolf3d/base/sprites/415.5551 new file mode 100644 index 0000000..3dbbe8b Binary files /dev/null and b/wolf3d/base/sprites/415.5551 differ diff --git a/wolf3d/base/sprites/416.5551 b/wolf3d/base/sprites/416.5551 new file mode 100644 index 0000000..fe98f21 Binary files /dev/null and b/wolf3d/base/sprites/416.5551 differ diff --git a/wolf3d/base/sprites/417.5551 b/wolf3d/base/sprites/417.5551 new file mode 100644 index 0000000..701bdd0 Binary files /dev/null and b/wolf3d/base/sprites/417.5551 differ diff --git a/wolf3d/base/sprites/418.5551 b/wolf3d/base/sprites/418.5551 new file mode 100644 index 0000000..2b8cb57 Binary files /dev/null and b/wolf3d/base/sprites/418.5551 differ diff --git a/wolf3d/base/sprites/419.5551 b/wolf3d/base/sprites/419.5551 new file mode 100644 index 0000000..1558df1 Binary files /dev/null and b/wolf3d/base/sprites/419.5551 differ diff --git a/wolf3d/base/sprites/420.5551 b/wolf3d/base/sprites/420.5551 new file mode 100644 index 0000000..c23badb Binary files /dev/null and b/wolf3d/base/sprites/420.5551 differ diff --git a/wolf3d/base/sprites/421.5551 b/wolf3d/base/sprites/421.5551 new file mode 100644 index 0000000..f8ccaef Binary files /dev/null and b/wolf3d/base/sprites/421.5551 differ diff --git a/wolf3d/base/sprites/422.5551 b/wolf3d/base/sprites/422.5551 new file mode 100644 index 0000000..9cdd7f9 Binary files /dev/null and b/wolf3d/base/sprites/422.5551 differ diff --git a/wolf3d/base/sprites/423.5551 b/wolf3d/base/sprites/423.5551 new file mode 100644 index 0000000..37bafe8 Binary files /dev/null and b/wolf3d/base/sprites/423.5551 differ diff --git a/wolf3d/base/sprites/424.5551 b/wolf3d/base/sprites/424.5551 new file mode 100644 index 0000000..735616f Binary files /dev/null and b/wolf3d/base/sprites/424.5551 differ diff --git a/wolf3d/base/sprites/425.5551 b/wolf3d/base/sprites/425.5551 new file mode 100644 index 0000000..20b06dd Binary files /dev/null and b/wolf3d/base/sprites/425.5551 differ diff --git a/wolf3d/base/sprites/426.5551 b/wolf3d/base/sprites/426.5551 new file mode 100644 index 0000000..8000aba Binary files /dev/null and b/wolf3d/base/sprites/426.5551 differ diff --git a/wolf3d/base/sprites/427.5551 b/wolf3d/base/sprites/427.5551 new file mode 100644 index 0000000..a7ad818 Binary files /dev/null and b/wolf3d/base/sprites/427.5551 differ diff --git a/wolf3d/base/sprites/428.5551 b/wolf3d/base/sprites/428.5551 new file mode 100644 index 0000000..06f0691 Binary files /dev/null and b/wolf3d/base/sprites/428.5551 differ diff --git a/wolf3d/base/sprites/429.5551 b/wolf3d/base/sprites/429.5551 new file mode 100644 index 0000000..15b648a Binary files /dev/null and b/wolf3d/base/sprites/429.5551 differ diff --git a/wolf3d/base/sprites/430.5551 b/wolf3d/base/sprites/430.5551 new file mode 100644 index 0000000..4d212cd Binary files /dev/null and b/wolf3d/base/sprites/430.5551 differ diff --git a/wolf3d/base/sprites/431.5551 b/wolf3d/base/sprites/431.5551 new file mode 100644 index 0000000..fa7ab94 Binary files /dev/null and b/wolf3d/base/sprites/431.5551 differ diff --git a/wolf3d/base/sprites/432.5551 b/wolf3d/base/sprites/432.5551 new file mode 100644 index 0000000..12d193f Binary files /dev/null and b/wolf3d/base/sprites/432.5551 differ diff --git a/wolf3d/base/sprites/433.5551 b/wolf3d/base/sprites/433.5551 new file mode 100644 index 0000000..1c4999b Binary files /dev/null and b/wolf3d/base/sprites/433.5551 differ diff --git a/wolf3d/base/sprites/434.5551 b/wolf3d/base/sprites/434.5551 new file mode 100644 index 0000000..1764de1 Binary files /dev/null and b/wolf3d/base/sprites/434.5551 differ diff --git a/wolf3d/base/sprites/435.5551 b/wolf3d/base/sprites/435.5551 new file mode 100644 index 0000000..b4d1cd5 Binary files /dev/null and b/wolf3d/base/sprites/435.5551 differ diff --git a/wolf3d/base/sprites/436.5551 b/wolf3d/base/sprites/436.5551 new file mode 100644 index 0000000..167482a Binary files /dev/null and b/wolf3d/base/sprites/436.5551 differ diff --git a/wolf3d/base/sprites/437.5551 b/wolf3d/base/sprites/437.5551 new file mode 100644 index 0000000..56a149c Binary files /dev/null and b/wolf3d/base/sprites/437.5551 differ diff --git a/wolf3d/base/sprites/438.5551 b/wolf3d/base/sprites/438.5551 new file mode 100644 index 0000000..a5b5f8d Binary files /dev/null and b/wolf3d/base/sprites/438.5551 differ diff --git a/wolf3d/base/sprites/514.5551 b/wolf3d/base/sprites/514.5551 new file mode 100644 index 0000000..ebdd1e6 Binary files /dev/null and b/wolf3d/base/sprites/514.5551 differ diff --git a/wolf3d/base/sprites/515.5551 b/wolf3d/base/sprites/515.5551 new file mode 100644 index 0000000..4b821d2 Binary files /dev/null and b/wolf3d/base/sprites/515.5551 differ diff --git a/wolf3d/base/sprites/516.5551 b/wolf3d/base/sprites/516.5551 new file mode 100644 index 0000000..e25bc7f Binary files /dev/null and b/wolf3d/base/sprites/516.5551 differ diff --git a/wolf3d/base/sprites/517.5551 b/wolf3d/base/sprites/517.5551 new file mode 100644 index 0000000..8803a41 Binary files /dev/null and b/wolf3d/base/sprites/517.5551 differ diff --git a/wolf3d/base/sprites/518.5551 b/wolf3d/base/sprites/518.5551 new file mode 100644 index 0000000..e25bc7f Binary files /dev/null and b/wolf3d/base/sprites/518.5551 differ diff --git a/wolf3d/base/sprites/519.5551 b/wolf3d/base/sprites/519.5551 new file mode 100644 index 0000000..5a6a622 Binary files /dev/null and b/wolf3d/base/sprites/519.5551 differ diff --git a/wolf3d/base/sprites/520.5551 b/wolf3d/base/sprites/520.5551 new file mode 100644 index 0000000..d02a938 Binary files /dev/null and b/wolf3d/base/sprites/520.5551 differ diff --git a/wolf3d/base/sprites/521.5551 b/wolf3d/base/sprites/521.5551 new file mode 100644 index 0000000..e98265e Binary files /dev/null and b/wolf3d/base/sprites/521.5551 differ diff --git a/wolf3d/base/sprites/522.5551 b/wolf3d/base/sprites/522.5551 new file mode 100644 index 0000000..6752b7c Binary files /dev/null and b/wolf3d/base/sprites/522.5551 differ diff --git a/wolf3d/base/sprites/523.5551 b/wolf3d/base/sprites/523.5551 new file mode 100644 index 0000000..568aa78 Binary files /dev/null and b/wolf3d/base/sprites/523.5551 differ diff --git a/wolf3d/base/sprites/524.5551 b/wolf3d/base/sprites/524.5551 new file mode 100644 index 0000000..b6cbe6e Binary files /dev/null and b/wolf3d/base/sprites/524.5551 differ diff --git a/wolf3d/base/sprites/525.5551 b/wolf3d/base/sprites/525.5551 new file mode 100644 index 0000000..ab5efd5 Binary files /dev/null and b/wolf3d/base/sprites/525.5551 differ diff --git a/wolf3d/base/sprites/526.5551 b/wolf3d/base/sprites/526.5551 new file mode 100644 index 0000000..6571777 Binary files /dev/null and b/wolf3d/base/sprites/526.5551 differ diff --git a/wolf3d/base/sprites/527.5551 b/wolf3d/base/sprites/527.5551 new file mode 100644 index 0000000..7941a37 Binary files /dev/null and b/wolf3d/base/sprites/527.5551 differ diff --git a/wolf3d/base/sprites/528.5551 b/wolf3d/base/sprites/528.5551 new file mode 100644 index 0000000..ab5efd5 Binary files /dev/null and b/wolf3d/base/sprites/528.5551 differ diff --git a/wolf3d/base/sprites/529.5551 b/wolf3d/base/sprites/529.5551 new file mode 100644 index 0000000..02baa20 Binary files /dev/null and b/wolf3d/base/sprites/529.5551 differ diff --git a/wolf3d/base/sprites/530.5551 b/wolf3d/base/sprites/530.5551 new file mode 100644 index 0000000..3aa485c Binary files /dev/null and b/wolf3d/base/sprites/530.5551 differ diff --git a/wolf3d/base/sprites/531.5551 b/wolf3d/base/sprites/531.5551 new file mode 100644 index 0000000..495ceb2 Binary files /dev/null and b/wolf3d/base/sprites/531.5551 differ diff --git a/wolf3d/base/sprites/532.5551 b/wolf3d/base/sprites/532.5551 new file mode 100644 index 0000000..f7de98e Binary files /dev/null and b/wolf3d/base/sprites/532.5551 differ diff --git a/wolf3d/base/sprites/533.5551 b/wolf3d/base/sprites/533.5551 new file mode 100644 index 0000000..1b95b12 Binary files /dev/null and b/wolf3d/base/sprites/533.5551 differ diff --git a/wolf3d/base/walls/000.5551 b/wolf3d/base/walls/000.5551 new file mode 100644 index 0000000..62b96d4 Binary files /dev/null and b/wolf3d/base/walls/000.5551 differ diff --git a/wolf3d/base/walls/001.5551 b/wolf3d/base/walls/001.5551 new file mode 100644 index 0000000..0f536e9 Binary files /dev/null and b/wolf3d/base/walls/001.5551 differ diff --git a/wolf3d/base/walls/002.5551 b/wolf3d/base/walls/002.5551 new file mode 100644 index 0000000..41e5972 Binary files /dev/null and b/wolf3d/base/walls/002.5551 differ diff --git a/wolf3d/base/walls/003.5551 b/wolf3d/base/walls/003.5551 new file mode 100644 index 0000000..b2f4cb7 Binary files /dev/null and b/wolf3d/base/walls/003.5551 differ diff --git a/wolf3d/base/walls/004.5551 b/wolf3d/base/walls/004.5551 new file mode 100644 index 0000000..6d9d727 Binary files /dev/null and b/wolf3d/base/walls/004.5551 differ diff --git a/wolf3d/base/walls/005.5551 b/wolf3d/base/walls/005.5551 new file mode 100644 index 0000000..af8cb27 Binary files /dev/null and b/wolf3d/base/walls/005.5551 differ diff --git a/wolf3d/base/walls/006.5551 b/wolf3d/base/walls/006.5551 new file mode 100644 index 0000000..435b101 Binary files /dev/null and b/wolf3d/base/walls/006.5551 differ diff --git a/wolf3d/base/walls/007.5551 b/wolf3d/base/walls/007.5551 new file mode 100644 index 0000000..3ca194c Binary files /dev/null and b/wolf3d/base/walls/007.5551 differ diff --git a/wolf3d/base/walls/008.5551 b/wolf3d/base/walls/008.5551 new file mode 100644 index 0000000..1442da0 Binary files /dev/null and b/wolf3d/base/walls/008.5551 differ diff --git a/wolf3d/base/walls/009.5551 b/wolf3d/base/walls/009.5551 new file mode 100644 index 0000000..3133bb4 Binary files /dev/null and b/wolf3d/base/walls/009.5551 differ diff --git a/wolf3d/base/walls/010.5551 b/wolf3d/base/walls/010.5551 new file mode 100644 index 0000000..50bffc0 Binary files /dev/null and b/wolf3d/base/walls/010.5551 differ diff --git a/wolf3d/base/walls/011.5551 b/wolf3d/base/walls/011.5551 new file mode 100644 index 0000000..a97a929 Binary files /dev/null and b/wolf3d/base/walls/011.5551 differ diff --git a/wolf3d/base/walls/012.5551 b/wolf3d/base/walls/012.5551 new file mode 100644 index 0000000..26544ed Binary files /dev/null and b/wolf3d/base/walls/012.5551 differ diff --git a/wolf3d/base/walls/013.5551 b/wolf3d/base/walls/013.5551 new file mode 100644 index 0000000..a002977 Binary files /dev/null and b/wolf3d/base/walls/013.5551 differ diff --git a/wolf3d/base/walls/014.5551 b/wolf3d/base/walls/014.5551 new file mode 100644 index 0000000..038af7d Binary files /dev/null and b/wolf3d/base/walls/014.5551 differ diff --git a/wolf3d/base/walls/015.5551 b/wolf3d/base/walls/015.5551 new file mode 100644 index 0000000..cf20efb Binary files /dev/null and b/wolf3d/base/walls/015.5551 differ diff --git a/wolf3d/base/walls/016.5551 b/wolf3d/base/walls/016.5551 new file mode 100644 index 0000000..f56c40d Binary files /dev/null and b/wolf3d/base/walls/016.5551 differ diff --git a/wolf3d/base/walls/017.5551 b/wolf3d/base/walls/017.5551 new file mode 100644 index 0000000..1fa1a2a Binary files /dev/null and b/wolf3d/base/walls/017.5551 differ diff --git a/wolf3d/base/walls/018.5551 b/wolf3d/base/walls/018.5551 new file mode 100644 index 0000000..5bde9d8 Binary files /dev/null and b/wolf3d/base/walls/018.5551 differ diff --git a/wolf3d/base/walls/019.5551 b/wolf3d/base/walls/019.5551 new file mode 100644 index 0000000..43e0991 Binary files /dev/null and b/wolf3d/base/walls/019.5551 differ diff --git a/wolf3d/base/walls/020.5551 b/wolf3d/base/walls/020.5551 new file mode 100644 index 0000000..170a3ac Binary files /dev/null and b/wolf3d/base/walls/020.5551 differ diff --git a/wolf3d/base/walls/021.5551 b/wolf3d/base/walls/021.5551 new file mode 100644 index 0000000..8497e1d Binary files /dev/null and b/wolf3d/base/walls/021.5551 differ diff --git a/wolf3d/base/walls/022.5551 b/wolf3d/base/walls/022.5551 new file mode 100644 index 0000000..4c79225 Binary files /dev/null and b/wolf3d/base/walls/022.5551 differ diff --git a/wolf3d/base/walls/023.5551 b/wolf3d/base/walls/023.5551 new file mode 100644 index 0000000..861e44c Binary files /dev/null and b/wolf3d/base/walls/023.5551 differ diff --git a/wolf3d/base/walls/024.5551 b/wolf3d/base/walls/024.5551 new file mode 100644 index 0000000..ce3bc78 Binary files /dev/null and b/wolf3d/base/walls/024.5551 differ diff --git a/wolf3d/base/walls/025.5551 b/wolf3d/base/walls/025.5551 new file mode 100644 index 0000000..2f6325c Binary files /dev/null and b/wolf3d/base/walls/025.5551 differ diff --git a/wolf3d/base/walls/026.5551 b/wolf3d/base/walls/026.5551 new file mode 100644 index 0000000..bd2e4d2 Binary files /dev/null and b/wolf3d/base/walls/026.5551 differ diff --git a/wolf3d/base/walls/027.5551 b/wolf3d/base/walls/027.5551 new file mode 100644 index 0000000..3675d5a Binary files /dev/null and b/wolf3d/base/walls/027.5551 differ diff --git a/wolf3d/base/walls/028.5551 b/wolf3d/base/walls/028.5551 new file mode 100644 index 0000000..8964b65 Binary files /dev/null and b/wolf3d/base/walls/028.5551 differ diff --git a/wolf3d/base/walls/029.5551 b/wolf3d/base/walls/029.5551 new file mode 100644 index 0000000..0e38fd4 Binary files /dev/null and b/wolf3d/base/walls/029.5551 differ diff --git a/wolf3d/base/walls/030.5551 b/wolf3d/base/walls/030.5551 new file mode 100644 index 0000000..da313f3 Binary files /dev/null and b/wolf3d/base/walls/030.5551 differ diff --git a/wolf3d/base/walls/031.5551 b/wolf3d/base/walls/031.5551 new file mode 100644 index 0000000..8193564 Binary files /dev/null and b/wolf3d/base/walls/031.5551 differ diff --git a/wolf3d/base/walls/032.5551 b/wolf3d/base/walls/032.5551 new file mode 100644 index 0000000..4424733 Binary files /dev/null and b/wolf3d/base/walls/032.5551 differ diff --git a/wolf3d/base/walls/033.5551 b/wolf3d/base/walls/033.5551 new file mode 100644 index 0000000..378b3b6 Binary files /dev/null and b/wolf3d/base/walls/033.5551 differ diff --git a/wolf3d/base/walls/034.5551 b/wolf3d/base/walls/034.5551 new file mode 100644 index 0000000..4f1f51e Binary files /dev/null and b/wolf3d/base/walls/034.5551 differ diff --git a/wolf3d/base/walls/035.5551 b/wolf3d/base/walls/035.5551 new file mode 100644 index 0000000..a2ecb31 Binary files /dev/null and b/wolf3d/base/walls/035.5551 differ diff --git a/wolf3d/base/walls/036.5551 b/wolf3d/base/walls/036.5551 new file mode 100644 index 0000000..6d9aed4 Binary files /dev/null and b/wolf3d/base/walls/036.5551 differ diff --git a/wolf3d/base/walls/037.5551 b/wolf3d/base/walls/037.5551 new file mode 100644 index 0000000..ec5335f Binary files /dev/null and b/wolf3d/base/walls/037.5551 differ diff --git a/wolf3d/base/walls/038.5551 b/wolf3d/base/walls/038.5551 new file mode 100644 index 0000000..b88bae4 Binary files /dev/null and b/wolf3d/base/walls/038.5551 differ diff --git a/wolf3d/base/walls/039.5551 b/wolf3d/base/walls/039.5551 new file mode 100644 index 0000000..11ec2dc Binary files /dev/null and b/wolf3d/base/walls/039.5551 differ diff --git a/wolf3d/base/walls/040.5551 b/wolf3d/base/walls/040.5551 new file mode 100644 index 0000000..aa9be49 Binary files /dev/null and b/wolf3d/base/walls/040.5551 differ diff --git a/wolf3d/base/walls/041.5551 b/wolf3d/base/walls/041.5551 new file mode 100644 index 0000000..57fc25d Binary files /dev/null and b/wolf3d/base/walls/041.5551 differ diff --git a/wolf3d/base/walls/042.5551 b/wolf3d/base/walls/042.5551 new file mode 100644 index 0000000..cca4154 Binary files /dev/null and b/wolf3d/base/walls/042.5551 differ diff --git a/wolf3d/base/walls/043.5551 b/wolf3d/base/walls/043.5551 new file mode 100644 index 0000000..e89953e Binary files /dev/null and b/wolf3d/base/walls/043.5551 differ diff --git a/wolf3d/base/walls/044.5551 b/wolf3d/base/walls/044.5551 new file mode 100644 index 0000000..60cf937 Binary files /dev/null and b/wolf3d/base/walls/044.5551 differ diff --git a/wolf3d/base/walls/045.5551 b/wolf3d/base/walls/045.5551 new file mode 100644 index 0000000..a7e6203 Binary files /dev/null and b/wolf3d/base/walls/045.5551 differ diff --git a/wolf3d/base/walls/046.5551 b/wolf3d/base/walls/046.5551 new file mode 100644 index 0000000..540301b Binary files /dev/null and b/wolf3d/base/walls/046.5551 differ diff --git a/wolf3d/base/walls/047.5551 b/wolf3d/base/walls/047.5551 new file mode 100644 index 0000000..24374db Binary files /dev/null and b/wolf3d/base/walls/047.5551 differ diff --git a/wolf3d/base/walls/048.5551 b/wolf3d/base/walls/048.5551 new file mode 100644 index 0000000..03103c9 Binary files /dev/null and b/wolf3d/base/walls/048.5551 differ diff --git a/wolf3d/base/walls/049.5551 b/wolf3d/base/walls/049.5551 new file mode 100644 index 0000000..f1c063e Binary files /dev/null and b/wolf3d/base/walls/049.5551 differ diff --git a/wolf3d/base/walls/050.5551 b/wolf3d/base/walls/050.5551 new file mode 100644 index 0000000..4f2fb05 Binary files /dev/null and b/wolf3d/base/walls/050.5551 differ diff --git a/wolf3d/base/walls/051.5551 b/wolf3d/base/walls/051.5551 new file mode 100644 index 0000000..0df6565 Binary files /dev/null and b/wolf3d/base/walls/051.5551 differ diff --git a/wolf3d/base/walls/052.5551 b/wolf3d/base/walls/052.5551 new file mode 100644 index 0000000..fde40e7 Binary files /dev/null and b/wolf3d/base/walls/052.5551 differ diff --git a/wolf3d/base/walls/053.5551 b/wolf3d/base/walls/053.5551 new file mode 100644 index 0000000..2379dd7 Binary files /dev/null and b/wolf3d/base/walls/053.5551 differ diff --git a/wolf3d/base/walls/054.5551 b/wolf3d/base/walls/054.5551 new file mode 100644 index 0000000..cb82f09 Binary files /dev/null and b/wolf3d/base/walls/054.5551 differ diff --git a/wolf3d/base/walls/055.5551 b/wolf3d/base/walls/055.5551 new file mode 100644 index 0000000..23ac803 Binary files /dev/null and b/wolf3d/base/walls/055.5551 differ diff --git a/wolf3d/base/walls/056.5551 b/wolf3d/base/walls/056.5551 new file mode 100644 index 0000000..972917b Binary files /dev/null and b/wolf3d/base/walls/056.5551 differ diff --git a/wolf3d/base/walls/057.5551 b/wolf3d/base/walls/057.5551 new file mode 100644 index 0000000..58a0cc7 Binary files /dev/null and b/wolf3d/base/walls/057.5551 differ diff --git a/wolf3d/base/walls/058.5551 b/wolf3d/base/walls/058.5551 new file mode 100644 index 0000000..4ba7c7c Binary files /dev/null and b/wolf3d/base/walls/058.5551 differ diff --git a/wolf3d/base/walls/059.5551 b/wolf3d/base/walls/059.5551 new file mode 100644 index 0000000..3a56c55 Binary files /dev/null and b/wolf3d/base/walls/059.5551 differ diff --git a/wolf3d/base/walls/060.5551 b/wolf3d/base/walls/060.5551 new file mode 100644 index 0000000..a00b617 Binary files /dev/null and b/wolf3d/base/walls/060.5551 differ diff --git a/wolf3d/base/walls/061.5551 b/wolf3d/base/walls/061.5551 new file mode 100644 index 0000000..3998bdc Binary files /dev/null and b/wolf3d/base/walls/061.5551 differ diff --git a/wolf3d/base/walls/062.5551 b/wolf3d/base/walls/062.5551 new file mode 100644 index 0000000..96567b2 Binary files /dev/null and b/wolf3d/base/walls/062.5551 differ diff --git a/wolf3d/base/walls/063.5551 b/wolf3d/base/walls/063.5551 new file mode 100644 index 0000000..5359050 Binary files /dev/null and b/wolf3d/base/walls/063.5551 differ diff --git a/wolf3d/base/walls/064.5551 b/wolf3d/base/walls/064.5551 new file mode 100644 index 0000000..4e26f6b Binary files /dev/null and b/wolf3d/base/walls/064.5551 differ diff --git a/wolf3d/base/walls/065.5551 b/wolf3d/base/walls/065.5551 new file mode 100644 index 0000000..b888da7 Binary files /dev/null and b/wolf3d/base/walls/065.5551 differ diff --git a/wolf3d/base/walls/066.5551 b/wolf3d/base/walls/066.5551 new file mode 100644 index 0000000..be710d1 Binary files /dev/null and b/wolf3d/base/walls/066.5551 differ diff --git a/wolf3d/base/walls/067.5551 b/wolf3d/base/walls/067.5551 new file mode 100644 index 0000000..7578118 Binary files /dev/null and b/wolf3d/base/walls/067.5551 differ diff --git a/wolf3d/base/walls/068.5551 b/wolf3d/base/walls/068.5551 new file mode 100644 index 0000000..21dda5a Binary files /dev/null and b/wolf3d/base/walls/068.5551 differ diff --git a/wolf3d/base/walls/069.5551 b/wolf3d/base/walls/069.5551 new file mode 100644 index 0000000..215aeeb Binary files /dev/null and b/wolf3d/base/walls/069.5551 differ diff --git a/wolf3d/base/walls/070.5551 b/wolf3d/base/walls/070.5551 new file mode 100644 index 0000000..56a6759 Binary files /dev/null and b/wolf3d/base/walls/070.5551 differ diff --git a/wolf3d/base/walls/071.5551 b/wolf3d/base/walls/071.5551 new file mode 100644 index 0000000..685e2c0 Binary files /dev/null and b/wolf3d/base/walls/071.5551 differ diff --git a/wolf3d/base/walls/072.5551 b/wolf3d/base/walls/072.5551 new file mode 100644 index 0000000..4c61738 Binary files /dev/null and b/wolf3d/base/walls/072.5551 differ diff --git a/wolf3d/base/walls/073.5551 b/wolf3d/base/walls/073.5551 new file mode 100644 index 0000000..bc0fe1c Binary files /dev/null and b/wolf3d/base/walls/073.5551 differ diff --git a/wolf3d/base/walls/074.5551 b/wolf3d/base/walls/074.5551 new file mode 100644 index 0000000..5998878 Binary files /dev/null and b/wolf3d/base/walls/074.5551 differ diff --git a/wolf3d/base/walls/075.5551 b/wolf3d/base/walls/075.5551 new file mode 100644 index 0000000..ccb32d5 Binary files /dev/null and b/wolf3d/base/walls/075.5551 differ diff --git a/wolf3d/base/walls/076.5551 b/wolf3d/base/walls/076.5551 new file mode 100644 index 0000000..a95f330 Binary files /dev/null and b/wolf3d/base/walls/076.5551 differ diff --git a/wolf3d/base/walls/077.5551 b/wolf3d/base/walls/077.5551 new file mode 100644 index 0000000..7d48e77 Binary files /dev/null and b/wolf3d/base/walls/077.5551 differ diff --git a/wolf3d/base/walls/078.5551 b/wolf3d/base/walls/078.5551 new file mode 100644 index 0000000..69a7498 Binary files /dev/null and b/wolf3d/base/walls/078.5551 differ diff --git a/wolf3d/base/walls/079.5551 b/wolf3d/base/walls/079.5551 new file mode 100644 index 0000000..8280bdf Binary files /dev/null and b/wolf3d/base/walls/079.5551 differ diff --git a/wolf3d/base/walls/080.5551 b/wolf3d/base/walls/080.5551 new file mode 100644 index 0000000..b1b244b Binary files /dev/null and b/wolf3d/base/walls/080.5551 differ diff --git a/wolf3d/base/walls/081.5551 b/wolf3d/base/walls/081.5551 new file mode 100644 index 0000000..b2c01d2 Binary files /dev/null and b/wolf3d/base/walls/081.5551 differ diff --git a/wolf3d/base/walls/082.5551 b/wolf3d/base/walls/082.5551 new file mode 100644 index 0000000..53ee845 Binary files /dev/null and b/wolf3d/base/walls/082.5551 differ diff --git a/wolf3d/base/walls/083.5551 b/wolf3d/base/walls/083.5551 new file mode 100644 index 0000000..1cbba22 Binary files /dev/null and b/wolf3d/base/walls/083.5551 differ diff --git a/wolf3d/base/walls/084.5551 b/wolf3d/base/walls/084.5551 new file mode 100644 index 0000000..1075f70 Binary files /dev/null and b/wolf3d/base/walls/084.5551 differ diff --git a/wolf3d/base/walls/085.5551 b/wolf3d/base/walls/085.5551 new file mode 100644 index 0000000..b4a27bc Binary files /dev/null and b/wolf3d/base/walls/085.5551 differ diff --git a/wolf3d/base/walls/086.5551 b/wolf3d/base/walls/086.5551 new file mode 100644 index 0000000..50e7dfa Binary files /dev/null and b/wolf3d/base/walls/086.5551 differ diff --git a/wolf3d/base/walls/087.5551 b/wolf3d/base/walls/087.5551 new file mode 100644 index 0000000..7c40f63 Binary files /dev/null and b/wolf3d/base/walls/087.5551 differ diff --git a/wolf3d/base/walls/088.5551 b/wolf3d/base/walls/088.5551 new file mode 100644 index 0000000..e5c01ba Binary files /dev/null and b/wolf3d/base/walls/088.5551 differ diff --git a/wolf3d/base/walls/089.5551 b/wolf3d/base/walls/089.5551 new file mode 100644 index 0000000..bb540e0 Binary files /dev/null and b/wolf3d/base/walls/089.5551 differ diff --git a/wolf3d/base/walls/090.5551 b/wolf3d/base/walls/090.5551 new file mode 100644 index 0000000..17394b1 Binary files /dev/null and b/wolf3d/base/walls/090.5551 differ diff --git a/wolf3d/base/walls/091.5551 b/wolf3d/base/walls/091.5551 new file mode 100644 index 0000000..b3d0199 Binary files /dev/null and b/wolf3d/base/walls/091.5551 differ diff --git a/wolf3d/base/walls/092.5551 b/wolf3d/base/walls/092.5551 new file mode 100644 index 0000000..da9aa14 Binary files /dev/null and b/wolf3d/base/walls/092.5551 differ diff --git a/wolf3d/base/walls/093.5551 b/wolf3d/base/walls/093.5551 new file mode 100644 index 0000000..f1400a3 Binary files /dev/null and b/wolf3d/base/walls/093.5551 differ diff --git a/wolf3d/base/walls/094.5551 b/wolf3d/base/walls/094.5551 new file mode 100644 index 0000000..83e067d Binary files /dev/null and b/wolf3d/base/walls/094.5551 differ diff --git a/wolf3d/base/walls/095.5551 b/wolf3d/base/walls/095.5551 new file mode 100644 index 0000000..ed4b73d Binary files /dev/null and b/wolf3d/base/walls/095.5551 differ diff --git a/wolf3d/base/walls/096.5551 b/wolf3d/base/walls/096.5551 new file mode 100644 index 0000000..073eb1f Binary files /dev/null and b/wolf3d/base/walls/096.5551 differ diff --git a/wolf3d/base/walls/097.5551 b/wolf3d/base/walls/097.5551 new file mode 100644 index 0000000..2ebf2d6 Binary files /dev/null and b/wolf3d/base/walls/097.5551 differ diff --git a/wolf3d/base/walls/126.5551 b/wolf3d/base/walls/126.5551 new file mode 100644 index 0000000..dcac03e Binary files /dev/null and b/wolf3d/base/walls/126.5551 differ diff --git a/wolf3d/base/walls/127.5551 b/wolf3d/base/walls/127.5551 new file mode 100644 index 0000000..94530b6 Binary files /dev/null and b/wolf3d/base/walls/127.5551 differ diff --git a/wolf3d/base/walls/128.5551 b/wolf3d/base/walls/128.5551 new file mode 100644 index 0000000..97b56a5 Binary files /dev/null and b/wolf3d/base/walls/128.5551 differ diff --git a/wolf3d/base/walls/129.5551 b/wolf3d/base/walls/129.5551 new file mode 100644 index 0000000..b7982c9 Binary files /dev/null and b/wolf3d/base/walls/129.5551 differ diff --git a/wolf3d/base/walls/130.5551 b/wolf3d/base/walls/130.5551 new file mode 100644 index 0000000..a8ec8cf Binary files /dev/null and b/wolf3d/base/walls/130.5551 differ diff --git a/wolf3d/base/walls/131.5551 b/wolf3d/base/walls/131.5551 new file mode 100644 index 0000000..5ce9325 Binary files /dev/null and b/wolf3d/base/walls/131.5551 differ diff --git a/wolf3d/base/walls/132.5551 b/wolf3d/base/walls/132.5551 new file mode 100644 index 0000000..8259cad Binary files /dev/null and b/wolf3d/base/walls/132.5551 differ diff --git a/wolf3d/base/walls/133.5551 b/wolf3d/base/walls/133.5551 new file mode 100644 index 0000000..ae74781 Binary files /dev/null and b/wolf3d/base/walls/133.5551 differ diff --git a/wolf3d/gpl.txt b/wolf3d/gpl.txt new file mode 100644 index 0000000..b3f64f0 --- /dev/null +++ b/wolf3d/gpl.txt @@ -0,0 +1,345 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. \ No newline at end of file diff --git a/wolf3d/newCode/Tremor/CHANGELOG b/wolf3d/newCode/Tremor/CHANGELOG new file mode 100644 index 0000000..53f2335 --- /dev/null +++ b/wolf3d/newCode/Tremor/CHANGELOG @@ -0,0 +1,19 @@ +*** 20020517: 1.0.2 *** + + Playback bugfix to floor1; mode mistakenly used for sizing instead + of blockflag + +*** 20020515: 1.0.1 *** + + Added complete API documentation to source tarball. No code + changes. + +*** 20020412: 1.0.1 *** + + Fixed a clipping bug that affected ARM processors; negative + overflows were being properly clipped, but then clobbered to + positive by the positive overflow chec (asm_arm.h:CLIP_TO_15) + +*** 20020403: 1.0.0 *** + + Initial version \ No newline at end of file diff --git a/wolf3d/newCode/Tremor/COPYING b/wolf3d/newCode/Tremor/COPYING new file mode 100644 index 0000000..6111c6c --- /dev/null +++ b/wolf3d/newCode/Tremor/COPYING @@ -0,0 +1,28 @@ +Copyright (c) 2002, Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/wolf3d/newCode/Tremor/Makefile.am b/wolf3d/newCode/Tremor/Makefile.am new file mode 100644 index 0000000..d14081f --- /dev/null +++ b/wolf3d/newCode/Tremor/Makefile.am @@ -0,0 +1,38 @@ +AUTOMAKE_OPTIONS = foreign + +INCLUDES = -I./ + +lib_LTLIBRARIES = libvorbisidec.la + +libvorbisidec_la_SOURCES = mdct.c block.c window.c \ + synthesis.c info.c \ + floor1.c floor0.c vorbisfile.c \ + res012.c mapping0.c registry.c codebook.c \ + sharedbook.c framing.c bitwise.c \ + codebook.h misc.h mdct_lookup.h\ + os.h mdct.h block.h ivorbisfile.h lsp_lookup.h\ + registry.h window.h window_lookup.h\ + codec_internal.h backends.h ogg.h \ + asm_arm.h ivorbiscodec.h +libvorbisidec_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@ + +EXTRA_PROGRAMS = ivorbisfile_example +CLEANFILES = $(EXTRA_PROGRAMS) $(lib_LTLIBRARIES) + +ivorbisfile_example_SOURCES = ivorbisfile_example.c +ivorbisfile_example_LDFLAGS = -static +ivorbisfile_example_LDADD = libvorbisidec.la + +includedir = $(prefix)/include/tremor + +include_HEADERS = ivorbiscodec.h ivorbisfile.h ogg.h os_types.h config_types.h + +example: + -ln -fs . vorbis + $(MAKE) ivorbisfile_example + +debug: + $(MAKE) all CFLAGS="@DEBUG@" + +profile: + $(MAKE) all CFLAGS="@PROFILE@" diff --git a/wolf3d/newCode/Tremor/README b/wolf3d/newCode/Tremor/README new file mode 100644 index 0000000..1321175 --- /dev/null +++ b/wolf3d/newCode/Tremor/README @@ -0,0 +1,46 @@ +This README covers the Ogg Vorbis 'Tremor' integer playback codec +source as of date 2002 09 02, version 1.0.0. + + ****** + +The C source in this package will build on any ANSI C compiler and +function completely and properly on any platform. The included build +system assumes GNU build system and make tools (m4, automake, +autoconf, libtool and gmake). GCC is not required, although GCC is +the most tested compiler. To build using GNU tools, type in the +source directory: + +./autogen.sh +make + +Currently, the source implements playback in pure C on all platforms +except ARM, where a [currently] small amount of assembly (see +asm_arm.h) is used to implement 64 bit math operations and fast LSP +computation. If building on ARM without the benefit of GNU build +system tools, be sure that '_ARM_ASSEM_' is #defined by the build +system if this assembly is desired, else the resulting library will +use whatever 64 bit math builtins the compiler implements. + +No math library is required by this source. No floating point +operations are used at any point in either setup or decode. This +decoder library will properly decode any past, current or future +Vorbis I file or stream. + + ******** + +The build system produces a static and [when supported by the OS] +dynamic library named 'libvorbisidec'. This library exposes an API +nearly identical to the BSD reference library's 'libvorbisfile', +including all the features familiar to users of vorbisfile. This API +is similar enough that the proper header file to include is named +'ivorbisfile.h' [included in the source build directory]. Lower level +libvorbis-style headers and structures are in 'ivorbiscodec.h' +[included in the source build directory]. A simple example program, +ivorbisfile_example.c, can be built with 'make example'. + + ******** + +Detailed Tremor API Documentation begins at doc/index.html + +Monty +xiph.org diff --git a/wolf3d/newCode/Tremor/Version_script.in b/wolf3d/newCode/Tremor/Version_script.in new file mode 100644 index 0000000..c0dfde9 --- /dev/null +++ b/wolf3d/newCode/Tremor/Version_script.in @@ -0,0 +1,49 @@ +# +# Export file for libvorbisidec +# +# Only the symbols listed in the global section will be callable from +# applications linking to libvorbisidec. +# + +@PACKAGE@.so.1 +{ + global: + ov_clear; + ov_open; + ov_open_callbacks; + ov_test; + ov_test_callbacks; + ov_test_open; + ov_bitrate; + ov_bitrate_instant; + ov_streams; + ov_seekable; + ov_serialnumber; + ov_raw_total; + ov_pcm_total; + ov_time_total; + ov_raw_seek; + ov_pcm_seek; + ov_pcm_seek_page; + ov_time_seek; + ov_time_seek_page; + ov_raw_tell; + ov_pcm_tell; + ov_time_tell; + ov_info; + ov_comment; + ov_read; + + vorbis_info_init; + vorbis_info_clear; + vorbis_info_blocksize; + vorbis_comment_init; + vorbis_comment_add; + vorbis_comment_add_tag; + vorbis_comment_query; + vorbis_comment_query_count; + vorbis_comment_clear; + + local: + *; +}; diff --git a/wolf3d/newCode/Tremor/asm_arm.h b/wolf3d/newCode/Tremor/asm_arm.h new file mode 100644 index 0000000..3a3716d --- /dev/null +++ b/wolf3d/newCode/Tremor/asm_arm.h @@ -0,0 +1,243 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: arm7 and later wide math functions + + ********************************************************************/ + +#ifdef _ARM_ASSEM_ + +#if !defined(_V_WIDE_MATH) && !defined(_LOW_ACCURACY_) +#define _V_WIDE_MATH + +static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { + int lo,hi; + asm volatile("smull\t%0, %1, %2, %3" + : "=&r"(lo),"=&r"(hi) + : "%r"(x),"r"(y) + : "cc"); + return(hi); +} + +static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { + return MULT32(x,y)<<1; +} + +static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { + int lo,hi; + asm volatile("smull %0, %1, %2, %3\n\t" + "movs %0, %0, lsr #15\n\t" + "adc %1, %0, %1, lsl #17\n\t" + : "=&r"(lo),"=&r"(hi) + : "%r"(x),"r"(y) + : "cc"); + return(hi); +} + +#define MB() asm volatile ("" : : : "memory") + +static inline void XPROD32(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + int x1, y1, l; + asm( "smull %0, %1, %4, %6\n\t" + "smlal %0, %1, %5, %7\n\t" + "rsb %3, %4, #0\n\t" + "smull %0, %2, %5, %6\n\t" + "smlal %0, %2, %3, %7" + : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a) + : "3" (a), "r" (b), "r" (t), "r" (v) + : "cc" ); + *x = x1; + MB(); + *y = y1; +} + +static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + int x1, y1, l; + asm( "smull %0, %1, %4, %6\n\t" + "smlal %0, %1, %5, %7\n\t" + "rsb %3, %4, #0\n\t" + "smull %0, %2, %5, %6\n\t" + "smlal %0, %2, %3, %7" + : "=&r" (l), "=&r" (x1), "=&r" (y1), "=r" (a) + : "3" (a), "r" (b), "r" (t), "r" (v) + : "cc" ); + *x = x1 << 1; + MB(); + *y = y1 << 1; +} + +static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + int x1, y1, l; + asm( "rsb %2, %4, #0\n\t" + "smull %0, %1, %3, %5\n\t" + "smlal %0, %1, %2, %6\n\t" + "smull %0, %2, %4, %5\n\t" + "smlal %0, %2, %3, %6" + : "=&r" (l), "=&r" (x1), "=&r" (y1) + : "r" (a), "r" (b), "r" (t), "r" (v) + : "cc" ); + *x = x1 << 1; + MB(); + *y = y1 << 1; +} + +#endif + +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { + int tmp; + asm volatile("subs %1, %0, #32768\n\t" + "movpl %0, #0x7f00\n\t" + "orrpl %0, %0, #0xff\n" + "adds %1, %0, #32768\n\t" + "movmi %0, #0x8000" + : "+r"(x),"=r"(tmp) + : + : "cc"); + return(x); +} + +#endif + +#ifndef _V_LSP_MATH_ASM +#define _V_LSP_MATH_ASM + +static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, + ogg_int32_t *qexpp, + ogg_int32_t *ilsp,ogg_int32_t wi, + ogg_int32_t m){ + + ogg_uint32_t qi=*qip,pi=*pip; + ogg_int32_t qexp=*qexpp; + + asm("mov r0,%3;" + "mov r1,%5,asr#1;" + "add r0,r0,r1,lsl#3;" + "1:" + + "ldmdb r0!,{r1,r3};" + "subs r1,r1,%4;" //ilsp[j]-wi + "rsbmi r1,r1,#0;" //labs(ilsp[j]-wi) + "umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi) + + "subs r1,r3,%4;" //ilsp[j+1]-wi + "rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi) + "umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi) + + "cmn r2,r3;" // shift down 16? + "beq 0f;" + "add %2,%2,#16;" + "mov %0,%0,lsr #16;" + "orr %0,%0,r2,lsl #16;" + "mov %1,%1,lsr #16;" + "orr %1,%1,r3,lsl #16;" + "0:" + "cmp r0,%3;\n" + "bhi 1b;\n" + + // odd filter assymetry + "ands r0,%5,#1;\n" + "beq 2f;\n" + "add r0,%3,%5,lsl#2;\n" + + "ldr r1,[r0,#-4];\n" + "mov r0,#0x4000;\n" + + "subs r1,r1,%4;\n" //ilsp[j]-wi + "rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi) + "umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi) + "umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi) + + "cmn r2,r3;\n" // shift down 16? + "beq 2f;\n" + "add %2,%2,#16;\n" + "mov %0,%0,lsr #16;\n" + "orr %0,%0,r2,lsl #16;\n" + "mov %1,%1,lsr #16;\n" + "orr %1,%1,r3,lsl #16;\n" + + //qi=(pi>>shift)*labs(ilsp[j]-wi); + //pi=(qi>>shift)*labs(ilsp[j+1]-wi); + //qexp+=shift; + + //} + + /* normalize to max 16 sig figs */ + "2:" + "mov r2,#0;" + "orr r1,%0,%1;" + "tst r1,#0xff000000;" + "addne r2,r2,#8;" + "movne r1,r1,lsr #8;" + "tst r1,#0x00f00000;" + "addne r2,r2,#4;" + "movne r1,r1,lsr #4;" + "tst r1,#0x000c0000;" + "addne r2,r2,#2;" + "movne r1,r1,lsr #2;" + "tst r1,#0x00020000;" + "addne r2,r2,#1;" + "movne r1,r1,lsr #1;" + "tst r1,#0x00010000;" + "addne r2,r2,#1;" + "mov %0,%0,lsr r2;" + "mov %1,%1,lsr r2;" + "add %2,%2,r2;" + + : "+r"(qi),"+r"(pi),"+r"(qexp) + : "r"(ilsp),"r"(wi),"r"(m) + : "r0","r1","r2","r3","cc"); + + *qip=qi; + *pip=pi; + *qexpp=qexp; +} + +static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){ + + ogg_uint32_t qi=*qip; + ogg_int32_t qexp=*qexpp; + + asm("tst %0,#0x0000ff00;" + "moveq %0,%0,lsl #8;" + "subeq %1,%1,#8;" + "tst %0,#0x0000f000;" + "moveq %0,%0,lsl #4;" + "subeq %1,%1,#4;" + "tst %0,#0x0000c000;" + "moveq %0,%0,lsl #2;" + "subeq %1,%1,#2;" + "tst %0,#0x00008000;" + "moveq %0,%0,lsl #1;" + "subeq %1,%1,#1;" + : "+r"(qi),"+r"(qexp) + : + : "cc"); + *qip=qi; + *qexpp=qexp; +} + +#endif +#endif + diff --git a/wolf3d/newCode/Tremor/autogen.sh b/wolf3d/newCode/Tremor/autogen.sh new file mode 100644 index 0000000..73c8fca --- /dev/null +++ b/wolf3d/newCode/Tremor/autogen.sh @@ -0,0 +1,120 @@ +#!/bin/sh +# Run this to set up the build system: configure, makefiles, etc. +# (based on the version in enlightenment's cvs) + +package="vorbisdec" + +olddir=`pwd` +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +cd "$srcdir" +DIE=0 + +echo "checking for autoconf... " +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/" +VERSIONMKINT="sed -e s/[^0-9]//" + +# do we need automake? +if test -r Makefile.am; then + AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am` + AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP` + if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then + AM_NEEDED="" + fi + if test -z $AM_NEEDED; then + echo -n "checking for automake... " + AUTOMAKE=automake + ACLOCAL=aclocal + if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then + echo "yes" + else + echo "no" + AUTOMAKE= + fi + else + echo -n "checking for automake $AM_NEEDED or later... " + for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do + ($am --version < /dev/null > /dev/null 2>&1) || continue + ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` + verneeded=`echo $AM_NEEDED | $VERSIONMKINT` + if test $ver -ge $verneeded; then + AUTOMAKE=$am + echo $AUTOMAKE + break + fi + done + test -z $AUTOMAKE && echo "no" + echo -n "checking for aclocal $AM_NEEDED or later... " + for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do + ($ac --version < /dev/null > /dev/null 2>&1) || continue + ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT` + verneeded=`echo $AM_NEEDED | $VERSIONMKINT` + if test $ver -ge $verneeded; then + ACLOCAL=$ac + echo $ACLOCAL + break + fi + done + test -z $ACLOCAL && echo "no" + fi + test -z $AUTOMAKE || test -z $ACLOCAL && { + echo + echo "You must have automake installed to compile $package." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + exit 1 + } +fi + +echo -n "checking for libtool... " +for LIBTOOLIZE in libtoolize glibtoolize nope; do + ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break +done +if test x$LIBTOOLIZE = xnope; then + echo "nope." + LIBTOOLIZE=libtoolize +else + echo $LIBTOOLIZE +fi +($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have libtool installed to compile $package." + echo "Download the appropriate package for your system," + echo "or get the source from one of the GNU ftp sites" + echo "listed in http://www.gnu.org/order/ftp.html" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "I am going to run ./configure with no arguments - if you wish " + echo "to pass any to it, please specify them on the $0 command line." +fi + +echo "Generating configuration files for $package, please wait...." + +echo " $ACLOCAL $ACLOCAL_FLAGS" +$ACLOCAL $ACLOCAL_FLAGS || exit 1 +echo " $LIBTOOLIZE --automake" +$LIBTOOLIZE --automake || exit 1 +echo " autoheader" +autoheader || exit 1 +echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS" +$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1 +echo " autoconf" +autoconf || exit 1 + +cd $olddir +$srcdir/configure --enable-maintainer-mode "$@" && echo diff --git a/wolf3d/newCode/Tremor/backends.h b/wolf3d/newCode/Tremor/backends.h new file mode 100644 index 0000000..50c1c45 --- /dev/null +++ b/wolf3d/newCode/Tremor/backends.h @@ -0,0 +1,130 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: backend and mapping structures + + ********************************************************************/ + +/* this is exposed up here because we need it for static modes. + Lookups for each backend aren't exposed because there's no reason + to do so */ + +#ifndef _vorbis_backend_h_ +#define _vorbis_backend_h_ + +#include "codec_internal.h" + +/* this would all be simpler/shorter with templates, but.... */ +/* Transform backend generic *************************************/ + +/* only mdct right now. Flesh it out more if we ever transcend mdct + in the transform domain */ + +/* Floor backend generic *****************************************/ +typedef struct{ + vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); + vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, + vorbis_info_floor *); + void (*free_info) (vorbis_info_floor *); + void (*free_look) (vorbis_look_floor *); + void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); + int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, + void *buffer,ogg_int32_t *); +} vorbis_func_floor; + +typedef struct{ + int order; + long rate; + long barkmap; + + int ampbits; + int ampdB; + + int numbooks; /* <= 16 */ + int books[16]; + +} vorbis_info_floor0; + +#define VIF_POSIT 63 +#define VIF_CLASS 16 +#define VIF_PARTS 31 +typedef struct{ + int partitions; /* 0 to 31 */ + int partitionclass[VIF_PARTS]; /* 0 to 15 */ + + int class_dim[VIF_CLASS]; /* 1 to 8 */ + int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1< +#include +#include "ogg.h" + +static unsigned long mask[]= +{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, + 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, + 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, + 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, + 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, + 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, + 0x3fffffff,0x7fffffff,0xffffffff }; + +/* mark read process as having run off the end */ +static void _adv_halt(oggpack_buffer *b){ + b->headptr=b->head->buffer->data+b->head->begin+b->head->length; + b->headend=-1; + b->headbit=0; +} + +/* spans forward, skipping as many bytes as headend is negative; if + headend is zero, simply finds next byte. If we're up to the end + of the buffer, leaves headend at zero. If we've read past the end, + halt the decode process. */ +static void _span(oggpack_buffer *b){ + while(b->headend<1){ + if(b->head->next){ + b->count+=b->head->length; + b->head=b->head->next; + b->headptr=b->head->buffer->data+b->head->begin-b->headend; + b->headend+=b->head->length; + }else{ + /* we've either met the end of decode, or gone past it. halt + only if we're past */ + if(b->headend<0 || b->headbit) + /* read has fallen off the end */ + _adv_halt(b); + + break; + } + } +} + +void oggpack_readinit(oggpack_buffer *b,ogg_reference *r){ + memset(b,0,sizeof(*b)); + + b->tail=b->head=r; + b->count=0; + b->headptr=b->head->buffer->data+b->head->begin; + b->headend=b->head->length; + _span(b); +} + +#define _lookspan() while(!end){\ + head=head->next;\ + if(!head) return -1;\ + ptr=head->buffer->data + head->begin;\ + end=head->length;\ + } + +/* Read in bits without advancing the bitptr; bits <= 32 */ +long oggpack_look(oggpack_buffer *b,int bits){ + unsigned long m=mask[bits]; + unsigned long ret=-1; + + bits+=b->headbit; + + if(bits >= b->headend<<3){ + int end=b->headend; + unsigned char *ptr=b->headptr; + ogg_reference *head=b->head; + + if(end<0)return -1; + + if(bits){ + _lookspan(); + ret=*ptr++>>b->headbit; + if(bits>8){ + --end; + _lookspan(); + ret|=*ptr++<<(8-b->headbit); + if(bits>16){ + --end; + _lookspan(); + ret|=*ptr++<<(16-b->headbit); + if(bits>24){ + --end; + _lookspan(); + ret|=*ptr++<<(24-b->headbit); + if(bits>32 && b->headbit){ + --end; + _lookspan(); + ret|=*ptr<<(32-b->headbit); + } + } + } + } + } + + }else{ + + /* make this a switch jump-table */ + ret=b->headptr[0]>>b->headbit; + if(bits>8){ + ret|=b->headptr[1]<<(8-b->headbit); + if(bits>16){ + ret|=b->headptr[2]<<(16-b->headbit); + if(bits>24){ + ret|=b->headptr[3]<<(24-b->headbit); + if(bits>32 && b->headbit) + ret|=b->headptr[4]<<(32-b->headbit); + } + } + } + } + + ret&=m; + return ret; +} + +/* limited to 32 at a time */ +void oggpack_adv(oggpack_buffer *b,int bits){ + bits+=b->headbit; + b->headbit=bits&7; + b->headptr+=bits/8; + if((b->headend-=bits/8)<1)_span(b); +} + +/* spans forward and finds next byte. Never halts */ +static void _span_one(oggpack_buffer *b){ + while(b->headend<1){ + if(b->head->next){ + b->count+=b->head->length; + b->head=b->head->next; + b->headptr=b->head->buffer->data+b->head->begin; + b->headend=b->head->length; + }else + break; + } +} + +static int _halt_one(oggpack_buffer *b){ + if(b->headend<1){ + _adv_halt(b); + return -1; + } + return 0; +} + +int oggpack_eop(oggpack_buffer *b){ + if(b->headend<0)return -1; + return 0; +} + +/* bits <= 32 */ +long oggpack_read(oggpack_buffer *b,int bits){ + unsigned long m=mask[bits]; + ogg_uint32_t ret=-1; + + bits+=b->headbit; + + if(bits >= b->headend<<3){ + + if(b->headend<0)return -1; + + if(bits){ + if (_halt_one(b)) return -1; + ret=*b->headptr>>b->headbit; + + if(bits>=8){ + ++b->headptr; + --b->headend; + _span_one(b); + if(bits>8){ + if (_halt_one(b)) return -1; + ret|=*b->headptr<<(8-b->headbit); + + if(bits>=16){ + ++b->headptr; + --b->headend; + _span_one(b); + if(bits>16){ + if (_halt_one(b)) return -1; + ret|=*b->headptr<<(16-b->headbit); + + if(bits>=24){ + ++b->headptr; + --b->headend; + _span_one(b); + if(bits>24){ + if (_halt_one(b)) return -1; + ret|=*b->headptr<<(24-b->headbit); + + if(bits>=32){ + ++b->headptr; + --b->headend; + _span_one(b); + if(bits>32){ + if (_halt_one(b)) return -1; + if(b->headbit)ret|=*b->headptr<<(32-b->headbit); + + } + } + } + } + } + } + } + } + } + }else{ + + ret=b->headptr[0]>>b->headbit; + if(bits>8){ + ret|=b->headptr[1]<<(8-b->headbit); + if(bits>16){ + ret|=b->headptr[2]<<(16-b->headbit); + if(bits>24){ + ret|=b->headptr[3]<<(24-b->headbit); + if(bits>32 && b->headbit){ + ret|=b->headptr[4]<<(32-b->headbit); + } + } + } + } + + b->headptr+=bits/8; + b->headend-=bits/8; + } + + ret&=m; + b->headbit=bits&7; + return ret; +} + +long oggpack_bytes(oggpack_buffer *b){ + return(b->count+b->headptr-b->head->buffer->data-b->head->begin+ + (b->headbit+7)/8); +} + +long oggpack_bits(oggpack_buffer *b){ + return((b->count+b->headptr-b->head->buffer->data-b->head->begin)*8+ + b->headbit); +} + diff --git a/wolf3d/newCode/Tremor/block.c b/wolf3d/newCode/Tremor/block.c new file mode 100644 index 0000000..8949253 --- /dev/null +++ b/wolf3d/newCode/Tremor/block.c @@ -0,0 +1,453 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: PCM data vector blocking, windowing and dis/reassembly + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" + +#include "window.h" +#include "registry.h" +#include "misc.h" + +static int ilog(unsigned int v){ + int ret=0; + if(v)--v; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +/* pcm accumulator examples (not exhaustive): + + <-------------- lW ----------------> + <--------------- W ----------------> +: .....|..... _______________ | +: .''' | '''_--- | |\ | +:.....''' |_____--- '''......| | \_______| +:.................|__________________|_______|__|______| + |<------ Sl ------>| > Sr < |endW + |beginSl |endSl | |endSr + |beginW |endlW |beginSr + + + |< lW >| + <--------------- W ----------------> + | | .. ______________ | + | | ' `/ | ---_ | + |___.'___/`. | ---_____| + |_______|__|_______|_________________| + | >|Sl|< |<------ Sr ----->|endW + | | |endSl |beginSr |endSr + |beginW | |endlW + mult[0] |beginSl mult[n] + + <-------------- lW -----------------> + |<--W-->| +: .............. ___ | | +: .''' |`/ \ | | +:.....''' |/`....\|...| +:.........................|___|___|___| + |Sl |Sr |endW + | | |endSr + | |beginSr + | |endSl + |beginSl + |beginW +*/ + +/* block abstraction setup *********************************************/ + +#ifndef WORD_ALIGN +#define WORD_ALIGN 8 +#endif + +int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ + memset(vb,0,sizeof(*vb)); + vb->vd=v; + vb->localalloc=0; + vb->localstore=NULL; + + return(0); +} + +void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ + bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); + if(bytes+vb->localtop>vb->localalloc){ + /* can't just _ogg_realloc... there are outstanding pointers */ + if(vb->localstore){ + struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link)); + vb->totaluse+=vb->localtop; + link->next=vb->reap; + link->ptr=vb->localstore; + vb->reap=link; + } + /* highly conservative */ + vb->localalloc=bytes; + vb->localstore=_ogg_malloc(vb->localalloc); + vb->localtop=0; + } + { + void *ret=(void *)(((char *)vb->localstore)+vb->localtop); + vb->localtop+=bytes; + return ret; + } +} + +/* reap the chain, pull the ripcord */ +void _vorbis_block_ripcord(vorbis_block *vb){ + /* reap the chain */ + struct alloc_chain *reap=vb->reap; + while(reap){ + struct alloc_chain *next=reap->next; + _ogg_free(reap->ptr); + memset(reap,0,sizeof(*reap)); + _ogg_free(reap); + reap=next; + } + /* consolidate storage */ + if(vb->totaluse){ + vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); + vb->localalloc+=vb->totaluse; + vb->totaluse=0; + } + + /* pull the ripcord */ + vb->localtop=0; + vb->reap=NULL; +} + +int vorbis_block_clear(vorbis_block *vb){ + _vorbis_block_ripcord(vb); + if(vb->localstore)_ogg_free(vb->localstore); + + memset(vb,0,sizeof(*vb)); + return(0); +} + +static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ + int i; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + private_state *b=NULL; + + memset(v,0,sizeof(*v)); + b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); + + v->vi=vi; + b->modebits=ilog(ci->modes); + + /* Vorbis I uses only window type 0 */ + b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); + b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); + + /* finish the codebooks */ + if(!ci->fullbooks){ + ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); + for(i=0;ibooks;i++){ + vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); + /* decode codebooks are now standalone after init */ + vorbis_staticbook_destroy(ci->book_param[i]); + ci->book_param[i]=NULL; + } + } + + v->pcm_storage=ci->blocksizes[1]; + v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); + v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); + for(i=0;ichannels;i++) + v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); + + /* all 1 (large block) or 0 (small block) */ + /* explicitly set for the sake of clarity */ + v->lW=0; /* previous window size */ + v->W=0; /* current window size */ + + /* initialize all the mapping/backend lookups */ + b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); + for(i=0;imodes;i++){ + int mapnum=ci->mode_param[i]->mapping; + int maptype=ci->map_type[mapnum]; + b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], + ci->map_param[mapnum]); + } + return(0); +} + +int vorbis_synthesis_restart(vorbis_dsp_state *v){ + vorbis_info *vi=v->vi; + codec_setup_info *ci; + + if(!v->backend_state)return -1; + if(!vi)return -1; + ci=vi->codec_setup; + if(!ci)return -1; + + v->centerW=ci->blocksizes[1]/2; + v->pcm_current=v->centerW; + + v->pcm_returned=-1; + v->granulepos=-1; + v->sequence=-1; + ((private_state *)(v->backend_state))->sample_count=-1; + + return(0); +} + +int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ + _vds_init(v,vi); + vorbis_synthesis_restart(v); + + return(0); +} + +void vorbis_dsp_clear(vorbis_dsp_state *v){ + int i; + if(v){ + vorbis_info *vi=v->vi; + codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); + private_state *b=(private_state *)v->backend_state; + + if(v->pcm){ + for(i=0;ichannels;i++) + if(v->pcm[i])_ogg_free(v->pcm[i]); + _ogg_free(v->pcm); + if(v->pcmret)_ogg_free(v->pcmret); + } + + /* free mode lookups; these are actually vorbis_look_mapping structs */ + if(ci){ + for(i=0;imodes;i++){ + int mapnum=ci->mode_param[i]->mapping; + int maptype=ci->map_type[mapnum]; + if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); + } + } + + if(b){ + if(b->mode)_ogg_free(b->mode); + _ogg_free(b); + } + + memset(v,0,sizeof(*v)); + } +} + +/* Unlike in analysis, the window is only partially applied for each + block. The time domain envelope is not yet handled at the point of + calling (as it relies on the previous block). */ + +int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ + vorbis_info *vi=v->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + private_state *b=v->backend_state; + int i,j; + + if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); + + v->lW=v->W; + v->W=vb->W; + v->nW=-1; + + if((v->sequence==-1)|| + (v->sequence+1 != vb->sequence)){ + v->granulepos=-1; /* out of sequence; lose count */ + b->sample_count=-1; + } + + v->sequence=vb->sequence; + + if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly + was called on block */ + int n=ci->blocksizes[v->W]/2; + int n0=ci->blocksizes[0]/2; + int n1=ci->blocksizes[1]/2; + + int thisCenter; + int prevCenter; + + if(v->centerW){ + thisCenter=n1; + prevCenter=0; + }else{ + thisCenter=0; + prevCenter=n1; + } + + /* v->pcm is now used like a two-stage double buffer. We don't want + to have to constantly shift *or* adjust memory usage. Don't + accept a new block until the old is shifted out */ + + /* overlap/add PCM */ + + for(j=0;jchannels;j++){ + /* the overlap/add section */ + if(v->lW){ + if(v->W){ + /* large/large */ + ogg_int32_t *pcm=v->pcm[j]+prevCenter; + ogg_int32_t *p=vb->pcm[j]; + for(i=0;ipcm[j]+prevCenter+n1/2-n0/2; + ogg_int32_t *p=vb->pcm[j]; + for(i=0;iW){ + /* small/large */ + ogg_int32_t *pcm=v->pcm[j]+prevCenter; + ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; + for(i=0;ipcm[j]+prevCenter; + ogg_int32_t *p=vb->pcm[j]; + for(i=0;ipcm[j]+thisCenter; + ogg_int32_t *p=vb->pcm[j]+n; + for(i=0;icenterW) + v->centerW=0; + else + v->centerW=n1; + + /* deal with initial packet state; we do this using the explicit + pcm_returned==-1 flag otherwise we're sensitive to first block + being short or long */ + + if(v->pcm_returned==-1){ + v->pcm_returned=thisCenter; + v->pcm_current=thisCenter; + }else{ + v->pcm_returned=prevCenter; + v->pcm_current=prevCenter+ + ci->blocksizes[v->lW]/4+ + ci->blocksizes[v->W]/4; + } + + } + + /* track the frame number... This is for convenience, but also + making sure our last packet doesn't end with added padding. If + the last packet is partial, the number of samples we'll have to + return will be past the vb->granulepos. + + This is not foolproof! It will be confused if we begin + decoding at the last page after a seek or hole. In that case, + we don't have a starting point to judge where the last frame + is. For this reason, vorbisfile will always try to make sure + it reads the last two marked pages in proper sequence */ + + if(b->sample_count==-1){ + b->sample_count=0; + }else{ + b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; + } + + if(v->granulepos==-1){ + if(vb->granulepos!=-1){ /* only set if we have a position to set to */ + + v->granulepos=vb->granulepos; + + /* is this a short page? */ + if(b->sample_count>v->granulepos){ + /* corner case; if this is both the first and last audio page, + then spec says the end is cut, not beginning */ + if(vb->eofflag){ + /* trim the end */ + /* no preceeding granulepos; assume we started at zero (we'd + have to in a short single-page stream) */ + /* granulepos could be -1 due to a seek, but that would result + in a long coun`t, not short count */ + + v->pcm_current-=(b->sample_count-v->granulepos); + }else{ + /* trim the beginning */ + v->pcm_returned+=(b->sample_count-v->granulepos); + if(v->pcm_returned>v->pcm_current) + v->pcm_returned=v->pcm_current; + } + + } + + } + }else{ + v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; + if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ + + if(v->granulepos>vb->granulepos){ + long extra=v->granulepos-vb->granulepos; + + if(extra) + if(vb->eofflag){ + /* partial last frame. Strip the extra samples off */ + v->pcm_current-=extra; + } /* else {Shouldn't happen *unless* the bitstream is out of + spec. Either way, believe the bitstream } */ + } /* else {Shouldn't happen *unless* the bitstream is out of + spec. Either way, believe the bitstream } */ + v->granulepos=vb->granulepos; + } + } + + /* Update, cleanup */ + + if(vb->eofflag)v->eofflag=1; + return(0); +} + +/* pcm==NULL indicates we just want the pending samples, no more */ +int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ + vorbis_info *vi=v->vi; + if(v->pcm_returned>-1 && v->pcm_returnedpcm_current){ + if(pcm){ + int i; + for(i=0;ichannels;i++) + v->pcmret[i]=v->pcm[i]+v->pcm_returned; + *pcm=v->pcmret; + } + return(v->pcm_current-v->pcm_returned); + } + return(0); +} + +int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){ + if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL); + v->pcm_returned+=bytes; + return(0); +} + diff --git a/wolf3d/newCode/Tremor/block.h b/wolf3d/newCode/Tremor/block.h new file mode 100644 index 0000000..5e19354 --- /dev/null +++ b/wolf3d/newCode/Tremor/block.h @@ -0,0 +1,24 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2008 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: shared block functions + + ********************************************************************/ + +#ifndef _V_BLOCK_ +#define _V_BLOCK_ + +extern void _vorbis_block_ripcord(vorbis_block *vb); +extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); + +#endif diff --git a/wolf3d/newCode/Tremor/codebook.c b/wolf3d/newCode/Tremor/codebook.c new file mode 100644 index 0000000..d055870 --- /dev/null +++ b/wolf3d/newCode/Tremor/codebook.c @@ -0,0 +1,371 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: basic codebook pack/unpack/code/decode operations + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codebook.h" +#include "misc.h" + +/* unpacks a codebook from the packet buffer into the codebook struct, + readies the codebook auxiliary structures for decode *************/ +int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ + long i,j; + memset(s,0,sizeof(*s)); + + /* make sure alignment is correct */ + if(oggpack_read(opb,24)!=0x564342)goto _eofout; + + /* first the basic parameters */ + s->dim=oggpack_read(opb,16); + s->entries=oggpack_read(opb,24); + if(s->entries==-1)goto _eofout; + + /* codeword ordering.... length ordered or unordered? */ + switch((int)oggpack_read(opb,1)){ + case 0: + /* unordered */ + s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); + + /* allocated but unused entries? */ + if(oggpack_read(opb,1)){ + /* yes, unused entries */ + + for(i=0;ientries;i++){ + if(oggpack_read(opb,1)){ + long num=oggpack_read(opb,5); + if(num==-1)goto _eofout; + s->lengthlist[i]=num+1; + }else + s->lengthlist[i]=0; + } + }else{ + /* all entries used; no tagging */ + for(i=0;ientries;i++){ + long num=oggpack_read(opb,5); + if(num==-1)goto _eofout; + s->lengthlist[i]=num+1; + } + } + + break; + case 1: + /* ordered */ + { + long length=oggpack_read(opb,5)+1; + s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); + + for(i=0;ientries;){ + long num=oggpack_read(opb,_ilog(s->entries-i)); + if(num==-1)goto _eofout; + for(j=0;jentries;j++,i++) + s->lengthlist[i]=length; + length++; + } + } + break; + default: + /* EOF */ + return(-1); + } + + /* Do we have a mapping to unpack? */ + switch((s->maptype=oggpack_read(opb,4))){ + case 0: + /* no mapping */ + break; + case 1: case 2: + /* implicitly populated value mapping */ + /* explicitly populated value mapping */ + + s->q_min=oggpack_read(opb,32); + s->q_delta=oggpack_read(opb,32); + s->q_quant=oggpack_read(opb,4)+1; + s->q_sequencep=oggpack_read(opb,1); + + { + int quantvals=0; + switch(s->maptype){ + case 1: + quantvals=_book_maptype1_quantvals(s); + break; + case 2: + quantvals=s->entries*s->dim; + break; + } + + /* quantized values */ + s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); + for(i=0;iquantlist[i]=oggpack_read(opb,s->q_quant); + + if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; + } + break; + default: + goto _errout; + } + + /* all set */ + return(0); + + _errout: + _eofout: + vorbis_staticbook_clear(s); + return(-1); +} + +/* the 'eliminate the decode tree' optimization actually requires the + codewords to be MSb first, not LSb. This is an annoying inelegancy + (and one of the first places where carefully thought out design + turned out to be wrong; Vorbis II and future Ogg codecs should go + to an MSb bitpacker), but not actually the huge hit it appears to + be. The first-stage decode table catches most words so that + bitreverse is not in the main execution path. */ + +static ogg_uint32_t bitreverse(ogg_uint32_t x){ + x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); + x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); + x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); + x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc); + return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa); +} + +STIN long decode_packed_entry_number(codebook *book, + oggpack_buffer *b){ + int read=book->dec_maxlength; + long lo,hi; + long lok = oggpack_look(b,book->dec_firsttablen); + + if (lok >= 0) { + long entry = book->dec_firsttable[lok]; + if(entry&0x80000000UL){ + lo=(entry>>15)&0x7fff; + hi=book->used_entries-(entry&0x7fff); + }else{ + oggpack_adv(b, book->dec_codelengths[entry-1]); + return(entry-1); + } + }else{ + lo=0; + hi=book->used_entries; + } + + lok = oggpack_look(b, read); + + while(lok<0 && read>1) + lok = oggpack_look(b, --read); + + if(lok<0){ + oggpack_adv(b,1); /* force eop */ + return -1; + } + + /* bisect search for the codeword in the ordered list */ + { + ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok); + + while(hi-lo>1){ + long p=(hi-lo)>>1; + long test=book->codelist[lo+p]>testword; + lo+=p&(test-1); + hi-=p&(-test); + } + + if(book->dec_codelengths[lo]<=read){ + oggpack_adv(b, book->dec_codelengths[lo]); + return(lo); + } + } + + oggpack_adv(b, read+1); + return(-1); +} + +/* Decode side is specced and easier, because we don't need to find + matches using different criteria; we simply read and map. There are + two things we need to do 'depending': + + We may need to support interleave. We don't really, but it's + convenient to do it here rather than rebuild the vector later. + + Cascades may be additive or multiplicitive; this is not inherent in + the codebook, but set in the code using the codebook. Like + interleaving, it's easiest to do it here. + addmul==0 -> declarative (set the value) + addmul==1 -> additive + addmul==2 -> multiplicitive */ + +/* returns the [original, not compacted] entry number or -1 on eof *********/ +long vorbis_book_decode(codebook *book, oggpack_buffer *b){ + if(book->used_entries>0){ + long packed_entry=decode_packed_entry_number(book,b); + if(packed_entry>=0) + return(book->dec_index[packed_entry]); + } + + /* if there's no dec_index, the codebook unpacking isn't collapsed */ + return(-1); +} + +/* returns 0 on OK or -1 on eof *************************************/ +long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, + oggpack_buffer *b,int n,int point){ + if(book->used_entries>0){ + int step=n/book->dim; + long *entry = (long *)alloca(sizeof(*entry)*step); + ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step); + int i,j,o; + int shift=point-book->binarypoint; + + if(shift>=0){ + for (i = 0; i < step; i++) { + entry[i]=decode_packed_entry_number(book,b); + if(entry[i]==-1)return(-1); + t[i] = book->valuelist+entry[i]*book->dim; + } + for(i=0,o=0;idim;i++,o+=step) + for (j=0;j>shift; + }else{ + for (i = 0; i < step; i++) { + entry[i]=decode_packed_entry_number(book,b); + if(entry[i]==-1)return(-1); + t[i] = book->valuelist+entry[i]*book->dim; + } + for(i=0,o=0;idim;i++,o+=step) + for (j=0;jused_entries>0){ + int i,j,entry; + ogg_int32_t *t; + int shift=point-book->binarypoint; + + if(shift>=0){ + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;) + a[i++]+=t[j++]>>shift; + } + }else{ + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;) + a[i++]+=t[j++]<<-shift; + } + } + } + return(0); +} + +long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, + oggpack_buffer *b,int n,int point){ + if(book->used_entries>0){ + int i,j,entry; + ogg_int32_t *t; + int shift=point-book->binarypoint; + + if(shift>=0){ + + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;){ + a[i++]=t[j++]>>shift; + } + } + }else{ + + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;){ + a[i++]=t[j++]<<-shift; + } + } + } + }else{ + + int i,j; + for(i=0;idim;){ + a[i++]=0; + } + } + } + return(0); +} + +long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\ + long offset,int ch, + oggpack_buffer *b,int n,int point){ + if(book->used_entries>0){ + long i,j,entry; + int chptr=0; + int shift=point-book->binarypoint; + + if(shift>=0){ + + for(i=offset;ivaluelist+entry*book->dim; + for (j=0;jdim;j++){ + a[chptr++][i]+=t[j]>>shift; + if(chptr==ch){ + chptr=0; + i++; + } + } + } + } + }else{ + + for(i=offset;ivaluelist+entry*book->dim; + for (j=0;jdim;j++){ + a[chptr++][i]+=t[j]<<-shift; + if(chptr==ch){ + chptr=0; + i++; + } + } + } + } + } + } + return(0); +} diff --git a/wolf3d/newCode/Tremor/codebook.h b/wolf3d/newCode/Tremor/codebook.h new file mode 100644 index 0000000..14f6538 --- /dev/null +++ b/wolf3d/newCode/Tremor/codebook.h @@ -0,0 +1,102 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: basic shared codebook operations + + ********************************************************************/ + +#ifndef _V_CODEBOOK_H_ +#define _V_CODEBOOK_H_ + +#include "ogg.h" + +/* This structure encapsulates huffman and VQ style encoding books; it + doesn't do anything specific to either. + + valuelist/quantlist are nonNULL (and q_* significant) only if + there's entry->value mapping to be done. + + If encode-side mapping must be done (and thus the entry needs to be + hunted), the auxiliary encode pointer will point to a decision + tree. This is true of both VQ and huffman, but is mostly useful + with VQ. + +*/ + +typedef struct static_codebook{ + long dim; /* codebook dimensions (elements per vector) */ + long entries; /* codebook entries */ + long *lengthlist; /* codeword lengths in bits */ + + /* mapping ***************************************************************/ + int maptype; /* 0=none + 1=implicitly populated values from map column + 2=listed arbitrary values */ + + /* The below does a linear, single monotonic sequence mapping. */ + long q_min; /* packed 32 bit float; quant value 0 maps to minval */ + long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ + int q_quant; /* bits: 0 < quant <= 16 */ + int q_sequencep; /* bitflag */ + + long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map + map == 2: list of dim*entries quantized entry vals + */ +} static_codebook; + +typedef struct codebook{ + long dim; /* codebook dimensions (elements per vector) */ + long entries; /* codebook entries */ + long used_entries; /* populated codebook entries */ + + /* the below are ordered by bitreversed codeword and only used + entries are populated */ + int binarypoint; + ogg_int32_t *valuelist; /* list of dim*entries actual entry values */ + ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ + + int *dec_index; + char *dec_codelengths; + ogg_uint32_t *dec_firsttable; + int dec_firsttablen; + int dec_maxlength; + + long q_min; /* packed 32 bit float; quant value 0 maps to minval */ + long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ + +} codebook; + +extern void vorbis_staticbook_clear(static_codebook *b); +extern void vorbis_staticbook_destroy(static_codebook *b); +extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); + +extern void vorbis_book_clear(codebook *b); +extern long _book_maptype1_quantvals(const static_codebook *b); + +extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); + +extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); +extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, + long off,int ch, + oggpack_buffer *b,int n,int point); + +extern int _ilog(unsigned int v); + + +#endif diff --git a/wolf3d/newCode/Tremor/codec_internal.h b/wolf3d/newCode/Tremor/codec_internal.h new file mode 100644 index 0000000..3ca7f54 --- /dev/null +++ b/wolf3d/newCode/Tremor/codec_internal.h @@ -0,0 +1,92 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: libvorbis codec headers + + ********************************************************************/ + +#ifndef _V_CODECI_H_ +#define _V_CODECI_H_ + +#include "codebook.h" + +typedef void vorbis_look_mapping; +typedef void vorbis_look_floor; +typedef void vorbis_look_residue; +typedef void vorbis_look_transform; + +/* mode ************************************************************/ +typedef struct { + int blockflag; + int windowtype; + int transformtype; + int mapping; +} vorbis_info_mode; + +typedef void vorbis_info_floor; +typedef void vorbis_info_residue; +typedef void vorbis_info_mapping; + +typedef struct private_state { + /* local lookup storage */ + const void *window[2]; + + /* backend lookups are tied to the mode, not the backend or naked mapping */ + int modebits; + vorbis_look_mapping **mode; + + ogg_int64_t sample_count; + +} private_state; + +/* codec_setup_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). +*********************************************************************/ + +typedef struct codec_setup_info { + + /* Vorbis supports only short and long blocks, but allows the + encoder to choose the sizes */ + + long blocksizes[2]; + + /* modes are the primary means of supporting on-the-fly different + blocksizes, different channel mappings (LR or M/A), + different residue backends, etc. Each mode consists of a + blocksize flag and a mapping (along with the mapping setup */ + + int modes; + int maps; + int times; + int floors; + int residues; + int books; + + vorbis_info_mode *mode_param[64]; + int map_type[64]; + vorbis_info_mapping *map_param[64]; + int time_type[64]; + int floor_type[64]; + vorbis_info_floor *floor_param[64]; + int residue_type[64]; + vorbis_info_residue *residue_param[64]; + static_codebook *book_param[256]; + codebook *fullbooks; + + int passlimit[32]; /* iteration limit per couple/quant pass */ + int coupling_passes; +} codec_setup_info; + +#endif diff --git a/wolf3d/newCode/Tremor/config_types.h b/wolf3d/newCode/Tremor/config_types.h new file mode 100644 index 0000000..1fdcb27 --- /dev/null +++ b/wolf3d/newCode/Tremor/config_types.h @@ -0,0 +1,25 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + + ********************************************************************/ +#ifndef _OS_CVTYPES_H +#define _OS_CVTYPES_H + +typedef long long ogg_int64_t; +typedef int ogg_int32_t; +typedef unsigned int ogg_uint32_t; +typedef short ogg_int16_t; + +#endif diff --git a/wolf3d/newCode/Tremor/configure.in b/wolf3d/newCode/Tremor/configure.in new file mode 100644 index 0000000..2b44ee4 --- /dev/null +++ b/wolf3d/newCode/Tremor/configure.in @@ -0,0 +1,131 @@ +dnl Process this file with autoconf to produce a configure script + +dnl ------------------------------------------------ +dnl Initialization and Versioning +dnl ------------------------------------------------ + +AC_INIT(mdct.c) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE(libvorbisidec,1.2.0) + +dnl Library versioning + +V_LIB_CURRENT=1 +V_LIB_REVISION=2 +V_LIB_AGE=0 +AC_SUBST(V_LIB_CURRENT) +AC_SUBST(V_LIB_REVISION) +AC_SUBST(V_LIB_AGE) + +dnl -------------------------------------------------- +dnl Check for programs +dnl -------------------------------------------------- + +dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2" +dnl if $CFLAGS is blank +cflags_save="$CFLAGS" +AC_PROG_CC +AC_PROG_CPP +CFLAGS="$cflags_save" + +AM_PROG_LIBTOOL + +dnl -------------------------------------------------- +dnl Set build flags based on environment +dnl -------------------------------------------------- + +dnl Set some target options + +cflags_save="$CFLAGS" +ldflags_save="$LDFLAGS" +if test -z "$GCC"; then + case $host in + arm-*-*) + DEBUG="-g -D_ARM_ASSEM_" + CFLAGS="-O -D_ARM_ASSEM_" + PROFILE="-p -g -O -D_ARM_ASSEM_" ;; + *) + DEBUG="-g" + CFLAGS="-O" + PROFILE="-g -p" ;; + esac +else + + case $host in + arm-*-*) + DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -D_ARM_ASSEM_" + CFLAGS="-O2 -D_ARM_ASSEM_ -fsigned-char" + PROFILE="-W -pg -g -O2 -D_ARM_ASSEM_ -fsigned-char -fno-inline-functions";; + + *) + DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char" + CFLAGS="-O2 -Wall -fsigned-char" + PROFILE="-Wall -pg -g -O2 -fsigned-char -fno-inline-functions";; + esac +fi +CFLAGS="$CFLAGS $cflags_save -D_REENTRANT" +LDFLAGS="$LDFLAGS $ldflags_save" + + +# Test whenever ld supports -version-script +AC_PROG_LD +AC_PROG_LD_GNU +if test "x$lt_cv_prog_gnu_ld" = "xyes"; then + SHLIB_VERSION_ARG="Wl,--version-script=Version_script" + + dnl Set extra linker options + case "$target_os" in + linux* | solaris* ) + SHLIB_VERSION_ARG="-Wl,--version-script=Version_script" + ;; + *) + ;; + esac + LDFLAGS="$LDFLAGS $SHLIB_VERSION_ARG" +fi + +dnl -------------------------------------------------- +dnl Options +dnl -------------------------------------------------- + +AC_ARG_ENABLE( + low-accuracy, + [ --enable-low-accuracy enable 32 bit only multiply operations], + CFLAGS="$CFLAGS -D_LOW_ACCURACY_" +) + +dnl -------------------------------------------------- +dnl Check for headers +dnl -------------------------------------------------- + +AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:) + +dnl -------------------------------------------------- +dnl Check for typedefs, structures, etc +dnl -------------------------------------------------- + +dnl none + +dnl -------------------------------------------------- +dnl Check for library functions +dnl -------------------------------------------------- + +AC_FUNC_ALLOCA +AC_FUNC_MEMCMP + +dnl -------------------------------------------------- +dnl Do substitutions +dnl -------------------------------------------------- + +LIBS="$LIBS" + +AC_SUBST(LIBS) +AC_SUBST(DEBUG) +AC_SUBST(PROFILE) + +AC_OUTPUT(Makefile Version_script) diff --git a/wolf3d/newCode/Tremor/debian/Makefile.am b/wolf3d/newCode/Tremor/debian/Makefile.am new file mode 100644 index 0000000..45a0f01 --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/Makefile.am @@ -0,0 +1,6 @@ +## Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS = foreign + +EXTRA_DIST = changelog control copyright libvorbisidec1.install\ + libvorbisidec-dev.install rules diff --git a/wolf3d/newCode/Tremor/debian/changelog b/wolf3d/newCode/Tremor/debian/changelog new file mode 100644 index 0000000..0cb4935 --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/changelog @@ -0,0 +1,9 @@ +libvorbisidec (1.2.0-1) unstable; urgency=low + + * Initial Release. + + -- Christopher L Cheney Wed, 09 Oct 2002 22:00:00 -0500 + +Local variables: +mode: debian-changelog +End: diff --git a/wolf3d/newCode/Tremor/debian/control b/wolf3d/newCode/Tremor/debian/control new file mode 100644 index 0000000..f286e91 --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/control @@ -0,0 +1,22 @@ +Source: libvorbisidec +Section: libs +Priority: optional +Maintainer: Christopher L Cheney +Build-Depends: autotools-dev, debhelper (>> 4.0.18), devscripts, gawk +Standards-Version: 3.5.7.0 + +Package: libvorbisidec1 +Architecture: any +Section: libs +Depends: ${shlibs:Depends} +Description: Ogg Bitstream Library + Libogg is a library for manipulating ogg bitstreams. It handles + both making ogg bitstreams and getting packets from ogg bitstreams. + +Package: libvorbisidec-dev +Architecture: any +Section: devel +Depends: libvorbisidec1 (= ${Source-Version}), libc6-dev +Description: Ogg Bitstream Library Development + The libogg-dev package contains the header files and documentation + needed to develop applications with libogg. diff --git a/wolf3d/newCode/Tremor/debian/copyright b/wolf3d/newCode/Tremor/debian/copyright new file mode 100644 index 0000000..ef98ddd --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/copyright @@ -0,0 +1,37 @@ +This package was debianized by Christopher L Cheney on +Wed, 09 Oct 2002 22:00:00 -0500. + +It was downloaded from cvs. + +Upstream Author(s): Monty + +Copyright: +Copyright (c) 2002, Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.Org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/wolf3d/newCode/Tremor/debian/libvorbisidec-dev.install b/wolf3d/newCode/Tremor/debian/libvorbisidec-dev.install new file mode 100644 index 0000000..5c3ccf9 --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/libvorbisidec-dev.install @@ -0,0 +1,8 @@ +debian/tmp/usr/include/tremor/config_types.h +debian/tmp/usr/include/tremor/ivorbiscodec.h +debian/tmp/usr/include/tremor/ivorbisfile.h +debian/tmp/usr/include/tremor/ogg.h +debian/tmp/usr/include/tremor/os_types.h +debian/tmp/usr/lib/libvorbisidec.a +debian/tmp/usr/lib/libvorbisidec.la +debian/tmp/usr/lib/libvorbisidec.so diff --git a/wolf3d/newCode/Tremor/debian/libvorbisidec1.install b/wolf3d/newCode/Tremor/debian/libvorbisidec1.install new file mode 100644 index 0000000..b824d1e --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/libvorbisidec1.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libvorbisidec.so.* diff --git a/wolf3d/newCode/Tremor/debian/rules b/wolf3d/newCode/Tremor/debian/rules new file mode 100644 index 0000000..c684884 --- /dev/null +++ b/wolf3d/newCode/Tremor/debian/rules @@ -0,0 +1,151 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatibility version to use. +export DH_COMPAT=4 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +objdir = $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE) + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + + # make build directory + mkdir $(objdir) + + # run configure with build tree $(objdir) + # change ../configure to ../autogen.sh for CVS build + cd $(objdir) && \ + ../configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \ + --prefix=/usr + + touch configure-stamp + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + + cd $(objdir) && \ + $(MAKE) + + touch build-stamp + +autotools: + OLDDATESUB=`./config.sub -t | tr -d -` ;\ + OLDDATEGUESS=`./config.guess -t | tr -d -` ;\ + NEWDATESUB=`/usr/share/misc/config.sub -t | tr -d -` ;\ + NEWDATEGUESS=`/usr/share/misc/config.guess -t | tr -d -` ;\ + if [ $$OLDDATESUB -lt $$NEWDATESUB -o \ + $$OLDDATEGUESS -lt $$NEWDATEGUESS ]; then \ + dch -a -p "GNU config automated update: config.sub\ + ($$OLDDATESUB to $$NEWDATESUB), config.guess\ + ($$OLDDATEGUESS to $$NEWDATEGUESS)" ;\ + cp -f /usr/share/misc/config.sub config.sub ;\ + cp -f /usr/share/misc/config.guess config.guess ;\ + echo WARNING: GNU config scripts updated from master copies 1>&2 ;\ + fi + +debian-clean: + dh_testdir + dh_testroot + + dh_clean + +clean: autotools + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Remove build tree + rm -rf $(objdir) + + # if Makefile exists run distclean + if test -f Makefile; then \ + $(MAKE) distclean; \ + fi + + #if test -d CVS; then \ + $(MAKE) cvs-clean ;\ + fi + + dh_clean + +install: DH_OPTIONS= +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(objdir) && \ + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp + + dh_install --list-missing + +# This single target is used to build all the packages, all at once, or +# one at a time. So keep in mind: any options passed to commands here will +# affect _all_ packages. Anything you want to only affect one package +# should be put in another target, such as the install target. +binary-common: + dh_testdir + dh_testroot +# dh_installxfonts + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo +# dh_undocumented + dh_installman + dh_strip + dh_link + dh_compress + dh_fixperms + dh_makeshlibs -V + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +# Build architecture independant packages using the common target. +binary-indep: build install +# $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common + +# Build architecture dependant packages using the common target. +binary-arch: build install + $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common + +# Any other binary targets build just one binary package at a time. +binary-%: build install + $(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$* + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/wolf3d/newCode/Tremor/doc/OggVorbis_File.html b/wolf3d/newCode/Tremor/doc/OggVorbis_File.html new file mode 100644 index 0000000..9201d18 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/OggVorbis_File.html @@ -0,0 +1,132 @@ + + + +Tremor - datatype - OggVorbis_File + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

OggVorbis_File

+ +

declared in "ivorbisfile.h"

+ +

+The OggVorbis_File structure defines an Ogg Vorbis file. +

+ +This structure is used in all libvorbisidec routines. Before it can be used, +it must be initialized by ov_open() or ov_open_callbacks(). + +

+After use, the OggVorbis_File structure must be deallocated with a +call to ov_clear(). + +

+Once a file or data source is opened successfully by libvorbisidec +(using ov_open() or ov_open_callbacks()), it is owned by +libvorbisidec. The file should not be used by any other applications or +functions outside of the libvorbisidec API. The file must not be closed +directly by the application at any time after a successful open; +libvorbisidec expects to close the file within ov_clear(). +

+If the call to ov_open() or ov_open_callbacks() fails, +libvorbisidec does not assume ownership of the file and the +application is expected to close it if necessary. + +

+ + + + +
+
typedef struct {
+  void             *datasource; /* Pointer to a FILE *, etc. */
+  int              seekable;
+  ogg_int64_t      offset;
+  ogg_int64_t      end;
+  ogg_sync_state   oy; 
+
+  /* If the FILE handle isn't seekable (eg, a pipe), only the current
+     stream appears */
+  int              links;
+  ogg_int64_t      *offsets;
+  ogg_int64_t      *dataoffsets;
+  long             *serialnos;
+  ogg_int64_t      *pcmlengths;
+  vorbis_info      *vi;
+  vorbis_comment   *vc;
+
+  /* Decoding working state local storage */
+  ogg_int64_t      pcm_offset;
+  int              ready_state;
+  long             current_serialno;
+  int              current_link;
+
+  ogg_int64_t      bittrack;
+  ogg_int64_t      samptrack;
+
+  ogg_stream_state os; /* take physical pages, weld into a logical
+                          stream of packets */
+  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+  vorbis_block     vb; /* local working space for packet->PCM decode */
+
+  ov_callbacks callbacks;
+
+} OggVorbis_File;
+
+ +

Relevant Struct Members

+
+
datasource
+ +
Pointer to file or other ogg source. When using stdio based +file/stream access, this field contains a FILE pointer. When using +custom IO via callbacks, libvorbisidec treats this void pointer as a +black box only to be passed to the callback routines provided by the +application.
+ +
seekable
+
Read-only int indicating whether file is seekable. E.g., a physical file is seekable, a pipe isn't.
+
links
+
Read-only int indicating the number of logical bitstreams within the physical bitstream.
+
ov_callbacks
+
Collection of file manipulation routines to be used on this data source. When using stdio/FILE access via ov_open(), the callbacks will be filled in with stdio calls or wrappers to stdio calls.
+
+ +

Notes

+ +

Tremor requires a native 64 bit integer type to compile and +function; The GNU build system will locate and typedef +ogg_int64_t to the appropriate native type. If not using the +GNU build tools, you will need to define ogg_int64_t as a +64-bit type inside your system's project file/Makefile, etc. On win32, +for example, this should be defined as __int64. +

+ + +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/build.html b/wolf3d/newCode/Tremor/doc/build.html new file mode 100644 index 0000000..6f0f4ee --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/build.html @@ -0,0 +1,111 @@ + + + +Tremor - Build + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Tremor: Building libvorbisidec

+ +

+ +The C source in the Tremor package will build on any ANSI C compiler +and function completely and properly on any platform. The included +build system assumes GNU build system and make tools (m4, automake, +autoconf, libtool and gmake). GCC is not required, although GCC is +the most tested compiler. To build using GNU tools, type in the +source directory: + +

+


+./autogen.sh
+gmake
+
+

+or if GNU make is the standard make on the build system: +


+./autogen.sh
+make
+
+ +

+Currently, the source implements playback in pure C on all platforms +except ARM, where a [currently] small amount of assembly (see the file +asm_arm.h) is used to implement 64 bit math operations and +fast LSP computation. If building on ARM without the benefit of GNU +build system tools, be sure that _ARM_ASSEM_ is #defined by +the build system if this assembly is desired, else the resulting +library will use whatever 64 bit math builtins the compiler +implements. + +

+No math library is required by this source. No floating point +operations are used at any point in either setup or decode. This +decoder library will properly decode any past, current or future +Vorbis I file or stream. + +

+The GNU build system produces static and, when supported by the OS, +dynamic libraries named 'libvorbisidec'. This library exposes an API +nearly identical to the BSD reference library's 'libvorbisfile', +including all the features familiar to users of vorbisfile. This API +is similar enough that the proper header file to include is named +'ivorbisfile.h', included in the source build directory. +Lower level libvorbis-style headers and structures are +in 'ivorbiscodec.h', also included in the source build directory. A +simple example program, ivorbisfile_example.c, can be built with 'make +ivorbisfile_example'. +

+(We've summarized differences between the free, +reference vorbisfile library and Tremor's libvorbisidec in a separate +document.) + +

Notes

+ +

Tremor requires a native 64 bit integer type to compile and +function; The GNU build system will locate and typedef +ogg_int64_t to the appropriate native type. If not using the +GNU build tools, you will need to define ogg_int64_t as a +64-bit type inside your system's project file/Makefile, etc. On win32, +for example, this should be defined as __int64. +

+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + + + + + + + + + + + + + + + + + diff --git a/wolf3d/newCode/Tremor/doc/callbacks.html b/wolf3d/newCode/Tremor/doc/callbacks.html new file mode 100644 index 0000000..9a6d392 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/callbacks.html @@ -0,0 +1,113 @@ + + + +Tremor - Callbacks and non-stdio I/O + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Callbacks and non-stdio I/O

+ +Although stdio is convenient and nearly universally implemented as per +ANSI C, it is not suited to all or even most potential uses of Vorbis. +For additional flexibility, embedded applications may provide their +own I/O functions for use with Tremor when stdio is unavailable or not +suitable. One common example is decoding a Vorbis stream from a +memory buffer.

+ +Use custom I/O functions by populating an ov_callbacks structure and calling ov_open_callbacks() or ov_test_callbacks() rather than the +typical ov_open() or ov_test(). Past the open call, use of +libvorbisidec is identical to using it with stdio. + +

Read function

+ +The read-like function provided in the read_func field is +used to fetch the requested amount of data. It expects the fetch +operation to function similar to file-access, that is, a multiple read +operations will retrieve contiguous sequential pieces of data, +advancing a position cursor after each read.

+ +The following behaviors are also expected:

+

    +
  • a return of '0' indicates end-of-data (if the by-thread errno is unset) +
  • short reads mean nothing special (short reads are not treated as error conditions) +
  • a return of zero with the by-thread errno set to nonzero indicates a read error +
+

+ +

Seek function

+ +The seek-like function provided in the seek_func field is +used to request non-sequential data access by libvorbisidec, moving +the access cursor to the requested position.

+ +libvorbisidec expects the following behavior: +

    +
  • The seek function must always return -1 (failure) if the given +data abstraction is not seekable. It may choose to always return -1 +if the application desires libvorbisidec to treat the Vorbis data +strictly as a stream (which makes for a less expensive open +operation).

    + +

  • If the seek function initially indicates seekability, it must +always succeed upon being given a valid seek request.

    + +

  • The seek function must implement all of SEEK_SET, SEEK_CUR and +SEEK_END. The implementation of SEEK_END should set the access cursor +one past the last byte of accessible data, as would stdio +fseek()

    +

+ +

Close function

+ +The close function should deallocate any access state used by the +passed in instance of the data access abstraction and invalidate the +instance handle. The close function is assumed to succeed.

+ +One common use of callbacks and the close function is to change the +behavior of libvorbisidec with respect to file closure for applications +that must fclose data files themselves. By passing +the normal stdio calls as callback functions, but passing a +close_func that does nothing, an application may call ov_clear() and then fclose() the +file originally passed to libvorbisidec. + +

Tell function

+ +The tell function is intended to mimic the +behavior of ftell() and must return the byte position of the +next data byte that would be read. If the data access cursor is at +the end of the 'file' (pointing to one past the last byte of data, as +it would be after calling fseek(file,SEEK_END,0)), the tell +function must return the data position (and thus the total file size), +not an error.

+ +The tell function need not be provided if the data IO abstraction is +not seekable.
+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/datastructures.html b/wolf3d/newCode/Tremor/doc/datastructures.html new file mode 100644 index 0000000..2b3da07 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/datastructures.html @@ -0,0 +1,61 @@ + + + +Tremor - Base Data Structures + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Base Data Structures

+

There are several data structures used to hold file and bitstream information during libvorbisidec decoding. These structures are declared in "ivorbisfile.h" and "ivorbiscodec.h". +

+

When using libvorbisidec, it's not necessary to know about most of the contents of these data structures, but it may be helpful to understand what they contain. +

+ + + + + + + + + + + + + + + + + + + + + + +
datatypepurpose
OggVorbis_FileThis structure represents the basic file information. It contains + a pointer to the physical file or bitstream and various information about that bitstream.
vorbis_commentThis structure contains the file comments. It contains + a pointer to unlimited user comments, information about the number of comments, and a vendor description.
vorbis_infoThis structure contains encoder-related information about the bitstream. It includes encoder info, channel info, and bitrate limits.
ov_callbacksThis structure contains pointers to the application-specified file manipulation routines set for use by ov_open_callbacks(). See also the provided document on using application-provided callbacks instead of stdio.
+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/decoding.html b/wolf3d/newCode/Tremor/doc/decoding.html new file mode 100644 index 0000000..1f61b47 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/decoding.html @@ -0,0 +1,82 @@ + + + +Tremor - Decoding + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Decoding

+ +

+All libivorbisdec decoding routines are declared in "ivorbisfile.h". +

+ +After initialization, decoding audio +is as simple as calling ov_read(). This +function works similarly to reading from a normal file using +read().

+ +However, a few differences are worth noting: + +

multiple stream links

+ +A Vorbis stream may consist of multiple sections (called links) that +encode differing numbers of channels or sample rates. It is vitally +important to pay attention to the link numbers returned by ov_read and handle audio changes that may +occur at link boundaries. Such multi-section files do exist in the +wild and are not merely a specification curiosity. + +

returned data amount

+ +ov_read does not attempt to completely fill +a large, passed in data buffer; it merely guarantees that the passed +back data does not overflow the passed in buffer size. Large buffers +may be filled by iteratively looping over calls to ov_read (incrementing the buffer pointer) +until the original buffer is filled. + +

file cursor position

+ +Vorbis files do not necessarily start at a sample number or time offset +of zero. Do not be surprised if a file begins at a positive offset of +several minutes or hours, such as would happen if a large stream (such +as a concert recording) is chopped into multiple seperate files. + +

+ + + + + + + + + +
functionpurpose
ov_readThis function makes up the main chunk of a decode loop. It takes an +OggVorbis_File structure, which must have been initialized by a previous +call to ov_open().
+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/diff.html b/wolf3d/newCode/Tremor/doc/diff.html new file mode 100644 index 0000000..ae0b908 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/diff.html @@ -0,0 +1,67 @@ + + + +Tremor - Vorbisfile Differences + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Tremor / Vorbisfile API Differences

+ +

+ +The Tremor libvorbisidec library exposes an API intended to be as +similar as possible to the familiar 'vorbisfile' library included with +the open source Vorbis reference libraries distributed for free by +Xiph.org. Differences are summarized below.

+ +

OggVorbis_File structure

+ +The bittrack and samptrack fields in the OggVorbis_File structure are changed to +64 bit integers in Tremor, from doubles in vorbisfile. + +

Time-related seek and tell function calls

+ +The ov_time_total() and ov_time_tell() functions return milliseconds as +64 bit integers in Tremor. In vorbisfile, these functions returned +seconds as doubles.

+ +In Tremor, the ov_time_seek() and ov_time_seek_page() calls take +seeking positions in milliseconds as 64 bit integers, rather than in +seconds as doubles as in Vorbisfile.

+ +

Reading decoded data

+ +Tremor ov_read() always returns data as +signed 16 bit interleaved PCM in host byte order. As such, it does not +take arguments to request specific signedness, byte order or bit depth +as in Vorbisfile.

+ +Tremor does not implement ov_read_float().

+ + +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/example.html b/wolf3d/newCode/Tremor/doc/example.html new file mode 100644 index 0000000..2b9a1dd --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/example.html @@ -0,0 +1,205 @@ + + + +Tremor - Example Code + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Example Code

+ +

+The following is a run-through of the decoding example program supplied +with libvorbisidec, ivorbisfile_example.c. +This program takes a vorbis bitstream from stdin and writes raw pcm to stdout. + +

+First, relevant headers, including vorbis-specific "ivorbiscodec.h" and "ivorbisfile.h" have to be included. + +

+ + + + +
+

+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "ivorbiscodec.h"
+#include "ivorbisfile.h"
+
+
+

+We also have to make a concession to Windows users here. If we are using windows for decoding, we must declare these libraries so that we can set stdin/stdout to binary. +

+ + + + +
+

+#ifdef _WIN32
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+
+

+Next, a buffer for the pcm audio output is declared. + +

+ + + + +
+

+char pcmout[4096];
+
+
+ +

Inside main(), we declare our primary OggVorbis_File structure. We also declare a few other helpful variables to track out progress within the file. +Also, we make our final concession to Windows users by setting the stdin and stdout to binary mode. +

+ + + + +
+

+int main(int argc, char **argv){
+  OggVorbis_File vf;
+  int eof=0;
+  int current_section;
+
+#ifdef _WIN32
+  _setmode( _fileno( stdin ), _O_BINARY );
+  _setmode( _fileno( stdout ), _O_BINARY );
+#endif
+
+
+ +

ov_open() must be +called to initialize the OggVorbis_File structure with default values. +ov_open() also checks to ensure that we're reading Vorbis format and not something else. + +

+ + + + +
+

+  if(ov_open(stdin, &vf, NULL, 0) < 0) {
+      fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
+      exit(1);
+  }
+
+
+
+ +

+We're going to pull the channel and bitrate info from the file using ov_info() and show them to the user. +We also want to pull out and show the user a comment attached to the file using ov_comment(). + +

+ + + + +
+

+  {
+    char **ptr=ov_comment(&vf,-1)->user_comments;
+    vorbis_info *vi=ov_info(&vf,-1);
+    while(*ptr){
+      fprintf(stderr,"%s\n",*ptr);
+      ++ptr;
+    }
+    fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
+    fprintf(stderr,"\nDecoded length: %ld samples\n",
+            (long)ov_pcm_total(&vf,-1));
+    fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
+  }
+  
+
+
+ +

+Here's the read loop: + +

+ + + + +
+

+
+  while(!eof){
+    long ret=ov_read(&vf,pcmout,sizeof(pcmout),¤t_section);
+    if (ret == 0) {
+      /* EOF */
+      eof=1;
+    } else if (ret < 0) {
+      /* error in the stream.  Not a problem, just reporting it in
+	 case we (the app) cares.  In this case, we don't. */
+    } else {
+      /* we don't bother dealing with sample rate changes, etc, but
+	 you'll have to*/
+      fwrite(pcmout,1,ret,stdout);
+    }
+  }
+
+  
+
+
+ +

+The code is reading blocks of data using ov_read(). +Based on the value returned, we know if we're at the end of the file or have invalid data. If we have valid data, we write it to the pcm output. + +

+Now that we've finished playing, we can pack up and go home. It's important to call ov_clear() when we're finished. + +

+ + + + +
+

+
+  ov_clear(&vf);
+    
+  fprintf(stderr,"Done.\n");
+  return(0);
+}
+
+
+ +

+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/fileinfo.html b/wolf3d/newCode/Tremor/doc/fileinfo.html new file mode 100644 index 0000000..53dfd38 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/fileinfo.html @@ -0,0 +1,95 @@ + + + +Tremor - File Information + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

File Information

+

Libvorbisidec contains many functions to get information about bitstream attributes and decoding status. +

+All libvorbisidec file information routines are declared in "ivorbisfile.h". +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
functionpurpose
ov_bitrateReturns the average bitrate of the current logical bitstream.
ov_bitrate_instantReturns the exact bitrate since the last call of this function, or -1 if at the beginning of the bitream or no new information is available.
ov_streamsGives the number of logical bitstreams within the current physical bitstream.
ov_seekableIndicates whether the bitstream is seekable.
ov_serialnumberReturns the unique serial number of the specified logical bitstream.
ov_raw_totalReturns the total (compressed) bytes in a physical or logical seekable bitstream.
ov_pcm_totalReturns the total number of samples in a physical or logical seekable bitstream.
ov_time_totalReturns the total time length in seconds of a physical or logical seekable bitstream.
ov_raw_tellReturns the byte location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
ov_pcm_tellReturns the sample location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
ov_time_tellReturns the time location of the next sample to be read, giving the approximate location in the stream that the decoding engine has reached.
ov_infoReturns the vorbis_info struct for a specific bitstream section.
ov_commentReturns attached comments for the current bitstream.
+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/index.html b/wolf3d/newCode/Tremor/doc/index.html new file mode 100644 index 0000000..671f13f --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/index.html @@ -0,0 +1,53 @@ + + + +Tremor - Documentation + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Tremor Documentation

+ +

+ +The Tremor Vorbis I stream and file decoder provides an embeddable, +integer-only library [libvorbisidec] intended for decoding all current +and future Vorbis I compliant streams. The Tremor libvorbisidec +library exposes an API intended to be as similar as possible to the +familiar 'vorbisfile' library included with the open source Vorbis +reference libraries distributed for free by Xiph.org.

+ +Tremor can be used along with any ANSI compliant stdio implementation +for file/stream access, or use custom stream i/o routines provided by +the embedded environment. Both uses are described in detail in this +documentation. + +

+Building libvorbisidec
+API overview
+API reference
+Example code
+Tremor / vorbisfile API differences
+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/initialization.html b/wolf3d/newCode/Tremor/doc/initialization.html new file mode 100644 index 0000000..f9f6807 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/initialization.html @@ -0,0 +1,101 @@ + + + +Tremor - Setup/Teardown + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

Setup/Teardown

In order to decode audio using +libvorbisidec, a bitstream containing Vorbis audio must be properly +initialized before decoding and cleared when decoding is finished. +The simplest possible case is to use fopen() to open a Vorbis +file and then pass the FILE * to an ov_open() call. A successful return code from ov_open() indicates the file is ready for use. +Once the file is no longer needed, ov_clear() is used to close the file and +deallocate decoding resources. Do not call fclose() on the +file; libvorbisidec does this in the ov_clear() call. + +

+All libvorbisidec initialization and deallocation routines are declared in "ivorbisfile.h". +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
functionpurpose
ov_openInitializes the Ogg Vorbis bitstream with a pointer to a bitstream and default values. This must be called before other functions in the library may be + used.
ov_open_callbacksInitializes the Ogg Vorbis bitstream with a pointer to a bitstream, default values, and custom file/bitstream manipulation routines. Used instead of ov_open() when working with other than stdio based I/O.
ov_testPartially opens a file just far enough to determine if the file +is an Ogg Vorbis file or not. A successful return indicates that the +file appears to be an Ogg Vorbis file, but the OggVorbis_File struct is not yet fully +initialized for actual decoding. After a successful return, the file +may be closed using ov_clear() or fully +opened for decoding using ov_test_open().

This call is intended to +be used as a less expensive file open test than a full ov_open().

+Note that libvorbisidec owns the passed in file resource is it returns success; do not fclose() files owned by libvorbisidec.

ov_test_callbacksAs above but allowing application-define I/O callbacks.

+Note that libvorbisidec owns the passed in file resource is it returns success; do not fclose() files owned by libvorbisidec.

ov_test_open +Finish opening a file after a successful call to ov_test() or ov_test_callbacks().
ov_clear Closes the + bitstream and cleans up loose ends. Must be called when + finished with the bitstream. After return, the OggVorbis_File struct is + invalid and may not be used before being initialized again + before begin reinitialized. + +
+ +

+


+ + + + + + + + +

copyright © 2002 Xiph.org

Ogg Vorbis

Tremor documentation

Tremor version 1.0 - 20020403

+ + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_bitrate.html b/wolf3d/newCode/Tremor/doc/ov_bitrate.html new file mode 100644 index 0000000..65ebfc3 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_bitrate.html @@ -0,0 +1,72 @@ + + + +Tremor - function - ov_bitrate + + + + + + + + + +

Tremor documentation

Tremor version 1.0 - 20020403

+ +

ov_bitrate

+ +

declared in "ivorbisfile.h";

+ +

This function returns the average bitrate for the specified logical bitstream. This may be different from the ov_info->nominal_bitrate value, as it is based on the actual average for this bitstream if the file is seekable. +

Nonseekable files will return the nominal bitrate setting or the average of the upper and lower bounds, if any of these values are set. +

+ +

+ + + + +
+

+long ov_bitrate(OggVorbis_File *vf,int i);
+
+
+ +

Parameters

+
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
+
i
+
Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the bitrate for the entire bitstream, this parameter should be set to -1.
+
+ + +

Return Values

+
+
  • OV_EINVAL indicates that an invalid argument value was submitted or that the stream represented by vf is not open.
  • +
  • OV_FALSE means the call returned a 'false' status, which in this case most likely indicates that the file is nonseekable and the upper, lower, and nominal bitrates were unset. +
  • n indicates the bitrate for the given logical bitstream or the entire + physical bitstream. If the file is open for random (seekable) access, it will + find the *actual* average bitrate. If the file is streaming (nonseekable), it + returns the nominal bitrate (if set) or else the average of the + upper/lower bounds (if set).
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_bitrate_instant.html b/wolf3d/newCode/Tremor/doc/ov_bitrate_instant.html new file mode 100644 index 0000000..874671f --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_bitrate_instant.html @@ -0,0 +1,65 @@ + + + +Tremor - function - ov_bitrate + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_bitrate_instant

    + +

    declared in "ivorbisfile.h";

    + +

    Used to find the most recent bitrate played back within the file. Will return 0 if the bitrate has not changed or it is the beginning of the file. + +

    + + + + +
    +
    
    +long ov_bitrate_instant(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. +
    + + +

    Return Values

    +
    +
  • 0 indicates the beginning of the file or unchanged bitrate info.
  • +
  • n indicates the actual bitrate since the last call.
  • +
  • OV_FALSE indicates that playback is not in progress, and thus there is no instantaneous bitrate information to report.
  • +
  • OV_EINVAL indicates that the stream represented by vf is not open.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_callbacks.html b/wolf3d/newCode/Tremor/doc/ov_callbacks.html new file mode 100644 index 0000000..776352d --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_callbacks.html @@ -0,0 +1,78 @@ + + + +Tremor - datatype - ov_callbacks + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_callbacks

    + +

    declared in "ivorbiscodec.h"

    + +

    +The ov_callbacks structure contains file manipulation function prototypes necessary for opening, closing, seeking, and location. + +

    +The ov_callbacks structure does not need to be user-defined if you are +working with stdio-based file manipulation; the ov_open() call provides default callbacks for +stdio. ov_callbacks are defined and passed to ov_open_callbacks() when +implementing non-stdio based stream manipulation (such as playback +from a memory buffer). +

    + + + + + +
    +
    typedef struct {
    +  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
    +  int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
    +  int    (*close_func) (void *datasource);
    +  long   (*tell_func)  (void *datasource);
    +} ov_callbacks;
    +
    + +

    Relevant Struct Members

    +
    +
    read_func
    +
    Pointer to custom data reading function.
    +
    seek_func
    +
    Pointer to custom data seeking function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided seek callback should always return -1 (failure).
    +
    close_func
    +
    Pointer to custom data source closure function.
    +
    tell_func
    +
    Pointer to custom data location function.
    +
    + +

    + +See the callbacks and non-stdio I/O document for more +detailed information on required behavior of the various callback +functions.

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_clear.html b/wolf3d/newCode/Tremor/doc/ov_clear.html new file mode 100644 index 0000000..7c51bb7 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_clear.html @@ -0,0 +1,64 @@ + + + +Tremor - function - ov_clear + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_clear

    + +

    declared in "ivorbisfile.h";

    + +

    After a bitstream has been opened using ov_open()/ov_open_callbacks() and decoding is complete, the application must call ov_clear() to clear +the decoder's buffers and close the file.

    + +ov_clear() must also be called after a successful call to ov_test() or ov_test_callbacks().

    + +

    + + + + +
    +
    
    +int ov_clear(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. After ov_clear has been called, the structure is deallocated and can no longer be used.
    +
    + + +

    Return Values

    +
    +
  • 0 for success
  • +
    + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_comment.html b/wolf3d/newCode/Tremor/doc/ov_comment.html new file mode 100644 index 0000000..5d9cc0b --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_comment.html @@ -0,0 +1,66 @@ + + + +Tremor - function - ov_bitrate + + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_comment

    + +

    declared in "ivorbisfile.h";

    + +

    Returns a pointer to the vorbis_comment struct for the specified bitstream. For nonseekable streams, returns the struct for the current bitstream. +

    + +

    + + + + +
    +
    
    +vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_comment struct for the current bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • Returns the vorbis_comment struct for the specified bitstream.
  • +
  • NULL if the specified bitstream does not exist or the file has been initialized improperly.
  • +
    +

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_info.html b/wolf3d/newCode/Tremor/doc/ov_info.html new file mode 100644 index 0000000..d783bf3 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_info.html @@ -0,0 +1,64 @@ + + + +Tremor - function - ov_info + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_info

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the vorbis_info struct for the specified bitstream. For nonseekable files, always returns the current vorbis_info struct. + +

    + + + + +
    +
    
    +vorbis_info *ov_info(OggVorbis_File *vf,int link);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_info struct for the current bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • Returns the vorbis_info struct for the specified bitstream. Returns vorbis_info for current bitstream if the file is nonseekable or i=-1.
  • +
  • NULL if the specified bitstream does not exist or the file has been initialized improperly.
  • +
    +

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_open.html b/wolf3d/newCode/Tremor/doc/ov_open.html new file mode 100644 index 0000000..654cae8 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_open.html @@ -0,0 +1,115 @@ + + + +Tremor - function - ov_open + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_open

    + +

    declared in "ivorbisfile.h";

    + +

    This is the main function used to open and initialize an OggVorbis_File +structure. It sets up all the related decoding structure. +

    The first argument must be a file pointer to an already opened file +or pipe (it need not be seekable--though this obviously restricts what +can be done with the bitstream). vf should be a pointer to the +OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions. +

    Also, you should be aware that ov_open(), once successful, takes complete possession of the file resource. After you have opened a file using ov_open(), you MUST close it using ov_clear(), not fclose() or any other function. +

    +It is often useful to call ov_open() +simply to determine whether a given file is a vorbis bitstream. If the +ov_open() +call fails, then the file is not recognizable as such. +When you use ov_open() +for +this, you should fclose() the file pointer if, and only if, the +ov_open() +call fails. If it succeeds, you must call ov_clear() to clear +the decoder's buffers and close the file for you.

    + +(Note that ov_test() provides a less expensive way to test a file for Vorbisness.)

    + +

    + + + + +
    +
    
    +int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
    +
    +
    + +

    Parameters

    +
    +
    f
    +
    File pointer to an already opened file +or pipe (it need not be seekable--though this obviously restricts what +can be done with the bitstream).
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions.
    +
    initial
    +
    Typically set to NULL. This parameter is useful if some data has already been +read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial +should be a pointer to a buffer containing the data read.
    +
    ibytes
    +
    Typically set to 0. This parameter is useful if some data has already been +read from the file and the stream is not seekable. In this case, ibytes +should contain the length (in bytes) of the buffer. Used together with initial
    +
    + + +

    Return Values

    +
    +
  • 0 indicates success
  • + +
  • less than zero for failure:
  • +
      +
    • OV_EREAD - A read from media returned an error.
    • +
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • +
    • OV_EVERSION - Vorbis version mismatch.
    • +
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • +
    +
    +

    + +

    Notes

    +

    If your decoder is threaded, it is recommended that you NOT call +ov_open() +in the main control thread--instead, call ov_open() IN your decode/playback +thread. This is important because ov_open() may be a fairly time-consuming +call, given that the full structure of the file is determined at this point, +which may require reading large parts of the file under certain circumstances +(determining all the logical bitstreams in one physical bitstream, for +example). See Thread Safety for other information on using libvorbisidec with threads. + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_open_callbacks.html b/wolf3d/newCode/Tremor/doc/ov_open_callbacks.html new file mode 100644 index 0000000..64a2a92 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_open_callbacks.html @@ -0,0 +1,110 @@ + + + +Tremor - function - ov_open_callbacks + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_open_callbacks

    + +

    declared in "ivorbisfile.h";

    + +

    This is an alternative function used to open and initialize an OggVorbis_File +structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structure. +

    Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions. +

    +It is often useful to call ov_open_callbacks() +simply to determine whether a given file is a vorbis bitstream. If the +ov_open_callbacks() +call fails, then the file is not recognizable as such. When you use ov_open_callbacks() +for +this, you should fclose() the file pointer if, and only if, the +ov_open_callbacks() +call fails. If it succeeds, you must call ov_clear() to clear +the decoder's buffers and close the file for you.

    + +See also Callbacks and Non-stdio I/O for information on designing and specifying the required callback functions.

    + +

    + + + + +
    +
    
    +int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
    +
    +
    + +

    Parameters

    +
    +
    f
    +
    File pointer to an already opened file +or pipe (it need not be seekable--though this obviously restricts what +can be done with the bitstream).
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions.
    +
    initial
    +
    Typically set to NULL. This parameter is useful if some data has already been +read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial +should be a pointer to a buffer containing the data read.
    +
    ibytes
    +
    Typically set to 0. This parameter is useful if some data has already been +read from the file and the stream is not seekable. In this case, ibytes +should contain the length (in bytes) of the buffer. Used together with initial.
    +
    callbacks
    +
    Pointer to a completed ov_callbacks struct which indicates desired custom file manipulation routines.
    +
    + + +

    Return Values

    +
    +
  • 0 for success
  • +
  • less than zero for failure:
  • +
      +
    • OV_EREAD - A read from media returned an error.
    • +
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • +
    • OV_EVERSION - Vorbis version mismatch.
    • +
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • +
    +
    +

    + +

    Notes

    +

    If your decoder is threaded, it is recommended that you NOT call +ov_open_callbacks() +in the main control thread--instead, call ov_open_callbacks() IN your decode/playback +thread. This is important because ov_open_callbacks() may be a fairly time-consuming +call, given that the full structure of the file is determined at this point, +which may require reading large parts of the file under certain circumstances +(determining all the logical bitstreams in one physical bitstream, for +example). +See Thread Safety for other information on using libvorbisidec with threads. + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_pcm_seek.html b/wolf3d/newCode/Tremor/doc/ov_pcm_seek.html new file mode 100644 index 0000000..cf0351e --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_pcm_seek.html @@ -0,0 +1,81 @@ + + + +Tremor - function - ov_pcm_seek + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_pcm_seek

    + +

    declared in "ivorbisfile.h";

    + +

    Seeks to the offset specified (in pcm samples) within the physical bitstream. This function only works for seekable streams. +

    This also updates everything needed within the +decoder, so you can immediately call ov_read() and get data from +the newly seeked to position. +

    + +

    + + + + +
    +
    
    +int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    pos
    +
    Position in pcm samples to seek to in the bitstream.
    +
    + + +

    Return Values

    +
    +
  • 0 for success
  • + +
  • +nonzero indicates failure, described by several error codes:
  • +
      +
    • OV_ENOSEEK - Bitstream is not seekable. +
    • +
    • OV_EINVAL - Invalid argument value. +
    • +
    • OV_EREAD - A read from media returned an error. +
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack + corruption. +
    • +
    • OV_EBADLINK - Invalid stream section supplied to libvorbisidec, or the requested link is corrupt. +
    • +
    + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_pcm_seek_page.html b/wolf3d/newCode/Tremor/doc/ov_pcm_seek_page.html new file mode 100644 index 0000000..44468a8 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_pcm_seek_page.html @@ -0,0 +1,83 @@ + + + +Tremor - function - ov_pcm_seek_page + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_pcm_seek_page

    + +

    declared in "ivorbisfile.h";

    + +

    Seeks to the closest page preceding the specified location (in pcm samples) within the physical bitstream. This function only works for seekable streams. +

    This function is faster than ov_pcm_seek because the function can begin decoding at a page boundary rather than seeking through any remaining samples before the specified location. However, it is less accurate. +

    This also updates everything needed within the +decoder, so you can immediately call ov_read() and get data from +the newly seeked to position. +

    + +

    + + + + +
    +
    
    +int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    pos
    +
    Position in pcm samples to seek to in the bitstream.
    +
    + + +

    Return Values

    +
    +
  • +0 for success
  • + +
  • +nonzero indicates failure, described by several error codes:
  • +
      +
    • OV_ENOSEEK - Bitstream is not seekable. +
    • +
    • OV_EINVAL - Invalid argument value. +
    • +
    • OV_EREAD - A read from media returned an error. +
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack + corruption. +
    • +
    • OV_EBADLINK - Invalid stream section supplied to libvorbisidec, or the requested link is corrupt. +
    • +
    + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_pcm_tell.html b/wolf3d/newCode/Tremor/doc/ov_pcm_tell.html new file mode 100644 index 0000000..0bb98d7 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_pcm_tell.html @@ -0,0 +1,63 @@ + + + +Tremor - function - ov_pcm_tell + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_pcm_tell

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the current offset in samples. + +

    + + + + +
    +
    
    +ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    + + +

    Return Values

    +
    +
  • n indicates the current offset in samples.
  • +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_pcm_total.html b/wolf3d/newCode/Tremor/doc/ov_pcm_total.html new file mode 100644 index 0000000..a19744a --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_pcm_total.html @@ -0,0 +1,67 @@ + + + +Tremor - function - ov_pcm_total + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_pcm_total

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the total pcm samples of the physical bitstream or a specified logical bitstream. + +

    + + + + +
    +
    
    +ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. To retrieve the total pcm samples for the entire physical bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is unseekable.
  • +
  • +total length in pcm samples of content if i=-1.
  • +
  • length in pcm samples of logical bitstream if i=1 to n.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_raw_seek.html b/wolf3d/newCode/Tremor/doc/ov_raw_seek.html new file mode 100644 index 0000000..e7f0bd3 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_raw_seek.html @@ -0,0 +1,75 @@ + + + +Tremor - function - ov_raw_seek + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_raw_seek

    + +

    declared in "ivorbisfile.h";

    + +

    Seeks to the offset specified (in compressed raw bytes) within the physical bitstream. This function only works for seekable streams. +

    This also updates everything needed within the +decoder, so you can immediately call ov_read() and get data from +the newly seeked to position. +

    When seek speed is a priority, this is the best seek funtion to use. +

    + + + + +
    +
    
    +int ov_raw_seek(OggVorbis_File *vf,long pos);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    pos
    +
    Position in compressed bytes to seek to in the bitstream.
    +
    + + +

    Return Values

    +
    +
  • 0 indicates success
  • +
  • nonzero indicates failure, described by several error codes:
  • +
      +
    • OV_ENOSEEK - Bitstream is not seekable. +
    • +
    • OV_EINVAL - Invalid argument value. +
    • +
    • OV_EBADLINK - Invalid stream section supplied to libvorbisidec, or the requested link is corrupt. +
    • +
    +
    +

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_raw_tell.html b/wolf3d/newCode/Tremor/doc/ov_raw_tell.html new file mode 100644 index 0000000..f0d1f6a --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_raw_tell.html @@ -0,0 +1,63 @@ + + + +Tremor - function - ov_raw_tell + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_raw_tell

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the current offset in raw compressed bytes. + +

    + + + + +
    +
    
    +ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    + + +

    Return Values

    +
    +
  • n indicates the current offset in bytes.
  • +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_raw_total.html b/wolf3d/newCode/Tremor/doc/ov_raw_total.html new file mode 100644 index 0000000..d0af35f --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_raw_total.html @@ -0,0 +1,68 @@ + + + +Tremor - function - ov_raw_total + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_raw_total

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the total (compressed) bytes of the physical bitstream or a specified logical bitstream. + +

    + + + + +
    +
    
    +ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. To retrieve the total bytes for the entire physical bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is nonseekable
  • +
  • n +total length in compressed bytes of content if i=-1.
  • +
  • n length in compressed bytes of logical bitstream if i=1 to n.
  • +
    +

    + + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_read.html b/wolf3d/newCode/Tremor/doc/ov_read.html new file mode 100644 index 0000000..208ef18 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_read.html @@ -0,0 +1,115 @@ + + + +Tremor - function - ov_read + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_read()

    + +

    declared in "ivorbisfile.h";

    + +

    + This is the main function used to decode a Vorbis file within a + loop. It returns up to the specified number of bytes of decoded audio + in host-endian, signed 16 bit PCM format. If the audio is + multichannel, the channels are interleaved in the output buffer. + If the passed in buffer is large, ov_read() will not fill + it; the passed in buffer size is treated as a limit and + not a request. +

    + +Note that up to this point, the Tremor API could more or less hide the + multiple logical bitstream nature of chaining from the toplevel + application if the toplevel application didn't particularly care. + However, when reading audio back, the application must be aware + that multiple bitstream sections do not necessarily use the same + number of channels or sampling rate.

    ov_read() passes + back the index of the sequential logical bitstream currently being + decoded (in *bitstream) along with the PCM data in order + that the toplevel application can handle channel and/or sample + rate changes. This number will be incremented at chaining + boundaries even for non-seekable streams. For seekable streams, it + represents the actual chaining index within the physical bitstream. +

    + +

    + + + + +
    +
    
    +long ov_read(OggVorbis_File *vf, char *buffer, int length, int *bitstream);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    buffer
    +
    A pointer to an output buffer. The decoded output is inserted into this buffer.
    +
    length
    +
    Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.
    +
    bitstream
    +
    A pointer to the number of the current logical bitstream.
    +
    + + +

    Return Values

    +
    +
    +
    OV_HOLE
    +
    indicates there was an interruption in the data. +
    (one of: garbage between pages, loss of sync followed by + recapture, or a corrupt page)
    +
    OV_EBADLINK
    +
    indicates that an invalid stream section was supplied to + libvorbisidec, or the requested link is corrupt.
    +
    0
    +
    indicates EOF
    +
    n
    +
    indicates actual number of bytes read. ov_read() will + decode at most one vorbis packet per invocation, so the value + returned will generally be less than length. +
    +
    + +

    Notes

    +

    Typical usage: +

    +bytes_read = ov_read(&vf, +buffer, 4096,&current_section) +
    + +This reads up to 4096 bytes into a buffer, with signed 16-bit +little-endian samples. +

    + + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_seekable.html b/wolf3d/newCode/Tremor/doc/ov_seekable.html new file mode 100644 index 0000000..9bd7fc3 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_seekable.html @@ -0,0 +1,63 @@ + + + +Tremor - function - ov_seekable + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_seekable

    + +

    declared in "ivorbisfile.h";

    + +

    This indicates whether or not the bitstream is seekable. + + +

    + + + + +
    +
    
    +long ov_seekable(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    + + +

    Return Values

    +
    +
  • 0 indicates that the file is not seekable.
  • +
  • nonzero indicates that the file is seekable.
  • +
    +

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_serialnumber.html b/wolf3d/newCode/Tremor/doc/ov_serialnumber.html new file mode 100644 index 0000000..d7d7c62 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_serialnumber.html @@ -0,0 +1,67 @@ + + + +Tremor - function - ov_serialnumber + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_serialnumber

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the serialnumber of the specified logical bitstream link number within the overall physical bitstream. + +

    + + + + +
    +
    
    +long ov_serialnumber(OggVorbis_File *vf,int i);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the serial number of the current bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • +-1 if the specified logical bitstream i does not exist.
  • + +
  • Returns the serial number of the logical bitstream i or the serial number of the current bitstream if the file is nonseekable.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_streams.html b/wolf3d/newCode/Tremor/doc/ov_streams.html new file mode 100644 index 0000000..7ffee42 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_streams.html @@ -0,0 +1,64 @@ + + + +Tremor - function - ov_streams + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_streams

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the number of logical bitstreams within our physical bitstream. + +

    + + + + +
    +
    
    +long ov_streams(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    + + +

    Return Values

    +
    +
  • +1 indicates a single logical bitstream or an unseekable file.
  • +
  • n indicates the number of logical bitstreams.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_test.html b/wolf3d/newCode/Tremor/doc/ov_test.html new file mode 100644 index 0000000..96a9af0 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_test.html @@ -0,0 +1,89 @@ + + + +Tremor - function - ov_test + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_test

    + +

    declared in "ivorbisfile.h";

    + +

    +This partially opens a vorbis file to test for Vorbis-ness. It loads +the headers for the first chain, and tests for seekability (but does not seek). +Use ov_test_open() to finish opening the file +or ov_clear to close/free it. +

    + + + + + +
    +
    
    +int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
    +
    +
    + +

    Parameters

    +
    +
    f
    +
    File pointer to an already opened file +or pipe (it need not be seekable--though this obviously restricts what +can be done with the bitstream).
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions.
    +
    initial
    +
    Typically set to NULL. This parameter is useful if some data has already been +read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial +should be a pointer to a buffer containing the data read.
    +
    ibytes
    +
    Typically set to 0. This parameter is useful if some data has already been +read from the file and the stream is not seekable. In this case, ibytes +should contain the length (in bytes) of the buffer. Used together with initial
    +
    + + +

    Return Values

    +
    +
  • 0 for success
  • + +
  • less than zero for failure:
  • +
      +
    • OV_EREAD - A read from media returned an error.
    • +
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • +
    • OV_EVERSION - Vorbis version mismatch.
    • +
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • +
    +
    +

    + + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_test_callbacks.html b/wolf3d/newCode/Tremor/doc/ov_test_callbacks.html new file mode 100644 index 0000000..4049548 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_test_callbacks.html @@ -0,0 +1,90 @@ + + + +Tremor - function - ov_test_callbacks + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_test_callbacks

    + +

    declared in "ivorbisfile.h";

    + +

    This is an alternative function used to open and test an OggVorbis_File +structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structures. +

    Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions. +

    +

    + + + + +
    +
    
    +int ov_test_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
    +
    +
    + +

    Parameters

    +
    +
    f
    +
    File pointer to an already opened file +or pipe (it need not be seekable--though this obviously restricts what +can be done with the bitstream).
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions.
    +
    initial
    +
    Typically set to NULL. This parameter is useful if some data has already been +read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial +should be a pointer to a buffer containing the data read.
    +
    ibytes
    +
    Typically set to 0. This parameter is useful if some data has already been +read from the file and the stream is not seekable. In this case, ibytes +should contain the length (in bytes) of the buffer. Used together with initial.
    +
    callbacks
    +
    Pointer to a completed ov_callbacks struct which indicates desired custom file manipulation routines.
    +
    + + +

    Return Values

    +
    +
  • 0 for success
  • +
  • less than zero for failure:
  • +
      +
    • OV_EREAD - A read from media returned an error.
    • +
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • +
    • OV_EVERSION - Vorbis version mismatch.
    • +
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • +
    +
    +

    + + + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_test_open.html b/wolf3d/newCode/Tremor/doc/ov_test_open.html new file mode 100644 index 0000000..74f4410 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_test_open.html @@ -0,0 +1,82 @@ + + + +Tremor - function - ov_test_open + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_test_open

    + +

    declared in "ivorbisfile.h";

    + +

    +Finish opening a file partially opened with ov_test() +or ov_test_callbacks(). +

    + + + + + +
    +
    
    +int ov_test_open(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions. Once this has been called, the same OggVorbis_File +struct should be passed to all the libvorbisidec functions.
    +
    + + +

    Return Values

    +
    +
  • +0 for success
  • + +
  • less than zero for failure:
  • +
      +
    • OV_EREAD - A read from media returned an error.
    • +
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • +
    • OV_EVERSION - Vorbis version mismatch.
    • +
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • +
    +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + + + + + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_time_seek.html b/wolf3d/newCode/Tremor/doc/ov_time_seek.html new file mode 100644 index 0000000..6dfa130 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_time_seek.html @@ -0,0 +1,70 @@ + + + +Tremor - function - ov_time_seek + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_time_seek

    + +

    declared in "ivorbisfile.h";

    + +

    For seekable +streams, this seeks to the given time. For implementing seeking in a player, +this is the only function generally needed. This also updates everything needed within the +decoder, so you can immediately call ov_read() and get data from +the newly seeked to position. This function does not work for unseekable streams. + +

    + + + + +
    +
    
    +int ov_time_seek(OggVorbis_File *vf, ogg_int64_t ms);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    Pointer to our already opened and initialized OggVorbis_File structure.
    +
    ms
    +
    Location to seek to within the file, specified in milliseconds.
    +
    + + +

    Return Values

    +
    +
  • +0 for success
  • + +
  • +Nonzero for failure
  • +
    + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_time_seek_page.html b/wolf3d/newCode/Tremor/doc/ov_time_seek_page.html new file mode 100644 index 0000000..83cfefb --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_time_seek_page.html @@ -0,0 +1,83 @@ + + + +Tremor - function - ov_time_seek_page + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_time_seek_page

    + +

    declared in "ivorbisfile.h";

    + +

    For seekable +streams, this seeks to closest full page preceding the given time. This function is faster than ov_time_seek because it doesn't seek through the last few samples to reach an exact time, but it is also less accurate. This should be used when speed is important. +

    This function also updates everything needed within the +decoder, so you can immediately call ov_read() and get data from +the newly seeked to position. +

    This function does not work for unseekable streams. + +

    + + + + +
    +
    
    +int ov_time_seek_page(OggVorbis_File *vf, ogg_int64_t ms);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    Pointer to our already opened and initialized OggVorbis_File structure.
    +
    ms
    +
    Location to seek to within the file, specified in milliseconds.
    +
    + + +

    Return Values

    +
    +
  • +0 for success
  • + +
  • +nonzero indicates failure, described by several error codes:
  • +
      +
    • OV_ENOSEEK - Bitstream is not seekable. +
    • +
    • OV_EINVAL - Invalid argument value. +
    • +
    • OV_EREAD - A read from media returned an error. +
    • +
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack + corruption. +
    • +
    • OV_EBADLINK - Invalid stream section supplied to libvorbisidec, or the requested link is corrupt. +
    • +
    + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_time_tell.html b/wolf3d/newCode/Tremor/doc/ov_time_tell.html new file mode 100644 index 0000000..25d159b --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_time_tell.html @@ -0,0 +1,63 @@ + + + +Tremor - function - ov_bitrate + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_time_tell

    + +

    declared in "ivorbisfile.h";

    + +

    Returns the current decoding offset in milliseconds. + +

    + + + + +
    +
    
    +ogg_int64_t ov_time_tell(OggVorbis_File *vf);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    + + +

    Return Values

    +
    +
  • n indicates the current decoding time offset in milliseconds.
  • +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist.
  • +
    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/ov_time_total.html b/wolf3d/newCode/Tremor/doc/ov_time_total.html new file mode 100644 index 0000000..7c26b92 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/ov_time_total.html @@ -0,0 +1,67 @@ + + + +Tremor - function - ov_time_total + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    ov_time_total

    + +

    declared in "ivorbisfile.h";

    + + +

    Returns the total time in seconds of the physical bitstream or a specified logical bitstream. + + +

    + + + + +
    +
    
    +ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
    +
    +
    + +

    Parameters

    +
    +
    vf
    +
    A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec +functions.
    +
    i
    +
    Link to the desired logical bitstream. To retrieve the time total for the entire physical bitstream, this parameter should be set to -1.
    +
    + + +

    Return Values

    +
    +
  • OV_EINVAL means that the argument was invalid. In this case, the requested bitstream did not exist or the bitstream is nonseekable.
  • +
  • n total length in milliseconds of content if i=-1.
  • +
  • n length in milliseconds of logical bitstream if i=1 to n.
  • +
    +

    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/overview.html b/wolf3d/newCode/Tremor/doc/overview.html new file mode 100644 index 0000000..0c82cb2 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/overview.html @@ -0,0 +1,61 @@ + + + +Tremor - API Overview + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    Tremor API Overview

    + +

    The makeup of the Tremor libvorbisidec library API is relatively +simple. It revolves around a single file resource. This file resource is +passed to libvorbisidec, where it is opened, manipulated, and closed, +in the form of an OggVorbis_File +struct. +

    +The Tremor API consists of the following functional categories: +

    +

    +

    +In addition, the following subjects deserve attention additional to +the above general overview: +

    +

    +

    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + + diff --git a/wolf3d/newCode/Tremor/doc/reference.html b/wolf3d/newCode/Tremor/doc/reference.html new file mode 100644 index 0000000..20e0a5f --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/reference.html @@ -0,0 +1,75 @@ + + + +Tremor API Reference + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    Tremor API Reference

    + +

    +Data Structures
    +OggVorbis_File
    +vorbis_comment
    +vorbis_info
    +ov_callbacks
    +
    +Setup/Teardown
    +ov_open()
    +ov_open_callbacks()
    +ov_clear()
    +ov_test()
    +ov_test_callbacks()
    +ov_test_open()
    +
    +Decoding
    +ov_read()
    +
    +Seeking
    +ov_raw_seek()
    +ov_pcm_seek()
    +ov_time_seek()
    +ov_pcm_seek_page()
    +ov_time_seek_page()
    +
    +File Information
    +ov_bitrate()
    +ov_bitrate_instant()
    +ov_streams()
    +ov_seekable()
    +ov_serialnumber()
    +ov_raw_total()
    +ov_pcm_total()
    +ov_time_total()
    +ov_raw_tell()
    +ov_pcm_tell()
    +ov_time_tell()
    +ov_info()
    +ov_comment()
    +
    +Return Codes
    + + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/return.html b/wolf3d/newCode/Tremor/doc/return.html new file mode 100644 index 0000000..0a3f96c --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/return.html @@ -0,0 +1,77 @@ + + + +Tremor - Return Codes + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    Return Codes

    + +

    + +The following return codes are #defined in "ivorbiscodec.h" +may be returned by libvorbisidec. Descriptions of a code relevant to +a specific function are found in the reference description of that +function. + +

    + +
    OV_FALSE
    +
    Not true, or no data available
    + +
    OV_HOLE
    +
    Tremor encoutered missing or corrupt data in the bitstream. Recovery +is normally automatic and this return code is for informational purposes only.
    + +
    OV_EREAD
    +
    Read error while fetching compressed data for decode
    + +
    OV_EFAULT
    +
    Internal inconsistency in decode state. Continuing is likely not possible.
    + +
    OV_EIMPL
    +
    Feature not implemented
    + +
    OV_EINVAL
    +
    Either an invalid argument, or incompletely initialized argument passed to libvorbisidec call
    + +
    OV_ENOTVORBIS
    +
    The given file/data was not recognized as Ogg Vorbis data.
    + +
    OV_EBADHEADER
    +
    The file/data is apparently an Ogg Vorbis stream, but contains a corrupted or undecipherable header.
    + +
    OV_EVERSION
    +
    The bitstream format revision of the given stream is not supported.
    + +
    OV_EBADLINK
    +
    The given link exists in the Vorbis data stream, but is not decipherable due to garbacge or corruption.
    + +
    OV_ENOSEEK
    +
    The given stream is not seekable
    + +
    + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/seeking.html b/wolf3d/newCode/Tremor/doc/seeking.html new file mode 100644 index 0000000..652368a --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/seeking.html @@ -0,0 +1,74 @@ + + + +Tremor - Seeking + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    Seeking

    +

    Seeking functions allow you to specify a specific point in the stream to begin or continue decoding. +

    +All libvorbisidec seeking routines are declared in "ivorbisfile.h". + +

    Certain seeking functions are best suited to different situations. +When speed is important and exact positioning isn't required, +page-level seeking should be used. Note also that Vorbis files do not +necessarily start at a sample number or time offset of zero. Do not +be surprised if a file begins at a positive offset of several minutes +or hours, such as would happen if a large stream (such as a concert +recording) is chopped into multiple separate files. Requesting to +seek to a position before the beginning of such a file will seek to +the position where audio begins.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    functionpurpose
    ov_raw_seekThis function seeks to a position specified in the compressed bitstream, specified in bytes.
    ov_pcm_seekThis function seeks to a specific audio sample number, specified in pcm samples.
    ov_pcm_seek_pageThis function seeks to the closest page preceding the specified audio sample number, specified in pcm samples.
    ov_time_seekThis function seeks to the specific time location in the bitstream, specified in integer milliseconds. Note that this differs from the reference vorbisfile implementation, which takes seconds as a float.
    ov_time_seek_pageThis function seeks to the closest page preceding the specified time position in the bitstream, specified in integer milliseconds.
    + +

    +


    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/style.css b/wolf3d/newCode/Tremor/doc/style.css new file mode 100644 index 0000000..81cf417 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/style.css @@ -0,0 +1,7 @@ +BODY { font-family: Helvetica, sans-serif } +TD { font-family: Helvetica, sans-serif } +P { font-family: Helvetica, sans-serif } +H1 { font-family: Helvetica, sans-serif } +H2 { font-family: Helvetica, sans-serif } +H4 { font-family: Helvetica, sans-serif } +P.tiny { font-size: 8pt } diff --git a/wolf3d/newCode/Tremor/doc/threads.html b/wolf3d/newCode/Tremor/doc/threads.html new file mode 100644 index 0000000..53ed76a --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/threads.html @@ -0,0 +1,50 @@ + + + +Tremor - Thread Safety + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    Thread Safety

    + +Tremor's libvorbisidec may be used safely in a threading environment +so long as thread access to individual OggVorbis_File instances is serialized. +
      + +
    • Only one thread at a time may enter a function that takes a given OggVorbis_File instance, even if the +functions involved appear to be read-only.

      + +

    • Multiple threads may enter +libvorbisidec at a given time, so long as each thread's function calls +are using different OggVorbis_File +instances.

      + +

    • Any one OggVorbis_File instance may be used safely from multiple threads so long as only one thread at a time is making calls using that instance.

      +

    + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/vorbis_comment.html b/wolf3d/newCode/Tremor/doc/vorbis_comment.html new file mode 100644 index 0000000..3232d96 --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/vorbis_comment.html @@ -0,0 +1,70 @@ + + + +Tremor - datatype - vorbis_comment + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    vorbis_comment

    + +

    declared in "ivorbiscodec.h"

    + +

    +The vorbis_comment structure defines an Ogg Vorbis comment. +

    +Only the fields the program needs must be defined. If a field isn't +defined by the application, it will either be blank (if it's a string value) +or set to some reasonable default (usually 0). +

    + + + + + +
    +
    typedef struct vorbis_comment{
    +  /* unlimited user comment fields. */
    +  char **user_comments;
    +  int  *comment_lengths;
    +  int  comments;
    +  char *vendor;
    +
    +} vorbis_comment;
    +
    + +

    Parameters

    +
    +
    user_comments
    +
    Unlimited user comment array. The individual strings in the array are 8 bit clean, by the Vorbis specification, and as such the comment_lengths array should be consulted to determine string length. For convenience, each string is also NULL-terminated by the decode library (although Vorbis comments are not NULL terminated within the bitstream itself).
    +
    comment_lengths
    +
    An int array that stores the length of each comment string
    +
    comments
    +
    Int signifying number of user comments in user_comments field.
    +
    vendor
    +
    Information about the creator of the file. Stored in a standard C 0-terminated string.
    +
    + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/doc/vorbis_info.html b/wolf3d/newCode/Tremor/doc/vorbis_info.html new file mode 100644 index 0000000..bd938cd --- /dev/null +++ b/wolf3d/newCode/Tremor/doc/vorbis_info.html @@ -0,0 +1,80 @@ + + + +Tremor - datatype - vorbis_info + + + + + + + + + +

    Tremor documentation

    Tremor version 1.0 - 20020403

    + +

    vorbis_info

    + +

    declared in "ivorbiscodec.h"

    + +

    +The vorbis_info structure contains basic information about the audio in a vorbis bitstream. +

    + + + + + +
    +
    typedef struct vorbis_info{
    +  int version;
    +  int channels;
    +  long rate;
    +  
    +  long bitrate_upper;
    +  long bitrate_nominal;
    +  long bitrate_lower;
    +  long bitrate_window;
    +
    +  void *codec_setup;
    +
    +} vorbis_info;
    +
    + +

    Relevant Struct Members

    +
    +
    version
    +
    Vorbis encoder version used to create this bitstream.
    +
    channels
    +
    Int signifying number of channels in bitstream.
    +
    rate
    +
    Sampling rate of the bitstream.
    +
    bitrate_upper
    +
    Specifies the upper limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_lower parameters, the stream is fixed bitrate. May be unset if no limit exists.
    +
    bitrate_nominal
    +
    Specifies the average bitrate for a VBR bitstream. May be unset. If the bitrate_upper and bitrate_lower parameters match, the stream is fixed bitrate.
    +
    bitrate_lower
    +
    Specifies the lower limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_upper parameters, the stream is fixed bitrate. May be unset if no limit exists.
    +
    bitrate_window
    +
    Currently unset.
    + +
    codec_setup
    +
    Internal structure that contains the detailed/unpacked configuration for decoding the current Vorbis bitstream.
    +
    + + +

    +
    + + + + + + + + +

    copyright © 2002 Xiph.org

    Ogg Vorbis

    Tremor documentation

    Tremor version 1.0 - 20020403

    + + + + diff --git a/wolf3d/newCode/Tremor/floor0.c b/wolf3d/newCode/Tremor/floor0.c new file mode 100644 index 0000000..bdb83b8 --- /dev/null +++ b/wolf3d/newCode/Tremor/floor0.c @@ -0,0 +1,435 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: floor backend 0 implementation + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "block.h" + +#define LSP_FRACBITS 14 + +typedef struct { + long n; + int ln; + int m; + int *linearmap; + + vorbis_info_floor0 *vi; + ogg_int32_t *lsp_look; + +} vorbis_look_floor0; + +/*************** LSP decode ********************/ + +#include "lsp_lookup.h" + +/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in + 16.16 format + returns in m.8 format */ + +static long ADJUST_SQRT2[2]={8192,5792}; +STIN ogg_int32_t vorbis_invsqlook_i(long a,long e){ + long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); + long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */ + long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ + ((INVSQ_LOOKUP_IDel[i]*d)>>INVSQ_LOOKUP_I_SHIFT); /* result 1.16 */ + val*=ADJUST_SQRT2[e&1]; + e=(e>>1)+21; + return(val>>e); +} + +/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ +/* a is in n.12 format */ +STIN ogg_int32_t vorbis_fromdBlook_i(long a){ + int i=(-a)>>(12-FROMdB2_SHIFT); + if(i<0) return 0x7fffffff; + if(i>=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT] * FROMdB2_LOOKUP[i&FROMdB2_MASK]; +} + +/* interpolated lookup based cos function, domain 0 to PI only */ +/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ +STIN ogg_int32_t vorbis_coslook_i(long a){ + int i=a>>COS_LOOKUP_I_SHIFT; + int d=a&COS_LOOKUP_I_MASK; + return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> + COS_LOOKUP_I_SHIFT); +} + +/* interpolated lookup based cos function */ +/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */ +STIN ogg_int32_t vorbis_coslook2_i(long a){ + a=a&0x1ffff; + + if(a>0x10000)a=0x20000-a; + { + int i=a>>COS_LOOKUP_I_SHIFT; + int d=a&COS_LOOKUP_I_MASK; + a=((COS_LOOKUP_I[i]<> + (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14); + } + + return(a); +} + +static const int barklook[28]={ + 0,100,200,301, 405,516,635,766, + 912,1077,1263,1476, 1720,2003,2333,2721, + 3184,3742,4428,5285, 6376,7791,9662,12181, + 15624,20397,27087,36554 +}; + +/* used in init only; interpolate the long way */ +STIN ogg_int32_t toBARK(int n){ + int i; + for(i=0;i<27;i++) + if(n>=barklook[i] && n>10)*0x517d)>>14; +#endif + + /* safeguard against a malicious stream */ + if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){ + memset(curve,0,sizeof(*curve)*n); + return; + } + + ilsp[i]=vorbis_coslook_i(val); + } + + i=0; + while(i>16); + qi=((qi*qi)>>16); + + if(m&1){ + qexp= qexp*2-28*((m+1)>>1)+m; + pi*=(1<<14)-((wi*wi)>>14); + qi+=pi>>14; + }else{ + qexp= qexp*2-13*m; + + pi*=(1<<14)-wi; + qi*=(1<<14)+wi; + + qi=(qi+pi)>>14; + } + + if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ + qi>>=1; qexp++; + }else + lsp_norm_asm(&qi,&qexp); + +#else + + qi*=labs(ilsp[0]-wi); + pi*=labs(ilsp[1]-wi); + + for(j=3;j>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + qi=(qi>>shift)*labs(ilsp[j-1]-wi); + pi=(pi>>shift)*labs(ilsp[j]-wi); + qexp+=shift; + } + if(!(shift=MLOOP_1[(pi|qi)>>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + + /* pi,qi normalized collectively, both tracked using qexp */ + + if(m&1){ + /* odd order filter; slightly assymetric */ + /* the last coefficient */ + qi=(qi>>shift)*labs(ilsp[j-1]-wi); + pi=(pi>>shift)<<14; + qexp+=shift; + + if(!(shift=MLOOP_1[(pi|qi)>>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + + pi>>=shift; + qi>>=shift; + qexp+=shift-14*((m+1)>>1); + + pi=((pi*pi)>>16); + qi=((qi*qi)>>16); + qexp=qexp*2+m; + + pi*=(1<<14)-((wi*wi)>>14); + qi+=pi>>14; + + }else{ + /* even order filter; still symmetric */ + + /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't + worth tracking step by step */ + + pi>>=shift; + qi>>=shift; + qexp+=shift-7*m; + + pi=((pi*pi)>>16); + qi=((qi*qi)>>16); + qexp=qexp*2+m; + + pi*=(1<<14)-wi; + qi*=(1<<14)+wi; + qi=(qi+pi)>>14; + + } + + + /* we've let the normalization drift because it wasn't important; + however, for the lookup, things must be normalized again. We + need at most one right shift or a number of left shifts */ + + if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ + qi>>=1; qexp++; + }else + while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ + qi<<=1; qexp--; + } + +#endif + + amp=vorbis_fromdBlook_i(ampi* /* n.4 */ + vorbis_invsqlook_i(qi,qexp)- + /* m.8, m+n<=8 */ + ampoffseti); /* 8.12[0] */ + +#ifdef _LOW_ACCURACY_ + amp>>=9; +#endif + curve[i]= MULT31_SHIFT15(curve[i],amp); + while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp); + } +} + +/*************** vorbis decode glue ************/ + +static void floor0_free_info(vorbis_info_floor *i){ + vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void floor0_free_look(vorbis_look_floor *i){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + if(look){ + + if(look->linearmap)_ogg_free(look->linearmap); + if(look->lsp_look)_ogg_free(look->lsp_look); + memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int j; + + vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info)); + info->order=oggpack_read(opb,8); + info->rate=oggpack_read(opb,16); + info->barkmap=oggpack_read(opb,16); + info->ampbits=oggpack_read(opb,6); + info->ampdB=oggpack_read(opb,8); + info->numbooks=oggpack_read(opb,4)+1; + + if(info->order<1)goto err_out; + if(info->rate<1)goto err_out; + if(info->barkmap<1)goto err_out; + if(info->numbooks<1)goto err_out; + + for(j=0;jnumbooks;j++){ + info->books[j]=oggpack_read(opb,8); + if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; + } + return(info); + + err_out: + floor0_free_info(info); + return(NULL); +} + +/* initialize Bark scale and normalization lookups. We could do this + with static tables, but Vorbis allows a number of possible + combinations, so it's best to do it computationally. + + The below is authoritative in terms of defining scale mapping. + Note that the scale depends on the sampling rate as well as the + linear block and mapping sizes */ + +static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi, + vorbis_info_floor *i){ + int j; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; + vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look)); + look->m=info->order; + look->n=ci->blocksizes[mi->blockflag]/2; + look->ln=info->barkmap; + look->vi=info; + + /* the mapping from a linear scale to a smaller bark scale is + straightforward. We do *not* make sure that the linear mapping + does not skip bark-scale bins; the decoder simply skips them and + the encoder may do what it wishes in filling them. They're + necessary in some mapping combinations to keep the scale spacing + accurate */ + look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap)); + for(j=0;jn;j++){ + + int val=(look->ln* + ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; + + if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ + look->linearmap[j]=val; + } + look->linearmap[j]=-1; + + look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look)); + for(j=0;jln;j++) + look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln); + + return look; +} + +static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + vorbis_info_floor0 *info=look->vi; + int j,k; + + int ampraw=oggpack_read(&vb->opb,info->ampbits); + if(ampraw>0){ /* also handles the -1 out of data case */ + long maxval=(1<ampbits)-1; + int amp=((ampraw*info->ampdB)<<4)/maxval; + int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks)); + + if(booknum!=-1 && booknumnumbooks){ /* be paranoid */ + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + codebook *b=ci->fullbooks+info->books[booknum]; + ogg_int32_t last=0; + ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); + + for(j=0;jm;j+=b->dim) + if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop; + for(j=0;jm;){ + for(k=0;kdim;k++,j++)lsp[j]+=last; + last=lsp[j-1]; + } + + lsp[look->m]=amp; + return(lsp); + } + } + eop: + return(NULL); +} + +static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, + void *memo,ogg_int32_t *out){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + vorbis_info_floor0 *info=look->vi; + + if(memo){ + ogg_int32_t *lsp=(ogg_int32_t *)memo; + ogg_int32_t amp=lsp[look->m]; + + /* take the coefficients back to a spectral envelope curve */ + vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, + lsp,look->m,amp,info->ampdB,look->lsp_look); + return(1); + } + memset(out,0,sizeof(*out)*look->n); + return(0); +} + +/* export hooks */ +vorbis_func_floor floor0_exportbundle={ + &floor0_unpack,&floor0_look,&floor0_free_info, + &floor0_free_look,&floor0_inverse1,&floor0_inverse2 +}; + + diff --git a/wolf3d/newCode/Tremor/floor1.c b/wolf3d/newCode/Tremor/floor1.c new file mode 100644 index 0000000..276ed8d --- /dev/null +++ b/wolf3d/newCode/Tremor/floor1.c @@ -0,0 +1,441 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: floor backend 1 implementation + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "block.h" + +#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ + +typedef struct { + int forward_index[VIF_POSIT+2]; + + int hineighbor[VIF_POSIT]; + int loneighbor[VIF_POSIT]; + int posts; + + int n; + int quant_q; + vorbis_info_floor1 *vi; + +} vorbis_look_floor1; + +/***********************************************/ + +static void floor1_free_info(vorbis_info_floor *i){ + vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void floor1_free_look(vorbis_look_floor *i){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)i; + if(look){ + memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static int ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int j,k,count=0,maxclass=-1,rangebits; + + vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info)); + /* read partitions */ + info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */ + for(j=0;jpartitions;j++){ + info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */ + if(maxclasspartitionclass[j])maxclass=info->partitionclass[j]; + } + + /* read partition classes */ + for(j=0;jclass_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */ + info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */ + if(info->class_subs[j]<0) + goto err_out; + if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8); + if(info->class_book[j]<0 || info->class_book[j]>=ci->books) + goto err_out; + for(k=0;k<(1<class_subs[j]);k++){ + info->class_subbook[j][k]=oggpack_read(opb,8)-1; + if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books) + goto err_out; + } + } + + /* read the post list */ + info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */ + rangebits=oggpack_read(opb,4); + + for(j=0,k=0;jpartitions;j++){ + count+=info->class_dim[info->partitionclass[j]]; + for(;kpostlist[k+2]=oggpack_read(opb,rangebits); + if(t<0 || t>=(1<postlist[0]=0; + info->postlist[1]=1<vi=info; + look->n=info->postlist[1]; + + /* we drop each position value in-between already decoded values, + and use linear interpolation to predict each new value past the + edges. The positions are read in the order of the position + list... we precompute the bounding positions in the lookup. Of + course, the neighbors can change (if a position is declined), but + this is an initial mapping */ + + for(i=0;ipartitions;i++)n+=info->class_dim[info->partitionclass[i]]; + n+=2; + look->posts=n; + + /* also store a sorted position index */ + for(i=0;ipostlist+i; + qsort(sortpointer,n,sizeof(*sortpointer),icomp); + + /* points from sort order back to range number */ + for(i=0;iforward_index[i]=sortpointer[i]-info->postlist; + + /* quantize values to multiplier spec */ + switch(info->mult){ + case 1: /* 1024 -> 256 */ + look->quant_q=256; + break; + case 2: /* 1024 -> 128 */ + look->quant_q=128; + break; + case 3: /* 1024 -> 86 */ + look->quant_q=86; + break; + case 4: /* 1024 -> 64 */ + look->quant_q=64; + break; + } + + /* discover our neighbors for decode where we don't use fit flags + (that would push the neighbors outward) */ + for(i=0;in; + int currentx=info->postlist[i+2]; + for(j=0;jpostlist[j]; + if(x>lx && xcurrentx){ + hi=j; + hx=x; + } + } + look->loneighbor[i]=lo; + look->hineighbor[i]=hi; + } + + return(look); +} + +static int render_point(int x0,int x1,int y0,int y1,int x){ + y0&=0x7fff; /* mask off flag */ + y1&=0x7fff; + + { + int dy=y1-y0; + int adx=x1-x0; + int ady=abs(dy); + int err=ady*(x-x0); + + int off=err/adx; + if(dy<0)return(y0-off); + return(y0+off); + } +} + +#ifdef _LOW_ACCURACY_ +# define XdB(n) ((((n)>>8)+1)>>1) +#else +# define XdB(n) (n) +#endif + +static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={ + XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114), + XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163), + XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9), + XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c), + XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4), + XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd), + XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4), + XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a), + XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818), + XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69), + XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64), + XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a), + XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629), + XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82), + XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac), + XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c), + XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf), + XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10), + XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b), + XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e), + XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d), + XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4), + XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd), + XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf), + XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e), + XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962), + XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109), + XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4), + XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23), + XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306), + XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20), + XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6), + XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471), + XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1), + XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7), + XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d), + XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1), + XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc), + XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2), + XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488), + XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0), + XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f), + XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41), + XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17), + XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e), + XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7), + XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf), + XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea), + XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793), + XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2), + XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013), + XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204), + XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299), + XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e), + XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca), + XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea), + XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1), + XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1), + XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870), + XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6), + XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44), + XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e), + XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298), + XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff), +}; + +static void render_line(int n, int x0,int x1,int y0,int y1,ogg_int32_t *d){ + int dy=y1-y0; + int adx=x1-x0; + int ady=abs(dy); + int base=dy/adx; + int sy=(dy<0?base-1:base+1); + int x=x0; + int y=y0; + int err=0; + + if(n>x1)n=x1; + ady-=abs(base*adx); + + if(x=adx){ + err-=adx; + y+=sy; + }else{ + y+=base; + } + d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]); + } +} + +static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; + vorbis_info_floor1 *info=look->vi; + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + + int i,j,k; + codebook *books=ci->fullbooks; + + /* unpack wrapped/predicted values from stream */ + if(oggpack_read(&vb->opb,1)==1){ + int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value)); + + fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1)); + fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1)); + + /* partition by partition */ + /* partition by partition */ + for(i=0,j=2;ipartitions;i++){ + int classv=info->partitionclass[i]; + int cdim=info->class_dim[classv]; + int csubbits=info->class_subs[classv]; + int csub=1<class_book[classv],&vb->opb); + + if(cval==-1)goto eop; + } + + for(k=0;kclass_subbook[classv][cval&(csub-1)]; + cval>>=csubbits; + if(book>=0){ + if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1) + goto eop; + }else{ + fit_value[j+k]=0; + } + } + j+=cdim; + } + + /* unwrap positive values and reconsitute via linear interpolation */ + for(i=2;iposts;i++){ + int predicted=render_point(info->postlist[look->loneighbor[i-2]], + info->postlist[look->hineighbor[i-2]], + fit_value[look->loneighbor[i-2]], + fit_value[look->hineighbor[i-2]], + info->postlist[i]); + int hiroom=look->quant_q-predicted; + int loroom=predicted; + int room=(hiroom=room){ + if(hiroom>loroom){ + val = val-loroom; + }else{ + val = -1-(val-hiroom); + } + }else{ + if(val&1){ + val= -((val+1)>>1); + }else{ + val>>=1; + } + } + + fit_value[i]=val+predicted; + fit_value[look->loneighbor[i-2]]&=0x7fff; + fit_value[look->hineighbor[i-2]]&=0x7fff; + + }else{ + fit_value[i]=predicted|0x8000; + } + + } + + return(fit_value); + } + eop: + return(NULL); +} + +static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, + ogg_int32_t *out){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; + vorbis_info_floor1 *info=look->vi; + + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + int n=ci->blocksizes[vb->W]/2; + int j; + + if(memo){ + /* render the lines */ + int *fit_value=(int *)memo; + int hx=0; + int lx=0; + int ly=fit_value[0]*info->mult; + for(j=1;jposts;j++){ + int current=look->forward_index[j]; + int hy=fit_value[current]&0x7fff; + if(hy==fit_value[current]){ + + hy*=info->mult; + hx=info->postlist[current]; + + render_line(n,lx,hx,ly,hy,out); + + lx=hx; + ly=hy; + } + } + for(j=hx;j +#include +#include "ogg.h" +#include "misc.h" + + +/* A complete description of Ogg framing exists in docs/framing.html */ + +/* basic, centralized Ogg memory management based on linked lists of + references to refcounted memory buffers. References and buffers + are both recycled. Buffers are passed around and consumed in + reference form. */ + +static ogg_buffer_state *ogg_buffer_create(void){ + ogg_buffer_state *bs=_ogg_calloc(1,sizeof(*bs)); + return bs; +} + +/* destruction is 'lazy'; there may be memory references outstanding, + and yanking the buffer state out from underneath would be + antisocial. Dealloc what is currently unused and have + _release_one watch for the stragglers to come in. When they do, + finish destruction. */ + +/* call the helper while holding lock */ +static void _ogg_buffer_destroy(ogg_buffer_state *bs){ + ogg_buffer *bt; + ogg_reference *rt; + + if(bs->shutdown){ + + bt=bs->unused_buffers; + rt=bs->unused_references; + + while(bt){ + ogg_buffer *b=bt; + bt=b->ptr.next; + if(b->data)_ogg_free(b->data); + _ogg_free(b); + } + bs->unused_buffers=0; + while(rt){ + ogg_reference *r=rt; + rt=r->next; + _ogg_free(r); + } + bs->unused_references=0; + + if(!bs->outstanding) + _ogg_free(bs); + + } +} + +static void ogg_buffer_destroy(ogg_buffer_state *bs){ + bs->shutdown=1; + _ogg_buffer_destroy(bs); +} + +static ogg_buffer *_fetch_buffer(ogg_buffer_state *bs,long bytes){ + ogg_buffer *ob; + bs->outstanding++; + + /* do we have an unused buffer sitting in the pool? */ + if(bs->unused_buffers){ + ob=bs->unused_buffers; + bs->unused_buffers=ob->ptr.next; + + /* if the unused buffer is too small, grow it */ + if(ob->sizedata=_ogg_realloc(ob->data,bytes); + ob->size=bytes; + } + }else{ + /* allocate a new buffer */ + ob=_ogg_malloc(sizeof(*ob)); + ob->data=_ogg_malloc(bytes<16?16:bytes); + ob->size=bytes; + } + + ob->refcount=1; + ob->ptr.owner=bs; + return ob; +} + +static ogg_reference *_fetch_ref(ogg_buffer_state *bs){ + ogg_reference *or; + bs->outstanding++; + + /* do we have an unused reference sitting in the pool? */ + if(bs->unused_references){ + or=bs->unused_references; + bs->unused_references=or->next; + }else{ + /* allocate a new reference */ + or=_ogg_malloc(sizeof(*or)); + } + + or->begin=0; + or->length=0; + or->next=0; + return or; +} + +/* fetch a reference pointing to a fresh, initially continguous buffer + of at least [bytes] length */ +static ogg_reference *ogg_buffer_alloc(ogg_buffer_state *bs,long bytes){ + ogg_buffer *ob=_fetch_buffer(bs,bytes); + ogg_reference *or=_fetch_ref(bs); + or->buffer=ob; + return or; +} + +/* enlarge the data buffer in the current link */ +static void ogg_buffer_realloc(ogg_reference *or,long bytes){ + ogg_buffer *ob=or->buffer; + + /* if the unused buffer is too small, grow it */ + if(ob->sizedata=_ogg_realloc(ob->data,bytes); + ob->size=bytes; + } +} + +static void _ogg_buffer_mark_one(ogg_reference *or){ + or->buffer->refcount++; +} + +/* increase the refcount of the buffers to which the reference points */ +static void ogg_buffer_mark(ogg_reference *or){ + while(or){ + _ogg_buffer_mark_one(or); + or=or->next; + } +} + +/* duplicate a reference (pointing to the same actual buffer memory) + and increment buffer refcount. If the desired segment begins out + of range, NULL is returned; if the desired segment is simply zero + length, a zero length ref is returned. Partial range overlap + returns the overlap of the ranges */ +static ogg_reference *ogg_buffer_sub(ogg_reference *or,long begin,long length){ + ogg_reference *ret=0,*head=0; + + /* walk past any preceeding fragments we don't want */ + while(or && begin>=or->length){ + begin-=or->length; + or=or->next; + } + + /* duplicate the reference chain; increment refcounts */ + while(or && length){ + ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner); + if(head) + head->next=temp; + else + ret=temp; + head=temp; + head->buffer=or->buffer; + head->begin=or->begin+begin; + head->length=length; + if(head->length>or->length-begin) + head->length=or->length-begin; + + begin=0; + length-=head->length; + or=or->next; + } + + ogg_buffer_mark(ret); + return ret; +} + +ogg_reference *ogg_buffer_dup(ogg_reference *or){ + ogg_reference *ret=0,*head=0; + /* duplicate the reference chain; increment refcounts */ + while(or){ + ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner); + if(head) + head->next=temp; + else + ret=temp; + head=temp; + head->buffer=or->buffer; + head->begin=or->begin; + head->length=or->length; + or=or->next; + } + + ogg_buffer_mark(ret); + return ret; +} + +/* split a reference into two references; 'return' is a reference to + the buffer preceeding pos and 'head'/'tail' are the buffer past the + split. If pos is at or past the end of the passed in segment, + 'head/tail' are NULL */ +static ogg_reference *ogg_buffer_split(ogg_reference **tail, + ogg_reference **head,long pos){ + + /* walk past any preceeding fragments to one of: + a) the exact boundary that seps two fragments + b) the fragment that needs split somewhere in the middle */ + ogg_reference *ret=*tail; + ogg_reference *or=*tail; + + while(or && pos>or->length){ + pos-=or->length; + or=or->next; + } + + if(!or || pos==0){ + + return 0; + + }else{ + + if(pos>=or->length){ + /* exact split, or off the end? */ + if(or->next){ + + /* a split */ + *tail=or->next; + or->next=0; + + }else{ + + /* off or at the end */ + *tail=*head=0; + + } + }else{ + + /* split within a fragment */ + long lengthA=pos; + long beginB=or->begin+pos; + long lengthB=or->length-pos; + + /* make a new reference to tail the second piece */ + *tail=_fetch_ref(or->buffer->ptr.owner); + + (*tail)->buffer=or->buffer; + (*tail)->begin=beginB; + (*tail)->length=lengthB; + (*tail)->next=or->next; + _ogg_buffer_mark_one(*tail); + if(head && or==*head)*head=*tail; + + /* update the first piece */ + or->next=0; + or->length=lengthA; + + } + } + return ret; +} + +static void ogg_buffer_release_one(ogg_reference *or){ + ogg_buffer *ob=or->buffer; + ogg_buffer_state *bs=ob->ptr.owner; + + ob->refcount--; + if(ob->refcount==0){ + bs->outstanding--; /* for the returned buffer */ + ob->ptr.next=bs->unused_buffers; + bs->unused_buffers=ob; + } + + bs->outstanding--; /* for the returned reference */ + or->next=bs->unused_references; + bs->unused_references=or; + + _ogg_buffer_destroy(bs); /* lazy cleanup (if needed) */ + +} + +/* release the references, decrease the refcounts of buffers to which + they point, release any buffers with a refcount that drops to zero */ +static void ogg_buffer_release(ogg_reference *or){ + while(or){ + ogg_reference *next=or->next; + ogg_buffer_release_one(or); + or=next; + } +} + +static ogg_reference *ogg_buffer_pretruncate(ogg_reference *or,long pos){ + /* release preceeding fragments we don't want */ + while(or && pos>=or->length){ + ogg_reference *next=or->next; + pos-=or->length; + ogg_buffer_release_one(or); + or=next; + } + if (or) { + or->begin+=pos; + or->length-=pos; + } + return or; +} + +static ogg_reference *ogg_buffer_walk(ogg_reference *or){ + if(!or)return NULL; + while(or->next){ + or=or->next; + } + return(or); +} + +/* *head is appended to the front end (head) of *tail; both continue to + be valid pointers, with *tail at the tail and *head at the head */ +static ogg_reference *ogg_buffer_cat(ogg_reference *tail, ogg_reference *head){ + if(!tail)return head; + + while(tail->next){ + tail=tail->next; + } + tail->next=head; + return ogg_buffer_walk(head); +} + +static void _positionB(oggbyte_buffer *b,int pos){ + if(pospos){ + /* start at beginning, scan forward */ + b->ref=b->baseref; + b->pos=0; + b->end=b->pos+b->ref->length; + b->ptr=b->ref->buffer->data+b->ref->begin; + } +} + +static void _positionF(oggbyte_buffer *b,int pos){ + /* scan forward for position */ + while(pos>=b->end){ + /* just seek forward */ + b->pos+=b->ref->length; + b->ref=b->ref->next; + b->end=b->ref->length+b->pos; + b->ptr=b->ref->buffer->data+b->ref->begin; + } +} + +static int oggbyte_init(oggbyte_buffer *b,ogg_reference *or){ + memset(b,0,sizeof(*b)); + if(or){ + b->ref=b->baseref=or; + b->pos=0; + b->end=b->ref->length; + b->ptr=b->ref->buffer->data+b->ref->begin; + return 0; + }else + return -1; +} + +static void oggbyte_set4(oggbyte_buffer *b,ogg_uint32_t val,int pos){ + int i; + _positionB(b,pos); + for(i=0;i<4;i++){ + _positionF(b,pos); + b->ptr[pos-b->pos]=val; + val>>=8; + ++pos; + } +} + +static unsigned char oggbyte_read1(oggbyte_buffer *b,int pos){ + _positionB(b,pos); + _positionF(b,pos); + return b->ptr[pos-b->pos]; +} + +static ogg_uint32_t oggbyte_read4(oggbyte_buffer *b,int pos){ + ogg_uint32_t ret; + _positionB(b,pos); + _positionF(b,pos); + ret=b->ptr[pos-b->pos]; + _positionF(b,++pos); + ret|=b->ptr[pos-b->pos]<<8; + _positionF(b,++pos); + ret|=b->ptr[pos-b->pos]<<16; + _positionF(b,++pos); + ret|=b->ptr[pos-b->pos]<<24; + return ret; +} + +static ogg_int64_t oggbyte_read8(oggbyte_buffer *b,int pos){ + ogg_int64_t ret; + unsigned char t[7]; + int i; + _positionB(b,pos); + for(i=0;i<7;i++){ + _positionF(b,pos); + t[i]=b->ptr[pos++ -b->pos]; + } + + _positionF(b,pos); + ret=b->ptr[pos-b->pos]; + + for(i=6;i>=0;--i) + ret= ret<<8 | t[i]; + + return ret; +} + +/* Now we get to the actual framing code */ + +int ogg_page_version(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read1(&ob,4); +} + +int ogg_page_continued(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read1(&ob,5)&0x01; +} + +int ogg_page_bos(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read1(&ob,5)&0x02; +} + +int ogg_page_eos(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read1(&ob,5)&0x04; +} + +ogg_int64_t ogg_page_granulepos(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read8(&ob,6); +} + +ogg_uint32_t ogg_page_serialno(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read4(&ob,14); +} + +ogg_uint32_t ogg_page_pageno(ogg_page *og){ + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + return oggbyte_read4(&ob,18); +} + +/* returns the number of packets that are completed on this page (if + the leading packet is begun on a previous page, but ends on this + page, it's counted */ + +/* NOTE: +If a page consists of a packet begun on a previous page, and a new +packet begun (but not completed) on this page, the return will be: + ogg_page_packets(page) ==1, + ogg_page_continued(page) !=0 + +If a page happens to be a single packet that was begun on a +previous page, and spans to the next page (in the case of a three or +more page packet), the return will be: + ogg_page_packets(page) ==0, + ogg_page_continued(page) !=0 +*/ + +int ogg_page_packets(ogg_page *og){ + int i; + int n; + int count=0; + oggbyte_buffer ob; + oggbyte_init(&ob,og->header); + + n=oggbyte_read1(&ob,26); + for(i=0;ibufferpool=ogg_buffer_create(); + return oy; +} + +int ogg_sync_destroy(ogg_sync_state *oy){ + if(oy){ + ogg_sync_reset(oy); + ogg_buffer_destroy(oy->bufferpool); + memset(oy,0,sizeof(*oy)); + _ogg_free(oy); + } + return OGG_SUCCESS; +} + +unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long bytes){ + + /* [allocate and] expose a buffer for data submission. + + If there is no head fragment + allocate one and expose it + else + if the current head fragment has sufficient unused space + expose it + else + if the current head fragment is unused + resize and expose it + else + allocate new fragment and expose it + */ + + /* base case; fifo uninitialized */ + if(!oy->fifo_head){ + oy->fifo_head=oy->fifo_tail=ogg_buffer_alloc(oy->bufferpool,bytes); + return oy->fifo_head->buffer->data; + } + + /* space left in current fragment case */ + if(oy->fifo_head->buffer->size- + oy->fifo_head->length- + oy->fifo_head->begin >= bytes) + return oy->fifo_head->buffer->data+ + oy->fifo_head->length+oy->fifo_head->begin; + + /* current fragment is unused, but too small */ + if(!oy->fifo_head->length){ + ogg_buffer_realloc(oy->fifo_head,bytes); + return oy->fifo_head->buffer->data+oy->fifo_head->begin; + } + + /* current fragment used/full; get new fragment */ + { + ogg_reference *new=ogg_buffer_alloc(oy->bufferpool,bytes); + oy->fifo_head->next=new; + oy->fifo_head=new; + } + return oy->fifo_head->buffer->data; +} + +int ogg_sync_wrote(ogg_sync_state *oy, long bytes){ + if(!oy->fifo_head)return OGG_EINVAL; + if(oy->fifo_head->buffer->size-oy->fifo_head->length-oy->fifo_head->begin < + bytes)return OGG_EINVAL; + oy->fifo_head->length+=bytes; + oy->fifo_fill+=bytes; + return OGG_SUCCESS; +} + +static ogg_uint32_t _checksum(ogg_reference *or, int bytes){ + ogg_uint32_t crc_reg=0; + int j,post; + + while(or){ + unsigned char *data=or->buffer->data+or->begin; + post=(byteslength?bytes:or->length); + for(j=0;j> 24)&0xff)^data[j]]; + bytes-=j; + or=or->next; + } + + return crc_reg; +} + + +/* sync the stream. This is meant to be useful for finding page + boundaries. + + return values for this: + -n) skipped n bytes + 0) page not ready; more data (no bytes skipped) + n) page synced at current location; page length n bytes + +*/ + +long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ + oggbyte_buffer page; + long bytes,ret=0; + + ogg_page_release(og); + + bytes=oy->fifo_fill; + oggbyte_init(&page,oy->fifo_tail); + + if(oy->headerbytes==0){ + if(bytes<27)goto sync_out; /* not enough for even a minimal header */ + + /* verify capture pattern */ + if(oggbyte_read1(&page,0)!=(int)'O' || + oggbyte_read1(&page,1)!=(int)'g' || + oggbyte_read1(&page,2)!=(int)'g' || + oggbyte_read1(&page,3)!=(int)'S' ) goto sync_fail; + + oy->headerbytes=oggbyte_read1(&page,26)+27; + } + if(bytesheaderbytes)goto sync_out; /* not enough for header + + seg table */ + if(oy->bodybytes==0){ + int i; + /* count up body length in the segment table */ + for(i=0;iheaderbytes-27;i++) + oy->bodybytes+=oggbyte_read1(&page,27+i); + } + + if(oy->bodybytes+oy->headerbytes>bytes)goto sync_out; + + /* we have what appears to be a complete page; last test: verify + checksum */ + { + ogg_uint32_t chksum=oggbyte_read4(&page,22); + oggbyte_set4(&page,0,22); + + /* Compare checksums; memory continues to be common access */ + if(chksum!=_checksum(oy->fifo_tail,oy->bodybytes+oy->headerbytes)){ + + /* D'oh. Mismatch! Corrupt page (or miscapture and not a page + at all). replace the computed checksum with the one actually + read in; remember all the memory is common access */ + + oggbyte_set4(&page,chksum,22); + goto sync_fail; + } + oggbyte_set4(&page,chksum,22); + } + + /* We have a page. Set up page return. */ + if(og){ + /* set up page output */ + og->header=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->headerbytes); + og->header_len=oy->headerbytes; + og->body=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->bodybytes); + og->body_len=oy->bodybytes; + }else{ + /* simply advance */ + oy->fifo_tail= + ogg_buffer_pretruncate(oy->fifo_tail,oy->headerbytes+oy->bodybytes); + if(!oy->fifo_tail)oy->fifo_head=0; + } + + ret=oy->headerbytes+oy->bodybytes; + oy->unsynced=0; + oy->headerbytes=0; + oy->bodybytes=0; + oy->fifo_fill-=ret; + + return ret; + + sync_fail: + + oy->headerbytes=0; + oy->bodybytes=0; + oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,1); + ret--; + + /* search forward through fragments for possible capture */ + while(oy->fifo_tail){ + /* invariant: fifo_cursor points to a position in fifo_tail */ + unsigned char *now=oy->fifo_tail->buffer->data+oy->fifo_tail->begin; + unsigned char *next=memchr(now, 'O', oy->fifo_tail->length); + + if(next){ + /* possible capture in this segment */ + long bytes=next-now; + oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes); + ret-=bytes; + break; + }else{ + /* no capture. advance to next segment */ + long bytes=oy->fifo_tail->length; + ret-=bytes; + oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes); + } + } + if(!oy->fifo_tail)oy->fifo_head=0; + oy->fifo_fill+=ret; + + sync_out: + return ret; +} + +/* sync the stream and get a page. Keep trying until we find a page. + Supress 'sync errors' after reporting the first. + + return values: + OGG_HOLE) recapture (hole in data) + 0) need more data + 1) page returned + + Returns pointers into buffered data; invalidated by next call to + _stream, _clear, _init, or _buffer */ + +int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ + + /* all we need to do is verify a page at the head of the stream + buffer. If it doesn't verify, we look for the next potential + frame */ + + while(1){ + long ret=ogg_sync_pageseek(oy,og); + if(ret>0){ + /* have a page */ + return 1; + } + if(ret==0){ + /* need more data */ + return 0; + } + + /* head did not start a synced page... skipped some bytes */ + if(!oy->unsynced){ + oy->unsynced=1; + return OGG_HOLE; + } + + /* loop. keep looking */ + + } +} + +/* clear things to an initial state. Good to call, eg, before seeking */ +int ogg_sync_reset(ogg_sync_state *oy){ + + ogg_buffer_release(oy->fifo_tail); + oy->fifo_tail=0; + oy->fifo_head=0; + oy->fifo_fill=0; + + oy->unsynced=0; + oy->headerbytes=0; + oy->bodybytes=0; + return OGG_SUCCESS; +} + +ogg_stream_state *ogg_stream_create(int serialno){ + ogg_stream_state *os=_ogg_calloc(1,sizeof(*os)); + os->serialno=serialno; + os->pageno=-1; + return os; +} + +int ogg_stream_destroy(ogg_stream_state *os){ + if(os){ + ogg_buffer_release(os->header_tail); + ogg_buffer_release(os->body_tail); + memset(os,0,sizeof(*os)); + _ogg_free(os); + } + return OGG_SUCCESS; +} + + +#define FINFLAG 0x80000000UL +#define FINMASK 0x7fffffffUL + +static void _next_lace(oggbyte_buffer *ob,ogg_stream_state *os){ + /* search ahead one lace */ + os->body_fill_next=0; + while(os->laceptrlacing_fill){ + int val=oggbyte_read1(ob,27+os->laceptr++); + os->body_fill_next+=val; + if(val<255){ + os->body_fill_next|=FINFLAG; + os->clearflag=1; + break; + } + } +} + +static void _span_queued_page(ogg_stream_state *os){ + while( !(os->body_fill&FINFLAG) ){ + + if(!os->header_tail)break; + + /* first flush out preceeding page header (if any). Body is + flushed as it's consumed, so that's not done here. */ + + if(os->lacing_fill>=0) + os->header_tail=ogg_buffer_pretruncate(os->header_tail, + os->lacing_fill+27); + os->lacing_fill=0; + os->laceptr=0; + os->clearflag=0; + + if(!os->header_tail){ + os->header_head=0; + break; + }else{ + + /* process/prepare next page, if any */ + + long pageno; + oggbyte_buffer ob; + ogg_page og; /* only for parsing header values */ + og.header=os->header_tail; /* only for parsing header values */ + pageno=ogg_page_pageno(&og); + + oggbyte_init(&ob,os->header_tail); + os->lacing_fill=oggbyte_read1(&ob,26); + + /* are we in sequence? */ + if(pageno!=os->pageno){ + if(os->pageno==-1) /* indicates seek or reset */ + os->holeflag=1; /* set for internal use */ + else + os->holeflag=2; /* set for external reporting */ + + os->body_tail=ogg_buffer_pretruncate(os->body_tail, + os->body_fill); + if(os->body_tail==0)os->body_head=0; + os->body_fill=0; + + } + + if(ogg_page_continued(&og)){ + if(os->body_fill==0){ + /* continued packet, but no preceeding data to continue */ + /* dump the first partial packet on the page */ + _next_lace(&ob,os); + os->body_tail= + ogg_buffer_pretruncate(os->body_tail,os->body_fill_next&FINMASK); + if(os->body_tail==0)os->body_head=0; + /* set span flag */ + if(!os->spanflag && !os->holeflag)os->spanflag=2; + } + }else{ + if(os->body_fill>0){ + /* preceeding data to continue, but not a continued page */ + /* dump body_fill */ + os->body_tail=ogg_buffer_pretruncate(os->body_tail, + os->body_fill); + if(os->body_tail==0)os->body_head=0; + os->body_fill=0; + + /* set espan flag */ + if(!os->spanflag && !os->holeflag)os->spanflag=2; + } + } + + if(os->laceptrlacing_fill){ + os->granulepos=ogg_page_granulepos(&og); + + /* get current packet size & flag */ + _next_lace(&ob,os); + os->body_fill+=os->body_fill_next; /* addition handles the flag fine; + unsigned on purpose */ + /* ...and next packet size & flag */ + _next_lace(&ob,os); + + } + + os->pageno=pageno+1; + os->e_o_s=ogg_page_eos(&og); + os->b_o_s=ogg_page_bos(&og); + + } + } +} + +/* add the incoming page to the stream state; we decompose the page + into packet segments here as well. */ + +int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){ + + int serialno=ogg_page_serialno(og); + int version=ogg_page_version(og); + + /* check the serial number */ + if(serialno!=os->serialno){ + ogg_page_release(og); + return OGG_ESERIAL; + } + if(version>0){ + ogg_page_release(og); + return OGG_EVERSION; + } + + /* add to fifos */ + if(!os->body_tail){ + os->body_tail=og->body; + os->body_head=ogg_buffer_walk(og->body); + }else{ + os->body_head=ogg_buffer_cat(os->body_head,og->body); + } + if(!os->header_tail){ + os->header_tail=og->header; + os->header_head=ogg_buffer_walk(og->header); + os->lacing_fill=-27; + }else{ + os->header_head=ogg_buffer_cat(os->header_head,og->header); + } + + memset(og,0,sizeof(*og)); + return OGG_SUCCESS; +} + +int ogg_stream_reset(ogg_stream_state *os){ + + ogg_buffer_release(os->header_tail); + ogg_buffer_release(os->body_tail); + os->header_tail=os->header_head=0; + os->body_tail=os->body_head=0; + + os->e_o_s=0; + os->b_o_s=0; + os->pageno=-1; + os->packetno=0; + os->granulepos=0; + + os->body_fill=0; + os->lacing_fill=0; + + os->holeflag=0; + os->spanflag=0; + os->clearflag=0; + os->laceptr=0; + os->body_fill_next=0; + + return OGG_SUCCESS; +} + +int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){ + ogg_stream_reset(os); + os->serialno=serialno; + return OGG_SUCCESS; +} + +static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){ + + ogg_packet_release(op); + _span_queued_page(os); + + if(os->holeflag){ + int temp=os->holeflag; + if(os->clearflag) + os->holeflag=0; + else + os->holeflag=1; + if(temp==2){ + os->packetno++; + return OGG_HOLE; + } + } + if(os->spanflag){ + int temp=os->spanflag; + if(os->clearflag) + os->spanflag=0; + else + os->spanflag=1; + if(temp==2){ + os->packetno++; + return OGG_SPAN; + } + } + + if(!(os->body_fill&FINFLAG)) return 0; + if(!op && !adv)return 1; /* just using peek as an inexpensive way + to ask if there's a whole packet + waiting */ + if(op){ + op->b_o_s=os->b_o_s; + if(os->e_o_s && os->body_fill_next==0) + op->e_o_s=os->e_o_s; + else + op->e_o_s=0; + if( (os->body_fill&FINFLAG) && !(os->body_fill_next&FINFLAG) ) + op->granulepos=os->granulepos; + else + op->granulepos=-1; + op->packetno=os->packetno; + } + + if(adv){ + oggbyte_buffer ob; + oggbyte_init(&ob,os->header_tail); + + /* split the body contents off */ + if(op){ + op->packet=ogg_buffer_split(&os->body_tail,&os->body_head, + os->body_fill&FINMASK); + op->bytes=os->body_fill&FINMASK; + }else{ + os->body_tail=ogg_buffer_pretruncate(os->body_tail, + os->body_fill&FINMASK); + if(os->body_tail==0)os->body_head=0; + } + + /* update lacing pointers */ + os->body_fill=os->body_fill_next; + _next_lace(&ob,os); + }else{ + if(op){ + op->packet=ogg_buffer_sub(os->body_tail,0,os->body_fill&FINMASK); + op->bytes=os->body_fill&FINMASK; + } + } + + if(adv){ + os->packetno++; + os->b_o_s=0; + } + + return 1; +} + +int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ + return _packetout(os,op,1); +} + +int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ + return _packetout(os,op,0); +} + +int ogg_packet_release(ogg_packet *op) { + if(op){ + ogg_buffer_release(op->packet); + memset(op, 0, sizeof(*op)); + } + return OGG_SUCCESS; +} + +int ogg_page_release(ogg_page *og) { + if(og){ + ogg_buffer_release(og->header); + ogg_buffer_release(og->body); + memset(og, 0, sizeof(*og)); + } + return OGG_SUCCESS; +} + +void ogg_page_dup(ogg_page *dup,ogg_page *orig){ + dup->header_len=orig->header_len; + dup->body_len=orig->body_len; + dup->header=ogg_buffer_dup(orig->header); + dup->body=ogg_buffer_dup(orig->body); +} + diff --git a/wolf3d/newCode/Tremor/info.c b/wolf3d/newCode/Tremor/info.c new file mode 100644 index 0000000..33acf16 --- /dev/null +++ b/wolf3d/newCode/Tremor/info.c @@ -0,0 +1,356 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: maintain the info structure, info <-> header packets + + ********************************************************************/ + +/* general handling of the header and the vorbis_info structure (and + substructures) */ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "codebook.h" +#include "registry.h" +#include "window.h" +#include "misc.h" + +/* helpers */ +static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ + while(bytes--){ + *buf++=oggpack_read(o,8); + } +} + +void vorbis_comment_init(vorbis_comment *vc){ + memset(vc,0,sizeof(*vc)); +} + +/* This is more or less the same as strncasecmp - but that doesn't exist + * everywhere, and this is a fairly trivial function, so we include it */ +static int tagcompare(const char *s1, const char *s2, int n){ + int c=0; + while(c < n){ + if(toupper(s1[c]) != toupper(s2[c])) + return !0; + c++; + } + return 0; +} + +char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ + long i; + int found = 0; + int taglen = strlen(tag)+1; /* +1 for the = we append */ + char *fulltag = (char *)alloca(taglen+ 1); + + strcpy(fulltag, tag); + strcat(fulltag, "="); + + for(i=0;icomments;i++){ + if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ + if(count == found) + /* We return a pointer to the data, not a copy */ + return vc->user_comments[i] + taglen; + else + found++; + } + } + return NULL; /* didn't find anything */ +} + +int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ + int i,count=0; + int taglen = strlen(tag)+1; /* +1 for the = we append */ + char *fulltag = (char *)alloca(taglen+1); + strcpy(fulltag,tag); + strcat(fulltag, "="); + + for(i=0;icomments;i++){ + if(!tagcompare(vc->user_comments[i], fulltag, taglen)) + count++; + } + + return count; +} + +void vorbis_comment_clear(vorbis_comment *vc){ + if(vc){ + long i; + for(i=0;icomments;i++) + if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); + if(vc->user_comments)_ogg_free(vc->user_comments); + if(vc->comment_lengths)_ogg_free(vc->comment_lengths); + if(vc->vendor)_ogg_free(vc->vendor); + memset(vc,0,sizeof(*vc)); + } +} + +/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. + They may be equal, but short will never ge greater than long */ +int vorbis_info_blocksize(vorbis_info *vi,int zo){ + codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; + return ci ? ci->blocksizes[zo] : -1; +} + +/* used by synthesis, which has a full, alloced vi */ +void vorbis_info_init(vorbis_info *vi){ + memset(vi,0,sizeof(*vi)); + vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); +} + +void vorbis_info_clear(vorbis_info *vi){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int i; + + if(ci){ + + for(i=0;imodes;i++) + if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); + + for(i=0;imaps;i++) /* unpack does the range checking */ + if(ci->map_param[i]) + _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); + + for(i=0;ifloors;i++) /* unpack does the range checking */ + if(ci->floor_param[i]) + _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); + + for(i=0;iresidues;i++) /* unpack does the range checking */ + if(ci->residue_param[i]) + _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); + + for(i=0;ibooks;i++){ + if(ci->book_param[i]){ + /* knows if the book was not alloced */ + vorbis_staticbook_destroy(ci->book_param[i]); + } + if(ci->fullbooks) + vorbis_book_clear(ci->fullbooks+i); + } + if(ci->fullbooks) + _ogg_free(ci->fullbooks); + + _ogg_free(ci); + } + + memset(vi,0,sizeof(*vi)); +} + +/* Header packing/unpacking ********************************************/ + +static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + if(!ci)return(OV_EFAULT); + + vi->version=oggpack_read(opb,32); + if(vi->version!=0)return(OV_EVERSION); + + vi->channels=oggpack_read(opb,8); + vi->rate=oggpack_read(opb,32); + + vi->bitrate_upper=oggpack_read(opb,32); + vi->bitrate_nominal=oggpack_read(opb,32); + vi->bitrate_lower=oggpack_read(opb,32); + + ci->blocksizes[0]=1<blocksizes[1]=1<rate<1)goto err_out; + if(vi->channels<1)goto err_out; + if(ci->blocksizes[0]<64)goto err_out; + if(ci->blocksizes[1]blocksizes[0])goto err_out; + if(ci->blocksizes[1]>8192)goto err_out; + + if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ + + return(0); + err_out: + vorbis_info_clear(vi); + return(OV_EBADHEADER); +} + +static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ + int i; + int vendorlen=oggpack_read(opb,32); + if(vendorlen<0)goto err_out; + vc->vendor=(char *)_ogg_calloc(vendorlen+1,1); + _v_readstring(opb,vc->vendor,vendorlen); + vc->comments=oggpack_read(opb,32); + if(vc->comments<0)goto err_out; + vc->user_comments=(char **)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); + vc->comment_lengths=(int *)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); + + for(i=0;icomments;i++){ + int len=oggpack_read(opb,32); + if(len<0)goto err_out; + vc->comment_lengths[i]=len; + vc->user_comments[i]=(char *)_ogg_calloc(len+1,1); + _v_readstring(opb,vc->user_comments[i],len); + } + if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ + + return(0); + err_out: + vorbis_comment_clear(vc); + return(OV_EBADHEADER); +} + +/* all of the real encoding details are here. The modes, books, + everything */ +static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int i; + if(!ci)return(OV_EFAULT); + + /* codebooks */ + ci->books=oggpack_read(opb,8)+1; + /*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/ + for(i=0;ibooks;i++){ + ci->book_param[i]=(static_codebook *)_ogg_calloc(1,sizeof(*ci->book_param[i])); + if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out; + } + + /* time backend settings */ + ci->times=oggpack_read(opb,6)+1; + /*ci->time_type=_ogg_malloc(ci->times*sizeof(*ci->time_type));*/ + /*ci->time_param=_ogg_calloc(ci->times,sizeof(void *));*/ + for(i=0;itimes;i++){ + ci->time_type[i]=oggpack_read(opb,16); + if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out; + /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb); + Vorbis I has no time backend */ + /*if(!ci->time_param[i])goto err_out;*/ + } + + /* floor backend settings */ + ci->floors=oggpack_read(opb,6)+1; + /*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/ + /*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/ + for(i=0;ifloors;i++){ + ci->floor_type[i]=oggpack_read(opb,16); + if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; + ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb); + if(!ci->floor_param[i])goto err_out; + } + + /* residue backend settings */ + ci->residues=oggpack_read(opb,6)+1; + /*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/ + /*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/ + for(i=0;iresidues;i++){ + ci->residue_type[i]=oggpack_read(opb,16); + if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; + ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb); + if(!ci->residue_param[i])goto err_out; + } + + /* map backend settings */ + ci->maps=oggpack_read(opb,6)+1; + /*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/ + /*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/ + for(i=0;imaps;i++){ + ci->map_type[i]=oggpack_read(opb,16); + if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; + ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb); + if(!ci->map_param[i])goto err_out; + } + + /* mode settings */ + ci->modes=oggpack_read(opb,6)+1; + /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/ + for(i=0;imodes;i++){ + ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i])); + ci->mode_param[i]->blockflag=oggpack_read(opb,1); + ci->mode_param[i]->windowtype=oggpack_read(opb,16); + ci->mode_param[i]->transformtype=oggpack_read(opb,16); + ci->mode_param[i]->mapping=oggpack_read(opb,8); + + if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; + if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; + if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; + } + + if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ + + return(0); + err_out: + vorbis_info_clear(vi); + return(OV_EBADHEADER); +} + +/* The Vorbis header is in three packets; the initial small packet in + the first page that identifies basic parameters, a second packet + with bitstream comments and a third packet that holds the + codebook. */ + +int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){ + oggpack_buffer opb; + + if(op){ + oggpack_readinit(&opb,op->packet); + + /* Which of the three types of header is this? */ + /* Also verify header-ness, vorbis */ + { + char buffer[6]; + int packtype=oggpack_read(&opb,8); + memset(buffer,0,6); + _v_readstring(&opb,buffer,6); + if(memcmp(buffer,"vorbis",6)){ + /* not a vorbis header */ + return(OV_ENOTVORBIS); + } + switch(packtype){ + case 0x01: /* least significant *bit* is read first */ + if(!op->b_o_s){ + /* Not the initial packet */ + return(OV_EBADHEADER); + } + if(vi->rate!=0){ + /* previously initialized info header */ + return(OV_EBADHEADER); + } + + return(_vorbis_unpack_info(vi,&opb)); + + case 0x03: /* least significant *bit* is read first */ + if(vi->rate==0){ + /* um... we didn't get the initial header */ + return(OV_EBADHEADER); + } + + return(_vorbis_unpack_comment(vc,&opb)); + + case 0x05: /* least significant *bit* is read first */ + if(vi->rate==0 || vc->vendor==NULL){ + /* um... we didn;t get the initial header or comments yet */ + return(OV_EBADHEADER); + } + + return(_vorbis_unpack_books(vi,&opb)); + + default: + /* Not a valid vorbis header type */ + return(OV_EBADHEADER); + break; + } + } + } + return(OV_EBADHEADER); +} + diff --git a/wolf3d/newCode/Tremor/ivorbiscodec.h b/wolf3d/newCode/Tremor/ivorbiscodec.h new file mode 100644 index 0000000..d4de1fd --- /dev/null +++ b/wolf3d/newCode/Tremor/ivorbiscodec.h @@ -0,0 +1,202 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: libvorbis codec headers + + ********************************************************************/ + +#ifndef _vorbis_codec_h_ +#define _vorbis_codec_h_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "ogg.h" + +typedef struct vorbis_info{ + int version; + int channels; + long rate; + + /* The below bitrate declarations are *hints*. + Combinations of the three values carry the following implications: + + all three set to the same value: + implies a fixed rate bitstream + only nominal set: + implies a VBR stream that averages the nominal bitrate. No hard + upper/lower limit + upper and or lower set: + implies a VBR bitstream that obeys the bitrate limits. nominal + may also be set to give a nominal rate. + none set: + the coder does not care to speculate. + */ + + long bitrate_upper; + long bitrate_nominal; + long bitrate_lower; + long bitrate_window; + + void *codec_setup; +} vorbis_info; + +/* vorbis_dsp_state buffers the current vorbis audio + analysis/synthesis state. The DSP state belongs to a specific + logical bitstream ****************************************************/ +typedef struct vorbis_dsp_state{ + int analysisp; + vorbis_info *vi; + + ogg_int32_t **pcm; + ogg_int32_t **pcmret; + int pcm_storage; + int pcm_current; + int pcm_returned; + + int preextrapolate; + int eofflag; + + long lW; + long W; + long nW; + long centerW; + + ogg_int64_t granulepos; + ogg_int64_t sequence; + + void *backend_state; +} vorbis_dsp_state; + +typedef struct vorbis_block{ + /* necessary stream state for linking to the framing abstraction */ + ogg_int32_t **pcm; /* this is a pointer into local storage */ + oggpack_buffer opb; + + long lW; + long W; + long nW; + int pcmend; + int mode; + + int eofflag; + ogg_int64_t granulepos; + ogg_int64_t sequence; + vorbis_dsp_state *vd; /* For read-only access of configuration */ + + /* local storage to avoid remallocing; it's up to the mapping to + structure it */ + void *localstore; + long localtop; + long localalloc; + long totaluse; + struct alloc_chain *reap; + +} vorbis_block; + +/* vorbis_block is a single block of data to be processed as part of +the analysis/synthesis stream; it belongs to a specific logical +bitstream, but is independant from other vorbis_blocks belonging to +that logical bitstream. *************************************************/ + +struct alloc_chain{ + void *ptr; + struct alloc_chain *next; +}; + +/* vorbis_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). vorbis_info and substructures are in backends.h. +*********************************************************************/ + +/* the comments are not part of vorbis_info so that vorbis_info can be + static storage */ +typedef struct vorbis_comment{ + /* unlimited user comment fields. libvorbis writes 'libvorbis' + whatever vendor is set to in encode */ + char **user_comments; + int *comment_lengths; + int comments; + char *vendor; + +} vorbis_comment; + + +/* libvorbis encodes in two abstraction layers; first we perform DSP + and produce a packet (see docs/analysis.txt). The packet is then + coded into a framed OggSquish bitstream by the second layer (see + docs/framing.txt). Decode is the reverse process; we sync/frame + the bitstream and extract individual packets, then decode the + packet back into PCM audio. + + The extra framing/packetizing is used in streaming formats, such as + files. Over the net (such as with UDP), the framing and + packetization aren't necessary as they're provided by the transport + and the streaming layer is not used */ + +/* Vorbis PRIMITIVES: general ***************************************/ + +extern void vorbis_info_init(vorbis_info *vi); +extern void vorbis_info_clear(vorbis_info *vi); +extern int vorbis_info_blocksize(vorbis_info *vi,int zo); +extern void vorbis_comment_init(vorbis_comment *vc); +extern void vorbis_comment_add(vorbis_comment *vc, char *comment); +extern void vorbis_comment_add_tag(vorbis_comment *vc, + char *tag, char *contents); +extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); +extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); +extern void vorbis_comment_clear(vorbis_comment *vc); + +extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); +extern int vorbis_block_clear(vorbis_block *vb); +extern void vorbis_dsp_clear(vorbis_dsp_state *v); + +/* Vorbis PRIMITIVES: synthesis layer *******************************/ +extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, + ogg_packet *op); + +extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_synthesis_restart(vorbis_dsp_state *v); +extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep); +extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); +extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); +extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); + +/* Vorbis ERRORS and return codes ***********************************/ + +#define OV_FALSE -1 +#define OV_EOF -2 +#define OV_HOLE -3 + +#define OV_EREAD -128 +#define OV_EFAULT -129 +#define OV_EIMPL -130 +#define OV_EINVAL -131 +#define OV_ENOTVORBIS -132 +#define OV_EBADHEADER -133 +#define OV_EVERSION -134 +#define OV_ENOTAUDIO -135 +#define OV_EBADPACKET -136 +#define OV_EBADLINK -137 +#define OV_ENOSEEK -138 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/wolf3d/newCode/Tremor/ivorbisfile.h b/wolf3d/newCode/Tremor/ivorbisfile.h new file mode 100644 index 0000000..dd77378 --- /dev/null +++ b/wolf3d/newCode/Tremor/ivorbisfile.h @@ -0,0 +1,130 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + + ********************************************************************/ + +#ifndef _OV_FILE_H_ +#define _OV_FILE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include +#include "ivorbiscodec.h" + +#define CHUNKSIZE 1024 +/* The function prototypes for the callbacks are basically the same as for + * the stdio functions fread, fseek, fclose, ftell. + * The one difference is that the FILE * arguments have been replaced with + * a void * - this is to be used as a pointer to whatever internal data these + * functions might need. In the stdio case, it's just a FILE * cast to a void * + * + * If you use other functions, check the docs for these functions and return + * the right values. For seek_func(), you *MUST* return -1 if the stream is + * unseekable + */ +typedef struct { + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); + int (*close_func) (void *datasource); + long (*tell_func) (void *datasource); +} ov_callbacks; + +#define NOTOPEN 0 +#define PARTOPEN 1 +#define OPENED 2 +#define STREAMSET 3 +#define INITSET 4 + +typedef struct OggVorbis_File { + void *datasource; /* Pointer to a FILE *, etc. */ + int seekable; + ogg_int64_t offset; + ogg_int64_t end; + ogg_sync_state *oy; + + /* If the FILE handle isn't seekable (eg, a pipe), only the current + stream appears */ + int links; + ogg_int64_t *offsets; + ogg_int64_t *dataoffsets; + ogg_uint32_t *serialnos; + ogg_int64_t *pcmlengths; + vorbis_info *vi; + vorbis_comment *vc; + + /* Decoding working state local storage */ + ogg_int64_t pcm_offset; + int ready_state; + ogg_uint32_t current_serialno; + int current_link; + + ogg_int64_t bittrack; + ogg_int64_t samptrack; + + ogg_stream_state *os; /* take physical pages, weld into a logical + stream of packets */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + + ov_callbacks callbacks; + +} OggVorbis_File; + +extern int ov_clear(OggVorbis_File *vf); +extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); + +extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); +extern int ov_test_open(OggVorbis_File *vf); + +extern long ov_bitrate(OggVorbis_File *vf,int i); +extern long ov_bitrate_instant(OggVorbis_File *vf); +extern long ov_streams(OggVorbis_File *vf); +extern long ov_seekable(OggVorbis_File *vf); +extern long ov_serialnumber(OggVorbis_File *vf,int i); + +extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i); + +extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos); + +extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_time_tell(OggVorbis_File *vf); + +extern vorbis_info *ov_info(OggVorbis_File *vf,int link); +extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); + +extern long ov_read(OggVorbis_File *vf,char *buffer,int length, + int *bitstream); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/wolf3d/newCode/Tremor/ivorbisfile_example.c b/wolf3d/newCode/Tremor/ivorbisfile_example.c new file mode 100644 index 0000000..c99cfd2 --- /dev/null +++ b/wolf3d/newCode/Tremor/ivorbisfile_example.c @@ -0,0 +1,86 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: simple example decoder using vorbisidec + + ********************************************************************/ + +/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to + stdout using vorbisfile. Using vorbisfile is much simpler than + dealing with libvorbis. */ + +#include +#include +#include "ivorbiscodec.h" +#include "ivorbisfile.h" + +#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ +#include +#include +#endif + +char pcmout[4096]; /* take 4k out of the data segment, not the stack */ + +int main(){ + OggVorbis_File vf; + int eof=0; + int current_section; + +#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ + /* Beware the evil ifdef. We avoid these where we can, but this one we + cannot. Don't add any more, you'll probably go to hell if you do. */ + _setmode( _fileno( stdin ), _O_BINARY ); + _setmode( _fileno( stdout ), _O_BINARY ); +#endif + + if(ov_open(stdin, &vf, NULL, 0) < 0) { + fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); + exit(1); + } + + /* Throw the comments plus a few lines about the bitstream we're + decoding */ + { + char **ptr=ov_comment(&vf,-1)->user_comments; + vorbis_info *vi=ov_info(&vf,-1); + while(*ptr){ + fprintf(stderr,"%s\n",*ptr); + ++ptr; + } + fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate); + fprintf(stderr,"\nDecoded length: %ld samples\n", + (long)ov_pcm_total(&vf,-1)); + fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor); + } + + while(!eof){ + long ret=ov_read(&vf,pcmout,sizeof(pcmout),¤t_section); + if (ret == 0) { + /* EOF */ + eof=1; + } else if (ret < 0) { + /* error in the stream. Not a problem, just reporting it in + case we (the app) cares. In this case, we don't. */ + } else { + /* we don't bother dealing with sample rate changes, etc, but + you'll have to*/ + fwrite(pcmout,1,ret,stdout); + } + } + + /* cleanup */ + ov_clear(&vf); + + fprintf(stderr,"Done.\n"); + return(0); +} diff --git a/wolf3d/newCode/Tremor/lsp_lookup.h b/wolf3d/newCode/Tremor/lsp_lookup.h new file mode 100644 index 0000000..fa84851 --- /dev/null +++ b/wolf3d/newCode/Tremor/lsp_lookup.h @@ -0,0 +1,136 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: lookup data + + ********************************************************************/ + +#ifndef _V_LOOKUP_DATA_H_ +#define _V_LOOKUP_DATA_H_ + +#include "os_types.h" + +#define FROMdB_LOOKUP_SZ 35 +#define FROMdB2_LOOKUP_SZ 32 +#define FROMdB_SHIFT 5 +#define FROMdB2_SHIFT 3 +#define FROMdB2_MASK 31 + +static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={ + 0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a, + 0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42, + 0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760, + 0x0000413a, 0x00002928, 0x000019f8, 0x00001062, + 0x00000a56, 0x00000686, 0x0000041e, 0x00000299, + 0x000001a3, 0x00000109, 0x000000a7, 0x00000069, + 0x00000042, 0x0000002a, 0x0000001a, 0x00000011, + 0x0000000b, 0x00000007, 0x00000004, 0x00000003, + 0x00000002, 0x00000001, 0x00000001}; + +static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={ + 0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7, + 0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc, + 0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2, + 0x000001ac, 0x000001a6, 0x000001a0, 0x0000019a, + 0x00000194, 0x0000018e, 0x00000188, 0x00000183, + 0x0000017d, 0x00000178, 0x00000172, 0x0000016d, + 0x00000168, 0x00000163, 0x0000015e, 0x00000159, + 0x00000154, 0x0000014f, 0x0000014a, 0x00000145, +}; + +#define INVSQ_LOOKUP_I_SHIFT 10 +#define INVSQ_LOOKUP_I_MASK 1023 +static const long INVSQ_LOOKUP_I[64+1]={ + 92682, 91966, 91267, 90583, + 89915, 89261, 88621, 87995, + 87381, 86781, 86192, 85616, + 85051, 84497, 83953, 83420, + 82897, 82384, 81880, 81385, + 80899, 80422, 79953, 79492, + 79039, 78594, 78156, 77726, + 77302, 76885, 76475, 76072, + 75674, 75283, 74898, 74519, + 74146, 73778, 73415, 73058, + 72706, 72359, 72016, 71679, + 71347, 71019, 70695, 70376, + 70061, 69750, 69444, 69141, + 68842, 68548, 68256, 67969, + 67685, 67405, 67128, 66855, + 66585, 66318, 66054, 65794, + 65536, +}; + +static const long INVSQ_LOOKUP_IDel[64]={ + 716, 699, 684, 668, + 654, 640, 626, 614, + 600, 589, 576, 565, + 554, 544, 533, 523, + 513, 504, 495, 486, + 477, 469, 461, 453, + 445, 438, 430, 424, + 417, 410, 403, 398, + 391, 385, 379, 373, + 368, 363, 357, 352, + 347, 343, 337, 332, + 328, 324, 319, 315, + 311, 306, 303, 299, + 294, 292, 287, 284, + 280, 277, 273, 270, + 267, 264, 260, 258, +}; + +#define COS_LOOKUP_I_SHIFT 9 +#define COS_LOOKUP_I_MASK 511 +#define COS_LOOKUP_I_SZ 128 +static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={ + 16384, 16379, 16364, 16340, + 16305, 16261, 16207, 16143, + 16069, 15986, 15893, 15791, + 15679, 15557, 15426, 15286, + 15137, 14978, 14811, 14635, + 14449, 14256, 14053, 13842, + 13623, 13395, 13160, 12916, + 12665, 12406, 12140, 11866, + 11585, 11297, 11003, 10702, + 10394, 10080, 9760, 9434, + 9102, 8765, 8423, 8076, + 7723, 7366, 7005, 6639, + 6270, 5897, 5520, 5139, + 4756, 4370, 3981, 3590, + 3196, 2801, 2404, 2006, + 1606, 1205, 804, 402, + 0, -401, -803, -1204, + -1605, -2005, -2403, -2800, + -3195, -3589, -3980, -4369, + -4755, -5138, -5519, -5896, + -6269, -6638, -7004, -7365, + -7722, -8075, -8422, -8764, + -9101, -9433, -9759, -10079, + -10393, -10701, -11002, -11296, + -11584, -11865, -12139, -12405, + -12664, -12915, -13159, -13394, + -13622, -13841, -14052, -14255, + -14448, -14634, -14810, -14977, + -15136, -15285, -15425, -15556, + -15678, -15790, -15892, -15985, + -16068, -16142, -16206, -16260, + -16304, -16339, -16363, -16378, + -16383, +}; + +#endif + + + + + diff --git a/wolf3d/newCode/Tremor/mapping0.c b/wolf3d/newCode/Tremor/mapping0.c new file mode 100644 index 0000000..c54c896 --- /dev/null +++ b/wolf3d/newCode/Tremor/mapping0.c @@ -0,0 +1,322 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: channel mapping 0 implementation + + ********************************************************************/ + +#include +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "mdct.h" +#include "codec_internal.h" +#include "codebook.h" +#include "window.h" +#include "registry.h" +#include "misc.h" + +/* simplistic, wasteful way of doing this (unique lookup for each + mode/submapping); there should be a central repository for + identical lookups. That will require minor work, so I'm putting it + off as low priority. + + Why a lookup for each backend in a given mode? Because the + blocksize is set by the mode, and low backend lookups may require + parameters from other areas of the mode/mapping */ + +typedef struct { + vorbis_info_mode *mode; + vorbis_info_mapping0 *map; + + vorbis_look_floor **floor_look; + + vorbis_look_residue **residue_look; + + vorbis_func_floor **floor_func; + vorbis_func_residue **residue_func; + + int ch; + long lastframe; /* if a different mode is called, we need to + invalidate decay */ +} vorbis_look_mapping0; + +static void mapping0_free_info(vorbis_info_mapping *i){ + vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void mapping0_free_look(vorbis_look_mapping *look){ + int i; + vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look; + if(l){ + + for(i=0;imap->submaps;i++){ + l->floor_func[i]->free_look(l->floor_look[i]); + l->residue_func[i]->free_look(l->residue_look[i]); + } + + _ogg_free(l->floor_func); + _ogg_free(l->residue_func); + _ogg_free(l->floor_look); + _ogg_free(l->residue_look); + memset(l,0,sizeof(*l)); + _ogg_free(l); + } +} + +static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, + vorbis_info_mapping *m){ + int i; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look)); + vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m; + look->mode=vm; + + look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look)); + + look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look)); + + look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func)); + look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func)); + + for(i=0;isubmaps;i++){ + int floornum=info->floorsubmap[i]; + int resnum=info->residuesubmap[i]; + + look->floor_func[i]=_floor_P[ci->floor_type[floornum]]; + look->floor_look[i]=look->floor_func[i]-> + look(vd,vm,ci->floor_param[floornum]); + look->residue_func[i]=_residue_P[ci->residue_type[resnum]]; + look->residue_look[i]=look->residue_func[i]-> + look(vd,vm,ci->residue_param[resnum]); + + } + + look->ch=vi->channels; + + return(look); +} + +static int ilog(unsigned int v){ + int ret=0; + if(v)--v; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +/* also responsible for range checking */ +static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ + int i; + vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info)); + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + memset(info,0,sizeof(*info)); + + if(oggpack_read(opb,1)) + info->submaps=oggpack_read(opb,4)+1; + else + info->submaps=1; + + if(oggpack_read(opb,1)){ + info->coupling_steps=oggpack_read(opb,8)+1; + + for(i=0;icoupling_steps;i++){ + int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels)); + int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels)); + + if(testM<0 || + testA<0 || + testM==testA || + testM>=vi->channels || + testA>=vi->channels) goto err_out; + } + + } + + if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */ + + if(info->submaps>1){ + for(i=0;ichannels;i++){ + info->chmuxlist[i]=oggpack_read(opb,4); + if(info->chmuxlist[i]>=info->submaps)goto err_out; + } + } + for(i=0;isubmaps;i++){ + int temp=oggpack_read(opb,8); + if(temp>=ci->times)goto err_out; + info->floorsubmap[i]=oggpack_read(opb,8); + if(info->floorsubmap[i]>=ci->floors)goto err_out; + info->residuesubmap[i]=oggpack_read(opb,8); + if(info->residuesubmap[i]>=ci->residues)goto err_out; + } + + return info; + + err_out: + mapping0_free_info(info); + return(NULL); +} + +static int seq=0; +static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ + vorbis_dsp_state *vd=vb->vd; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + private_state *b=(private_state *)vd->backend_state; + vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l; + vorbis_info_mapping0 *info=look->map; + + int i,j; + long n=vb->pcmend=ci->blocksizes[vb->W]; + + ogg_int32_t **pcmbundle=(ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels); + int *zerobundle=(int *)alloca(sizeof(*zerobundle)*vi->channels); + + int *nonzero =(int *)alloca(sizeof(*nonzero)*vi->channels); + void **floormemo=(void **)alloca(sizeof(*floormemo)*vi->channels); + + /* time domain information decode (note that applying the + information would have to happen later; we'll probably add a + function entry to the harness for that later */ + /* NOT IMPLEMENTED */ + + /* recover the spectral envelope; store it in the PCM vector for now */ + for(i=0;ichannels;i++){ + int submap=info->chmuxlist[i]; + floormemo[i]=look->floor_func[submap]-> + inverse1(vb,look->floor_look[submap]); + if(floormemo[i]) + nonzero[i]=1; + else + nonzero[i]=0; + memset(vb->pcm[i],0,sizeof(*vb->pcm[i])*n/2); + } + + /* channel coupling can 'dirty' the nonzero listing */ + for(i=0;icoupling_steps;i++){ + if(nonzero[info->coupling_mag[i]] || + nonzero[info->coupling_ang[i]]){ + nonzero[info->coupling_mag[i]]=1; + nonzero[info->coupling_ang[i]]=1; + } + } + + /* recover the residue into our working vectors */ + for(i=0;isubmaps;i++){ + int ch_in_bundle=0; + for(j=0;jchannels;j++){ + if(info->chmuxlist[j]==i){ + if(nonzero[j]) + zerobundle[ch_in_bundle]=1; + else + zerobundle[ch_in_bundle]=0; + pcmbundle[ch_in_bundle++]=vb->pcm[j]; + } + } + + look->residue_func[i]->inverse(vb,look->residue_look[i], + pcmbundle,zerobundle,ch_in_bundle); + } + + //for(j=0;jchannels;j++) + //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0); + + + /* channel coupling */ + for(i=info->coupling_steps-1;i>=0;i--){ + ogg_int32_t *pcmM=vb->pcm[info->coupling_mag[i]]; + ogg_int32_t *pcmA=vb->pcm[info->coupling_ang[i]]; + + for(j=0;j0) + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag-ang; + }else{ + pcmA[j]=mag; + pcmM[j]=mag+ang; + } + else + if(ang>0){ + pcmM[j]=mag; + pcmA[j]=mag+ang; + }else{ + pcmA[j]=mag; + pcmM[j]=mag-ang; + } + } + } + + //for(j=0;jchannels;j++) + //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); + + /* compute and apply spectral envelope */ + for(i=0;ichannels;i++){ + ogg_int32_t *pcm=vb->pcm[i]; + int submap=info->chmuxlist[i]; + look->floor_func[submap]-> + inverse2(vb,look->floor_look[submap],floormemo[i],pcm); + } + + //for(j=0;jchannels;j++) + //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); + + /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ + /* only MDCT right now.... */ + for(i=0;ichannels;i++){ + ogg_int32_t *pcm=vb->pcm[i]; + mdct_backward(n,pcm,pcm); + } + + //for(j=0;jchannels;j++) + //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0); + + /* window the data */ + for(i=0;ichannels;i++){ + ogg_int32_t *pcm=vb->pcm[i]; + if(nonzero[i]) + _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW); + else + for(j=0;jchannels;j++) + //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0); + + seq+=vi->channels; + /* all done! */ + return(0); +} + +/* export hooks */ +vorbis_func_mapping mapping0_exportbundle={ + &mapping0_unpack, + &mapping0_look, + &mapping0_free_info, + &mapping0_free_look, + &mapping0_inverse +}; diff --git a/wolf3d/newCode/Tremor/mdct.c b/wolf3d/newCode/Tremor/mdct.c new file mode 100644 index 0000000..4f39e7d --- /dev/null +++ b/wolf3d/newCode/Tremor/mdct.c @@ -0,0 +1,510 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: normalized modified discrete cosine transform + power of two length transform only [64 <= n ] + last mod: $Id: mdct.c,v 1.9 2002/10/16 09:17:39 xiphmont Exp $ + + Original algorithm adapted long ago from _The use of multirate filter + banks for coding of high quality digital audio_, by T. Sporer, + K. Brandenburg and B. Edler, collection of the European Signal + Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp + 211-214 + + The below code implements an algorithm that no longer looks much like + that presented in the paper, but the basic structure remains if you + dig deep enough to see it. + + This module DOES NOT INCLUDE code to generate/apply the window + function. Everybody has their own weird favorite including me... I + happen to like the properties of y=sin(.5PI*sin^2(x)), but others may + vehemently disagree. + + ********************************************************************/ + +#include "ivorbiscodec.h" +#include "codebook.h" +#include "misc.h" +#include "mdct.h" +#include "mdct_lookup.h" + + +/* 8 point butterfly (in place) */ +STIN void mdct_butterfly_8(DATA_TYPE *x){ + + REG_TYPE r0 = x[4] + x[0]; + REG_TYPE r1 = x[4] - x[0]; + REG_TYPE r2 = x[5] + x[1]; + REG_TYPE r3 = x[5] - x[1]; + REG_TYPE r4 = x[6] + x[2]; + REG_TYPE r5 = x[6] - x[2]; + REG_TYPE r6 = x[7] + x[3]; + REG_TYPE r7 = x[7] - x[3]; + + x[0] = r5 + r3; + x[1] = r7 - r1; + x[2] = r5 - r3; + x[3] = r7 + r1; + x[4] = r4 - r0; + x[5] = r6 - r2; + x[6] = r4 + r0; + x[7] = r6 + r2; + MB(); +} + +/* 16 point butterfly (in place, 4 register) */ +STIN void mdct_butterfly_16(DATA_TYPE *x){ + + REG_TYPE r0, r1; + + r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0]; + r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1]; + x[ 0] = MULT31((r0 + r1) , cPI2_8); + x[ 1] = MULT31((r1 - r0) , cPI2_8); + MB(); + + r0 = x[10] - x[ 2]; x[10] += x[ 2]; + r1 = x[ 3] - x[11]; x[11] += x[ 3]; + x[ 2] = r1; x[ 3] = r0; + MB(); + + r0 = x[12] - x[ 4]; x[12] += x[ 4]; + r1 = x[13] - x[ 5]; x[13] += x[ 5]; + x[ 4] = MULT31((r0 - r1) , cPI2_8); + x[ 5] = MULT31((r0 + r1) , cPI2_8); + MB(); + + r0 = x[14] - x[ 6]; x[14] += x[ 6]; + r1 = x[15] - x[ 7]; x[15] += x[ 7]; + x[ 6] = r0; x[ 7] = r1; + MB(); + + mdct_butterfly_8(x); + mdct_butterfly_8(x+8); +} + +/* 32 point butterfly (in place, 4 register) */ +STIN void mdct_butterfly_32(DATA_TYPE *x){ + + REG_TYPE r0, r1; + + r0 = x[30] - x[14]; x[30] += x[14]; + r1 = x[31] - x[15]; x[31] += x[15]; + x[14] = r0; x[15] = r1; + MB(); + + r0 = x[28] - x[12]; x[28] += x[12]; + r1 = x[29] - x[13]; x[29] += x[13]; + XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] ); + MB(); + + r0 = x[26] - x[10]; x[26] += x[10]; + r1 = x[27] - x[11]; x[27] += x[11]; + x[10] = MULT31((r0 - r1) , cPI2_8); + x[11] = MULT31((r0 + r1) , cPI2_8); + MB(); + + r0 = x[24] - x[ 8]; x[24] += x[ 8]; + r1 = x[25] - x[ 9]; x[25] += x[ 9]; + XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] ); + MB(); + + r0 = x[22] - x[ 6]; x[22] += x[ 6]; + r1 = x[ 7] - x[23]; x[23] += x[ 7]; + x[ 6] = r1; x[ 7] = r0; + MB(); + + r0 = x[ 4] - x[20]; x[20] += x[ 4]; + r1 = x[ 5] - x[21]; x[21] += x[ 5]; + XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] ); + MB(); + + r0 = x[ 2] - x[18]; x[18] += x[ 2]; + r1 = x[ 3] - x[19]; x[19] += x[ 3]; + x[ 2] = MULT31((r1 + r0) , cPI2_8); + x[ 3] = MULT31((r1 - r0) , cPI2_8); + MB(); + + r0 = x[ 0] - x[16]; x[16] += x[ 0]; + r1 = x[ 1] - x[17]; x[17] += x[ 1]; + XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] ); + MB(); + + mdct_butterfly_16(x); + mdct_butterfly_16(x+16); +} + +/* N/stage point generic N stage butterfly (in place, 2 register) */ +STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){ + + LOOKUP_T *T = sincos_lookup0; + DATA_TYPE *x1 = x + points - 8; + DATA_TYPE *x2 = x + (points>>1) - 8; + REG_TYPE r0; + REG_TYPE r1; + + do{ + r0 = x1[6] - x2[6]; x1[6] += x2[6]; + r1 = x2[7] - x1[7]; x1[7] += x2[7]; + XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step; + + r0 = x1[4] - x2[4]; x1[4] += x2[4]; + r1 = x2[5] - x1[5]; x1[5] += x2[5]; + XPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T+=step; + + r0 = x1[2] - x2[2]; x1[2] += x2[2]; + r1 = x2[3] - x1[3]; x1[3] += x2[3]; + XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step; + + r0 = x1[0] - x2[0]; x1[0] += x2[0]; + r1 = x2[1] - x1[1]; x1[1] += x2[1]; + XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T+=step; + + x1-=8; x2-=8; + }while(Tsincos_lookup0); + do{ + r0 = x2[6] - x1[6]; x1[6] += x2[6]; + r1 = x2[7] - x1[7]; x1[7] += x2[7]; + XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step; + + r0 = x2[4] - x1[4]; x1[4] += x2[4]; + r1 = x2[5] - x1[5]; x1[5] += x2[5]; + XPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T+=step; + + r0 = x2[2] - x1[2]; x1[2] += x2[2]; + r1 = x2[3] - x1[3]; x1[3] += x2[3]; + XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step; + + r0 = x2[0] - x1[0]; x1[0] += x2[0]; + r1 = x2[1] - x1[1]; x1[1] += x2[1]; + XPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T+=step; + + x1-=8; x2-=8; + }while(Tsincos_lookup0); +} + +STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){ + + int stages=8-shift; + int i,j; + + for(i=0;--stages>0;i++){ + for(j=0;j<(1<>i)*j,points>>i,4<<(i+shift)); + } + + for(j=0;j>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8); +} + +STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){ + + int bit = 0; + DATA_TYPE *w0 = x; + DATA_TYPE *w1 = x = w0+(n>>1); + LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1; + LOOKUP_T *Ttop = T+1024; + DATA_TYPE r2; + + do{ + DATA_TYPE r3 = bitrev12(bit++); + DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1; + DATA_TYPE *x1 = x + (r3>>shift); + + REG_TYPE r0 = x0[0] + x1[0]; + REG_TYPE r1 = x1[1] - x0[1]; + + XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step; + + w1 -= 4; + + r0 = (x0[1] + x1[1])>>1; + r1 = (x0[0] - x1[0])>>1; + w0[0] = r0 + r2; + w0[1] = r1 + r3; + w1[2] = r0 - r2; + w1[3] = r3 - r1; + + r3 = bitrev12(bit++); + x0 = x + ((r3 ^ 0xfff)>>shift) -1; + x1 = x + (r3>>shift); + + r0 = x0[0] + x1[0]; + r1 = x1[1] - x0[1]; + + XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step; + + r0 = (x0[1] + x1[1])>>1; + r1 = (x0[0] - x1[0])>>1; + w0[2] = r0 + r2; + w0[3] = r1 + r3; + w1[0] = r0 - r2; + w1[1] = r3 - r1; + + w0 += 4; + }while(T>shift) -1; + DATA_TYPE *x1 = x + (r3>>shift); + + REG_TYPE r0 = x0[0] + x1[0]; + REG_TYPE r1 = x1[1] - x0[1]; + + T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 ); + + w1 -= 4; + + r0 = (x0[1] + x1[1])>>1; + r1 = (x0[0] - x1[0])>>1; + w0[0] = r0 + r2; + w0[1] = r1 + r3; + w1[2] = r0 - r2; + w1[3] = r3 - r1; + + r3 = bitrev12(bit++); + x0 = x + ((r3 ^ 0xfff)>>shift) -1; + x1 = x + (r3>>shift); + + r0 = x0[0] + x1[0]; + r1 = x1[1] - x0[1]; + + T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 ); + + r0 = (x0[1] + x1[1])>>1; + r1 = (x0[0] - x1[0])>>1; + w0[2] = r0 + r2; + w0[3] = r1 + r3; + w1[0] = r0 - r2; + w1[1] = r3 - r1; + + w0 += 4; + }while(w0>1; + int n4=n>>2; + DATA_TYPE *iX; + DATA_TYPE *oX; + LOOKUP_T *T; + LOOKUP_T *V; + int shift; + int step; + + for (shift=6;!(n&(1<=in+n4); + do{ + oX-=4; + XPROD31( iX[4], iX[6], T[1], T[0], &oX[2], &oX[3] ); T-=step; + XPROD31( iX[0], iX[2], T[1], T[0], &oX[0], &oX[1] ); T-=step; + iX-=8; + }while(iX>=in); + + iX = in+n2-8; + oX = out+n2+n4; + T = sincos_lookup0; + + do{ + T+=step; XNPROD31( iX[6], iX[4], T[0], T[1], &oX[0], &oX[1] ); + T+=step; XNPROD31( iX[2], iX[0], T[0], T[1], &oX[2], &oX[3] ); + iX-=8; + oX+=4; + }while(iX>=in+n4); + do{ + T-=step; XNPROD31( iX[6], iX[4], T[1], T[0], &oX[0], &oX[1] ); + T-=step; XNPROD31( iX[2], iX[0], T[1], T[0], &oX[2], &oX[3] ); + iX-=8; + oX+=4; + }while(iX>=in); + + mdct_butterflies(out+n2,n2,shift); + mdct_bitreverse(out,n,step,shift); + + /* rotate + window */ + + step>>=2; + { + DATA_TYPE *oX1=out+n2+n4; + DATA_TYPE *oX2=out+n2+n4; + DATA_TYPE *iX =out; + + switch(step) { + default: { + T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1; + do{ + oX1-=4; + XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step; + XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step; + XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step; + XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step; + oX2+=4; + iX+=8; + }while(iX>1; + t1 = (*T++)>>1; + do{ + oX1-=4; + + t0 += (v0 = (*V++)>>1); + t1 += (v1 = (*V++)>>1); + XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] ); + v0 += (t0 = (*T++)>>1); + v1 += (t1 = (*T++)>>1); + XPROD31( iX[2], -iX[3], v0, v1, &oX1[2], &oX2[1] ); + t0 += (v0 = (*V++)>>1); + t1 += (v1 = (*V++)>>1); + XPROD31( iX[4], -iX[5], t0, t1, &oX1[1], &oX2[2] ); + v0 += (t0 = (*T++)>>1); + v1 += (t1 = (*T++)>>1); + XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] ); + + oX2+=4; + iX+=8; + }while(iX>2); + t1 += (q1 = (v1-t1)>>2); + XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] ); + t0 = v0-q0; + t1 = v1-q1; + XPROD31( iX[2], -iX[3], t0, t1, &oX1[2], &oX2[1] ); + + t0 = *T++; + t1 = *T++; + v0 += (q0 = (t0-v0)>>2); + v1 += (q1 = (t1-v1)>>2); + XPROD31( iX[4], -iX[5], v0, v1, &oX1[1], &oX2[2] ); + v0 = t0-q0; + v1 = t1-q1; + XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] ); + + oX2+=4; + iX+=8; + }while(iXoX2); + } +} + diff --git a/wolf3d/newCode/Tremor/mdct.h b/wolf3d/newCode/Tremor/mdct.h new file mode 100644 index 0000000..6d88907 --- /dev/null +++ b/wolf3d/newCode/Tremor/mdct.h @@ -0,0 +1,52 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: modified discrete cosine transform prototypes + + ********************************************************************/ + +#ifndef _OGG_mdct_H_ +#define _OGG_mdct_H_ + +#include "ivorbiscodec.h" +#include "misc.h" + +#define DATA_TYPE ogg_int32_t +#define REG_TYPE register ogg_int32_t + +#ifdef _LOW_ACCURACY_ +#define cPI3_8 (0x0062) +#define cPI2_8 (0x00b5) +#define cPI1_8 (0x00ed) +#else +#define cPI3_8 (0x30fbc54d) +#define cPI2_8 (0x5a82799a) +#define cPI1_8 (0x7641af3d) +#endif + +extern void mdct_forward(int n, DATA_TYPE *in, DATA_TYPE *out); +extern void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out); + +#endif + + + + + + + + + + + + diff --git a/wolf3d/newCode/Tremor/mdct_lookup.h b/wolf3d/newCode/Tremor/mdct_lookup.h new file mode 100644 index 0000000..970e199 --- /dev/null +++ b/wolf3d/newCode/Tremor/mdct_lookup.h @@ -0,0 +1,540 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: sin,cos lookup tables + + ********************************************************************/ + +#include "os_types.h" + +/* {sin(2*i*PI/4096), cos(2*i*PI/4096)}, with i = 0 to 512 */ +static LOOKUP_T sincos_lookup0[1026] = { + X(0x00000000), X(0x7fffffff), X(0x003243f5), X(0x7ffff621), + X(0x006487e3), X(0x7fffd886), X(0x0096cbc1), X(0x7fffa72c), + X(0x00c90f88), X(0x7fff6216), X(0x00fb5330), X(0x7fff0943), + X(0x012d96b1), X(0x7ffe9cb2), X(0x015fda03), X(0x7ffe1c65), + X(0x01921d20), X(0x7ffd885a), X(0x01c45ffe), X(0x7ffce093), + X(0x01f6a297), X(0x7ffc250f), X(0x0228e4e2), X(0x7ffb55ce), + X(0x025b26d7), X(0x7ffa72d1), X(0x028d6870), X(0x7ff97c18), + X(0x02bfa9a4), X(0x7ff871a2), X(0x02f1ea6c), X(0x7ff75370), + X(0x03242abf), X(0x7ff62182), X(0x03566a96), X(0x7ff4dbd9), + X(0x0388a9ea), X(0x7ff38274), X(0x03bae8b2), X(0x7ff21553), + X(0x03ed26e6), X(0x7ff09478), X(0x041f6480), X(0x7feeffe1), + X(0x0451a177), X(0x7fed5791), X(0x0483ddc3), X(0x7feb9b85), + X(0x04b6195d), X(0x7fe9cbc0), X(0x04e8543e), X(0x7fe7e841), + X(0x051a8e5c), X(0x7fe5f108), X(0x054cc7b1), X(0x7fe3e616), + X(0x057f0035), X(0x7fe1c76b), X(0x05b137df), X(0x7fdf9508), + X(0x05e36ea9), X(0x7fdd4eec), X(0x0615a48b), X(0x7fdaf519), + X(0x0647d97c), X(0x7fd8878e), X(0x067a0d76), X(0x7fd6064c), + X(0x06ac406f), X(0x7fd37153), X(0x06de7262), X(0x7fd0c8a3), + X(0x0710a345), X(0x7fce0c3e), X(0x0742d311), X(0x7fcb3c23), + X(0x077501be), X(0x7fc85854), X(0x07a72f45), X(0x7fc560cf), + X(0x07d95b9e), X(0x7fc25596), X(0x080b86c2), X(0x7fbf36aa), + X(0x083db0a7), X(0x7fbc040a), X(0x086fd947), X(0x7fb8bdb8), + X(0x08a2009a), X(0x7fb563b3), X(0x08d42699), X(0x7fb1f5fc), + X(0x09064b3a), X(0x7fae7495), X(0x09386e78), X(0x7faadf7c), + X(0x096a9049), X(0x7fa736b4), X(0x099cb0a7), X(0x7fa37a3c), + X(0x09cecf89), X(0x7f9faa15), X(0x0a00ece8), X(0x7f9bc640), + X(0x0a3308bd), X(0x7f97cebd), X(0x0a6522fe), X(0x7f93c38c), + X(0x0a973ba5), X(0x7f8fa4b0), X(0x0ac952aa), X(0x7f8b7227), + X(0x0afb6805), X(0x7f872bf3), X(0x0b2d7baf), X(0x7f82d214), + X(0x0b5f8d9f), X(0x7f7e648c), X(0x0b919dcf), X(0x7f79e35a), + X(0x0bc3ac35), X(0x7f754e80), X(0x0bf5b8cb), X(0x7f70a5fe), + X(0x0c27c389), X(0x7f6be9d4), X(0x0c59cc68), X(0x7f671a05), + X(0x0c8bd35e), X(0x7f62368f), X(0x0cbdd865), X(0x7f5d3f75), + X(0x0cefdb76), X(0x7f5834b7), X(0x0d21dc87), X(0x7f531655), + X(0x0d53db92), X(0x7f4de451), X(0x0d85d88f), X(0x7f489eaa), + X(0x0db7d376), X(0x7f434563), X(0x0de9cc40), X(0x7f3dd87c), + X(0x0e1bc2e4), X(0x7f3857f6), X(0x0e4db75b), X(0x7f32c3d1), + X(0x0e7fa99e), X(0x7f2d1c0e), X(0x0eb199a4), X(0x7f2760af), + X(0x0ee38766), X(0x7f2191b4), X(0x0f1572dc), X(0x7f1baf1e), + X(0x0f475bff), X(0x7f15b8ee), X(0x0f7942c7), X(0x7f0faf25), + X(0x0fab272b), X(0x7f0991c4), X(0x0fdd0926), X(0x7f0360cb), + X(0x100ee8ad), X(0x7efd1c3c), X(0x1040c5bb), X(0x7ef6c418), + X(0x1072a048), X(0x7ef05860), X(0x10a4784b), X(0x7ee9d914), + X(0x10d64dbd), X(0x7ee34636), X(0x11082096), X(0x7edc9fc6), + X(0x1139f0cf), X(0x7ed5e5c6), X(0x116bbe60), X(0x7ecf1837), + X(0x119d8941), X(0x7ec8371a), X(0x11cf516a), X(0x7ec14270), + X(0x120116d5), X(0x7eba3a39), X(0x1232d979), X(0x7eb31e78), + X(0x1264994e), X(0x7eabef2c), X(0x1296564d), X(0x7ea4ac58), + X(0x12c8106f), X(0x7e9d55fc), X(0x12f9c7aa), X(0x7e95ec1a), + X(0x132b7bf9), X(0x7e8e6eb2), X(0x135d2d53), X(0x7e86ddc6), + X(0x138edbb1), X(0x7e7f3957), X(0x13c0870a), X(0x7e778166), + X(0x13f22f58), X(0x7e6fb5f4), X(0x1423d492), X(0x7e67d703), + X(0x145576b1), X(0x7e5fe493), X(0x148715ae), X(0x7e57dea7), + X(0x14b8b17f), X(0x7e4fc53e), X(0x14ea4a1f), X(0x7e47985b), + X(0x151bdf86), X(0x7e3f57ff), X(0x154d71aa), X(0x7e37042a), + X(0x157f0086), X(0x7e2e9cdf), X(0x15b08c12), X(0x7e26221f), + X(0x15e21445), X(0x7e1d93ea), X(0x16139918), X(0x7e14f242), + X(0x16451a83), X(0x7e0c3d29), X(0x1676987f), X(0x7e0374a0), + X(0x16a81305), X(0x7dfa98a8), X(0x16d98a0c), X(0x7df1a942), + X(0x170afd8d), X(0x7de8a670), X(0x173c6d80), X(0x7ddf9034), + X(0x176dd9de), X(0x7dd6668f), X(0x179f429f), X(0x7dcd2981), + X(0x17d0a7bc), X(0x7dc3d90d), X(0x1802092c), X(0x7dba7534), + X(0x183366e9), X(0x7db0fdf8), X(0x1864c0ea), X(0x7da77359), + X(0x18961728), X(0x7d9dd55a), X(0x18c7699b), X(0x7d9423fc), + X(0x18f8b83c), X(0x7d8a5f40), X(0x192a0304), X(0x7d808728), + X(0x195b49ea), X(0x7d769bb5), X(0x198c8ce7), X(0x7d6c9ce9), + X(0x19bdcbf3), X(0x7d628ac6), X(0x19ef0707), X(0x7d58654d), + X(0x1a203e1b), X(0x7d4e2c7f), X(0x1a517128), X(0x7d43e05e), + X(0x1a82a026), X(0x7d3980ec), X(0x1ab3cb0d), X(0x7d2f0e2b), + X(0x1ae4f1d6), X(0x7d24881b), X(0x1b161479), X(0x7d19eebf), + X(0x1b4732ef), X(0x7d0f4218), X(0x1b784d30), X(0x7d048228), + X(0x1ba96335), X(0x7cf9aef0), X(0x1bda74f6), X(0x7ceec873), + X(0x1c0b826a), X(0x7ce3ceb2), X(0x1c3c8b8c), X(0x7cd8c1ae), + X(0x1c6d9053), X(0x7ccda169), X(0x1c9e90b8), X(0x7cc26de5), + X(0x1ccf8cb3), X(0x7cb72724), X(0x1d00843d), X(0x7cabcd28), + X(0x1d31774d), X(0x7ca05ff1), X(0x1d6265dd), X(0x7c94df83), + X(0x1d934fe5), X(0x7c894bde), X(0x1dc4355e), X(0x7c7da505), + X(0x1df5163f), X(0x7c71eaf9), X(0x1e25f282), X(0x7c661dbc), + X(0x1e56ca1e), X(0x7c5a3d50), X(0x1e879d0d), X(0x7c4e49b7), + X(0x1eb86b46), X(0x7c4242f2), X(0x1ee934c3), X(0x7c362904), + X(0x1f19f97b), X(0x7c29fbee), X(0x1f4ab968), X(0x7c1dbbb3), + X(0x1f7b7481), X(0x7c116853), X(0x1fac2abf), X(0x7c0501d2), + X(0x1fdcdc1b), X(0x7bf88830), X(0x200d888d), X(0x7bebfb70), + X(0x203e300d), X(0x7bdf5b94), X(0x206ed295), X(0x7bd2a89e), + X(0x209f701c), X(0x7bc5e290), X(0x20d0089c), X(0x7bb9096b), + X(0x21009c0c), X(0x7bac1d31), X(0x21312a65), X(0x7b9f1de6), + X(0x2161b3a0), X(0x7b920b89), X(0x219237b5), X(0x7b84e61f), + X(0x21c2b69c), X(0x7b77ada8), X(0x21f3304f), X(0x7b6a6227), + X(0x2223a4c5), X(0x7b5d039e), X(0x225413f8), X(0x7b4f920e), + X(0x22847de0), X(0x7b420d7a), X(0x22b4e274), X(0x7b3475e5), + X(0x22e541af), X(0x7b26cb4f), X(0x23159b88), X(0x7b190dbc), + X(0x2345eff8), X(0x7b0b3d2c), X(0x23763ef7), X(0x7afd59a4), + X(0x23a6887f), X(0x7aef6323), X(0x23d6cc87), X(0x7ae159ae), + X(0x24070b08), X(0x7ad33d45), X(0x243743fa), X(0x7ac50dec), + X(0x24677758), X(0x7ab6cba4), X(0x2497a517), X(0x7aa8766f), + X(0x24c7cd33), X(0x7a9a0e50), X(0x24f7efa2), X(0x7a8b9348), + X(0x25280c5e), X(0x7a7d055b), X(0x2558235f), X(0x7a6e648a), + X(0x2588349d), X(0x7a5fb0d8), X(0x25b84012), X(0x7a50ea47), + X(0x25e845b6), X(0x7a4210d8), X(0x26184581), X(0x7a332490), + X(0x26483f6c), X(0x7a24256f), X(0x26783370), X(0x7a151378), + X(0x26a82186), X(0x7a05eead), X(0x26d809a5), X(0x79f6b711), + X(0x2707ebc7), X(0x79e76ca7), X(0x2737c7e3), X(0x79d80f6f), + X(0x27679df4), X(0x79c89f6e), X(0x27976df1), X(0x79b91ca4), + X(0x27c737d3), X(0x79a98715), X(0x27f6fb92), X(0x7999dec4), + X(0x2826b928), X(0x798a23b1), X(0x2856708d), X(0x797a55e0), + X(0x288621b9), X(0x796a7554), X(0x28b5cca5), X(0x795a820e), + X(0x28e5714b), X(0x794a7c12), X(0x29150fa1), X(0x793a6361), + X(0x2944a7a2), X(0x792a37fe), X(0x29743946), X(0x7919f9ec), + X(0x29a3c485), X(0x7909a92d), X(0x29d34958), X(0x78f945c3), + X(0x2a02c7b8), X(0x78e8cfb2), X(0x2a323f9e), X(0x78d846fb), + X(0x2a61b101), X(0x78c7aba2), X(0x2a911bdc), X(0x78b6fda8), + X(0x2ac08026), X(0x78a63d11), X(0x2aefddd8), X(0x789569df), + X(0x2b1f34eb), X(0x78848414), X(0x2b4e8558), X(0x78738bb3), + X(0x2b7dcf17), X(0x786280bf), X(0x2bad1221), X(0x7851633b), + X(0x2bdc4e6f), X(0x78403329), X(0x2c0b83fa), X(0x782ef08b), + X(0x2c3ab2b9), X(0x781d9b65), X(0x2c69daa6), X(0x780c33b8), + X(0x2c98fbba), X(0x77fab989), X(0x2cc815ee), X(0x77e92cd9), + X(0x2cf72939), X(0x77d78daa), X(0x2d263596), X(0x77c5dc01), + X(0x2d553afc), X(0x77b417df), X(0x2d843964), X(0x77a24148), + X(0x2db330c7), X(0x7790583e), X(0x2de2211e), X(0x777e5cc3), + X(0x2e110a62), X(0x776c4edb), X(0x2e3fec8b), X(0x775a2e89), + X(0x2e6ec792), X(0x7747fbce), X(0x2e9d9b70), X(0x7735b6af), + X(0x2ecc681e), X(0x77235f2d), X(0x2efb2d95), X(0x7710f54c), + X(0x2f29ebcc), X(0x76fe790e), X(0x2f58a2be), X(0x76ebea77), + X(0x2f875262), X(0x76d94989), X(0x2fb5fab2), X(0x76c69647), + X(0x2fe49ba7), X(0x76b3d0b4), X(0x30133539), X(0x76a0f8d2), + X(0x3041c761), X(0x768e0ea6), X(0x30705217), X(0x767b1231), + X(0x309ed556), X(0x76680376), X(0x30cd5115), X(0x7654e279), + X(0x30fbc54d), X(0x7641af3d), X(0x312a31f8), X(0x762e69c4), + X(0x3158970e), X(0x761b1211), X(0x3186f487), X(0x7607a828), + X(0x31b54a5e), X(0x75f42c0b), X(0x31e39889), X(0x75e09dbd), + X(0x3211df04), X(0x75ccfd42), X(0x32401dc6), X(0x75b94a9c), + X(0x326e54c7), X(0x75a585cf), X(0x329c8402), X(0x7591aedd), + X(0x32caab6f), X(0x757dc5ca), X(0x32f8cb07), X(0x7569ca99), + X(0x3326e2c3), X(0x7555bd4c), X(0x3354f29b), X(0x75419de7), + X(0x3382fa88), X(0x752d6c6c), X(0x33b0fa84), X(0x751928e0), + X(0x33def287), X(0x7504d345), X(0x340ce28b), X(0x74f06b9e), + X(0x343aca87), X(0x74dbf1ef), X(0x3468aa76), X(0x74c7663a), + X(0x34968250), X(0x74b2c884), X(0x34c4520d), X(0x749e18cd), + X(0x34f219a8), X(0x7489571c), X(0x351fd918), X(0x74748371), + X(0x354d9057), X(0x745f9dd1), X(0x357b3f5d), X(0x744aa63f), + X(0x35a8e625), X(0x74359cbd), X(0x35d684a6), X(0x74208150), + X(0x36041ad9), X(0x740b53fb), X(0x3631a8b8), X(0x73f614c0), + X(0x365f2e3b), X(0x73e0c3a3), X(0x368cab5c), X(0x73cb60a8), + X(0x36ba2014), X(0x73b5ebd1), X(0x36e78c5b), X(0x73a06522), + X(0x3714f02a), X(0x738acc9e), X(0x37424b7b), X(0x73752249), + X(0x376f9e46), X(0x735f6626), X(0x379ce885), X(0x73499838), + X(0x37ca2a30), X(0x7333b883), X(0x37f76341), X(0x731dc70a), + X(0x382493b0), X(0x7307c3d0), X(0x3851bb77), X(0x72f1aed9), + X(0x387eda8e), X(0x72db8828), X(0x38abf0ef), X(0x72c54fc1), + X(0x38d8fe93), X(0x72af05a7), X(0x39060373), X(0x7298a9dd), + X(0x3932ff87), X(0x72823c67), X(0x395ff2c9), X(0x726bbd48), + X(0x398cdd32), X(0x72552c85), X(0x39b9bebc), X(0x723e8a20), + X(0x39e6975e), X(0x7227d61c), X(0x3a136712), X(0x7211107e), + X(0x3a402dd2), X(0x71fa3949), X(0x3a6ceb96), X(0x71e35080), + X(0x3a99a057), X(0x71cc5626), X(0x3ac64c0f), X(0x71b54a41), + X(0x3af2eeb7), X(0x719e2cd2), X(0x3b1f8848), X(0x7186fdde), + X(0x3b4c18ba), X(0x716fbd68), X(0x3b78a007), X(0x71586b74), + X(0x3ba51e29), X(0x71410805), X(0x3bd19318), X(0x7129931f), + X(0x3bfdfecd), X(0x71120cc5), X(0x3c2a6142), X(0x70fa74fc), + X(0x3c56ba70), X(0x70e2cbc6), X(0x3c830a50), X(0x70cb1128), + X(0x3caf50da), X(0x70b34525), X(0x3cdb8e09), X(0x709b67c0), + X(0x3d07c1d6), X(0x708378ff), X(0x3d33ec39), X(0x706b78e3), + X(0x3d600d2c), X(0x70536771), X(0x3d8c24a8), X(0x703b44ad), + X(0x3db832a6), X(0x7023109a), X(0x3de4371f), X(0x700acb3c), + X(0x3e10320d), X(0x6ff27497), X(0x3e3c2369), X(0x6fda0cae), + X(0x3e680b2c), X(0x6fc19385), X(0x3e93e950), X(0x6fa90921), + X(0x3ebfbdcd), X(0x6f906d84), X(0x3eeb889c), X(0x6f77c0b3), + X(0x3f1749b8), X(0x6f5f02b2), X(0x3f430119), X(0x6f463383), + X(0x3f6eaeb8), X(0x6f2d532c), X(0x3f9a5290), X(0x6f1461b0), + X(0x3fc5ec98), X(0x6efb5f12), X(0x3ff17cca), X(0x6ee24b57), + X(0x401d0321), X(0x6ec92683), X(0x40487f94), X(0x6eaff099), + X(0x4073f21d), X(0x6e96a99d), X(0x409f5ab6), X(0x6e7d5193), + X(0x40cab958), X(0x6e63e87f), X(0x40f60dfb), X(0x6e4a6e66), + X(0x4121589b), X(0x6e30e34a), X(0x414c992f), X(0x6e174730), + X(0x4177cfb1), X(0x6dfd9a1c), X(0x41a2fc1a), X(0x6de3dc11), + X(0x41ce1e65), X(0x6dca0d14), X(0x41f93689), X(0x6db02d29), + X(0x42244481), X(0x6d963c54), X(0x424f4845), X(0x6d7c3a98), + X(0x427a41d0), X(0x6d6227fa), X(0x42a5311b), X(0x6d48047e), + X(0x42d0161e), X(0x6d2dd027), X(0x42faf0d4), X(0x6d138afb), + X(0x4325c135), X(0x6cf934fc), X(0x4350873c), X(0x6cdece2f), + X(0x437b42e1), X(0x6cc45698), X(0x43a5f41e), X(0x6ca9ce3b), + X(0x43d09aed), X(0x6c8f351c), X(0x43fb3746), X(0x6c748b3f), + X(0x4425c923), X(0x6c59d0a9), X(0x4450507e), X(0x6c3f055d), + X(0x447acd50), X(0x6c242960), X(0x44a53f93), X(0x6c093cb6), + X(0x44cfa740), X(0x6bee3f62), X(0x44fa0450), X(0x6bd3316a), + X(0x452456bd), X(0x6bb812d1), X(0x454e9e80), X(0x6b9ce39b), + X(0x4578db93), X(0x6b81a3cd), X(0x45a30df0), X(0x6b66536b), + X(0x45cd358f), X(0x6b4af279), X(0x45f7526b), X(0x6b2f80fb), + X(0x4621647d), X(0x6b13fef5), X(0x464b6bbe), X(0x6af86c6c), + X(0x46756828), X(0x6adcc964), X(0x469f59b4), X(0x6ac115e2), + X(0x46c9405c), X(0x6aa551e9), X(0x46f31c1a), X(0x6a897d7d), + X(0x471cece7), X(0x6a6d98a4), X(0x4746b2bc), X(0x6a51a361), + X(0x47706d93), X(0x6a359db9), X(0x479a1d67), X(0x6a1987b0), + X(0x47c3c22f), X(0x69fd614a), X(0x47ed5be6), X(0x69e12a8c), + X(0x4816ea86), X(0x69c4e37a), X(0x48406e08), X(0x69a88c19), + X(0x4869e665), X(0x698c246c), X(0x48935397), X(0x696fac78), + X(0x48bcb599), X(0x69532442), X(0x48e60c62), X(0x69368bce), + X(0x490f57ee), X(0x6919e320), X(0x49389836), X(0x68fd2a3d), + X(0x4961cd33), X(0x68e06129), X(0x498af6df), X(0x68c387e9), + X(0x49b41533), X(0x68a69e81), X(0x49dd282a), X(0x6889a4f6), + X(0x4a062fbd), X(0x686c9b4b), X(0x4a2f2be6), X(0x684f8186), + X(0x4a581c9e), X(0x683257ab), X(0x4a8101de), X(0x68151dbe), + X(0x4aa9dba2), X(0x67f7d3c5), X(0x4ad2a9e2), X(0x67da79c3), + X(0x4afb6c98), X(0x67bd0fbd), X(0x4b2423be), X(0x679f95b7), + X(0x4b4ccf4d), X(0x67820bb7), X(0x4b756f40), X(0x676471c0), + X(0x4b9e0390), X(0x6746c7d8), X(0x4bc68c36), X(0x67290e02), + X(0x4bef092d), X(0x670b4444), X(0x4c177a6e), X(0x66ed6aa1), + X(0x4c3fdff4), X(0x66cf8120), X(0x4c6839b7), X(0x66b187c3), + X(0x4c9087b1), X(0x66937e91), X(0x4cb8c9dd), X(0x6675658c), + X(0x4ce10034), X(0x66573cbb), X(0x4d092ab0), X(0x66390422), + X(0x4d31494b), X(0x661abbc5), X(0x4d595bfe), X(0x65fc63a9), + X(0x4d8162c4), X(0x65ddfbd3), X(0x4da95d96), X(0x65bf8447), + X(0x4dd14c6e), X(0x65a0fd0b), X(0x4df92f46), X(0x65826622), + X(0x4e210617), X(0x6563bf92), X(0x4e48d0dd), X(0x6545095f), + X(0x4e708f8f), X(0x6526438f), X(0x4e984229), X(0x65076e25), + X(0x4ebfe8a5), X(0x64e88926), X(0x4ee782fb), X(0x64c99498), + X(0x4f0f1126), X(0x64aa907f), X(0x4f369320), X(0x648b7ce0), + X(0x4f5e08e3), X(0x646c59bf), X(0x4f857269), X(0x644d2722), + X(0x4faccfab), X(0x642de50d), X(0x4fd420a4), X(0x640e9386), + X(0x4ffb654d), X(0x63ef3290), X(0x50229da1), X(0x63cfc231), + X(0x5049c999), X(0x63b0426d), X(0x5070e92f), X(0x6390b34a), + X(0x5097fc5e), X(0x637114cc), X(0x50bf031f), X(0x635166f9), + X(0x50e5fd6d), X(0x6331a9d4), X(0x510ceb40), X(0x6311dd64), + X(0x5133cc94), X(0x62f201ac), X(0x515aa162), X(0x62d216b3), + X(0x518169a5), X(0x62b21c7b), X(0x51a82555), X(0x6292130c), + X(0x51ced46e), X(0x6271fa69), X(0x51f576ea), X(0x6251d298), + X(0x521c0cc2), X(0x62319b9d), X(0x524295f0), X(0x6211557e), + X(0x5269126e), X(0x61f1003f), X(0x528f8238), X(0x61d09be5), + X(0x52b5e546), X(0x61b02876), X(0x52dc3b92), X(0x618fa5f7), + X(0x53028518), X(0x616f146c), X(0x5328c1d0), X(0x614e73da), + X(0x534ef1b5), X(0x612dc447), X(0x537514c2), X(0x610d05b7), + X(0x539b2af0), X(0x60ec3830), X(0x53c13439), X(0x60cb5bb7), + X(0x53e73097), X(0x60aa7050), X(0x540d2005), X(0x60897601), + X(0x5433027d), X(0x60686ccf), X(0x5458d7f9), X(0x604754bf), + X(0x547ea073), X(0x60262dd6), X(0x54a45be6), X(0x6004f819), + X(0x54ca0a4b), X(0x5fe3b38d), X(0x54efab9c), X(0x5fc26038), + X(0x55153fd4), X(0x5fa0fe1f), X(0x553ac6ee), X(0x5f7f8d46), + X(0x556040e2), X(0x5f5e0db3), X(0x5585adad), X(0x5f3c7f6b), + X(0x55ab0d46), X(0x5f1ae274), X(0x55d05faa), X(0x5ef936d1), + X(0x55f5a4d2), X(0x5ed77c8a), X(0x561adcb9), X(0x5eb5b3a2), + X(0x56400758), X(0x5e93dc1f), X(0x566524aa), X(0x5e71f606), + X(0x568a34a9), X(0x5e50015d), X(0x56af3750), X(0x5e2dfe29), + X(0x56d42c99), X(0x5e0bec6e), X(0x56f9147e), X(0x5de9cc33), + X(0x571deefa), X(0x5dc79d7c), X(0x5742bc06), X(0x5da5604f), + X(0x57677b9d), X(0x5d8314b1), X(0x578c2dba), X(0x5d60baa7), + X(0x57b0d256), X(0x5d3e5237), X(0x57d5696d), X(0x5d1bdb65), + X(0x57f9f2f8), X(0x5cf95638), X(0x581e6ef1), X(0x5cd6c2b5), + X(0x5842dd54), X(0x5cb420e0), X(0x58673e1b), X(0x5c9170bf), + X(0x588b9140), X(0x5c6eb258), X(0x58afd6bd), X(0x5c4be5b0), + X(0x58d40e8c), X(0x5c290acc), X(0x58f838a9), X(0x5c0621b2), + X(0x591c550e), X(0x5be32a67), X(0x594063b5), X(0x5bc024f0), + X(0x59646498), X(0x5b9d1154), X(0x598857b2), X(0x5b79ef96), + X(0x59ac3cfd), X(0x5b56bfbd), X(0x59d01475), X(0x5b3381ce), + X(0x59f3de12), X(0x5b1035cf), X(0x5a1799d1), X(0x5aecdbc5), + X(0x5a3b47ab), X(0x5ac973b5), X(0x5a5ee79a), X(0x5aa5fda5), + X(0x5a82799a), X(0x5a82799a) + }; + + /* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */ +static LOOKUP_T sincos_lookup1[1024] = { + X(0x001921fb), X(0x7ffffd88), X(0x004b65ee), X(0x7fffe9cb), + X(0x007da9d4), X(0x7fffc251), X(0x00afeda8), X(0x7fff8719), + X(0x00e23160), X(0x7fff3824), X(0x011474f6), X(0x7ffed572), + X(0x0146b860), X(0x7ffe5f03), X(0x0178fb99), X(0x7ffdd4d7), + X(0x01ab3e97), X(0x7ffd36ee), X(0x01dd8154), X(0x7ffc8549), + X(0x020fc3c6), X(0x7ffbbfe6), X(0x024205e8), X(0x7ffae6c7), + X(0x027447b0), X(0x7ff9f9ec), X(0x02a68917), X(0x7ff8f954), + X(0x02d8ca16), X(0x7ff7e500), X(0x030b0aa4), X(0x7ff6bcf0), + X(0x033d4abb), X(0x7ff58125), X(0x036f8a51), X(0x7ff4319d), + X(0x03a1c960), X(0x7ff2ce5b), X(0x03d407df), X(0x7ff1575d), + X(0x040645c7), X(0x7fefcca4), X(0x04388310), X(0x7fee2e30), + X(0x046abfb3), X(0x7fec7c02), X(0x049cfba7), X(0x7feab61a), + X(0x04cf36e5), X(0x7fe8dc78), X(0x05017165), X(0x7fe6ef1c), + X(0x0533ab20), X(0x7fe4ee06), X(0x0565e40d), X(0x7fe2d938), + X(0x05981c26), X(0x7fe0b0b1), X(0x05ca5361), X(0x7fde7471), + X(0x05fc89b8), X(0x7fdc247a), X(0x062ebf22), X(0x7fd9c0ca), + X(0x0660f398), X(0x7fd74964), X(0x06932713), X(0x7fd4be46), + X(0x06c5598a), X(0x7fd21f72), X(0x06f78af6), X(0x7fcf6ce8), + X(0x0729bb4e), X(0x7fcca6a7), X(0x075bea8c), X(0x7fc9ccb2), + X(0x078e18a7), X(0x7fc6df08), X(0x07c04598), X(0x7fc3dda9), + X(0x07f27157), X(0x7fc0c896), X(0x08249bdd), X(0x7fbd9fd0), + X(0x0856c520), X(0x7fba6357), X(0x0888ed1b), X(0x7fb7132b), + X(0x08bb13c5), X(0x7fb3af4e), X(0x08ed3916), X(0x7fb037bf), + X(0x091f5d06), X(0x7facac7f), X(0x09517f8f), X(0x7fa90d8e), + X(0x0983a0a7), X(0x7fa55aee), X(0x09b5c048), X(0x7fa1949e), + X(0x09e7de6a), X(0x7f9dbaa0), X(0x0a19fb04), X(0x7f99ccf4), + X(0x0a4c1610), X(0x7f95cb9a), X(0x0a7e2f85), X(0x7f91b694), + X(0x0ab0475c), X(0x7f8d8de1), X(0x0ae25d8d), X(0x7f895182), + X(0x0b147211), X(0x7f850179), X(0x0b4684df), X(0x7f809dc5), + X(0x0b7895f0), X(0x7f7c2668), X(0x0baaa53b), X(0x7f779b62), + X(0x0bdcb2bb), X(0x7f72fcb4), X(0x0c0ebe66), X(0x7f6e4a5e), + X(0x0c40c835), X(0x7f698461), X(0x0c72d020), X(0x7f64aabf), + X(0x0ca4d620), X(0x7f5fbd77), X(0x0cd6da2d), X(0x7f5abc8a), + X(0x0d08dc3f), X(0x7f55a7fa), X(0x0d3adc4e), X(0x7f507fc7), + X(0x0d6cda53), X(0x7f4b43f2), X(0x0d9ed646), X(0x7f45f47b), + X(0x0dd0d01f), X(0x7f409164), X(0x0e02c7d7), X(0x7f3b1aad), + X(0x0e34bd66), X(0x7f359057), X(0x0e66b0c3), X(0x7f2ff263), + X(0x0e98a1e9), X(0x7f2a40d2), X(0x0eca90ce), X(0x7f247ba5), + X(0x0efc7d6b), X(0x7f1ea2dc), X(0x0f2e67b8), X(0x7f18b679), + X(0x0f604faf), X(0x7f12b67c), X(0x0f923546), X(0x7f0ca2e7), + X(0x0fc41876), X(0x7f067bba), X(0x0ff5f938), X(0x7f0040f6), + X(0x1027d784), X(0x7ef9f29d), X(0x1059b352), X(0x7ef390ae), + X(0x108b8c9b), X(0x7eed1b2c), X(0x10bd6356), X(0x7ee69217), + X(0x10ef377d), X(0x7edff570), X(0x11210907), X(0x7ed94538), + X(0x1152d7ed), X(0x7ed28171), X(0x1184a427), X(0x7ecbaa1a), + X(0x11b66dad), X(0x7ec4bf36), X(0x11e83478), X(0x7ebdc0c6), + X(0x1219f880), X(0x7eb6aeca), X(0x124bb9be), X(0x7eaf8943), + X(0x127d7829), X(0x7ea85033), X(0x12af33ba), X(0x7ea1039b), + X(0x12e0ec6a), X(0x7e99a37c), X(0x1312a230), X(0x7e922fd6), + X(0x13445505), X(0x7e8aa8ac), X(0x137604e2), X(0x7e830dff), + X(0x13a7b1bf), X(0x7e7b5fce), X(0x13d95b93), X(0x7e739e1d), + X(0x140b0258), X(0x7e6bc8eb), X(0x143ca605), X(0x7e63e03b), + X(0x146e4694), X(0x7e5be40c), X(0x149fe3fc), X(0x7e53d462), + X(0x14d17e36), X(0x7e4bb13c), X(0x1503153a), X(0x7e437a9c), + X(0x1534a901), X(0x7e3b3083), X(0x15663982), X(0x7e32d2f4), + X(0x1597c6b7), X(0x7e2a61ed), X(0x15c95097), X(0x7e21dd73), + X(0x15fad71b), X(0x7e194584), X(0x162c5a3b), X(0x7e109a24), + X(0x165dd9f0), X(0x7e07db52), X(0x168f5632), X(0x7dff0911), + X(0x16c0cef9), X(0x7df62362), X(0x16f2443e), X(0x7ded2a47), + X(0x1723b5f9), X(0x7de41dc0), X(0x17552422), X(0x7ddafdce), + X(0x17868eb3), X(0x7dd1ca75), X(0x17b7f5a3), X(0x7dc883b4), + X(0x17e958ea), X(0x7dbf298d), X(0x181ab881), X(0x7db5bc02), + X(0x184c1461), X(0x7dac3b15), X(0x187d6c82), X(0x7da2a6c6), + X(0x18aec0db), X(0x7d98ff17), X(0x18e01167), X(0x7d8f4409), + X(0x19115e1c), X(0x7d85759f), X(0x1942a6f3), X(0x7d7b93da), + X(0x1973ebe6), X(0x7d719eba), X(0x19a52ceb), X(0x7d679642), + X(0x19d669fc), X(0x7d5d7a74), X(0x1a07a311), X(0x7d534b50), + X(0x1a38d823), X(0x7d4908d9), X(0x1a6a0929), X(0x7d3eb30f), + X(0x1a9b361d), X(0x7d3449f5), X(0x1acc5ef6), X(0x7d29cd8c), + X(0x1afd83ad), X(0x7d1f3dd6), X(0x1b2ea43a), X(0x7d149ad5), + X(0x1b5fc097), X(0x7d09e489), X(0x1b90d8bb), X(0x7cff1af5), + X(0x1bc1ec9e), X(0x7cf43e1a), X(0x1bf2fc3a), X(0x7ce94dfb), + X(0x1c240786), X(0x7cde4a98), X(0x1c550e7c), X(0x7cd333f3), + X(0x1c861113), X(0x7cc80a0f), X(0x1cb70f43), X(0x7cbcccec), + X(0x1ce80906), X(0x7cb17c8d), X(0x1d18fe54), X(0x7ca618f3), + X(0x1d49ef26), X(0x7c9aa221), X(0x1d7adb73), X(0x7c8f1817), + X(0x1dabc334), X(0x7c837ad8), X(0x1ddca662), X(0x7c77ca65), + X(0x1e0d84f5), X(0x7c6c06c0), X(0x1e3e5ee5), X(0x7c602fec), + X(0x1e6f342c), X(0x7c5445e9), X(0x1ea004c1), X(0x7c4848ba), + X(0x1ed0d09d), X(0x7c3c3860), X(0x1f0197b8), X(0x7c3014de), + X(0x1f325a0b), X(0x7c23de35), X(0x1f63178f), X(0x7c179467), + X(0x1f93d03c), X(0x7c0b3777), X(0x1fc4840a), X(0x7bfec765), + X(0x1ff532f2), X(0x7bf24434), X(0x2025dcec), X(0x7be5ade6), + X(0x205681f1), X(0x7bd9047c), X(0x208721f9), X(0x7bcc47fa), + X(0x20b7bcfe), X(0x7bbf7860), X(0x20e852f6), X(0x7bb295b0), + X(0x2118e3dc), X(0x7ba59fee), X(0x21496fa7), X(0x7b989719), + X(0x2179f64f), X(0x7b8b7b36), X(0x21aa77cf), X(0x7b7e4c45), + X(0x21daf41d), X(0x7b710a49), X(0x220b6b32), X(0x7b63b543), + X(0x223bdd08), X(0x7b564d36), X(0x226c4996), X(0x7b48d225), + X(0x229cb0d5), X(0x7b3b4410), X(0x22cd12bd), X(0x7b2da2fa), + X(0x22fd6f48), X(0x7b1feee5), X(0x232dc66d), X(0x7b1227d3), + X(0x235e1826), X(0x7b044dc7), X(0x238e646a), X(0x7af660c2), + X(0x23beab33), X(0x7ae860c7), X(0x23eeec78), X(0x7ada4dd8), + X(0x241f2833), X(0x7acc27f7), X(0x244f5e5c), X(0x7abdef25), + X(0x247f8eec), X(0x7aafa367), X(0x24afb9da), X(0x7aa144bc), + X(0x24dfdf20), X(0x7a92d329), X(0x250ffeb7), X(0x7a844eae), + X(0x25401896), X(0x7a75b74f), X(0x25702cb7), X(0x7a670d0d), + X(0x25a03b11), X(0x7a584feb), X(0x25d0439f), X(0x7a497feb), + X(0x26004657), X(0x7a3a9d0f), X(0x26304333), X(0x7a2ba75a), + X(0x26603a2c), X(0x7a1c9ece), X(0x26902b39), X(0x7a0d836d), + X(0x26c01655), X(0x79fe5539), X(0x26effb76), X(0x79ef1436), + X(0x271fda96), X(0x79dfc064), X(0x274fb3ae), X(0x79d059c8), + X(0x277f86b5), X(0x79c0e062), X(0x27af53a6), X(0x79b15435), + X(0x27df1a77), X(0x79a1b545), X(0x280edb23), X(0x79920392), + X(0x283e95a1), X(0x79823f20), X(0x286e49ea), X(0x797267f2), + X(0x289df7f8), X(0x79627e08), X(0x28cd9fc1), X(0x79528167), + X(0x28fd4140), X(0x79427210), X(0x292cdc6d), X(0x79325006), + X(0x295c7140), X(0x79221b4b), X(0x298bffb2), X(0x7911d3e2), + X(0x29bb87bc), X(0x790179cd), X(0x29eb0957), X(0x78f10d0f), + X(0x2a1a847b), X(0x78e08dab), X(0x2a49f920), X(0x78cffba3), + X(0x2a796740), X(0x78bf56f9), X(0x2aa8ced3), X(0x78ae9fb0), + X(0x2ad82fd2), X(0x789dd5cb), X(0x2b078a36), X(0x788cf94c), + X(0x2b36ddf7), X(0x787c0a36), X(0x2b662b0e), X(0x786b088c), + X(0x2b957173), X(0x7859f44f), X(0x2bc4b120), X(0x7848cd83), + X(0x2bf3ea0d), X(0x7837942b), X(0x2c231c33), X(0x78264849), + X(0x2c52478a), X(0x7814e9df), X(0x2c816c0c), X(0x780378f1), + X(0x2cb089b1), X(0x77f1f581), X(0x2cdfa071), X(0x77e05f91), + X(0x2d0eb046), X(0x77ceb725), X(0x2d3db928), X(0x77bcfc3f), + X(0x2d6cbb10), X(0x77ab2ee2), X(0x2d9bb5f6), X(0x77994f11), + X(0x2dcaa9d5), X(0x77875cce), X(0x2df996a3), X(0x7775581d), + X(0x2e287c5a), X(0x776340ff), X(0x2e575af3), X(0x77511778), + X(0x2e863267), X(0x773edb8b), X(0x2eb502ae), X(0x772c8d3a), + X(0x2ee3cbc1), X(0x771a2c88), X(0x2f128d99), X(0x7707b979), + X(0x2f41482e), X(0x76f5340e), X(0x2f6ffb7a), X(0x76e29c4b), + X(0x2f9ea775), X(0x76cff232), X(0x2fcd4c19), X(0x76bd35c7), + X(0x2ffbe95d), X(0x76aa670d), X(0x302a7f3a), X(0x76978605), + X(0x30590dab), X(0x768492b4), X(0x308794a6), X(0x76718d1c), + X(0x30b61426), X(0x765e7540), X(0x30e48c22), X(0x764b4b23), + X(0x3112fc95), X(0x76380ec8), X(0x31416576), X(0x7624c031), + X(0x316fc6be), X(0x76115f63), X(0x319e2067), X(0x75fdec60), + X(0x31cc7269), X(0x75ea672a), X(0x31fabcbd), X(0x75d6cfc5), + X(0x3228ff5c), X(0x75c32634), X(0x32573a3f), X(0x75af6a7b), + X(0x32856d5e), X(0x759b9c9b), X(0x32b398b3), X(0x7587bc98), + X(0x32e1bc36), X(0x7573ca75), X(0x330fd7e1), X(0x755fc635), + X(0x333debab), X(0x754bafdc), X(0x336bf78f), X(0x7537876c), + X(0x3399fb85), X(0x75234ce8), X(0x33c7f785), X(0x750f0054), + X(0x33f5eb89), X(0x74faa1b3), X(0x3423d78a), X(0x74e63108), + X(0x3451bb81), X(0x74d1ae55), X(0x347f9766), X(0x74bd199f), + X(0x34ad6b32), X(0x74a872e8), X(0x34db36df), X(0x7493ba34), + X(0x3508fa66), X(0x747eef85), X(0x3536b5be), X(0x746a12df), + X(0x356468e2), X(0x74552446), X(0x359213c9), X(0x744023bc), + X(0x35bfb66e), X(0x742b1144), X(0x35ed50c9), X(0x7415ece2), + X(0x361ae2d3), X(0x7400b69a), X(0x36486c86), X(0x73eb6e6e), + X(0x3675edd9), X(0x73d61461), X(0x36a366c6), X(0x73c0a878), + X(0x36d0d746), X(0x73ab2ab4), X(0x36fe3f52), X(0x73959b1b), + X(0x372b9ee3), X(0x737ff9ae), X(0x3758f5f2), X(0x736a4671), + X(0x37864477), X(0x73548168), X(0x37b38a6d), X(0x733eaa96), + X(0x37e0c7cc), X(0x7328c1ff), X(0x380dfc8d), X(0x7312c7a5), + X(0x383b28a9), X(0x72fcbb8c), X(0x38684c19), X(0x72e69db7), + X(0x389566d6), X(0x72d06e2b), X(0x38c278d9), X(0x72ba2cea), + X(0x38ef821c), X(0x72a3d9f7), X(0x391c8297), X(0x728d7557), + X(0x39497a43), X(0x7276ff0d), X(0x39766919), X(0x7260771b), + X(0x39a34f13), X(0x7249dd86), X(0x39d02c2a), X(0x72333251), + X(0x39fd0056), X(0x721c7580), X(0x3a29cb91), X(0x7205a716), + X(0x3a568dd4), X(0x71eec716), X(0x3a834717), X(0x71d7d585), + X(0x3aaff755), X(0x71c0d265), X(0x3adc9e86), X(0x71a9bdba), + X(0x3b093ca3), X(0x71929789), X(0x3b35d1a5), X(0x717b5fd3), + X(0x3b625d86), X(0x7164169d), X(0x3b8ee03e), X(0x714cbbeb), + X(0x3bbb59c7), X(0x71354fc0), X(0x3be7ca1a), X(0x711dd220), + X(0x3c143130), X(0x7106430e), X(0x3c408f03), X(0x70eea28e), + X(0x3c6ce38a), X(0x70d6f0a4), X(0x3c992ec0), X(0x70bf2d53), + X(0x3cc5709e), X(0x70a7589f), X(0x3cf1a91c), X(0x708f728b), + X(0x3d1dd835), X(0x70777b1c), X(0x3d49fde1), X(0x705f7255), + X(0x3d761a19), X(0x70475839), X(0x3da22cd7), X(0x702f2ccd), + X(0x3dce3614), X(0x7016f014), X(0x3dfa35c8), X(0x6ffea212), + X(0x3e262bee), X(0x6fe642ca), X(0x3e52187f), X(0x6fcdd241), + X(0x3e7dfb73), X(0x6fb5507a), X(0x3ea9d4c3), X(0x6f9cbd79), + X(0x3ed5a46b), X(0x6f841942), X(0x3f016a61), X(0x6f6b63d8), + X(0x3f2d26a0), X(0x6f529d40), X(0x3f58d921), X(0x6f39c57d), + X(0x3f8481dd), X(0x6f20dc92), X(0x3fb020ce), X(0x6f07e285), + X(0x3fdbb5ec), X(0x6eeed758), X(0x40074132), X(0x6ed5bb10), + X(0x4032c297), X(0x6ebc8db0), X(0x405e3a16), X(0x6ea34f3d), + X(0x4089a7a8), X(0x6e89ffb9), X(0x40b50b46), X(0x6e709f2a), + X(0x40e064ea), X(0x6e572d93), X(0x410bb48c), X(0x6e3daaf8), + X(0x4136fa27), X(0x6e24175c), X(0x416235b2), X(0x6e0a72c5), + X(0x418d6729), X(0x6df0bd35), X(0x41b88e84), X(0x6dd6f6b1), + X(0x41e3abbc), X(0x6dbd1f3c), X(0x420ebecb), X(0x6da336dc), + X(0x4239c7aa), X(0x6d893d93), X(0x4264c653), X(0x6d6f3365), + X(0x428fbabe), X(0x6d551858), X(0x42baa4e6), X(0x6d3aec6e), + X(0x42e584c3), X(0x6d20afac), X(0x43105a50), X(0x6d066215), + X(0x433b2585), X(0x6cec03af), X(0x4365e65b), X(0x6cd1947c), + X(0x43909ccd), X(0x6cb71482), X(0x43bb48d4), X(0x6c9c83c3), + X(0x43e5ea68), X(0x6c81e245), X(0x44108184), X(0x6c67300b), + X(0x443b0e21), X(0x6c4c6d1a), X(0x44659039), X(0x6c319975), + X(0x449007c4), X(0x6c16b521), X(0x44ba74bd), X(0x6bfbc021), + X(0x44e4d71c), X(0x6be0ba7b), X(0x450f2edb), X(0x6bc5a431), + X(0x45397bf4), X(0x6baa7d49), X(0x4563be60), X(0x6b8f45c7), + X(0x458df619), X(0x6b73fdae), X(0x45b82318), X(0x6b58a503), + X(0x45e24556), X(0x6b3d3bcb), X(0x460c5cce), X(0x6b21c208), + X(0x46366978), X(0x6b0637c1), X(0x46606b4e), X(0x6aea9cf8), + X(0x468a624a), X(0x6acef1b2), X(0x46b44e65), X(0x6ab335f4), + X(0x46de2f99), X(0x6a9769c1), X(0x470805df), X(0x6a7b8d1e), + X(0x4731d131), X(0x6a5fa010), X(0x475b9188), X(0x6a43a29a), + X(0x478546de), X(0x6a2794c1), X(0x47aef12c), X(0x6a0b7689), + X(0x47d8906d), X(0x69ef47f6), X(0x48022499), X(0x69d3090e), + X(0x482badab), X(0x69b6b9d3), X(0x48552b9b), X(0x699a5a4c), + X(0x487e9e64), X(0x697dea7b), X(0x48a805ff), X(0x69616a65), + X(0x48d16265), X(0x6944da10), X(0x48fab391), X(0x6928397e), + X(0x4923f97b), X(0x690b88b5), X(0x494d341e), X(0x68eec7b9), + X(0x49766373), X(0x68d1f68f), X(0x499f8774), X(0x68b5153a), + X(0x49c8a01b), X(0x689823bf), X(0x49f1ad61), X(0x687b2224), + X(0x4a1aaf3f), X(0x685e106c), X(0x4a43a5b0), X(0x6840ee9b), + X(0x4a6c90ad), X(0x6823bcb7), X(0x4a957030), X(0x68067ac3), + X(0x4abe4433), X(0x67e928c5), X(0x4ae70caf), X(0x67cbc6c0), + X(0x4b0fc99d), X(0x67ae54ba), X(0x4b387af9), X(0x6790d2b6), + X(0x4b6120bb), X(0x677340ba), X(0x4b89badd), X(0x67559eca), + X(0x4bb24958), X(0x6737ecea), X(0x4bdacc28), X(0x671a2b20), + X(0x4c034345), X(0x66fc596f), X(0x4c2baea9), X(0x66de77dc), + X(0x4c540e4e), X(0x66c0866d), X(0x4c7c622d), X(0x66a28524), + X(0x4ca4aa41), X(0x66847408), X(0x4ccce684), X(0x6666531d), + X(0x4cf516ee), X(0x66482267), X(0x4d1d3b7a), X(0x6629e1ec), + X(0x4d455422), X(0x660b91af), X(0x4d6d60df), X(0x65ed31b5), + X(0x4d9561ac), X(0x65cec204), X(0x4dbd5682), X(0x65b0429f), + X(0x4de53f5a), X(0x6591b38c), X(0x4e0d1c30), X(0x657314cf), + X(0x4e34ecfc), X(0x6554666d), X(0x4e5cb1b9), X(0x6535a86b), + X(0x4e846a60), X(0x6516dacd), X(0x4eac16eb), X(0x64f7fd98), + X(0x4ed3b755), X(0x64d910d1), X(0x4efb4b96), X(0x64ba147d), + X(0x4f22d3aa), X(0x649b08a0), X(0x4f4a4f89), X(0x647bed3f), + X(0x4f71bf2e), X(0x645cc260), X(0x4f992293), X(0x643d8806), + X(0x4fc079b1), X(0x641e3e38), X(0x4fe7c483), X(0x63fee4f8), + X(0x500f0302), X(0x63df7c4d), X(0x50363529), X(0x63c0043b), + X(0x505d5af1), X(0x63a07cc7), X(0x50847454), X(0x6380e5f6), + X(0x50ab814d), X(0x63613fcd), X(0x50d281d5), X(0x63418a50), + X(0x50f975e6), X(0x6321c585), X(0x51205d7b), X(0x6301f171), + X(0x5147388c), X(0x62e20e17), X(0x516e0715), X(0x62c21b7e), + X(0x5194c910), X(0x62a219aa), X(0x51bb7e75), X(0x628208a1), + X(0x51e22740), X(0x6261e866), X(0x5208c36a), X(0x6241b8ff), + X(0x522f52ee), X(0x62217a72), X(0x5255d5c5), X(0x62012cc2), + X(0x527c4bea), X(0x61e0cff5), X(0x52a2b556), X(0x61c06410), + X(0x52c91204), X(0x619fe918), X(0x52ef61ee), X(0x617f5f12), + X(0x5315a50e), X(0x615ec603), X(0x533bdb5d), X(0x613e1df0), + X(0x536204d7), X(0x611d66de), X(0x53882175), X(0x60fca0d2), + X(0x53ae3131), X(0x60dbcbd1), X(0x53d43406), X(0x60bae7e1), + X(0x53fa29ed), X(0x6099f505), X(0x542012e1), X(0x6078f344), + X(0x5445eedb), X(0x6057e2a2), X(0x546bbdd7), X(0x6036c325), + X(0x54917fce), X(0x601594d1), X(0x54b734ba), X(0x5ff457ad), + X(0x54dcdc96), X(0x5fd30bbc), X(0x5502775c), X(0x5fb1b104), + X(0x55280505), X(0x5f90478a), X(0x554d858d), X(0x5f6ecf53), + X(0x5572f8ed), X(0x5f4d4865), X(0x55985f20), X(0x5f2bb2c5), + X(0x55bdb81f), X(0x5f0a0e77), X(0x55e303e6), X(0x5ee85b82), + X(0x5608426e), X(0x5ec699e9), X(0x562d73b2), X(0x5ea4c9b3), + X(0x565297ab), X(0x5e82eae5), X(0x5677ae54), X(0x5e60fd84), + X(0x569cb7a8), X(0x5e3f0194), X(0x56c1b3a1), X(0x5e1cf71c), + X(0x56e6a239), X(0x5dfade20), X(0x570b8369), X(0x5dd8b6a7), + X(0x5730572e), X(0x5db680b4), X(0x57551d80), X(0x5d943c4e), + X(0x5779d65b), X(0x5d71e979), X(0x579e81b8), X(0x5d4f883b), + X(0x57c31f92), X(0x5d2d189a), X(0x57e7afe4), X(0x5d0a9a9a), + X(0x580c32a7), X(0x5ce80e41), X(0x5830a7d6), X(0x5cc57394), + X(0x58550f6c), X(0x5ca2ca99), X(0x58796962), X(0x5c801354), + X(0x589db5b3), X(0x5c5d4dcc), X(0x58c1f45b), X(0x5c3a7a05), + X(0x58e62552), X(0x5c179806), X(0x590a4893), X(0x5bf4a7d2), + X(0x592e5e19), X(0x5bd1a971), X(0x595265df), X(0x5bae9ce7), + X(0x59765fde), X(0x5b8b8239), X(0x599a4c12), X(0x5b68596d), + X(0x59be2a74), X(0x5b452288), X(0x59e1faff), X(0x5b21dd90), + X(0x5a05bdae), X(0x5afe8a8b), X(0x5a29727b), X(0x5adb297d), + X(0x5a4d1960), X(0x5ab7ba6c), X(0x5a70b258), X(0x5a943d5e), +}; + diff --git a/wolf3d/newCode/Tremor/misc.h b/wolf3d/newCode/Tremor/misc.h new file mode 100644 index 0000000..a4bc82f --- /dev/null +++ b/wolf3d/newCode/Tremor/misc.h @@ -0,0 +1,244 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: miscellaneous math and prototypes + + ********************************************************************/ + +#ifndef _V_RANDOM_H_ +#define _V_RANDOM_H_ +#include "ivorbiscodec.h" +#include "os.h" + +#include "asm_arm.h" +#include /* for abs() */ + +#ifndef _V_WIDE_MATH +#define _V_WIDE_MATH + +#ifndef _LOW_ACCURACY_ +/* 64 bit multiply */ + +#if !(defined WIN32 && defined WINCE) +#include +#endif + +#if BYTE_ORDER==LITTLE_ENDIAN +union magic { + struct { + ogg_int32_t lo; + ogg_int32_t hi; + } halves; + ogg_int64_t whole; +}; +#endif + +#if BYTE_ORDER==BIG_ENDIAN +union magic { + struct { + ogg_int32_t hi; + ogg_int32_t lo; + } halves; + ogg_int64_t whole; +}; +#endif + +STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { + union magic magic; + magic.whole = (ogg_int64_t)x * y; + return magic.halves.hi; +} + +STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { + return MULT32(x,y)<<1; +} + +STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { + union magic magic; + magic.whole = (ogg_int64_t)x * y; + return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); +} + +#else +/* 32 bit multiply, more portable but less accurate */ + +/* + * Note: Precision is biased towards the first argument therefore ordering + * is important. Shift values were chosen for the best sound quality after + * many listening tests. + */ + +/* + * For MULT32 and MULT31: The second argument is always a lookup table + * value already preshifted from 31 to 8 bits. We therefore take the + * opportunity to save on text space and use unsigned char for those + * tables in this case. + */ + +STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { + return (x >> 9) * y; /* y preshifted >>23 */ +} + +STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { + return (x >> 8) * y; /* y preshifted >>23 */ +} + +STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { + return (x >> 6) * y; /* y preshifted >>9 */ +} + +#endif + +/* + * This should be used as a memory barrier, forcing all cached values in + * registers to wr writen back to memory. Might or might not be beneficial + * depending on the architecture and compiler. + */ +#define MB() + +/* + * The XPROD functions are meant to optimize the cross products found all + * over the place in mdct.c by forcing memory operation ordering to avoid + * unnecessary register reloads as soon as memory is being written to. + * However this is only beneficial on CPUs with a sane number of general + * purpose registers which exclude the Intel x86. On Intel, better let the + * compiler actually reload registers directly from original memory by using + * macros. + */ + +#ifdef __i386__ + +#define XPROD32(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT32(_a,_t)+MULT32(_b,_v); \ + *(_y)=MULT32(_b,_t)-MULT32(_a,_v); } +#define XPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } +#define XNPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } + +#else + +STIN void XPROD32(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + *x = MULT32(a, t) + MULT32(b, v); + *y = MULT32(b, t) - MULT32(a, v); +} + +STIN void XPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + *x = MULT31(a, t) + MULT31(b, v); + *y = MULT31(b, t) - MULT31(a, v); +} + +STIN void XNPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + *x = MULT31(a, t) - MULT31(b, v); + *y = MULT31(b, t) + MULT31(a, v); +} + +#endif + +#endif + +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +STIN ogg_int32_t CLIP_TO_15(ogg_int32_t x) { + int ret=x; + ret-= ((x<=32767)-1)&(x-32767); + ret-= ((x>=-32768)-1)&(x+32768); + return(ret); +} + +#endif + +STIN ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t b,ogg_int32_t bp, + ogg_int32_t *p){ + if(a && b){ +#ifndef _LOW_ACCURACY_ + *p=ap+bp+32; + return MULT32(a,b); +#else + *p=ap+bp+31; + return (a>>15)*(b>>16); +#endif + }else + return 0; +} + +int _ilog(unsigned int); + +STIN ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t i, + ogg_int32_t *p){ + + int ip=_ilog(abs(i))-31; + return VFLOAT_MULT(a,ap,i<<-ip,ip,p); +} + +STIN ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t b,ogg_int32_t bp, + ogg_int32_t *p){ + + if(!a){ + *p=bp; + return b; + }else if(!b){ + *p=ap; + return a; + } + + /* yes, this can leak a bit. */ + if(ap>bp){ + int shift=ap-bp+1; + *p=ap+1; + a>>=1; + if(shift<32){ + b=(b+(1<<(shift-1)))>>shift; + }else{ + b=0; + } + }else{ + int shift=bp-ap+1; + *p=bp+1; + b>>=1; + if(shift<32){ + a=(a+(1<<(shift-1)))>>shift; + }else{ + a=0; + } + } + + a+=b; + if((a&0xc0000000)==0xc0000000 || + (a&0xc0000000)==0){ + a<<=1; + (*p)--; + } + return(a); +} + +#endif + + + + diff --git a/wolf3d/newCode/Tremor/ogg.h b/wolf3d/newCode/Tremor/ogg.h new file mode 100644 index 0000000..85cb41b --- /dev/null +++ b/wolf3d/newCode/Tremor/ogg.h @@ -0,0 +1,206 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: subsumed libogg includes + + ********************************************************************/ +#ifndef _OGG_H +#define _OGG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "os_types.h" + +typedef struct ogg_buffer_state{ + struct ogg_buffer *unused_buffers; + struct ogg_reference *unused_references; + int outstanding; + int shutdown; +} ogg_buffer_state; + +typedef struct ogg_buffer { + unsigned char *data; + long size; + int refcount; + + union { + ogg_buffer_state *owner; + struct ogg_buffer *next; + } ptr; +} ogg_buffer; + +typedef struct ogg_reference { + ogg_buffer *buffer; + long begin; + long length; + + struct ogg_reference *next; +} ogg_reference; + +typedef struct oggpack_buffer { + int headbit; + unsigned char *headptr; + long headend; + + /* memory management */ + ogg_reference *head; + ogg_reference *tail; + + /* render the byte/bit counter API constant time */ + long count; /* doesn't count the tail */ +} oggpack_buffer; + +typedef struct oggbyte_buffer { + ogg_reference *baseref; + + ogg_reference *ref; + unsigned char *ptr; + long pos; + long end; +} oggbyte_buffer; + +typedef struct ogg_sync_state { + /* decode memory management pool */ + ogg_buffer_state *bufferpool; + + /* stream buffers */ + ogg_reference *fifo_head; + ogg_reference *fifo_tail; + long fifo_fill; + + /* stream sync management */ + int unsynced; + int headerbytes; + int bodybytes; + +} ogg_sync_state; + +typedef struct ogg_stream_state { + ogg_reference *header_head; + ogg_reference *header_tail; + ogg_reference *body_head; + ogg_reference *body_tail; + + int e_o_s; /* set when we have buffered the last + packet in the logical bitstream */ + int b_o_s; /* set after we've written the initial page + of a logical bitstream */ + long serialno; + long pageno; + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ + ogg_int64_t granulepos; + + int lacing_fill; + ogg_uint32_t body_fill; + + /* decode-side state data */ + int holeflag; + int spanflag; + int clearflag; + int laceptr; + ogg_uint32_t body_fill_next; + +} ogg_stream_state; + +typedef struct { + ogg_reference *packet; + long bytes; + long b_o_s; + long e_o_s; + ogg_int64_t granulepos; + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ +} ogg_packet; + +typedef struct { + ogg_reference *header; + int header_len; + ogg_reference *body; + long body_len; +} ogg_page; + +/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ + +extern void oggpack_readinit(oggpack_buffer *b,ogg_reference *r); +extern long oggpack_look(oggpack_buffer *b,int bits); +extern void oggpack_adv(oggpack_buffer *b,int bits); +extern long oggpack_read(oggpack_buffer *b,int bits); +extern long oggpack_bytes(oggpack_buffer *b); +extern long oggpack_bits(oggpack_buffer *b); +extern int oggpack_eop(oggpack_buffer *b); + +/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ + +extern ogg_sync_state *ogg_sync_create(void); +extern int ogg_sync_destroy(ogg_sync_state *oy); +extern int ogg_sync_reset(ogg_sync_state *oy); + +extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size); +extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); +extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); +extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); +extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); +extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); + +/* Ogg BITSTREAM PRIMITIVES: general ***************************/ + +extern ogg_stream_state *ogg_stream_create(int serialno); +extern int ogg_stream_destroy(ogg_stream_state *os); +extern int ogg_stream_reset(ogg_stream_state *os); +extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); +extern int ogg_stream_eos(ogg_stream_state *os); + +extern int ogg_page_checksum_set(ogg_page *og); + +extern int ogg_page_version(ogg_page *og); +extern int ogg_page_continued(ogg_page *og); +extern int ogg_page_bos(ogg_page *og); +extern int ogg_page_eos(ogg_page *og); +extern ogg_int64_t ogg_page_granulepos(ogg_page *og); +extern ogg_uint32_t ogg_page_serialno(ogg_page *og); +extern ogg_uint32_t ogg_page_pageno(ogg_page *og); +extern int ogg_page_packets(ogg_page *og); +extern int ogg_page_getbuffer(ogg_page *og, unsigned char **buffer); + +extern int ogg_packet_release(ogg_packet *op); +extern int ogg_page_release(ogg_page *og); + +extern void ogg_page_dup(ogg_page *d, ogg_page *s); + +/* Ogg BITSTREAM PRIMITIVES: return codes ***************************/ + +#define OGG_SUCCESS 0 + +#define OGG_HOLE -10 +#define OGG_SPAN -11 +#define OGG_EVERSION -12 +#define OGG_ESERIAL -13 +#define OGG_EINVAL -14 +#define OGG_EEOS -15 + + +#ifdef __cplusplus +} +#endif + +#endif /* _OGG_H */ diff --git a/wolf3d/newCode/Tremor/os.h b/wolf3d/newCode/Tremor/os.h new file mode 100644 index 0000000..95e6e27 --- /dev/null +++ b/wolf3d/newCode/Tremor/os.h @@ -0,0 +1,64 @@ +#ifndef _OS_H +#define _OS_H +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + + ********************************************************************/ + +#include +#include "os_types.h" + +#ifndef _V_IFDEFJAIL_H_ +# define _V_IFDEFJAIL_H_ + +# ifdef __GNUC__ +# define STIN static __inline__ +# elif _WIN32 +# define STIN static __inline +# endif +#else +# define STIN static +#endif + +#ifndef M_PI +# define M_PI (3.1415926536f) +#endif + +#ifdef _WIN32 +# include +# define rint(x) (floor((x)+0.5f)) +# define NO_FLOAT_MATH_LIB +# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) +# define LITTLE_ENDIAN 1 +# define BYTE_ORDER LITTLE_ENDIAN +#endif + +#ifdef HAVE_ALLOCA_H +# include +#endif + +#ifdef USE_MEMORY_H +# include +#endif + +#ifndef min +# define min(x,y) ((x)>(y)?(y):(x)) +#endif + +#ifndef max +# define max(x,y) ((x)<(y)?(y):(x)) +#endif + +#endif /* _OS_H */ diff --git a/wolf3d/newCode/Tremor/os_types.h b/wolf3d/newCode/Tremor/os_types.h new file mode 100644 index 0000000..b8ddb8e --- /dev/null +++ b/wolf3d/newCode/Tremor/os_types.h @@ -0,0 +1,88 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + + ********************************************************************/ +#ifndef _OS_TYPES_H +#define _OS_TYPES_H + +#ifdef _LOW_ACCURACY_ +# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9)) +# define LOOKUP_T const unsigned char +#else +# define X(n) (n) +# define LOOKUP_T const ogg_int32_t +#endif + +/* make it easy on the folks that want to compile the libs with a + different malloc than stdlib */ +#define _ogg_malloc malloc +#define _ogg_calloc calloc +#define _ogg_realloc realloc +#define _ogg_free free + +#ifdef _WIN32 + +# ifndef __GNUC__ + /* MSVC/Borland */ + typedef __int64 ogg_int64_t; + typedef __int32 ogg_int32_t; + typedef unsigned __int32 ogg_uint32_t; + typedef __int16 ogg_int16_t; +# else + /* Cygwin */ + #include <_G_config.h> + typedef _G_int64_t ogg_int64_t; + typedef _G_int32_t ogg_int32_t; + typedef _G_uint32_t ogg_uint32_t; + typedef _G_int16_t ogg_int16_t; +# endif + +#elif defined(__MACOS__) + +# include + typedef SInt16 ogg_int16_t; + typedef SInt32 ogg_int32_t; + typedef UInt32 ogg_uint32_t; + typedef SInt64 ogg_int64_t; + +#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ + +# include + typedef int16_t ogg_int16_t; + typedef int32_t ogg_int32_t; + typedef u_int32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#elif defined(__BEOS__) + + /* Be */ +# include + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short ogg_int16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + +#else + +# include +# include "config_types.h" + +#endif + +#endif /* _OS_TYPES_H */ diff --git a/wolf3d/newCode/Tremor/registry.c b/wolf3d/newCode/Tremor/registry.c new file mode 100644 index 0000000..c0b5fec --- /dev/null +++ b/wolf3d/newCode/Tremor/registry.c @@ -0,0 +1,50 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: registry for floor, res backends and channel mappings + + ********************************************************************/ + +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "misc.h" + + +/* seems like major overkill now; the backend numbers will grow into + the infrastructure soon enough */ + +extern vorbis_func_floor floor0_exportbundle; +extern vorbis_func_floor floor1_exportbundle; +extern vorbis_func_residue residue0_exportbundle; +extern vorbis_func_residue residue1_exportbundle; +extern vorbis_func_residue residue2_exportbundle; +extern vorbis_func_mapping mapping0_exportbundle; + +vorbis_func_floor *_floor_P[]={ + &floor0_exportbundle, + &floor1_exportbundle, +}; + +vorbis_func_residue *_residue_P[]={ + &residue0_exportbundle, + &residue1_exportbundle, + &residue2_exportbundle, +}; + +vorbis_func_mapping *_mapping_P[]={ + &mapping0_exportbundle, +}; + + + diff --git a/wolf3d/newCode/Tremor/registry.h b/wolf3d/newCode/Tremor/registry.h new file mode 100644 index 0000000..2bc8068 --- /dev/null +++ b/wolf3d/newCode/Tremor/registry.h @@ -0,0 +1,40 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: registry for time, floor, res backends and channel mappings + + ********************************************************************/ + +#ifndef _V_REG_H_ +#define _V_REG_H_ + +#define VI_TRANSFORMB 1 +#define VI_WINDOWB 1 +#define VI_TIMEB 1 +#define VI_FLOORB 2 +#define VI_RESB 3 +#define VI_MAPB 1 + +#include "backends.h" + +#if defined(_WIN32) && defined(VORBISDLL_IMPORT) +# define EXTERN __declspec(dllimport) extern +#else +# define EXTERN extern +#endif + +EXTERN vorbis_func_floor *_floor_P[]; +EXTERN vorbis_func_residue *_residue_P[]; +EXTERN vorbis_func_mapping *_mapping_P[]; + +#endif diff --git a/wolf3d/newCode/Tremor/res012.c b/wolf3d/newCode/Tremor/res012.c new file mode 100644 index 0000000..224b54e --- /dev/null +++ b/wolf3d/newCode/Tremor/res012.c @@ -0,0 +1,342 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: residue backend 0, 1 and 2 implementation + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "os.h" +#include "block.h" + +typedef struct { + vorbis_info_residue0 *info; + int map; + + int parts; + int stages; + codebook *fullbooks; + codebook *phrasebook; + codebook ***partbooks; + + int partvals; + int **decodemap; + +} vorbis_look_residue0; + +void res0_free_info(vorbis_info_residue *i){ + vorbis_info_residue0 *info=(vorbis_info_residue0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +void res0_free_look(vorbis_look_residue *i){ + int j; + if(i){ + + vorbis_look_residue0 *look=(vorbis_look_residue0 *)i; + + for(j=0;jparts;j++) + if(look->partbooks[j])_ogg_free(look->partbooks[j]); + _ogg_free(look->partbooks); + for(j=0;jpartvals;j++) + _ogg_free(look->decodemap[j]); + _ogg_free(look->decodemap); + + memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static int ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +static int icount(unsigned int v){ + int ret=0; + while(v){ + ret+=v&1; + v>>=1; + } + return(ret); +} + +/* vorbis_info is for range checking */ +vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ + int j,acc=0; + vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info)); + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + + info->begin=oggpack_read(opb,24); + info->end=oggpack_read(opb,24); + info->grouping=oggpack_read(opb,24)+1; + info->partitions=oggpack_read(opb,6)+1; + info->groupbook=oggpack_read(opb,8); + + for(j=0;jpartitions;j++){ + int cascade=oggpack_read(opb,3); + if(oggpack_read(opb,1)) + cascade|=(oggpack_read(opb,5)<<3); + info->secondstages[j]=cascade; + + acc+=icount(cascade); + } + for(j=0;jbooklist[j]=oggpack_read(opb,8); + + if(info->groupbook>=ci->books)goto errout; + for(j=0;jbooklist[j]>=ci->books)goto errout; + + return(info); + errout: + res0_free_info(info); + return(NULL); +} + +vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, + vorbis_info_residue *vr){ + vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; + vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look)); + codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup; + + int j,k,acc=0; + int dim; + int maxstage=0; + look->info=info; + look->map=vm->mapping; + + look->parts=info->partitions; + look->fullbooks=ci->fullbooks; + look->phrasebook=ci->fullbooks+info->groupbook; + dim=look->phrasebook->dim; + + look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks)); + + for(j=0;jparts;j++){ + int stages=ilog(info->secondstages[j]); + if(stages){ + if(stages>maxstage)maxstage=stages; + look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j])); + for(k=0;ksecondstages[j]&(1<partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; +#ifdef TRAIN_RES + look->training_data[k][j]=calloc(look->partbooks[j][k]->entries, + sizeof(***look->training_data)); +#endif + } + } + } + + look->partvals=look->parts; + for(j=1;jpartvals*=look->parts; + look->stages=maxstage; + look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap)); + for(j=0;jpartvals;j++){ + long val=j; + long mult=look->partvals/look->parts; + look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j])); + for(k=0;kparts; + look->decodemap[j][k]=deco; + } + } + + return(look); +} + + +/* a truncated packet here just means 'stop working'; it's not an error */ +static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, + ogg_int32_t **in,int ch, + long (*decodepart)(codebook *, ogg_int32_t *, + oggpack_buffer *,int,int)){ + + long i,j,k,l,s; + vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; + vorbis_info_residue0 *info=look->info; + + /* move all this setup out later */ + int samples_per_partition=info->grouping; + int partitions_per_word=look->phrasebook->dim; + int max=vb->pcmend>>1; + int end=(info->endend:max); + int n=end-info->begin; + + if(n>0){ + int partvals=n/samples_per_partition; + int partwords=(partvals+partitions_per_word-1)/partitions_per_word; + int ***partword=(int ***)alloca(ch*sizeof(*partword)); + + for(j=0;jstages;s++){ + + /* each loop decodes on partition codeword containing + partitions_pre_word partitions */ + for(i=0,l=0;iphrasebook,&vb->opb); + if(temp==-1)goto eopbreak; + partword[j][l]=look->decodemap[temp]; + if(partword[j][l]==NULL)goto errout; + } + } + + /* now we decode residual values for the partitions */ + for(k=0;kbegin+i*samples_per_partition; + if(info->secondstages[partword[j][l][k]]&(1<partbooks[partword[j][l][k]][s]; + if(stagebook){ + if(decodepart(stagebook,in[j]+offset,&vb->opb, + samples_per_partition,-8)==-1)goto eopbreak; + } + } + } + } + } + } + errout: + eopbreak: + return(0); +} + +int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, + ogg_int32_t **in,int *nonzero,int ch){ + int i,used=0; + for(i=0;iinfo; + + /* move all this setup out later */ + int samples_per_partition=info->grouping; + int partitions_per_word=look->phrasebook->dim; + int max=(vb->pcmend*ch)>>1; + int end=(info->endend:max); + int n=end-info->begin; + + if(n>0){ + + int partvals=n/samples_per_partition; + int partwords=(partvals+partitions_per_word-1)/partitions_per_word; + int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword)); + int beginoff=info->begin/ch; + + for(i=0;istages;s++){ + for(i=0,l=0;iphrasebook,&vb->opb); + if(temp==-1)goto eopbreak; + partword[l]=look->decodemap[temp]; + if(partword[l]==NULL)goto errout; + } + + /* now we decode residual values for the partitions */ + for(k=0;ksecondstages[partword[l][k]]&(1<partbooks[partword[l][k]][s]; + + if(stagebook){ + if(vorbis_book_decodevv_add(stagebook,in, + i*samples_per_partition+beginoff,ch, + &vb->opb, + samples_per_partition,-8)==-1) + goto eopbreak; + } + } + } + } + } + errout: + eopbreak: + return(0); +} + + +vorbis_func_residue residue0_exportbundle={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res0_inverse +}; + +vorbis_func_residue residue1_exportbundle={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res1_inverse +}; + +vorbis_func_residue residue2_exportbundle={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res2_inverse +}; diff --git a/wolf3d/newCode/Tremor/sharedbook.c b/wolf3d/newCode/Tremor/sharedbook.c new file mode 100644 index 0000000..8e07492 --- /dev/null +++ b/wolf3d/newCode/Tremor/sharedbook.c @@ -0,0 +1,439 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: basic shared codebook operations + + ********************************************************************/ + +#include +#include +#include +#include "ogg.h" +#include "misc.h" +#include "ivorbiscodec.h" +#include "codebook.h" + +/**** pack/unpack helpers ******************************************/ +int _ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +/* 32 bit float (not IEEE; nonnormalized mantissa + + biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm + Why not IEEE? It's just not that important here. */ + +#define VQ_FEXP 10 +#define VQ_FMAN 21 +#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */ + +static ogg_int32_t _float32_unpack(long val,int *point){ + long mant=val&0x1fffff; + int sign=val&0x80000000; + long exp =(val&0x7fe00000L)>>VQ_FMAN; + + exp-=(VQ_FMAN-1)+VQ_FEXP_BIAS; + + if(mant){ + while(!(mant&0x40000000)){ + mant<<=1; + exp-=1; + } + + if(sign)mant= -mant; + }else{ + sign=0; + exp=-9999; + } + + *point=exp; + return mant; +} + +/* given a list of word lengths, generate a list of codewords. Works + for length ordered or unordered, always assigns the lowest valued + codewords first. Extended to handle unused entries (length 0) */ +ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ + long i,j,count=0; + ogg_uint32_t marker[33]; + ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r)); + memset(marker,0,sizeof(marker)); + + for(i=0;i0){ + ogg_uint32_t entry=marker[length]; + + /* when we claim a node for an entry, we also claim the nodes + below it (pruning off the imagined tree that may have dangled + from it) as well as blocking the use of any nodes directly + above for leaves */ + + /* update ourself */ + if(length<32 && (entry>>length)){ + /* error condition; the lengths must specify an overpopulated tree */ + _ogg_free(r); + return(NULL); + } + r[count++]=entry; + + /* Look to see if the next shorter marker points to the node + above. if so, update it and repeat. */ + { + for(j=length;j>0;j--){ + + if(marker[j]&1){ + /* have to jump branches */ + if(j==1) + marker[1]++; + else + marker[j]=marker[j-1]<<1; + break; /* invariant says next upper marker would already + have been moved if it was on the same path */ + } + marker[j]++; + } + } + + /* prune the tree; the implicit invariant says all the longer + markers were dangling from our just-taken node. Dangle them + from our *new* node. */ + for(j=length+1;j<33;j++) + if((marker[j]>>1) == entry){ + entry=marker[j]; + marker[j]=marker[j-1]<<1; + }else + break; + }else + if(sparsecount==0)count++; + } + + /* bitreverse the words because our bitwise packer/unpacker is LSb + endian */ + for(i=0,count=0;i>j)&1; + } + + if(sparsecount){ + if(l[i]) + r[count++]=temp; + }else + r[count++]=temp; + } + + return(r); +} + +/* there might be a straightforward one-line way to do the below + that's portable and totally safe against roundoff, but I haven't + thought of it. Therefore, we opt on the side of caution */ +long _book_maptype1_quantvals(const static_codebook *b){ + /* get us a starting hint, we'll polish it below */ + int bits=_ilog(b->entries); + int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim); + + while(1){ + long acc=1; + long acc1=1; + int i; + for(i=0;idim;i++){ + acc*=vals; + acc1*=vals+1; + } + if(acc<=b->entries && acc1>b->entries){ + return(vals); + }else{ + if(acc>b->entries){ + vals--; + }else{ + vals++; + } + } + } +} + +/* different than what _book_unquantize does for mainline: + we repack the book in a fixed point format that shares the same + binary point. Upon first use, we can shift point if needed */ + +/* we need to deal with two map types: in map type 1, the values are + generated algorithmically (each column of the vector counts through + the values in the quant vector). in map type 2, all the values came + in in an explicit list. Both value lists must be unpacked */ + +ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap, + int *maxpoint){ + long j,k,count=0; + if(b->maptype==1 || b->maptype==2){ + int quantvals; + int minpoint,delpoint; + ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint); + ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint); + ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r)); + int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp)); + + *maxpoint=minpoint; + + /* maptype 1 and 2 both use a quantized value vector, but + different sizes */ + switch(b->maptype){ + case 1: + /* most of the time, entries%dimensions == 0, but we need to be + well defined. We define that the possible vales at each + scalar is values == entries/dim. If entries%dim != 0, we'll + have 'too few' values (values*dimentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ + ogg_int32_t last=0; + int lastpoint=0; + int indexdiv=1; + for(k=0;kdim;k++){ + int index= (j/indexdiv)%quantvals; + int point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[index]),&point); + + val=VFLOAT_ADD(mindel,minpoint,val,point,&point); + val=VFLOAT_ADD(last,lastpoint,val,point,&point); + + if(b->q_sequencep){ + last=val; + lastpoint=point; + } + + if(sparsemap){ + r[sparsemap[count]*b->dim+k]=val; + rp[sparsemap[count]*b->dim+k]=point; + }else{ + r[count*b->dim+k]=val; + rp[count*b->dim+k]=point; + } + if(*maxpointentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ + ogg_int32_t last=0; + int lastpoint=0; + + for(k=0;kdim;k++){ + int point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[j*b->dim+k]),&point); + + val=VFLOAT_ADD(mindel,minpoint,val,point,&point); + val=VFLOAT_ADD(last,lastpoint,val,point,&point); + + if(b->q_sequencep){ + last=val; + lastpoint=point; + } + + if(sparsemap){ + r[sparsemap[count]*b->dim+k]=val; + rp[sparsemap[count]*b->dim+k]=point; + }else{ + r[count*b->dim+k]=val; + rp[count*b->dim+k]=point; + } + if(*maxpointdim;j++) + if(rp[j]<*maxpoint) + r[j]>>=*maxpoint-rp[j]; + + _ogg_free(rp); + return(r); + } + return(NULL); +} + +void vorbis_staticbook_clear(static_codebook *b){ + if(b->quantlist)_ogg_free(b->quantlist); + if(b->lengthlist)_ogg_free(b->lengthlist); + memset(b,0,sizeof(*b)); + +} + +void vorbis_staticbook_destroy(static_codebook *b){ + vorbis_staticbook_clear(b); + _ogg_free(b); +} + +void vorbis_book_clear(codebook *b){ + /* static book is not cleared; we're likely called on the lookup and + the static codebook belongs to the info struct */ + if(b->valuelist)_ogg_free(b->valuelist); + if(b->codelist)_ogg_free(b->codelist); + + if(b->dec_index)_ogg_free(b->dec_index); + if(b->dec_codelengths)_ogg_free(b->dec_codelengths); + if(b->dec_firsttable)_ogg_free(b->dec_firsttable); + + memset(b,0,sizeof(*b)); +} + +static ogg_uint32_t bitreverse(ogg_uint32_t x){ + x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); + x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); + x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); + x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); + return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); +} + +static int sort32a(const void *a,const void *b){ + return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- + (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b); +} + +/* decode codebook arrangement is more heavily optimized than encode */ +int vorbis_book_init_decode(codebook *c,const static_codebook *s){ + int i,j,n=0,tabn; + int *sortindex; + memset(c,0,sizeof(*c)); + + /* count actually used entries */ + for(i=0;ientries;i++) + if(s->lengthlist[i]>0) + n++; + + c->entries=s->entries; + c->used_entries=n; + c->dim=s->dim; + + if(n>0){ + /* two different remappings go on here. + + First, we collapse the likely sparse codebook down only to + actually represented values/words. This collapsing needs to be + indexed as map-valueless books are used to encode original entry + positions as integers. + + Second, we reorder all vectors, including the entry index above, + by sorted bitreversed codeword to allow treeless decode. */ + + /* perform sort */ + ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); + ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n); + + if(codes==NULL)goto err_out; + + for(i=0;icodelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); + /* the index is a reverse index */ + for(i=0;icodelist[sortindex[i]]=codes[i]; + _ogg_free(codes); + + + + c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint); + c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index)); + + for(n=0,i=0;ientries;i++) + if(s->lengthlist[i]>0) + c->dec_index[sortindex[n++]]=i; + + c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); + for(n=0,i=0;ientries;i++) + if(s->lengthlist[i]>0) + c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; + + c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ + if(c->dec_firsttablen<5)c->dec_firsttablen=5; + if(c->dec_firsttablen>8)c->dec_firsttablen=8; + + tabn=1<dec_firsttablen; + c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); + c->dec_maxlength=0; + + for(i=0;idec_maxlengthdec_codelengths[i]) + c->dec_maxlength=c->dec_codelengths[i]; + if(c->dec_codelengths[i]<=c->dec_firsttablen){ + ogg_uint32_t orig=bitreverse(c->codelist[i]); + for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) + c->dec_firsttable[orig|(j<dec_codelengths[i])]=i+1; + } + } + + /* now fill in 'unused' entries in the firsttable with hi/lo search + hints for the non-direct-hits */ + { + ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); + long lo=0,hi=0; + + for(i=0;idec_firsttablen); + if(c->dec_firsttable[bitreverse(word)]==0){ + while((lo+1)codelist[lo+1]<=word)lo++; + while( hi=(c->codelist[hi]&mask))hi++; + + /* we only actually have 15 bits per hint to play with here. + In order to overflow gracefully (nothing breaks, efficiency + just drops), encode as the difference from the extremes. */ + { + unsigned long loval=lo; + unsigned long hival=n-hi; + + if(loval>0x7fff)loval=0x7fff; + if(hival>0x7fff)hival=0x7fff; + c->dec_firsttable[bitreverse(word)]= + 0x80000000UL | (loval<<15) | hival; + } + } + } + } + } + + return(0); + err_out: + vorbis_book_clear(c); + return(-1); +} + diff --git a/wolf3d/newCode/Tremor/synthesis.c b/wolf3d/newCode/Tremor/synthesis.c new file mode 100644 index 0000000..962c730 --- /dev/null +++ b/wolf3d/newCode/Tremor/synthesis.c @@ -0,0 +1,113 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: single-block PCM synthesis + last mod: $Id: synthesis.c,v 1.4 2003/03/29 03:07:21 xiphmont Exp $ + + ********************************************************************/ + +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "misc.h" +#include "block.h" + +int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){ + vorbis_dsp_state *vd=vb->vd; + private_state *b=(private_state *)vd->backend_state; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + oggpack_buffer *opb=&vb->opb; + int type,mode,i; + + /* first things first. Make sure decode is ready */ + _vorbis_block_ripcord(vb); + oggpack_readinit(opb,op->packet); + + /* Check the packet type */ + if(oggpack_read(opb,1)!=0){ + /* Oops. This is not an audio data packet */ + return(OV_ENOTAUDIO); + } + + /* read our mode and pre/post windowsize */ + mode=oggpack_read(opb,b->modebits); + if(mode==-1)return(OV_EBADPACKET); + + vb->mode=mode; + vb->W=ci->mode_param[mode]->blockflag; + if(vb->W){ + vb->lW=oggpack_read(opb,1); + vb->nW=oggpack_read(opb,1); + if(vb->nW==-1) return(OV_EBADPACKET); + }else{ + vb->lW=0; + vb->nW=0; + } + + /* more setup */ + vb->granulepos=op->granulepos; + vb->sequence=op->packetno-3; /* first block is third packet */ + vb->eofflag=op->e_o_s; + + if(decodep){ + /* alloc pcm passback storage */ + vb->pcmend=ci->blocksizes[vb->W]; + vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); + for(i=0;ichannels;i++) + vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); + + /* unpack_header enforces range checking */ + type=ci->map_type[ci->mode_param[mode]->mapping]; + + return(_mapping_P[type]->inverse(vb,b->mode[mode])); + }else{ + /* no pcm */ + vb->pcmend=0; + vb->pcm=NULL; + + return(0); + } +} + +long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + oggpack_buffer opb; + int mode; + + oggpack_readinit(&opb,op->packet); + + /* Check the packet type */ + if(oggpack_read(&opb,1)!=0){ + /* Oops. This is not an audio data packet */ + return(OV_ENOTAUDIO); + } + + { + int modebits=0; + int v=ci->modes; + while(v>1){ + modebits++; + v>>=1; + } + + /* read our mode and pre/post windowsize */ + mode=oggpack_read(&opb,modebits); + } + if(mode==-1)return(OV_EBADPACKET); + return(ci->blocksizes[ci->mode_param[mode]->blockflag]); +} + + diff --git a/wolf3d/newCode/Tremor/vorbisfile.c b/wolf3d/newCode/Tremor/vorbisfile.c new file mode 100644 index 0000000..0c48f1f --- /dev/null +++ b/wolf3d/newCode/Tremor/vorbisfile.c @@ -0,0 +1,1586 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + last mod: $Id: vorbisfile.c,v 1.6 2003/03/30 23:40:56 xiphmont Exp $ + + ********************************************************************/ + +#include +#include +#include +#include +#include + +#include "ivorbiscodec.h" +#include "ivorbisfile.h" + +#include "misc.h" + +/* A 'chained bitstream' is a Vorbis bitstream that contains more than + one logical bitstream arranged end to end (the only form of Ogg + multiplexing allowed in a Vorbis bitstream; grouping [parallel + multiplexing] is not allowed in Vorbis) */ + +/* A Vorbis file can be played beginning to end (streamed) without + worrying ahead of time about chaining (see decoder_example.c). If + we have the whole file, however, and want random access + (seeking/scrubbing) or desire to know the total length/time of a + file, we need to account for the possibility of chaining. */ + +/* We can handle things a number of ways; we can determine the entire + bitstream structure right off the bat, or find pieces on demand. + This example determines and caches structure for the entire + bitstream, but builds a virtual decoder on the fly when moving + between links in the chain. */ + +/* There are also different ways to implement seeking. Enough + information exists in an Ogg bitstream to seek to + sample-granularity positions in the output. Or, one can seek by + picking some portion of the stream roughly in the desired area if + we only want coarse navigation through the stream. */ + +/************************************************************************* + * Many, many internal helpers. The intention is not to be confusing; + * rampant duplication and monolithic function implementation would be + * harder to understand anyway. The high level functions are last. Begin + * grokking near the end of the file */ + + +/* read a little more data from the file/pipe into the ogg_sync framer */ +static long _get_data(OggVorbis_File *vf){ + errno=0; + if(vf->datasource){ + unsigned char *buffer=ogg_sync_bufferin(vf->oy,CHUNKSIZE); + long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource); + if(bytes>0)ogg_sync_wrote(vf->oy,bytes); + if(bytes==0 && errno)return(-1); + return(bytes); + }else + return(0); +} + +/* save a tiny smidge of verbosity to make the code more readable */ +static void _seek_helper(OggVorbis_File *vf,ogg_int64_t offset){ + if(vf->datasource){ + (vf->callbacks.seek_func)(vf->datasource, offset, SEEK_SET); + vf->offset=offset; + ogg_sync_reset(vf->oy); + }else{ + /* shouldn't happen unless someone writes a broken callback */ + return; + } +} + +/* The read/seek functions track absolute position within the stream */ + +/* from the head of the stream, get the next page. boundary specifies + if the function is allowed to fetch more data from the stream (and + how much) or only use internally buffered data. + + boundary: -1) unbounded search + 0) read no additional data; use cached only + n) search for a new page beginning for n bytes + + return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) + n) found a page at absolute offset n + + produces a refcounted page */ + +static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og, + ogg_int64_t boundary){ + if(boundary>0)boundary+=vf->offset; + while(1){ + long more; + + if(boundary>0 && vf->offset>=boundary)return(OV_FALSE); + more=ogg_sync_pageseek(vf->oy,og); + + if(more<0){ + /* skipped n bytes */ + vf->offset-=more; + }else{ + if(more==0){ + /* send more paramedics */ + if(!boundary)return(OV_FALSE); + { + long ret=_get_data(vf); + if(ret==0)return(OV_EOF); + if(ret<0)return(OV_EREAD); + } + }else{ + /* got a page. Return the offset at the page beginning, + advance the internal offset past the page end */ + ogg_int64_t ret=vf->offset; + vf->offset+=more; + return(ret); + + } + } + } +} + +/* find the latest page beginning before the current stream cursor + position. Much dirtier than the above as Ogg doesn't have any + backward search linkage. no 'readp' as it will certainly have to + read. */ +/* returns offset or OV_EREAD, OV_FAULT and produces a refcounted page */ + +static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){ + ogg_int64_t begin=vf->offset; + ogg_int64_t end=begin; + ogg_int64_t ret; + ogg_int64_t offset=-1; + + while(offset==-1){ + begin-=CHUNKSIZE; + if(begin<0) + begin=0; + _seek_helper(vf,begin); + while(vf->offsetoffset); + if(ret==OV_EREAD)return(OV_EREAD); + if(ret<0){ + break; + }else{ + offset=ret; + } + } + } + + /* we have the offset. Actually snork and hold the page now */ + _seek_helper(vf,offset); + ret=_get_next_page(vf,og,CHUNKSIZE); + if(ret<0) + /* this shouldn't be possible */ + return(OV_EFAULT); + + return(offset); +} + +/* finds each bitstream link one at a time using a bisection search + (has to begin by knowing the offset of the lb's initial page). + Recurses for each link so it can alloc the link storage after + finding them all, then unroll and fill the cache at the same time */ +static int _bisect_forward_serialno(OggVorbis_File *vf, + ogg_int64_t begin, + ogg_int64_t searched, + ogg_int64_t end, + ogg_uint32_t currentno, + long m){ + ogg_int64_t endsearched=end; + ogg_int64_t next=end; + ogg_page og={0,0,0,0}; + ogg_int64_t ret; + + /* the below guards against garbage seperating the last and + first pages of two links. */ + while(searched=0)next=ret; + }else{ + searched=ret+og.header_len+og.body_len; + } + ogg_page_release(&og); + } + + _seek_helper(vf,next); + ret=_get_next_page(vf,&og,-1); + if(ret==OV_EREAD)return(OV_EREAD); + + if(searched>=end || ret<0){ + ogg_page_release(&og); + vf->links=m+1; + vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets)); + vf->serialnos=_ogg_malloc(vf->links*sizeof(*vf->serialnos)); + vf->offsets[m+1]=searched; + }else{ + ret=_bisect_forward_serialno(vf,next,vf->offset, + end,ogg_page_serialno(&og),m+1); + ogg_page_release(&og); + if(ret==OV_EREAD)return(OV_EREAD); + } + + vf->offsets[m]=begin; + vf->serialnos[m]=currentno; + return(0); +} + +/* uses the local ogg_stream storage in vf; this is important for + non-streaming input sources */ +/* consumes the page that's passed in (if any) */ + +static int _fetch_headers(OggVorbis_File *vf, + vorbis_info *vi, + vorbis_comment *vc, + ogg_uint32_t *serialno, + ogg_page *og_ptr){ + ogg_page og={0,0,0,0}; + ogg_packet op={0,0,0,0,0,0}; + int i,ret; + + if(!og_ptr){ + ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); + if(llret==OV_EREAD)return(OV_EREAD); + if(llret<0)return OV_ENOTVORBIS; + og_ptr=&og; + } + + ogg_stream_reset_serialno(vf->os,ogg_page_serialno(og_ptr)); + if(serialno)*serialno=vf->os->serialno; + vf->ready_state=STREAMSET; + + /* extract the initial header from the first page and verify that the + Ogg bitstream is in fact Vorbis data */ + + vorbis_info_init(vi); + vorbis_comment_init(vc); + + i=0; + while(i<3){ + ogg_stream_pagein(vf->os,og_ptr); + while(i<3){ + int result=ogg_stream_packetout(vf->os,&op); + if(result==0)break; + if(result==-1){ + ret=OV_EBADHEADER; + goto bail_header; + } + if((ret=vorbis_synthesis_headerin(vi,vc,&op))){ + goto bail_header; + } + i++; + } + if(i<3) + if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ + ret=OV_EBADHEADER; + goto bail_header; + } + } + + ogg_packet_release(&op); + ogg_page_release(&og); + return 0; + + bail_header: + ogg_packet_release(&op); + ogg_page_release(&og); + vorbis_info_clear(vi); + vorbis_comment_clear(vc); + vf->ready_state=OPENED; + + return ret; +} + +/* last step of the OggVorbis_File initialization; get all the + vorbis_info structs and PCM positions. Only called by the seekable + initialization (local stream storage is hacked slightly; pay + attention to how that's done) */ + +/* this is void and does not propogate errors up because we want to be + able to open and use damaged bitstreams as well as we can. Just + watch out for missing information for links in the OggVorbis_File + struct */ +static void _prefetch_all_headers(OggVorbis_File *vf, ogg_int64_t dataoffset){ + ogg_page og={0,0,0,0}; + int i; + ogg_int64_t ret; + + vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); + vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc)); + vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets)); + vf->pcmlengths=_ogg_malloc(vf->links*2*sizeof(*vf->pcmlengths)); + + for(i=0;ilinks;i++){ + if(i==0){ + /* we already grabbed the initial header earlier. Just set the offset */ + vf->dataoffsets[i]=dataoffset; + _seek_helper(vf,dataoffset); + + }else{ + + /* seek to the location of the initial header */ + + _seek_helper(vf,vf->offsets[i]); + if(_fetch_headers(vf,vf->vi+i,vf->vc+i,NULL,NULL)<0){ + vf->dataoffsets[i]=-1; + }else{ + vf->dataoffsets[i]=vf->offset; + } + } + + /* fetch beginning PCM offset */ + + if(vf->dataoffsets[i]!=-1){ + ogg_int64_t accumulated=0,pos; + long lastblock=-1; + int result; + + ogg_stream_reset_serialno(vf->os,vf->serialnos[i]); + + while(1){ + ogg_packet op={0,0,0,0,0,0}; + + ret=_get_next_page(vf,&og,-1); + if(ret<0) + /* this should not be possible unless the file is + truncated/mangled */ + break; + + if(ogg_page_serialno(&og)!=vf->serialnos[i]) + break; + + pos=ogg_page_granulepos(&og); + + /* count blocksizes of all frames in the page */ + ogg_stream_pagein(vf->os,&og); + while((result=ogg_stream_packetout(vf->os,&op))){ + if(result>0){ /* ignore holes */ + long thisblock=vorbis_packet_blocksize(vf->vi+i,&op); + if(lastblock!=-1) + accumulated+=(lastblock+thisblock)>>2; + lastblock=thisblock; + } + } + ogg_packet_release(&op); + + if(pos!=-1){ + /* pcm offset of last packet on the first audio page */ + accumulated= pos-accumulated; + break; + } + } + + /* less than zero? This is a stream with samples trimmed off + the beginning, a normal occurrence; set the offset to zero */ + if(accumulated<0)accumulated=0; + + vf->pcmlengths[i*2]=accumulated; + } + + /* get the PCM length of this link. To do this, + get the last page of the stream */ + { + ogg_int64_t end=vf->offsets[i+1]; + _seek_helper(vf,end); + + while(1){ + ret=_get_prev_page(vf,&og); + if(ret<0){ + /* this should not be possible */ + vorbis_info_clear(vf->vi+i); + vorbis_comment_clear(vf->vc+i); + break; + } + if(ogg_page_granulepos(&og)!=-1){ + vf->pcmlengths[i*2+1]=ogg_page_granulepos(&og)-vf->pcmlengths[i*2]; + break; + } + vf->offset=ret; + } + } + } + ogg_page_release(&og); +} + +static void _make_decode_ready(OggVorbis_File *vf){ + if(vf->ready_state!=STREAMSET)return; + if(vf->seekable){ + vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link); + }else{ + vorbis_synthesis_init(&vf->vd,vf->vi); + } + vorbis_block_init(&vf->vd,&vf->vb); + vf->ready_state=INITSET; + vf->bittrack=0; + vf->samptrack=0; + return; +} + +static int _open_seekable2(OggVorbis_File *vf){ + ogg_uint32_t serialno=vf->current_serialno; + ogg_uint32_t tempserialno; + ogg_int64_t dataoffset=vf->offset, end; + ogg_page og={0,0,0,0}; + + /* we're partially open and have a first link header state in + storage in vf */ + /* we can seek, so set out learning all about this file */ + (vf->callbacks.seek_func)(vf->datasource,0,SEEK_END); + vf->offset=vf->end=(vf->callbacks.tell_func)(vf->datasource); + + /* We get the offset for the last page of the physical bitstream. + Most OggVorbis files will contain a single logical bitstream */ + end=_get_prev_page(vf,&og); + if(end<0)return(end); + + /* more than one logical bitstream? */ + tempserialno=ogg_page_serialno(&og); + ogg_page_release(&og); + + if(tempserialno!=serialno){ + + /* Chained bitstream. Bisect-search each logical bitstream + section. Do so based on serial number only */ + if(_bisect_forward_serialno(vf,0,0,end+1,serialno,0)<0)return(OV_EREAD); + + }else{ + + /* Only one logical bitstream */ + if(_bisect_forward_serialno(vf,0,end,end+1,serialno,0))return(OV_EREAD); + + } + + /* the initial header memory is referenced by vf after; don't free it */ + _prefetch_all_headers(vf,dataoffset); + return(ov_raw_seek(vf,0)); +} + +/* clear out the current logical bitstream decoder */ +static void _decode_clear(OggVorbis_File *vf){ + vorbis_dsp_clear(&vf->vd); + vorbis_block_clear(&vf->vb); + vf->ready_state=OPENED; +} + +/* fetch and process a packet. Handles the case where we're at a + bitstream boundary and dumps the decoding machine. If the decoding + machine is unloaded, it loads it. It also keeps pcm_offset up to + date (seek and read both use this. seek uses a special hack with + readp). + + return: <0) error, OV_HOLE (lost packet) or OV_EOF + 0) need more data (only if readp==0) + 1) got a packet +*/ + +static int _fetch_and_process_packet(OggVorbis_File *vf, + int readp, + int spanp){ + ogg_page og={0,0,0,0}; + ogg_packet op={0,0,0,0,0,0}; + int ret=0; + + /* handle one packet. Try to fetch it from current stream state */ + /* extract packets from page */ + while(1){ + + /* process a packet if we can. If the machine isn't loaded, + neither is a page */ + if(vf->ready_state==INITSET){ + while(1) { + int result=ogg_stream_packetout(vf->os,&op); + ogg_int64_t granulepos; + + if(result<0){ + ret=OV_HOLE; /* hole in the data. */ + goto cleanup; + } + if(result>0){ + /* got a packet. process it */ + granulepos=op.granulepos; + if(!vorbis_synthesis(&vf->vb,&op,1)){ /* lazy check for lazy + header handling. The + header packets aren't + audio, so if/when we + submit them, + vorbis_synthesis will + reject them */ + + /* suck in the synthesis data and track bitrate */ + { + int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL); + /* for proper use of libvorbis within libvorbisfile, + oldsamples will always be zero. */ + if(oldsamples){ + ret=OV_EFAULT; + goto cleanup; + } + + vorbis_synthesis_blockin(&vf->vd,&vf->vb); + vf->samptrack+=vorbis_synthesis_pcmout(&vf->vd,NULL)-oldsamples; + vf->bittrack+=op.bytes*8; + } + + /* update the pcm offset. */ + if(granulepos!=-1 && !op.e_o_s){ + int link=(vf->seekable?vf->current_link:0); + int i,samples; + + /* this packet has a pcm_offset on it (the last packet + completed on a page carries the offset) After processing + (above), we know the pcm position of the *last* sample + ready to be returned. Find the offset of the *first* + + As an aside, this trick is inaccurate if we begin + reading anew right at the last page; the end-of-stream + granulepos declares the last frame in the stream, and the + last packet of the last page may be a partial frame. + So, we need a previous granulepos from an in-sequence page + to have a reference point. Thus the !op.e_o_s clause + above */ + + if(vf->seekable && link>0) + granulepos-=vf->pcmlengths[link*2]; + if(granulepos<0)granulepos=0; /* actually, this + shouldn't be possible + here unless the stream + is very broken */ + + samples=vorbis_synthesis_pcmout(&vf->vd,NULL); + + granulepos-=samples; + for(i=0;ipcmlengths[i*2+1]; + vf->pcm_offset=granulepos; + } + ret=1; + goto cleanup; + } + } + else + break; + } + } + + if(vf->ready_state>=OPENED){ + int ret; + if(!readp){ + ret=0; + goto cleanup; + } + if((ret=_get_next_page(vf,&og,-1))<0){ + ret=OV_EOF; /* eof. leave unitialized */ + goto cleanup; + } + + /* bitrate tracking; add the header's bytes here, the body bytes + are done by packet above */ + vf->bittrack+=og.header_len*8; + + /* has our decoding just traversed a bitstream boundary? */ + if(vf->ready_state==INITSET){ + if(vf->current_serialno!=ogg_page_serialno(&og)){ + if(!spanp){ + ret=OV_EOF; + goto cleanup; + } + + _decode_clear(vf); + + if(!vf->seekable){ + vorbis_info_clear(vf->vi); + vorbis_comment_clear(vf->vc); + } + } + } + } + + /* Do we need to load a new machine before submitting the page? */ + /* This is different in the seekable and non-seekable cases. + + In the seekable case, we already have all the header + information loaded and cached; we just initialize the machine + with it and continue on our merry way. + + In the non-seekable (streaming) case, we'll only be at a + boundary if we just left the previous logical bitstream and + we're now nominally at the header of the next bitstream + */ + + if(vf->ready_state!=INITSET){ + int link; + + if(vf->ready_stateseekable){ + vf->current_serialno=ogg_page_serialno(&og); + + /* match the serialno to bitstream section. We use this rather than + offset positions to avoid problems near logical bitstream + boundaries */ + for(link=0;linklinks;link++) + if(vf->serialnos[link]==vf->current_serialno)break; + if(link==vf->links){ + ret=OV_EBADLINK; /* sign of a bogus stream. error out, + leave machine uninitialized */ + goto cleanup; + } + + vf->current_link=link; + + ogg_stream_reset_serialno(vf->os,vf->current_serialno); + vf->ready_state=STREAMSET; + + }else{ + /* we're streaming */ + /* fetch the three header packets, build the info struct */ + + int ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og); + if(ret) goto cleanup; + vf->current_link++; + link=0; + } + } + + _make_decode_ready(vf); + } + ogg_stream_pagein(vf->os,&og); + } + cleanup: + ogg_packet_release(&op); + ogg_page_release(&og); + return ret; +} + +/* if, eg, 64 bit stdio is configured by default, this will build with + fseek64 */ +static int _fseek64_wrap(FILE *f,ogg_int64_t off,int whence){ + if(f==NULL)return(-1); + return fseek(f,off,whence); +} + +static int _ov_open1(void *f,OggVorbis_File *vf,char *initial, + long ibytes, ov_callbacks callbacks){ + int offsettest=(f?callbacks.seek_func(f,0,SEEK_CUR):-1); + int ret; + + memset(vf,0,sizeof(*vf)); + vf->datasource=f; + vf->callbacks = callbacks; + + /* init the framing state */ + vf->oy=ogg_sync_create(); + + /* perhaps some data was previously read into a buffer for testing + against other stream types. Allow initialization from this + previously read data (as we may be reading from a non-seekable + stream) */ + if(initial){ + unsigned char *buffer=ogg_sync_bufferin(vf->oy,ibytes); + memcpy(buffer,initial,ibytes); + ogg_sync_wrote(vf->oy,ibytes); + } + + /* can we seek? Stevens suggests the seek test was portable */ + if(offsettest!=-1)vf->seekable=1; + + /* No seeking yet; Set up a 'single' (current) logical bitstream + entry for partial open */ + vf->links=1; + vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi)); + vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc)); + vf->os=ogg_stream_create(-1); /* fill in the serialno later */ + + /* Try to fetch the headers, maintaining all the storage */ + if((ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,NULL))<0){ + vf->datasource=NULL; + ov_clear(vf); + }else if(vf->ready_state < PARTOPEN) + vf->ready_state=PARTOPEN; + return(ret); +} + +static int _ov_open2(OggVorbis_File *vf){ + if(vf->ready_state < OPENED) + vf->ready_state=OPENED; + if(vf->seekable){ + int ret=_open_seekable2(vf); + if(ret){ + vf->datasource=NULL; + ov_clear(vf); + } + return(ret); + } + return 0; +} + + +/* clear out the OggVorbis_File struct */ +int ov_clear(OggVorbis_File *vf){ + if(vf){ + vorbis_block_clear(&vf->vb); + vorbis_dsp_clear(&vf->vd); + ogg_stream_destroy(vf->os); + + if(vf->vi && vf->links){ + int i; + for(i=0;ilinks;i++){ + vorbis_info_clear(vf->vi+i); + vorbis_comment_clear(vf->vc+i); + } + _ogg_free(vf->vi); + _ogg_free(vf->vc); + } + if(vf->dataoffsets)_ogg_free(vf->dataoffsets); + if(vf->pcmlengths)_ogg_free(vf->pcmlengths); + if(vf->serialnos)_ogg_free(vf->serialnos); + if(vf->offsets)_ogg_free(vf->offsets); + ogg_sync_destroy(vf->oy); + + if(vf->datasource)(vf->callbacks.close_func)(vf->datasource); + memset(vf,0,sizeof(*vf)); + } +#ifdef DEBUG_LEAKS + _VDBG_dump(); +#endif + return(0); +} + +/* inspects the OggVorbis file and finds/documents all the logical + bitstreams contained in it. Tries to be tolerant of logical + bitstream sections that are truncated/woogie. + + return: -1) error + 0) OK +*/ + +int ov_open_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes, + ov_callbacks callbacks){ + int ret=_ov_open1(f,vf,initial,ibytes,callbacks); + if(ret)return ret; + return _ov_open2(vf); +} + +int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes){ + ov_callbacks callbacks = { + (size_t (*)(void *, size_t, size_t, void *)) fread, + (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap, + (int (*)(void *)) fclose, + (long (*)(void *)) ftell + }; + + return ov_open_callbacks((void *)f, vf, initial, ibytes, callbacks); +} + +/* Only partially open the vorbis file; test for Vorbisness, and load + the headers for the first chain. Do not seek (although test for + seekability). Use ov_test_open to finish opening the file, else + ov_clear to close/free it. Same return codes as open. */ + +int ov_test_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes, + ov_callbacks callbacks) +{ + return _ov_open1(f,vf,initial,ibytes,callbacks); +} + +int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes){ + ov_callbacks callbacks = { + (size_t (*)(void *, size_t, size_t, void *)) fread, + (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap, + (int (*)(void *)) fclose, + (long (*)(void *)) ftell + }; + + return ov_test_callbacks((void *)f, vf, initial, ibytes, callbacks); +} + +int ov_test_open(OggVorbis_File *vf){ + if(vf->ready_state!=PARTOPEN)return(OV_EINVAL); + return _ov_open2(vf); +} + +/* How many logical bitstreams in this physical bitstream? */ +long ov_streams(OggVorbis_File *vf){ + return vf->links; +} + +/* Is the FILE * associated with vf seekable? */ +long ov_seekable(OggVorbis_File *vf){ + return vf->seekable; +} + +/* returns the bitrate for a given logical bitstream or the entire + physical bitstream. If the file is open for random access, it will + find the *actual* average bitrate. If the file is streaming, it + returns the nominal bitrate (if set) else the average of the + upper/lower bounds (if set) else -1 (unset). + + If you want the actual bitrate field settings, get them from the + vorbis_info structs */ + +long ov_bitrate(OggVorbis_File *vf,int i){ + if(vf->ready_state=vf->links)return(OV_EINVAL); + if(!vf->seekable && i!=0)return(ov_bitrate(vf,0)); + if(i<0){ + ogg_int64_t bits=0; + int i; + for(i=0;ilinks;i++) + bits+=(vf->offsets[i+1]-vf->dataoffsets[i])*8; + /* This once read: return(rint(bits/ov_time_total(vf,-1))); + * gcc 3.x on x86 miscompiled this at optimisation level 2 and above, + * so this is slightly transformed to make it work. + */ + return(bits*1000/ov_time_total(vf,-1)); + }else{ + if(vf->seekable){ + /* return the actual bitrate */ + return((vf->offsets[i+1]-vf->dataoffsets[i])*8000/ov_time_total(vf,i)); + }else{ + /* return nominal if set */ + if(vf->vi[i].bitrate_nominal>0){ + return vf->vi[i].bitrate_nominal; + }else{ + if(vf->vi[i].bitrate_upper>0){ + if(vf->vi[i].bitrate_lower>0){ + return (vf->vi[i].bitrate_upper+vf->vi[i].bitrate_lower)/2; + }else{ + return vf->vi[i].bitrate_upper; + } + } + return(OV_FALSE); + } + } + } +} + +/* returns the actual bitrate since last call. returns -1 if no + additional data to offer since last call (or at beginning of stream), + EINVAL if stream is only partially open +*/ +long ov_bitrate_instant(OggVorbis_File *vf){ + int link=(vf->seekable?vf->current_link:0); + long ret; + if(vf->ready_statesamptrack==0)return(OV_FALSE); + ret=vf->bittrack/vf->samptrack*vf->vi[link].rate; + vf->bittrack=0; + vf->samptrack=0; + return(ret); +} + +/* Guess */ +long ov_serialnumber(OggVorbis_File *vf,int i){ + if(i>=vf->links)return(ov_serialnumber(vf,vf->links-1)); + if(!vf->seekable && i>=0)return(ov_serialnumber(vf,-1)); + if(i<0){ + return(vf->current_serialno); + }else{ + return(vf->serialnos[i]); + } +} + +/* returns: total raw (compressed) length of content if i==-1 + raw (compressed) length of that logical bitstream for i==0 to n + OV_EINVAL if the stream is not seekable (we can't know the length) + or if stream is only partially open +*/ +ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i){ + if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); + if(i<0){ + ogg_int64_t acc=0; + int i; + for(i=0;ilinks;i++) + acc+=ov_raw_total(vf,i); + return(acc); + }else{ + return(vf->offsets[i+1]-vf->offsets[i]); + } +} + +/* returns: total PCM length (samples) of content if i==-1 PCM length + (samples) of that logical bitstream for i==0 to n + OV_EINVAL if the stream is not seekable (we can't know the + length) or only partially open +*/ +ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i){ + if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); + if(i<0){ + ogg_int64_t acc=0; + int i; + for(i=0;ilinks;i++) + acc+=ov_pcm_total(vf,i); + return(acc); + }else{ + return(vf->pcmlengths[i*2+1]); + } +} + +/* returns: total milliseconds of content if i==-1 + milliseconds in that logical bitstream for i==0 to n + OV_EINVAL if the stream is not seekable (we can't know the + length) or only partially open +*/ +ogg_int64_t ov_time_total(OggVorbis_File *vf,int i){ + if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); + if(i<0){ + ogg_int64_t acc=0; + int i; + for(i=0;ilinks;i++) + acc+=ov_time_total(vf,i); + return(acc); + }else{ + return(((ogg_int64_t)vf->pcmlengths[i*2+1])*1000/vf->vi[i].rate); + } +} + +/* seek to an offset relative to the *compressed* data. This also + scans packets to update the PCM cursor. It will cross a logical + bitstream boundary, but only if it can't get any packets out of the + tail of the bitstream we seek to (so no surprises). + + returns zero on success, nonzero on failure */ + +int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ + ogg_stream_state *work_os=NULL; + ogg_page og={0,0,0,0}; + ogg_packet op={0,0,0,0,0,0}; + + if(vf->ready_stateseekable) + return(OV_ENOSEEK); /* don't dump machine if we can't seek */ + + if(pos<0 || pos>vf->end)return(OV_EINVAL); + + /* don't yet clear out decoding machine (if it's initialized), in + the case we're in the same link. Restart the decode lapping, and + let _fetch_and_process_packet deal with a potential bitstream + boundary */ + vf->pcm_offset=-1; + ogg_stream_reset_serialno(vf->os, + vf->current_serialno); /* must set serialno */ + vorbis_synthesis_restart(&vf->vd); + + _seek_helper(vf,pos); + + /* we need to make sure the pcm_offset is set, but we don't want to + advance the raw cursor past good packets just to get to the first + with a granulepos. That's not equivalent behavior to beginning + decoding as immediately after the seek position as possible. + + So, a hack. We use two stream states; a local scratch state and + the shared vf->os stream state. We use the local state to + scan, and the shared state as a buffer for later decode. + + Unfortuantely, on the last page we still advance to last packet + because the granulepos on the last page is not necessarily on a + packet boundary, and we need to make sure the granpos is + correct. + */ + + { + int lastblock=0; + int accblock=0; + int thisblock; + int eosflag=0; + + work_os=ogg_stream_create(vf->current_serialno); /* get the memory ready */ + while(1){ + if(vf->ready_state>=STREAMSET){ + /* snarf/scan a packet if we can */ + int result=ogg_stream_packetout(work_os,&op); + + if(result>0){ + + if(vf->vi[vf->current_link].codec_setup){ + thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); + if(thisblock<0){ + ogg_stream_packetout(vf->os,NULL); + thisblock=0; + }else{ + + if(eosflag) + ogg_stream_packetout(vf->os,NULL); + else + if(lastblock)accblock+=(lastblock+thisblock)>>2; + } + + if(op.granulepos!=-1){ + int i,link=vf->current_link; + ogg_int64_t granulepos=op.granulepos-vf->pcmlengths[link*2]; + if(granulepos<0)granulepos=0; + + for(i=0;ipcmlengths[i*2+1]; + vf->pcm_offset=granulepos-accblock; + break; + } + lastblock=thisblock; + continue; + }else + ogg_stream_packetout(vf->os,NULL); + } + } + + if(!lastblock){ + if(_get_next_page(vf,&og,-1)<0){ + vf->pcm_offset=ov_pcm_total(vf,-1); + break; + } + }else{ + /* huh? Bogus stream with packets but no granulepos */ + vf->pcm_offset=-1; + break; + } + + /* has our decoding just traversed a bitstream boundary? */ + if(vf->ready_state>=STREAMSET) + if(vf->current_serialno!=ogg_page_serialno(&og)){ + _decode_clear(vf); /* clear out stream state */ + ogg_stream_destroy(work_os); + } + + if(vf->ready_statecurrent_serialno=ogg_page_serialno(&og); + for(link=0;linklinks;link++) + if(vf->serialnos[link]==vf->current_serialno)break; + if(link==vf->links) + goto seek_error; /* sign of a bogus stream. error out, + leave machine uninitialized */ + + vf->current_link=link; + + ogg_stream_reset_serialno(vf->os,vf->current_serialno); + ogg_stream_reset_serialno(work_os,vf->current_serialno); + vf->ready_state=STREAMSET; + + } + + { + ogg_page dup; + ogg_page_dup(&dup,&og); + eosflag=ogg_page_eos(&og); + ogg_stream_pagein(vf->os,&og); + ogg_stream_pagein(work_os,&dup); + } + } + } + + ogg_packet_release(&op); + ogg_page_release(&og); + ogg_stream_destroy(work_os); + vf->bittrack=0; + vf->samptrack=0; + return(0); + + seek_error: + ogg_packet_release(&op); + ogg_page_release(&og); + + /* dump the machine so we're in a known state */ + vf->pcm_offset=-1; + ogg_stream_destroy(work_os); + _decode_clear(vf); + return OV_EBADLINK; +} + +/* Page granularity seek (faster than sample granularity because we + don't do the last bit of decode to find a specific sample). + + Seek to the last [granule marked] page preceeding the specified pos + location, such that decoding past the returned point will quickly + arrive at the requested position. */ +int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){ + int link=-1; + ogg_int64_t result=0; + ogg_int64_t total=ov_pcm_total(vf,-1); + ogg_page og={0,0,0,0}; + ogg_packet op={0,0,0,0,0,0}; + + if(vf->ready_stateseekable)return(OV_ENOSEEK); + if(pos<0 || pos>total)return(OV_EINVAL); + + /* which bitstream section does this pcm offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + total-=vf->pcmlengths[link*2+1]; + if(pos>=total)break; + } + + /* search within the logical bitstream for the page with the highest + pcm_pos preceeding (or equal to) pos. There is a danger here; + missing pages or incorrect frame number information in the + bitstream could make our task impossible. Account for that (it + would be an error condition) */ + + /* new search algorithm by HB (Nicholas Vinen) */ + { + ogg_int64_t end=vf->offsets[link+1]; + ogg_int64_t begin=vf->offsets[link]; + ogg_int64_t begintime = vf->pcmlengths[link*2]; + ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime; + ogg_int64_t target=pos-total+begintime; + ogg_int64_t best=begin; + + while(beginoffset); + if(result==OV_EREAD) goto seek_error; + if(result<0){ + if(bisect<=begin+1) + end=begin; /* found it */ + else{ + if(bisect==0) goto seek_error; + bisect-=CHUNKSIZE; + if(bisect<=begin)bisect=begin+1; + _seek_helper(vf,bisect); + } + }else{ + ogg_int64_t granulepos=ogg_page_granulepos(&og); + if(granulepos==-1)continue; + if(granuleposoffset; /* raw offset of next page */ + begintime=granulepos; + + if(target-begintime>44100)break; + bisect=begin; /* *not* begin + 1 */ + }else{ + if(bisect<=begin+1) + end=begin; /* found it */ + else{ + if(end==vf->offset){ /* we're pretty close - we'd be stuck in */ + end=result; + bisect-=CHUNKSIZE; /* an endless loop otherwise. */ + if(bisect<=begin)bisect=begin+1; + _seek_helper(vf,bisect); + }else{ + end=result; + endtime=granulepos; + break; + } + } + } + } + } + } + + /* found our page. seek to it, update pcm offset. Easier case than + raw_seek, don't keep packets preceeding granulepos. */ + { + + /* seek */ + _seek_helper(vf,best); + vf->pcm_offset=-1; + + if(_get_next_page(vf,&og,-1)<0){ + ogg_page_release(&og); + return(OV_EOF); /* shouldn't happen */ + } + + if(link!=vf->current_link){ + /* Different link; dump entire decode machine */ + _decode_clear(vf); + + vf->current_link=link; + vf->current_serialno=ogg_page_serialno(&og); + vf->ready_state=STREAMSET; + + }else{ + vorbis_synthesis_restart(&vf->vd); + } + + ogg_stream_reset_serialno(vf->os,vf->current_serialno); + ogg_stream_pagein(vf->os,&og); + + /* pull out all but last packet; the one with granulepos */ + while(1){ + result=ogg_stream_packetpeek(vf->os,&op); + if(result==0){ + /* !!! the packet finishing this page originated on a + preceeding page. Keep fetching previous pages until we + get one with a granulepos or without the 'continued' flag + set. Then just use raw_seek for simplicity. */ + + _seek_helper(vf,best); + + while(1){ + result=_get_prev_page(vf,&og); + if(result<0) goto seek_error; + if(ogg_page_granulepos(&og)>-1 || + !ogg_page_continued(&og)){ + return ov_raw_seek(vf,result); + } + vf->offset=result; + } + } + if(result<0){ + result = OV_EBADPACKET; + goto seek_error; + } + if(op.granulepos!=-1){ + vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; + if(vf->pcm_offset<0)vf->pcm_offset=0; + vf->pcm_offset+=total; + break; + }else + result=ogg_stream_packetout(vf->os,NULL); + } + } + } + + /* verify result */ + if(vf->pcm_offset>pos || pos>ov_pcm_total(vf,-1)){ + result=OV_EFAULT; + goto seek_error; + } + vf->bittrack=0; + vf->samptrack=0; + + ogg_page_release(&og); + ogg_packet_release(&op); + return(0); + + seek_error: + + ogg_page_release(&og); + ogg_packet_release(&op); + + /* dump machine so we're in a known state */ + vf->pcm_offset=-1; + _decode_clear(vf); + return (int)result; +} + +/* seek to a sample offset relative to the decompressed pcm stream + returns zero on success, nonzero on failure */ + +int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){ + ogg_packet op={0,0,0,0,0,0}; + ogg_page og={0,0,0,0}; + int thisblock,lastblock=0; + int ret=ov_pcm_seek_page(vf,pos); + if(ret<0)return(ret); + _make_decode_ready(vf); + + /* discard leading packets we don't need for the lapping of the + position we want; don't decode them */ + + while(1){ + + int ret=ogg_stream_packetpeek(vf->os,&op); + if(ret>0){ + thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); + if(thisblock<0){ + ogg_stream_packetout(vf->os,NULL); + continue; /* non audio packet */ + } + if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2; + + if(vf->pcm_offset+((thisblock+ + vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break; + + /* remove the packet from packet queue and track its granulepos */ + ogg_stream_packetout(vf->os,NULL); + vorbis_synthesis(&vf->vb,&op,0); /* set up a vb with + only tracking, no + pcm_decode */ + vorbis_synthesis_blockin(&vf->vd,&vf->vb); + + /* end of logical stream case is hard, especially with exact + length positioning. */ + + if(op.granulepos>-1){ + int i; + /* always believe the stream markers */ + vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; + if(vf->pcm_offset<0)vf->pcm_offset=0; + for(i=0;icurrent_link;i++) + vf->pcm_offset+=vf->pcmlengths[i*2+1]; + } + + lastblock=thisblock; + + }else{ + if(ret<0 && ret!=OV_HOLE)break; + + /* suck in a new page */ + if(_get_next_page(vf,&og,-1)<0)break; + if(vf->current_serialno!=ogg_page_serialno(&og))_decode_clear(vf); + + if(vf->ready_statecurrent_serialno=ogg_page_serialno(&og); + for(link=0;linklinks;link++) + if(vf->serialnos[link]==vf->current_serialno)break; + if(link==vf->links){ + ogg_page_release(&og); + ogg_packet_release(&op); + return(OV_EBADLINK); + } + vf->current_link=link; + + ogg_stream_reset_serialno(vf->os,vf->current_serialno); + vf->ready_state=STREAMSET; + _make_decode_ready(vf); + lastblock=0; + } + + ogg_stream_pagein(vf->os,&og); + } + } + + vf->bittrack=0; + vf->samptrack=0; + /* discard samples until we reach the desired position. Crossing a + logical bitstream boundary with abandon is OK. */ + while(vf->pcm_offsetpcm_offset; + long samples=vorbis_synthesis_pcmout(&vf->vd,NULL); + + if(samples>target)samples=target; + vorbis_synthesis_read(&vf->vd,samples); + vf->pcm_offset+=samples; + + if(samplespcm_offset=ov_pcm_total(vf,-1); /* eof */ + } + + ogg_page_release(&og); + ogg_packet_release(&op); + return 0; +} + +/* seek to a playback time relative to the decompressed pcm stream + returns zero on success, nonzero on failure */ +int ov_time_seek(OggVorbis_File *vf,ogg_int64_t milliseconds){ + /* translate time to PCM position and call ov_pcm_seek */ + + int link=-1; + ogg_int64_t pcm_total=ov_pcm_total(vf,-1); + ogg_int64_t time_total=ov_time_total(vf,-1); + + if(vf->ready_stateseekable)return(OV_ENOSEEK); + if(milliseconds<0 || milliseconds>time_total)return(OV_EINVAL); + + /* which bitstream section does this time offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + pcm_total-=vf->pcmlengths[link*2+1]; + time_total-=ov_time_total(vf,link); + if(milliseconds>=time_total)break; + } + + /* enough information to convert time offset to pcm offset */ + { + ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000; + return(ov_pcm_seek(vf,target)); + } +} + +/* page-granularity version of ov_time_seek + returns zero on success, nonzero on failure */ +int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t milliseconds){ + /* translate time to PCM position and call ov_pcm_seek */ + + int link=-1; + ogg_int64_t pcm_total=ov_pcm_total(vf,-1); + ogg_int64_t time_total=ov_time_total(vf,-1); + + if(vf->ready_stateseekable)return(OV_ENOSEEK); + if(milliseconds<0 || milliseconds>time_total)return(OV_EINVAL); + + /* which bitstream section does this time offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + pcm_total-=vf->pcmlengths[link*2+1]; + time_total-=ov_time_total(vf,link); + if(milliseconds>=time_total)break; + } + + /* enough information to convert time offset to pcm offset */ + { + ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000; + return(ov_pcm_seek_page(vf,target)); + } +} + +/* tell the current stream offset cursor. Note that seek followed by + tell will likely not give the set offset due to caching */ +ogg_int64_t ov_raw_tell(OggVorbis_File *vf){ + if(vf->ready_stateoffset); +} + +/* return PCM offset (sample) of next PCM sample to be read */ +ogg_int64_t ov_pcm_tell(OggVorbis_File *vf){ + if(vf->ready_statepcm_offset); +} + +/* return time offset (milliseconds) of next PCM sample to be read */ +ogg_int64_t ov_time_tell(OggVorbis_File *vf){ + int link=0; + ogg_int64_t pcm_total=0; + ogg_int64_t time_total=0; + + if(vf->ready_stateseekable){ + pcm_total=ov_pcm_total(vf,-1); + time_total=ov_time_total(vf,-1); + + /* which bitstream section does this time offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + pcm_total-=vf->pcmlengths[link*2+1]; + time_total-=ov_time_total(vf,link); + if(vf->pcm_offset>=pcm_total)break; + } + } + + return(time_total+(1000*vf->pcm_offset-pcm_total)/vf->vi[link].rate); +} + +/* link: -1) return the vorbis_info struct for the bitstream section + currently being decoded + 0-n) to request information for a specific bitstream section + + In the case of a non-seekable bitstream, any call returns the + current bitstream. NULL in the case that the machine is not + initialized */ + +vorbis_info *ov_info(OggVorbis_File *vf,int link){ + if(vf->seekable){ + if(link<0) + if(vf->ready_state>=STREAMSET) + return vf->vi+vf->current_link; + else + return vf->vi; + else + if(link>=vf->links) + return NULL; + else + return vf->vi+link; + }else{ + return vf->vi; + } +} + +/* grr, strong typing, grr, no templates/inheritence, grr */ +vorbis_comment *ov_comment(OggVorbis_File *vf,int link){ + if(vf->seekable){ + if(link<0) + if(vf->ready_state>=STREAMSET) + return vf->vc+vf->current_link; + else + return vf->vc; + else + if(link>=vf->links) + return NULL; + else + return vf->vc+link; + }else{ + return vf->vc; + } +} + +/* up to this point, everything could more or less hide the multiple + logical bitstream nature of chaining from the toplevel application + if the toplevel application didn't particularly care. However, at + the point that we actually read audio back, the multiple-section + nature must surface: Multiple bitstream sections do not necessarily + have to have the same number of channels or sampling rate. + + ov_read returns the sequential logical bitstream number currently + being decoded along with the PCM data in order that the toplevel + application can take action on channel/sample rate changes. This + number will be incremented even for streamed (non-seekable) streams + (for seekable streams, it represents the actual logical bitstream + index within the physical bitstream. Note that the accessor + functions above are aware of this dichotomy). + + input values: buffer) a buffer to hold packed PCM data for return + length) the byte length requested to be placed into buffer + + return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) + 0) EOF + n) number of bytes of PCM actually returned. The + below works on a packet-by-packet basis, so the + return length is not related to the 'length' passed + in, just guaranteed to fit. + + *section) set to the logical bitstream number */ + +long ov_read(OggVorbis_File *vf,char *buffer,int bytes_req,int *bitstream){ + int i,j; + + ogg_int32_t **pcm; + long samples; + + if(vf->ready_stateready_state==INITSET){ + samples=vorbis_synthesis_pcmout(&vf->vd,&pcm); + if(samples)break; + } + + /* suck in another packet */ + { + int ret=_fetch_and_process_packet(vf,1,1); + if(ret==OV_EOF) + return(0); + if(ret<=0) + return(ret); + } + + } + + if(samples>0){ + + /* yay! proceed to pack data into the byte buffer */ + + long channels=ov_info(vf,-1)->channels; + + if(samples>(bytes_req/(2*channels))) + samples=bytes_req/(2*channels); + + for(i=0;i>9); + dest+=channels; + } + } + + vorbis_synthesis_read(&vf->vd,samples); + vf->pcm_offset+=samples; + if(bitstream)*bitstream=vf->current_link; + return(samples*2*channels); + }else{ + return(samples); + } +} diff --git a/wolf3d/newCode/Tremor/window.c b/wolf3d/newCode/Tremor/window.c new file mode 100644 index 0000000..006a1ee --- /dev/null +++ b/wolf3d/newCode/Tremor/window.c @@ -0,0 +1,83 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: window functions + + ********************************************************************/ + +#include +#include +#include "misc.h" +#include "window.h" +#include "window_lookup.h" + +const void *_vorbis_window(int type, int left){ + + switch(type){ + case 0: + + switch(left){ + case 32: + return vwin64; + case 64: + return vwin128; + case 128: + return vwin256; + case 256: + return vwin512; + case 512: + return vwin1024; + case 1024: + return vwin2048; + case 2048: + return vwin4096; + case 4096: + return vwin8192; + default: + return(0); + } + break; + default: + return(0); + } +} + +void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], + long *blocksizes, + int lW,int W,int nW){ + + LOOKUP_T *window[2]={window_p[0],window_p[1]}; + long n=blocksizes[W]; + long ln=blocksizes[lW]; + long rn=blocksizes[nW]; + + long leftbegin=n/4-ln/4; + long leftend=leftbegin+ln/2; + + long rightbegin=n/2+n/4-rn/4; + long rightend=rightbegin+rn/2; + + int i,p; + + for(i=0;i + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * angle.h: Angle math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +/* +----------------------------------------------------------------------------- + Function: angle_diff -Finds the difference between two angles. + + Parameters: angle1, angle2 -[in] Angles in Radians. + + Returns: + Returns the absolute difference between two angles, this will always + be between 0 and 180 degrees. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL float angle_diff( float angle1, float angle2 ) +{ + float d; + + if( angle1 > angle2 ) + { + d = angle1 - angle2; + } + else + { + d = angle2 - angle1; + } + + if( d > M_PI ) + { + return 2 * M_PI - d; + } + else + { + return d; + } +} + +/* +----------------------------------------------------------------------------- + Function: angle_wise -Clockwise distance between two angles. + + Parameters: angle1, angle2 -[in] Angles in Radians. + + Returns: + Returns the clockwise distance from angle2 to angle1, this may be + greater than 180 degrees. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL float angle_wise( float angle1, float angle2 ) +{ + if( angle1 > angle2 ) + { + return angle1 - angle2; + } + else + { + return angle1 + 2 * M_PI - angle2; + } +} + +/* +----------------------------------------------------------------------------- + Function: interpolate_angle -Linear interpolate between angle A and B by + fraction 'f'. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL float interpolate_angle( float from, float to, float fraction ) +{ + float diff = angle_diff( from, to ) * fraction; + + if( angle_wise( to, from ) >= M_PI ) + { + return from - diff; + } + else + { + return from + diff; + } +} + +/* +----------------------------------------------------------------------------- + Function: normalize_angle - + + Parameters: + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL float normalize_angle( float angle ) +{ + while( angle < 0 ) + { + angle += (2 * M_PI); + } + + while( angle >= (2 * M_PI) ) + { + angle -= (2 * M_PI); + } + + return angle; +} + +/* +----------------------------------------------------------------------------- + Function: LerpAngle -Linear interpolate allowing for the Modulo 360 problem. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL float LerpAngle( float from, float to, float frac ) +{ + if( to - from > 180 ) + { + to -= 360; + } + + if( to - from < -180 ) + { + to += 360; + } + + return from + frac * (to - from); +} diff --git a/wolf3d/newCode/env/angle.h b/wolf3d/newCode/env/angle.h new file mode 100644 index 0000000..500ac28 --- /dev/null +++ b/wolf3d/newCode/env/angle.h @@ -0,0 +1,53 @@ +/* + + Copyright (C) 2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * angle.h: Angle math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __ANGLE_H__ +#define __ANGLE_H__ + + +#define DEG2RAD( a ) ( (a) * 0.01745329251994329576f ) // a * M_PI / 180.0f +#define RAD2DEG( a ) ( (int)((a) / 0.01745329251994329576f) ) // a * 180.0f / M_PI + +#define ANGLE2SHORT( x ) ( (int)((x) * 65536 / 360) & 65535 ) +#define SHORT2ANGLE( x ) ( (x) * (360.0 / 65536) ) + + + +extern float angle_diff( float angle1, float angle2 ); +extern float angle_wise( float angle1, float angle2 ); +extern float interpolate_angle( float from, float to, float fraction ); +extern float normalize_angle( float angle ); +extern float LerpAngle( float from, float to, float frac ); + + + +#endif /* __ANGLE_H__ */ diff --git a/wolf3d/newCode/env/app_def.h b/wolf3d/newCode/env/app_def.h new file mode 100644 index 0000000..d74edb8 --- /dev/null +++ b/wolf3d/newCode/env/app_def.h @@ -0,0 +1,50 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * app_def.h: Engine interface to game layer. + * + */ + +#ifndef __APP_DEF__ +#define __APP_DEF__ + + + +#define WOLFENSTEIN3D 1 + + +#if WOLFENSTEIN3D + + #define APP_VERSION "0.01i" + + #define RELEASENAME "Nebka" + + #define BASEDIRNAME "base" + + + #define GAME_NAME "Wolfenstein 3-D Redux" + +#endif /* WOLFENSTEIN3D */ + + + +#endif /* __APP_DEF__ */ + diff --git a/wolf3d/newCode/env/arch.c b/wolf3d/newCode/env/arch.c new file mode 100644 index 0000000..9fb7aa0 --- /dev/null +++ b/wolf3d/newCode/env/arch.c @@ -0,0 +1,60 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * arch.c: Portable byte swapping. + * + * Author: Id Software, Inc. + * Date: 1997-2001 + * + */ + +#include "../wolfiphone.h" + + +/* +----------------------------------------------------------------------------- + Function: FloatSwap -Endian byte swapping on Float value. + + Parameters: f -[in] Float value to byte swap. + + Returns: Byte swapped float value. + + Notes: + +----------------------------------------------------------------------------- +*/ +INLINECALL float FloatSwap( float f ) +{ + union + { + float f; + W8 b[ 4 ]; + + } dat1, dat2; + + dat1.f = f; + dat2.b[ 0 ] = dat1.b[ 3 ]; + dat2.b[ 1 ] = dat1.b[ 2 ]; + dat2.b[ 2 ] = dat1.b[ 1 ]; + dat2.b[ 3 ] = dat1.b[ 0 ]; + + return dat2.f; +} diff --git a/wolf3d/newCode/env/arch.h b/wolf3d/newCode/env/arch.h new file mode 100644 index 0000000..73badb0 --- /dev/null +++ b/wolf3d/newCode/env/arch.h @@ -0,0 +1,273 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * arch.h: System dependant #defines and macros. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __ARCH_H__ +#define __ARCH_H__ + + + +// Define BUILDSTRING and CPUSTRING based on platform +#ifdef _WIN32 + + #ifdef _DEBUG + + #define BUILDSTRING "Win32 DEBUG" + + #else + + #define BUILDSTRING "Win32 RELEASE" + + #endif + + + #ifdef _M_IX86 + + #define CPUSTRING "x86" + + #elif defined _M_ALPHA + + #define CPUSTRING "AXP" + + #else + + #define CPUSTRING "Unknown CPU" + + #endif + + +#elif defined __linux__ + + #define BUILDSTRING "Linux" + + #ifdef __i386__ + + #define CPUSTRING "i386" + + #elif defined __alpha__ + + #define CPUSTRING "AXP" + + #else + + #define CPUSTRING "Unknown CPU" + + #endif + + +#elif defined __FreeBSD__ + + #define BUILDSTRING "FreeBSD" + + #ifdef __i386__ + + #define CPUSTRING "i386" + + #else + + #define CPUSTRING "Unknown CPU" + + #endif + + +#elif defined __sun__ + + #define BUILDSTRING "Solaris" + + #ifdef __i386__ + + #define CPUSTRING "i386" + + #else + + #define CPUSTRING "sparc" + + #endif + + +#elif defined MACOS + + #define BUILDSTRING "MAC" + + #ifdef __powerpc__ + + #define CPUSTRING "PowerPC" + + #else + + #define CPUSTRING "Unknown CPU" + + #endif + + +#else + + #define BUILDSTRING "Unknown OS" + #define CPUSTRING "Unknown CPU" + +#endif /* if WIN32 else __linux__ else __FreeBSD__ else __sun__ else MACOS */ + + + + + +/* + correct numeric types: W8, SW8, W16, SW16, W32, SW32, W64, SW64 + correct misc types: void, float, _boolean + + s -signed + XX -Number of bits + +*/ +#if( __GNUC__ || __WATCOMC__ || _MSC_VER ) + + + typedef unsigned char W8, *PW8; + typedef signed char SW8, *PSW8; + typedef unsigned short W16, *PW16; + typedef signed short SW16, *PSW16; + typedef unsigned long W32, *PW32; + typedef signed long SW32, *PSW32; + + + + #if( __GNUC__ ) + + typedef unsigned long long W64, *PW64; + typedef long long SW64, *PSW64; + + #elif( _MSC_VER || __WATCOMC__ ) + + typedef unsigned __int64 W64, *PW64; + typedef __int64 SW64, *PSW64; + + #else + + #error "please define W64" + + #endif + +#else + + #error "Unknown compiler, please define basic types" + +#endif + + +/* Define NULL pointer value */ +#ifndef NULL + + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + +#endif /* NULL */ + + + +/* Define INLINECALL keyword */ +#ifndef INLINECALL + + #if defined(__cplusplus) || defined(__GNUC__) + + #define INLINECALL inline + + #elif defined(_WIN32) && !defined(__WATCOMC__) + + #define INLINECALL __inline + + #else + + #define INLINECALL /* Not supported */ + + #endif + +#endif /* INLINECALL */ + + + + +typedef W8 colour3_t[ 3 ]; // RGB +typedef W8 colour4_t[ 4 ]; // RGBA +typedef W32 COLOURVAL, *PCOLOURVAL; // Represents a 32-bit colour value. + +#ifdef _WIN32 + + #define vsnprintf _vsnprintf + +#endif + + +typedef W8 _boolean; + +#define false 0 +#define true 1 + +//enum { false = 0, +// true = 1 }; + + + + +#define ShortSwap( x ) ( ( (((W16) (x)) & 0x00FF) << 8 ) | ( (((W16) (x))& 0xFF00) >> 8) ) +#define LongSwap( x ) ( ( ((W32) (x)) & 0xFF000000) >> 24 ) | ( ((( (W32) (x) ) & 0xFF0000) >> 8) ) | ( ((( (W32) (x) ) & 0xFF00) << 8 ) ) | ( (( (W32) (x) ) & 0xFF) << 24 ) + + + +#if defined( IPHONE) || defined(__i386__) || defined(_M_IX86) // Little endian + + #define BigShort( x ) ShortSwap( x ) + #define LittleShort( x ) ( x ) + + #define BigLong( x ) LongSwap( x ) + #define LittleLong( x ) ( x ) + + #define BigFloat( x ) FloatSwap( x ) + #define LittleFloat( x ) ( x ) + + +#else // Big endian + + #define BigShort( x ) ( x ) + #define LittleShort( x ) ShortSwap( x ) + + #define BigLong( x ) ( x ) + #define LittleLong( x ) LongSwap( x ) + + #define BigFloat( x ) ( x ) + #define LittleFloat( x ) FloatSwap( x ) + +#endif + + +#endif /* __ARCH_H__ */ diff --git a/wolf3d/newCode/env/cmd.c b/wolf3d/newCode/env/cmd.c new file mode 100644 index 0000000..b8644bd --- /dev/null +++ b/wolf3d/newCode/env/cmd.c @@ -0,0 +1,1195 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * cmd.c: Script command processing module. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + + +//void Cmd_ForwardToServer( void ); + +#define MAX_ALIAS_NAME 32 + +typedef struct cmdalias_s +{ + struct cmdalias_s *next; + char name[ MAX_ALIAS_NAME ]; + W32 id; + char *value; + +} cmdalias_t; + +cmdalias_t *cmd_alias; + +_boolean cmd_wait; + +#define ALIAS_LOOP_COUNT 16 +int alias_count; // for detecting runaway loops + + +//============================================================================= + +/* +----------------------------------------------------------------------------- + Function: Cmd_Wait_f -Wait command. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Causes execution of the remainder of the command buffer to be delayed until + next frame. This allows commands like: + bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2" + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_Wait_f( void ) +{ + cmd_wait = true; +} + + +/* +============================================================================= + + COMMAND BUFFER + +============================================================================= +*/ + +PRIVATE sizebuf_t cmd_text; + +PRIVATE W8 cmd_text_buf[ 8192 ]; +PRIVATE W8 defer_text_buf[ 8192 ]; + + +/* +----------------------------------------------------------------------------- + Function: Cmd_Init -Allocates an initial text buffer that will grow as needed. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: This must be called before using command buffer. + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cbuf_Init( void ) +{ + SZ_Init( &cmd_text, cmd_text_buf, sizeof( cmd_text_buf ) ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cbuf_AddText -Adds command text at the end of the buffer. + + Parameters: text -[in] Ponter to NUL-terminated string. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_AddText( const char *text ) +{ + W32 length; + + length = strlen( text ); + + if( cmd_text.cursize + length >= cmd_text.maxsize ) + { + Com_Printf( "Cbuf_AddText: overflow\n" ); + return; + } + + SZ_Write( &cmd_text, (void *)text, length ); +} + +/* +----------------------------------------------------------------------------- + Function: Cbuf_InsertText -Adds command text immediately after the current + command. + + Parameters: text -[in] Command text to add to buffer. + + Returns: Nothing. + + Notes: + Adds a \n to the text + FIXME: actually change the command buffer to do less copying +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_InsertText( char *text ) +{ + char *temp; + size_t templen; + +// copy off any commands still remaining in the exec buffer + templen = cmd_text.cursize; + if( templen ) + { + temp = Z_Malloc( templen ); + memcpy( temp, cmd_text.data, templen ); + SZ_Clear( &cmd_text ); + } + else + { + temp = NULL; // shut up compiler + } + +// add the entire text of the file + Cbuf_AddText( text ); + +// add the copied off data + if( templen ) + { + SZ_Write( &cmd_text, temp, templen ); + Z_Free( temp ); + } +} + + +/* +----------------------------------------------------------------------------- + Function: Cbuf_CopyToDefer -Copy command buffer to defer buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_CopyToDefer( void ) +{ + memcpy( defer_text_buf, cmd_text_buf, cmd_text.cursize ); + defer_text_buf[ cmd_text.cursize ] = 0; + cmd_text.cursize = 0; +} + +/* +----------------------------------------------------------------------------- + Function: Cbuf_InsertFromDefer -Insert commands from defer buffer to command + buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_InsertFromDefer( void ) +{ + Cbuf_InsertText( (char *)defer_text_buf ); + defer_text_buf[ 0 ] = 0; +} + + +/* +----------------------------------------------------------------------------- + Function: Cbuf_ExecuteText -Execute string. + + Parameters: exec_when -[in] see execwhen_t definition. + text -[in] string with command to execute. + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_ExecuteText( execwhen_t exec_when, char *text ) +{ + switch( exec_when ) + { + case EXEC_NOW: + Cmd_ExecuteString( text ); + break; + + case EXEC_INSERT: + Cbuf_InsertText( text ); + break; + + case EXEC_APPEND: + Cbuf_AddText( text ); + break; + + default: + Com_DPrintf( "Cbuf_ExecuteText: bad exec_when" ); + } +} + +/* +----------------------------------------------------------------------------- + Function: Cbuf_Execute -execute string from command buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_Execute( void ) +{ + int i; + char *text; + char line[ 1024 ]; + int quotes; + + alias_count = 0; // don't allow infinite alias loops + + while( cmd_text.cursize ) + { +// find a \n or ; line break + text = (char *)cmd_text.data; + + quotes = 0; + for( i = 0; i < cmd_text.cursize; ++i ) + { + if( text[ i ] == '"' ) + { + quotes++; + } + + if( !(quotes & 1) && text[ i ] == ';' ) + { + break; // don't break if inside a quoted string + } + + if( text[ i ] == '\n' || text[ i ] == '#' ) + { + break; // break on a newline or a hash mark + } + } + + + memcpy( line, text, i ); + line[ i ] = '\0'; // NUL-terminate string + +// delete the text from the command buffer and move remaining commands down +// this is necessary because commands (exec, alias) can insert data at the +// beginning of the text buffer + + if( i == cmd_text.cursize ) + { + cmd_text.cursize = 0; + } + else + { + i++; + cmd_text.cursize -= i; + memmove( text, text+i, cmd_text.cursize ); + } + +// execute the command line + Cmd_ExecuteString( line ); + + + if( cmd_wait ) + { + // skip out while text still remains in buffer, leaving it + // for next frame + cmd_wait = false; + break; + } + } +} + + + +/* +----------------------------------------------------------------------------- + Function: Cbuf_AddEarlyCommands -Adds command line parameters as script + statements. + + Parameters: clear -[in] Remove item from global array com_argv. + + Returns: Nothing. + + Notes: + Adds command line parameters as script statements + Commands lead with a +, and continue until another + + + Set commands are added early, so they are guaranteed to be set + before the client and server initialize for the first time. + + Other commands are added late, after all initialization is complete. +----------------------------------------------------------------------------- +*/ +PUBLIC void Cbuf_AddEarlyCommands( _boolean clear ) +{ + int i; + char *s; + + for( i = 0; i < COM_Argc(); ++i ) + { + s = COM_Argv( i ); + + if( strcmp( s, "+set" ) ) + continue; + + Cbuf_AddText( va("set %s %s\n", COM_Argv(i+1), COM_Argv(i+2))); + if( clear ) + { + COM_ClearArgv( i ); + COM_ClearArgv( i+1 ); + COM_ClearArgv( i+2 ); + } + i += 2; + } +} + +/* +----------------------------------------------------------------------------- + Function: Cbuf_AddLateCommands -Adds command line parameters as script + statements. + + Parameters: Nothing. + + Returns: true if any late commands were added, otherwise false. + + Notes: + Commands lead with a + and continue until another + or - + application.exe +map amlev1 + + Returns true if any late commands were added, which + will keep the demoloop from immediately starting +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Cbuf_AddLateCommands( void ) +{ + int i, j; + int s; + char *text, *build, c; + int argc; + _boolean ret; + +// build the combined string to parse from + s = 0; + argc = COM_Argc(); + for( i = 1; i < argc; ++i ) + { + s += strlen( COM_Argv( i ) ) + 1; + } + + if( ! s ) + { + return false; + } + + text = Z_Malloc( s + 1 ); + text[ 0 ] = '\0'; // Start with a NUL-terminated string. + + for( i = 1; i < argc; ++i ) + { + my_strlcat( text, COM_Argv( i ), s ); + if( i != argc-1 ) + { + my_strlcat( text, " ", s ); + } + } + +// pull out the commands + build = Z_Malloc( s + 1 ); + build[ 0 ] = '\0'; // Start with a NUL-terminated string. + + for( i = 0; i < s-1; ++i ) + { + if( text[ i ] == '+' ) + { + i++; + + for( j = i ; (text[ j ] != '+') && (text[ j ] != '-') && (text[ j ] != 0) ; j++ ) + ; + + c = text[ j ]; + text[ j ] = 0; + + my_strlcat( build, text+i, s+1 ); + my_strlcat( build, "\n", s+1 ); + text[ j ] = c; + i = j - 1; + } + } + + ret = (build[ 0 ] != 0); + if( ret ) + { + Cbuf_AddText (build); + } + + Z_Free( text ); + Z_Free( build ); + + return ret; +} + + +/* +============================================================================== + + SCRIPT COMMANDS + +============================================================================== +*/ + + + +/* +----------------------------------------------------------------------------- + Function: Cmd_Exec_f -Execute script file. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: Console function, exec + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_Exec_f( void ) +{ + filehandle_t *hfile; + char *f2; + int len; + + if( Cmd_Argc () != 2 ) + { + Com_Printf( "exec : execute a script file\n" ); + return; + } + + hfile = FS_OpenFile( Cmd_Argv( 1 ), FA_FILE_IPHONE_DOC_DIR ); + if( ! hfile ) + { + Com_Printf( "couldn't exec %s\n", Cmd_Argv( 1 ) ); + return; + } + + len = FS_GetFileSize( hfile ); + + Com_Printf( "execing %s\n", Cmd_Argv( 1 ) ); + + // the file doesn't have a trailing 0, so we need to copy it off + f2 = Z_Malloc( len + 1 ); + memcpy( f2, hfile->filedata, len ); + f2[ len ] = 0; + + printf( "%s", f2 ); // !@# + Cbuf_InsertText( f2 ); + + Z_Free( f2 ); + + FS_CloseFile( hfile ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_Echo_f -Prints the rest of the line to the console. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_Echo_f( void ) +{ + int i; + + for( i = 1 ; i < Cmd_Argc() ; ++i ) + { + Com_Printf( "%s ",Cmd_Argv( i ) ); + } + + Com_Printf( "\n" ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_Alias_f -Creates a new command that executes a command + string (possibly ; seperated). + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_Alias_f( void ) +{ + cmdalias_t *a; + char cmd[ 1024 ]; + int i, c; + char *s; + W32 hashid; + + if( Cmd_Argc() == 1 ) + { + Com_Printf( "Current alias commands:\n" ); + for( a = cmd_alias ; a ; a = a->next ) + { + Com_Printf( "%s : %s\n", a->name, a->value ); + } + return; + } + + s = Cmd_Argv( 1 ); + if( strlen( s ) >= MAX_ALIAS_NAME ) + { + Com_Printf( "Alias name is too long\n" ); + return; + } + + hashid = my_strhash( s ); + + // if the alias already exists, reuse it + for( a = cmd_alias ; a ; a = a->next ) + { + if( hashid == a->id ) + { + Z_Free( a->value ); + break; + } + } + + if( ! a ) + { + a = Z_Malloc( sizeof( cmdalias_t ) ); + a->next = cmd_alias; + cmd_alias = a; + } + my_strlcpy( a->name, s, sizeof( a->name ) ); + a->id = hashid; + +// copy the rest of the command line + cmd[ 0 ] = '\0'; // start out with a NUL-terminated string + c = Cmd_Argc(); + for( i = 2; i < c; ++i ) + { + my_strlcat( cmd, Cmd_Argv( i ), sizeof( cmd ) ); + if( i != (c - 1) ) + { + my_strlcat( cmd, " ", sizeof( cmd ) ); + } + } + my_strlcat( cmd, "\n", sizeof( cmd ) ); + + a->value = my_CopyString( cmd ); +} + +/* +============================================================================= + + COMMAND EXECUTION + +============================================================================= +*/ + +typedef struct cmd_function_s +{ + struct cmd_function_s *next; + char *name; + W32 id; + xcommand_t function; + +} cmd_function_t; + + +PRIVATE int cmd_argc; +PRIVATE char *cmd_argv[ MAX_STRING_TOKENS ]; +PRIVATE char *cmd_null_string = ""; +PRIVATE char cmd_args[ MAX_STRING_CHARS ]; + +PRIVATE cmd_function_t *cmd_functions; // possible commands to execute + +/* +----------------------------------------------------------------------------- + Function: Cmd_Argc -How many arguments are passed in. + + Parameters: Nothing. + + Returns: How many arguments are passed in. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC int Cmd_Argc( void ) +{ + return cmd_argc; +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_Argv -Retrieve one argument. + + Parameters: arg -[in] Which argument to retrieve. + + Returns: NULL if outside argument index, otherwise returns the argument + string. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cmd_Argv( int arg ) +{ + if( arg >= cmd_argc ) + { + return cmd_null_string; + } + + return cmd_argv[ arg ]; +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_Args -Retrieve all arguments. + + Parameters: Nothing. + + Returns: A single string containing argv(1) to argv(argc()-1) + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cmd_Args( void ) +{ + return cmd_args; +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_MacroExpandString + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE char *Cmd_MacroExpandString( char *text ) +{ + int i, j, count, len; + _boolean inquote; + char *scan; + static char expanded[ MAX_STRING_CHARS ]; + char temporary[MAX_STRING_CHARS]; + char *token, *start; + + inquote = false; + scan = text; + + len = strlen( scan ); + if( len >= MAX_STRING_CHARS ) + { + Com_Printf( "Line exceeded %i chars, discarded.\n", MAX_STRING_CHARS ); + return NULL; + } + + count = 0; + + for( i = 0 ; i < len ; ++i ) + { + if (scan[i] == '"') + inquote ^= 1; + + if (inquote) + continue; // don't expand inside quotes + + if (scan[i] != '$') + continue; + + // scan out the complete macro + start = scan+i+1; + token = COM_Parse( &start ); + if (!start) + continue; + + token = Cvar_VariableString (token); + + j = strlen(token); + len += j; + if (len >= MAX_STRING_CHARS) + { + Com_Printf ("Expanded line exceeded %i chars, discarded.\n", MAX_STRING_CHARS); + return NULL; + } + + strncpy( temporary, scan, i ); + my_strlcpy( temporary+i, token, sizeof( temporary ) - i ); + my_strlcpy( temporary+i+j, start, sizeof( temporary ) - i - j ); + + my_strlcpy( expanded, temporary, sizeof( expanded ) ); + scan = expanded; + i--; + + if( ++count == 100 ) + { + Com_Printf( "Macro expansion loop, discarded.\n" ); + return NULL; + } + } + + if( inquote ) + { + Com_Printf( "Line has unmatched quote, discarded.\n" ); + return NULL; + } + + return scan; +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_TokenizeString -Parses the given string into command line tokens. + + Parameters: text -[in] string to tokenize. + macroExpand -[in] Expand macro, true for yes, otherwise false. + + Returns: Nothing + + Notes: + $Cvars will be expanded unless they are in a quoted token +----------------------------------------------------------------------------- +*/ +PUBLIC void Cmd_TokenizeString( char *text, _boolean macroExpand ) +{ + int i; + char *com_token; + +// clear the args from the last string + for( i = 0 ; i < cmd_argc ; ++i ) + { + Z_Free( cmd_argv[ i ] ); + } + + cmd_argc = 0; + cmd_args[ 0 ] = 0; + + // macro expand the text + if( macroExpand ) + { + text = Cmd_MacroExpandString( text ); + } + + if( ! text ) + { + return; + } + + while( 1 ) + { +// skip whitespace up to a /n + while( *text && *text <= ' ' && *text != '\n' ) + { + text++; + } + + if( *text == '\n' ) + { // a newline seperates commands in the buffer + text++; + break; + } + + if( ! *text ) + { + return; + } + + // set cmd_args to everything after the first arg + if( cmd_argc == 1 ) + { + int l; + + my_strlcpy( cmd_args, text, sizeof( cmd_args ) - 1 ); + + // strip off any trailing whitespace + l = strlen( cmd_args ) - 1; + for( ; l >= 0 ; --l ) + { + if (cmd_args[l] <= ' ') + { + cmd_args[l] = 0; + } + else + { + break; + } + } + } + + com_token = COM_Parse( &text ); + if( ! text ) + { + return; + } + + if( cmd_argc < MAX_STRING_TOKENS ) + { + cmd_argv[ cmd_argc ] = Z_Malloc( strlen( com_token ) + 1 ); + my_strlcpy( cmd_argv[ cmd_argc ], com_token, strlen( com_token ) + 1 ); + cmd_argc++; + } + } + +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_AddCommand -Add a command name and function to the cmd repository. + + Parameters: + cmd_name -[in] Pointer to a NUL-terminated string that constains a + command name. + function -[in] Function to associate with cmd_name. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Cmd_AddCommand( char *cmd_name, xcommand_t function ) +{ + cmd_function_t *cmd; + W32 hashid; + +// fail if the command is a variable name + if( Cvar_VariableString( cmd_name )[ 0 ] ) + { + Com_Printf( "Cmd_AddCommand: \"%s\" already defined as a var\n", cmd_name ); + return; + } + + hashid = my_strhash( cmd_name ); + +// fail if the command already exists + for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) + { + if( hashid == cmd->id ) + { + Com_Printf( "Cmd_AddCommand: \"%s\" already defined\n", cmd_name ); + return; + } + } + + cmd = Z_Malloc( sizeof( cmd_function_t ) ); + cmd->name = cmd_name; + cmd->id = hashid; + cmd->function = function; + cmd->next = cmd_functions; + cmd_functions = cmd; + +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_RemoveCommand -Remove command. + + Parameters: cmd_name -[in] name of command to remove. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cmd_RemoveCommand( char *cmd_name ) +{ + cmd_function_t *cmd, **back; + W32 hashid; + + hashid = my_strhash( cmd_name ); + + back = &cmd_functions; + while( 1 ) + { + cmd = *back; + if( ! cmd ) + { + Com_DPrintf( "Cmd_RemoveCommand: %s was not added\n", cmd_name ); + return; + } + + if( hashid == cmd->id ) + { + *back = cmd->next; + Z_Free( cmd ); + return; + } + + back = &cmd->next; + } +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_Exists -Check to see if command already exists. + + Parameters: cmd_name -[in] name of command to check. + + Returns: true if the command already exists, otherwise false. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Cmd_Exists( char *cmd_name ) +{ + cmd_function_t *cmd; + W32 hashid = my_strhash( cmd_name ); + + for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) + { + if( hashid == cmd->id ) + { + return true; + } + } + + return false; +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_CompleteCommand -Complete partial command on console + command-line. + + Parameters: partial -[in] Partial name of command. + + Returns: NULL if no command exists, otherwise returns the complete name of + command. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cmd_CompleteCommand( char *partial ) +{ + cmd_function_t *cmd; + int len; + cmdalias_t *a; + W32 hashid; + + len = strlen( partial ); + + if( ! len ) + { + return NULL; + } + + + +// +// Check for exact match. +// + hashid = my_strhash( partial ); + + for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) + { + if( hashid == cmd->id ) + { + return cmd->name; + } + } + + for( a = cmd_alias ; a ; a = a->next ) + { + if( hashid == a->id ) + { + return a->name; + } + } + +// +// Check for partial match. +// + for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) + { + if( ! strncmp( partial, cmd->name, len ) ) + { + return cmd->name; + } + } + + for( a = cmd_alias ; a ; a = a->next ) + { + if( ! strncmp( partial, a->name, len ) ) + { + return a->name; + } + } + + return NULL; +} + + +/* +----------------------------------------------------------------------------- + Function: Cmd_ExecuteString -Execute command string. + + Parameters: text -[in] text string to execute. + + Returns: Nothing. + + Notes: + A complete command line has been parsed, so try to execute it + FIXME: lookupnoadd the token to speed search? +----------------------------------------------------------------------------- +*/ +PUBLIC void Cmd_ExecuteString( char *text ) +{ + cmd_function_t *cmd; + cmdalias_t *a; + W32 hashid; + + Cmd_TokenizeString( text, true ); + + // execute the command line + if( ! Cmd_Argc() ) + { + return; // no tokens + } + + hashid = my_strhash( cmd_argv[ 0 ] ); + + // check functions + for( cmd = cmd_functions ; cmd ; cmd = cmd->next ) + { + if( hashid == cmd->id ) + { + if( ! cmd->function ) + { // forward to server command + Cmd_ExecuteString( va( "cmd %s", text ) ); + } + else + { + cmd->function(); + } + + return; + } + } + + // check alias + for( a = cmd_alias ; a ; a = a->next ) + { + if( ! my_stricmp( cmd_argv[ 0 ], a->name ) ) + { + if( ++alias_count == ALIAS_LOOP_COUNT ) + { + Com_Printf( "ALIAS_LOOP_COUNT\n" ); + return; + } + Cbuf_InsertText( a->value ); + return; + } + } + + // check cvars + if( Cvar_Command() ) + { + return; + } + + // send it as a server command if we are connected +// Cmd_ForwardToServer(); +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_List_f -Callback function that list commands. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: List commands and total number of commands. +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_List_f( void ) +{ + cmd_function_t *cmd; + int i = 0; + + for( cmd = cmd_functions; cmd; cmd = cmd->next, ++i ) + { + Com_Printf( "%s\n", cmd->name ); + } + + Com_Printf( "%i commands\n", i ); +} + +/* +----------------------------------------------------------------------------- + Function: Cmd_Init -Initialize the command buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Cmd_Init( void ) +{ + Cbuf_Init(); + +// +// register our commands +// + Cmd_AddCommand( "listCmds", Cmd_List_f ); + Cmd_AddCommand( "exec", Cmd_Exec_f ); + Cmd_AddCommand( "echo", Cmd_Echo_f ); + Cmd_AddCommand( "alias", Cmd_Alias_f); + Cmd_AddCommand( "wait", Cmd_Wait_f ); +} + diff --git a/wolf3d/newCode/env/cmd.h b/wolf3d/newCode/env/cmd.h new file mode 100644 index 0000000..0bf5192 --- /dev/null +++ b/wolf3d/newCode/env/cmd.h @@ -0,0 +1,150 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * cmd.h: Command text buffering and command execution. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + + Notes: + + Any number of commands can be added in a frame, from several different sources. + Most commands come from either keybindings or console line input, but remote + servers can also send across commands and entire text files can be execed. + + The + command line options are also added to the command buffer. + + The game starts with a Cbuf_AddText( "exec DEFAULT.CFG\n" ); Cbuf_Execute(); + +*/ + +#ifndef __CMD_H__ +#define __CMD_H__ + +#include "arch.h" + + +typedef enum { + + EXEC_NOW, // don't return until completed + EXEC_INSERT, // insert at current position, but don't run yet + EXEC_APPEND // add to end of the command buffer + +} execwhen_t; + + +extern void Cbuf_AddText( const char *text ); +// as new commands are generated from the console or keybindings, +// the text is added to the end of the command buffer. + +extern void Cbuf_InsertText( char *text ); +// when a command wants to issue other commands immediately, the text is +// inserted at the beginning of the buffer, before any remaining unexecuted +// commands. + +extern void Cbuf_ExecuteText( execwhen_t exec_when, char *text ); +// this can be used in place of either Cbuf_AddText or Cbuf_InsertText + +extern void Cbuf_AddEarlyCommands( _boolean clear ); +// adds all the +set commands from the command line + +extern _boolean Cbuf_AddLateCommands( void ); +// adds all the remaining + commands from the command line +// Returns true if any late commands were added, which +// will keep the demoloop from immediately starting + +extern void Cbuf_Execute( void ); +// Pulls off \n terminated lines of text from the command buffer and sends +// them through Cmd_ExecuteString. Stops when the buffer is empty. +// Normally called once per frame, but may be explicitly invoked. +// Do not call inside a command function! + +extern void Cbuf_CopyToDefer( void ); +extern void Cbuf_InsertFromDefer( void ); +// These two functions are used to defer any pending commands while a map +// is being loaded + +//=========================================================================== + +#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString +#define MAX_STRING_TOKENS 80 // max tokens resulting from Cmd_TokenizeString +#define MAX_TOKEN_CHARS 128 // max length of an individual token + +/* + +Command execution takes a NUL-terminated string, breaks it into tokens, +then searches for a command or variable that matches the first token. + +*/ + +typedef void (*xcommand_t) (void); + +extern void Cmd_Init( void ); + +extern void Cmd_AddCommand( char *cmd_name, xcommand_t function ); +// called by the init functions of other parts of the program to +// register commands and functions to call for them. +// The cmd_name is referenced later, so it should not be in temp memory +// if function is NULL, the command will be forwarded to the server +// as a clc_stringcmd instead of executed locally +extern void Cmd_RemoveCommand( char *cmd_name ); + +extern _boolean Cmd_Exists( char *cmd_name ); +// used by the cvar code to check for cvar / command name overlap + +extern char *Cmd_CompleteCommand( char *partial ); +// attempts to match a partial command for automatic command line completion +// returns NULL if nothing fits + +extern int Cmd_Argc( void ); +extern char *Cmd_Argv( int arg ); +extern char *Cmd_Args( void ); +// The functions that execute commands get their parameters with these +// functions. Cmd_Argv () will return an empty string, not a NULL +// if arg > argc, so string operations are always safe. + +extern void Cmd_TokenizeString( char *text, _boolean macroExpand ); +// Takes a NUL-terminated string. Does not need to be /n terminated. +// breaks the string up into arg tokens. + +extern void Cmd_ExecuteString( char *text ); +// Parses a single line of text into arguments and tries to execute it +// as if it was typed at the console + +//extern void Cmd_ForwardToServer( void ); +// adds the current command line as a clc_stringcmd to the client message. +// things like godmode, noclip, etc, are commands directed to the server, +// so when they are typed in at the console, they will need to be forwarded. + + + + + + +#endif /* __CMD_H__ */ diff --git a/wolf3d/newCode/env/com_string.c b/wolf3d/newCode/env/com_string.c new file mode 100644 index 0000000..400007e --- /dev/null +++ b/wolf3d/newCode/env/com_string.c @@ -0,0 +1,518 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1998 Todd C. Miller + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * com_string.c: Common string functions done in a portable manner. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Portion of this code was derived from code that was originally + * written by Todd C. Miller. + * + */ + +#include "../wolfiphone.h" + + + + + +/* +----------------------------------------------------------------------------- + Function: my_strlcpy -Copies a specified number of characters from a + source string into a buffer. + + Parameters: dest -[in/out] Pointer to a buffer into which the function + copies characters + source -[in] Pointer to a NUL-terminated string from which + the function copies characters. + nMaxLength -[in] Specifies the number of bytes to be copied + from the string pointed to by source into the + buffer pointed to by dest. + + Returns: Returns strlen( source ); if retval >= nMaxLength, truncation + occurred. + + Notes: + At most nMaxLength-1 characters will be copied. Always NUL- + terminates (unless nMaxLength == 0). +----------------------------------------------------------------------------- +*/ +PUBLIC size_t my_strlcpy( char *dest, const char *source, size_t nMaxLength ) +{ + char *d = dest; + const char *s = source; + size_t n = nMaxLength; + + /* Copy as many bytes as will fit */ + if( n != 0 && --n != 0 ) + { + do + { + if( (*d++ = *s++) == 0 ) + { + break; + } + + } while( --n != 0 ); + } + + /* Not enough room in dest, add NUL and traverse rest of source */ + if( n == 0 ) + { + if( nMaxLength != 0 ) + { + *d = '\0'; /* NUL-terminate dest */ + } + + while( *s++ ) + { + ; + } + } + + return( s - source - 1 ); /* count does not include NUL */ +} + +/* +----------------------------------------------------------------------------- + Function: my_strlcat -Appends one string to another. + + Parameters: dest -[in/out] Pointer to a NUL-terminated string. The buffer + must be large enough to contain both strings or else + truncation will occur. + source -[in] Pointer to a NUL-terminated string from which + the function copies characters. + nMaxLength -[in] full size of dest, not space left. + + Returns: Returns strlen( source ) + MIN( nMaxLength, strlen( initial dest ) ). + If retval >= nMaxLength, truncation occurred. + + Notes: + At most nMaxLength-1 characters will be copied. Always NUL- + terminates (unless nMaxLength <= strlen( dest ) ). +----------------------------------------------------------------------------- +*/ +PUBLIC size_t my_strlcat( char *dest, const char *source, size_t nMaxLength ) +{ + char *d = dest; + const char *s = source; + size_t n = nMaxLength; + size_t dlen; + + /* Find the end of dest and adjust bytes left but don't go past end */ + while( n-- != 0 && *d != '\0' ) + { + d++; + } + + dlen = d - dest; + n = nMaxLength - dlen; + + /* No room left to append string */ + if( n == 0 ) + { + return( dlen + strlen( s ) ); + } + + while( *s != '\0' ) + { + if( n != 1 ) + { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; /* NUL-terminate string */ + + return( dlen + (s - source) ); /* count does not include NUL */ + +} + + +/* +----------------------------------------------------------------------------- + Function: my_strnicmp -Compare characters of two strings without regard to case. + + Parameters: string1, string2 -[in] NUL-terminated strings to compare. + count -[in] Number of characters to compare. + + Returns: 0 string1 identical to string2, -1 otherwise. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC int my_strnicmp( const char *string1, const char *string2, size_t count ) +{ + char c1, c2; + + if( ! string1 || ! *string1 || + ! string2 || ! *string2 ) + { + return -1; + } + + do + { + c1 = *string1++; + c2 = *string2++; + + if( ! count-- ) + { + return 0; /* strings are equal until end point */ + } + + if( c1 != c2 ) + { + if( TOUPPER( c1 ) != TOUPPER( c2 ) ) /* Uppercase compare */ + { + return -1; /* strings are not equal */ + } + } + + } while( c1 ); + + return 0; /* strings are equal */ +} + +/* +----------------------------------------------------------------------------- + Function: my_stricmp -Perform an uppercase comparison of strings. + + Parameters: string1, string2 -[in] NUL-terminated strings to compare. + + Returns: 0 string1 identical to string2, -1 otherwise. + + Notes: + Calls my_strnicmp, where count is 99999 +----------------------------------------------------------------------------- +*/ +PUBLIC int my_stricmp( const char *string1, const char *string2 ) +{ + return my_strnicmp( string1, string2, 99999 ); +} + +/* +----------------------------------------------------------------------------- + Function: my_snprintf -Write formatted data to a string. + + Parameters: dest -[out] Storage location for output. + size -[in] Maximum number of characters to store. + format -[in] Format-control string. + ... -[in] Optional arguments. + + Returns: Nothing. + + Notes: If the format string is longer than 32768 truncation will occur. + Also, if format is longer than dest truncation will occur. +----------------------------------------------------------------------------- +*/ +PUBLIC void my_snprintf( char *dest, size_t size, const char *format, ... ) +{ + va_list argptr; + char bigbuffer[ 0x8000 ]; + + va_start( argptr, format ); + (void)vsnprintf( bigbuffer, sizeof( bigbuffer ), format, argptr ); + va_end( argptr ); + + bigbuffer[ sizeof( bigbuffer ) - 1 ] = '\0'; + + my_strlcpy( dest, bigbuffer, size ); +} + + +/* +----------------------------------------------------------------------------- + Function: my_CopyString -Allocate a duplicate copy of a string, and return + duplicate. + + Parameters: in -[in] String to duplicate. + + + Returns: + Pointer to duplicate string. Caller is responsible for freeing + memory with Z_Free. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC char *my_CopyString( const char *in ) +{ + char *out; + + out = Z_Malloc( strlen( in ) + 1 ); + my_strlcpy( out, in, strlen( in ) + 1 ); + + return out; +} + +/* +----------------------------------------------------------------------------- + Function: my_strhash -Create a hash id from string. + + Parameters: string -[in] NUL-terminated string. + + + Returns: Hash id. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W32 my_strhash( const char *string ) +{ + W32 hash = *string; + + if( hash ) + { + for( string += 1; *string != '\0'; ++string ) + { + hash = (hash << 5) - hash + *string; + } + } + + return hash; +} + + +/* +----------------------------------------------------------------------------- + Function: my_strupr -Convert a string to uppercase. + + Parameters: string -[in/out] NUL-terminated string to capitalize. + + Returns: + This functions returns a pointer to the converted string. Because + the modification is done in place, the pointer returned is the same + as the pointer passed as the input argument. No return value is + reserved to indicate an error. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *my_strupr( char *string ) +{ + char *ptr; + + if( ! string || ! *string ) + { + return string; + } + + ptr = string; + + do + { + *ptr = TOUPPER( *ptr ); + + } while( *ptr++ ); + + + return string; +} + +/* +----------------------------------------------------------------------------- + Function: my_strlwr -Convert a string to lowercase. + + Parameters: string -[in/out] NUL-terminated string to convert to lowercase. + + Returns: + This functions returns a pointer to the converted string. Because + the modification is done in place, the pointer returned is the same + as the pointer passed as the input argument. No return value is + reserved to indicate an error. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *my_strlwr( char *string ) +{ + char *ptr; + + if( ! string || ! *string ) + { + return string; + } + + ptr = string; + + do + { + *ptr = TOLOWER( *ptr ); + + } while( *ptr++ ); + + + return string; +} + +/* +----------------------------------------------------------------------------- + Function: StringToInteger -Convert string to integer. + + Parameters: string -[in] NUL-terminated string to be converted. + error -[out] Error code. See header. + + Returns: An integer value. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC SW32 StringToInteger( const char *string, W32 *error ) +{ + const char *ptr = string; + SW32 temp; + SW32 number = 0; + W32 errortag = 0; + _boolean bNegative = false; + + if( ! string || ! *string ) + { + *error = SCE_NULL_VALUE; + + return 0; + } + + if( *ptr == '-' ) + { + bNegative = true; + + ptr++; + } + + while( *ptr && ISNUMERIC( *ptr ) ) + { + temp = number; + number = (number * 10) + *ptr - '0'; + + if( number < temp ) + { + errortag &= SCE_BUFFER_OVERFLOW; + } + + ptr++; + } + + if( *ptr ) + { + errortag &= SCE_NON_NUMERIC; + } + + + if( bNegative ) + { + number = -number; + } + + + *error = errortag; + + return number; +} + +/* +----------------------------------------------------------------------------- + Function: StringToFloat -Convert string to float. + + Parameters: string -[in] NUL-terminated string to be converted. + error -[out] Error code. See header. + + Returns: A float value. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC double StringToFloat( const char *string, W32 *error ) +{ + const char *ptr = string; + double number = 0; + SW32 exponent = 0; + W32 expError; + _boolean bNegative = false; + + *error = 0; + + if( ! string || ! *string ) + { + *error &= SCE_NULL_VALUE; + + return 0; + } + + if( *ptr == '-' ) + { + bNegative = true; + + ptr++; + } + else if( *ptr == '+' ) + { + ptr++; + } + + while( *ptr && ISNUMERIC( *ptr ) ) + { + number = (number * 10) + (double)(*ptr - '0'); + + ptr++; + } + + if( *ptr == '.' ) + { + ptr++; + + while( *ptr && ISNUMERIC( *ptr ) ) + { + number = (number * 10) + (double)(*ptr - '0'); + exponent--; + + ptr++; + } + } + + if( TOLOWER( *ptr ) == 'e' ) + { + ptr++; + + exponent += StringToInteger( ptr, &expError ); + } + + if( bNegative ) + { + number = -number; + } + + if( expError ) + { + *error |= expError; + } + + return (number * pow( 10, exponent )); +} diff --git a/wolf3d/newCode/env/com_string.h b/wolf3d/newCode/env/com_string.h new file mode 100644 index 0000000..ae510f8 --- /dev/null +++ b/wolf3d/newCode/env/com_string.h @@ -0,0 +1,87 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (c) 1998 Todd C. Miller + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * com_string.h: Common string functions done in a portable manner. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Portion of this code was derived from code that was originally + * written by Todd C. Miller. + * + */ + +/* + Notes: + This module is implemented by com_string.c. + +*/ + +#ifndef __COM_STRING_H__ +#define __COM_STRING_H__ + +#define ISSPACE( c ) ( ( c ) == ' ' || ( c ) == '\f' || ( c ) == '\n' || ( c ) == '\r' || ( c ) == '\t' || ( c ) == '\v' ) +#define ISUPPER( c ) ( ( c ) >= 'A' && ( c ) <= 'Z' ) +#define ISLOWER( c ) ( ( c ) >= 'a' && ( c ) <= 'z' ) +#define ISALPHA( c ) ( ISUPPER( c ) || ISLOWER( c ) ) +#define TOUPPER( c ) ( ISLOWER( c ) ? (c) - 'a' + 'A' : ( c ) ) +#define TOLOWER( c ) ( ISUPPER( c ) ? (c) - 'A' + 'a' : ( c ) ) + +#define ISNUMERIC( c ) ( ( c ) >= '0' && ( c ) <= '9' ) +#define ISALPHANUMERIC( c ) ( ISALPHA( c ) || ISNUMERIC( c ) ) + + + + +extern size_t my_strlcpy( char *dest, const char *source, size_t nMaxLength ); +extern size_t my_strlcat( char *dest, const char *source, size_t nMaxLength ); + + +extern int my_stricmp( const char *string1, const char *string2 ); +extern int my_strnicmp( const char *string1, const char *string2, size_t count ); + + +extern void my_snprintf( char *dest, size_t size, const char *format, ... ); + +extern char *my_CopyString( const char *in ); + +extern W32 my_strhash( const char *string ); + +extern char *my_strupr( char *string ); +extern char *my_strlwr( char *string ); + + +/* String conversion error */ +#define SCE_NON_NUMERIC (1 << 0) /* Non-numeric value was encountered */ +#define SCE_BUFFER_OVERFLOW (1 << 1) /* Numberic overflowed */ +#define SCE_NULL_VALUE (1 << 2) /* NULL string was passed into function */ + + +extern SW32 StringToInteger( const char *string, W32 *error ); +extern double StringToFloat( const char *string, W32 *error ); + + +#endif /* __COM_STRING_H__ */ diff --git a/wolf3d/newCode/env/common.c b/wolf3d/newCode/env/common.c new file mode 100644 index 0000000..1572967 --- /dev/null +++ b/wolf3d/newCode/env/common.c @@ -0,0 +1,593 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * common.c: Misc functions used in client and server. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +#define MAXPRINTMSG 4096 + +#define MAX_NUM_ARGVS 50 + + +colour3_t colourBlack = { 0, 0, 0 }; +colour3_t colourRed = { 255, 0, 0 }; +colour3_t colourGreen = { 0, 255, 0 }; +colour3_t colourBlue = { 0, 0, 255 }; +colour3_t colourWhite = { 255, 255, 255 }; + + +int com_argc; +char *com_argv[ MAX_NUM_ARGVS + 1 ]; + + +jmp_buf abortframe; // an ERR_DROP occured, exit the entire frame + + +FILE *log_stats_file; + +cvar_t *log_stats; +cvar_t *developer; +cvar_t *logfile_active; // 1 = buffer log, 2 = flush after each print + +FILE *logfile; + + +/* +============================================================================ + +CLIENT / SERVER interactions + +============================================================================ +*/ +static int rd_target; +static char *rd_buffer; +static int rd_buffersize; +static void (*rd_flush)( int target, char *buffer ); + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Com_BeginRedirect( int target, char *buffer, int buffersize, void (*flush) ) +{ + if( ! target || ! buffer || ! buffersize || ! flush ) + { + return; + } + + rd_target = target; + rd_buffer = buffer; + rd_buffersize = buffersize; + rd_flush = flush; + + *rd_buffer = 0; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Com_EndRedirect( void ) +{ + rd_flush( rd_target, rd_buffer ); + + rd_target = 0; + rd_buffer = NULL; + rd_buffersize = 0; + rd_flush = NULL; +} + +/* +----------------------------------------------------------------------------- + Function: Com_Printf -print out message. + + Parameters: + + Returns: Nothing. + + Notes: + Both client and server can use this, and it will output + to the apropriate place. +----------------------------------------------------------------------------- +*/ +PUBLIC void Com_Printf( const char *fmt, ... ) +{ + va_list argptr; + static char msg[ MAXPRINTMSG ]; + + va_start( argptr, fmt ); + (void)vsnprintf( msg, sizeof( msg ), fmt, argptr ); + va_end( argptr ); + + msg[ sizeof( msg ) - 1 ] = '\0'; + + if( rd_target ) + { + if( (strlen( msg ) + strlen( rd_buffer ) ) > (rd_buffersize - 1) ) + { + rd_flush( rd_target, rd_buffer ); + *rd_buffer = '\0'; + } + my_strlcat( rd_buffer, msg, rd_buffersize ); + return; + } + + Con_Print( msg ); +#ifdef _WIN32 + OutputDebugString( msg ); +#endif + + // also echo to debugging console +// Sys_ConsoleOutput( msg ); + + // logfile + if( logfile_active && logfile_active->value ) + { + char name[ MAX_GAMEPATH ]; + + if( ! logfile ) + { + my_snprintf( name, sizeof( name ), "%s/console.log", FS_Gamedir() ); + if( logfile_active->value > 2 ) + { + logfile = fopen( name, "a" ); + } + else + { + logfile = fopen( name, "w" ); + } + } + if( logfile ) + { + fprintf( logfile, "%s", msg ); + } + + if( logfile_active->value > 1 ) + { + fflush( logfile ); // force it to save every time + } + } +} + +/* +----------------------------------------------------------------------------- + Function: Com_DPrintf -A Com_Printf that only shows up if the "developer" + cvar is set + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Com_DPrintf( const char *fmt, ... ) +{ + va_list argptr; + static char msg[ MAXPRINTMSG ]; + + if( ! developer || ! developer->value ) + { + return; // don't confuse non-developers with techie stuff... + } + + va_start( argptr, fmt ); + (void)vsnprintf( msg, sizeof( msg ), fmt, argptr ); + va_end( argptr ); + + msg[ sizeof( msg ) - 1 ] = '\0'; + + Com_Printf( "%s", msg ); +} + + +/* +----------------------------------------------------------------------------- + Function: Com_Error + + Parameters: + + Returns: + + Notes: + Both client and server can use this, and it will + do the apropriate things. +----------------------------------------------------------------------------- +*/ +PUBLIC void Com_Error( int code, const char *fmt, ... ) +{ + va_list argptr; + static char msg[ MAXPRINTMSG ]; + static _boolean recursive; + + if( recursive ) + { + Sys_Error( "recursive error after: %s", msg ); + } + + recursive = true; + + va_start (argptr,fmt); + (void)vsnprintf( msg, sizeof( msg ), fmt, argptr ); + va_end (argptr); + + msg[ sizeof( msg ) - 1 ] = '\0'; + + if( code == ERR_DISCONNECT ) + { + recursive = false; + longjmp (abortframe, -1); + } + else if( code == ERR_DROP ) + { + Com_Printf( "********************\nERROR: %s\n********************\n", msg ); + recursive = false; + longjmp( abortframe, -1 ); + } + else + { + } + + if( logfile ) + { + fclose( logfile ); + logfile = NULL; + } + + Sys_Error( "%s", msg ); +} + + + +//=========================================================================== + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void SZ_Init( sizebuf_t *buf, PW8 data, int length ) +{ + memset( buf, 0, sizeof( *buf ) ); + buf->data = data; + buf->maxsize = length; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void SZ_Clear( sizebuf_t *buf ) +{ + buf->cursize = 0; + buf->overflowed = false; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void *SZ_GetSpace( sizebuf_t *buf, int length ) +{ + void *data; + + if( buf->cursize + length > buf->maxsize ) + { + if( ! buf->allowoverflow ) + { + Com_Error( ERR_FATAL, "SZ_GetSpace: overflow without allowoverflow set" ); + } + + if( length > buf->maxsize ) + { + Com_Error( ERR_FATAL, "SZ_GetSpace: %i is > full buffer size", length ); + } + + Com_Printf( "SZ_GetSpace: overflow\n" ); + SZ_Clear( buf ); + buf->overflowed = true; + } + + data = buf->data + buf->cursize; + buf->cursize += length; + + return data; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void SZ_Write( sizebuf_t *buf, void *data, int length ) +{ + memcpy( SZ_GetSpace( buf, length ), data, length ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void SZ_Print( sizebuf_t *buf, W8 *data ) +{ + int len; + + len = strlen( (char *)data ) + 1; + + if (buf->cursize) + { + if( buf->data[ buf->cursize - 1 ] ) + { + memcpy( (PW8)SZ_GetSpace( buf, len ), data, len ); // no trailing 0 + } + else + { + memcpy( (PW8)SZ_GetSpace( buf, len - 1 ) - 1, data, len ); // write over trailing 0 + } + } + else + { + memcpy( (PW8)SZ_GetSpace( buf, len ),data,len ); + } +} + + +//============================================================================ + + +/* +----------------------------------------------------------------------------- + Function: COM_CheckParm + + Parameters: + + Returns: + The position (1 to argc-1) in the program's argument list + where the given parameter apears, or 0 if not present + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC int COM_CheckParm( char *parm ) +{ + int i; + + for( i = 1 ; i < com_argc ; ++i ) + { + if( ! strcmp( parm, com_argv[ i ] ) ) + { + return i; + } + } + + return 0; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC int COM_Argc (void) +{ + return com_argc; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *COM_Argv (int arg) +{ + if (arg < 0 || arg >= com_argc || !com_argv[arg]) + return ""; + return com_argv[arg]; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void COM_ClearArgv( int arg ) +{ + if (arg < 0 || arg >= com_argc || !com_argv[arg]) + { + return; + } + + com_argv[ arg ] = ""; +} + + +/* +----------------------------------------------------------------------------- + Function: COM_InitArgv -Set global argv values with commadline argv values. + + Parameters: + argc -[in] An integer specifying how many arguments are in argv[]. + argv -[in] An array of null-terminated strings. The last pointer + (argv[argc]) is NULL. + + Returns: Nothing. + + Notes: Sets global variables com_argc and com_argv. +----------------------------------------------------------------------------- +*/ +PUBLIC void COM_InitArgv( int argc, char *argv[] ) +{ + int i; + + if( argc > MAX_NUM_ARGVS ) + { + argc = MAX_NUM_ARGVS; + Com_DPrintf( "argc > MAX_NUM_ARGVS\n" ); + } + + com_argc = argc; + for( i = 0; i < argc; ++i ) + { + if( ! argv[ i ] || strlen( argv[ i ] ) >= MAX_TOKEN_CHARS ) + { + com_argv[ i ] = ""; + } + else + { + com_argv[ i ] = argv[ i ]; + } + } +} + + +/* +----------------------------------------------------------------------------- + Function: COM_AddParm -Adds the given string at the end of the current + argument list + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void COM_AddParm( char *parm ) +{ + if( com_argc == MAX_NUM_ARGVS ) + { + Com_Error( ERR_FATAL, "COM_AddParm: MAX_NUM_ARGS" ); + } + + com_argv[ com_argc++ ] = parm; +} + +/* +----------------------------------------------------------------------------- + Function: Com_Error_f -Just throw a fatal error to test error shutdown + procedures. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Com_Error_f (void) +{ + Com_Error( ERR_FATAL, "%s", Cmd_Argv( 1 ) ); +} + + diff --git a/wolf3d/newCode/env/common.h b/wolf3d/newCode/env/common.h new file mode 100644 index 0000000..a487392 --- /dev/null +++ b/wolf3d/newCode/env/common.h @@ -0,0 +1,206 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * common.h: Common definitions between client and server. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by common.c. + +*/ + + +#ifndef __COMMON_H__ +#define __COMMON_H__ + + +//============================================================================ + +typedef struct sizebuf_s +{ + _boolean allowoverflow; // if false, do a Com_Error + _boolean overflowed; // set to true if the buffer size failed + W8 *data; + int maxsize; + int cursize; + int readcount; + +} sizebuf_t; + +extern void SZ_Init( sizebuf_t *buf, PW8 data, int length ); +extern void SZ_Clear( sizebuf_t *buf ); +extern void *SZ_GetSpace( sizebuf_t *buf, int length ); +extern void SZ_Write( sizebuf_t *buf, void *data, int length ); +extern void SZ_Print( sizebuf_t *buf, W8 *data ); // memcpy onto the sizebuf + +//============================================================================ + + +extern int COM_Argc( void ); +extern char *COM_Argv( int arg ); // range and null checked +extern void COM_ClearArgv( int arg ); +extern int COM_CheckParm( char *parm ); +extern void COM_AddParm( char *parm ); + +extern void COM_Init( void ); +extern void COM_InitArgv( int argc, char *argv[] ); + + +extern char *COM_Parse( char **data_p ); +// data is an in/out parm, returns a parsed out token + + + +//============================================================================ + + + + +///////////////////////////////////////////////////////////////////// +// +// Colour +// +///////////////////////////////////////////////////////////////////// + +extern colour3_t colourBlack; +extern colour3_t colourRed; +extern colour3_t colourBlue; +extern colour3_t colourGreen; +extern colour3_t colourWhite; + + +///////////////////////////////////////////////////////////////////// +// End Colour +///////////////////////////////////////////////////////////////////// + + + + +/* +============================================================== + + MISC + +============================================================== +*/ + + +#define ERR_FATAL 0 // exit the entire game with a popup window +#define ERR_DROP 1 // print to console and disconnect from game +#define ERR_QUIT 2 // not an error, just a normal exit +#define ERR_DISCONNECT 4 // don't kill server + +#define EXEC_NOW 0 // don't return until completed +#define EXEC_INSERT 1 // insert at current position, but don't run yet +#define EXEC_APPEND 2 // add to end of the command buffer + +#define PRINT_ALL 0 +#define PRINT_DEVELOPER 1 // only print when "developer 1" + +extern void Com_BeginRedirect( int target, char *buffer, int buffersize, void (*flush) ); +extern void Com_EndRedirect( void ); +extern void Com_Printf( const char *fmt, ... ); +extern void Com_DPrintf( const char *fmt, ... ); +extern void Com_Error( int code, const char *fmt, ... ); + + +extern char *va( char *format, ... ); + + + +extern cvar_t *developer; +extern cvar_t *log_stats; +extern cvar_t *logfile_active; +extern FILE *log_stats_file; + + +extern void common_Init( int argc, char *argv[] ); +extern void common_Frame( int msec ); + + + + +/* +============================================================== + + NON-PORTABLE SYSTEM SERVICES + +============================================================== +*/ +extern char *Sys_ConsoleInput( void ); +extern void Sys_ConsoleOutput( const char *string ); +extern void Sys_SendKeyEvents( void ); +extern void Sys_Error( const char *format, ... ); +extern void Sys_Quit( void ); +extern char *Sys_GetClipboardData( void ); +extern void Sys_CopyProtect( void ); + + +/* +============================================================== + + CLIENT / SERVER SYSTEMS + +============================================================== +*/ +extern void Client_Init( void ); + + + + +// +// button bits +// +#define BUTTON_ATTACK 1 +#define BUTTON_USE 2 +#define BUTTON_ANY 128 // any key whatsoever + + + + +// usercmd_t is sent to the server each client frame +typedef struct usercmd_s +{ + W8 msec; + W8 buttons; + short angles[ 3 ]; + short forwardmove, sidemove, upmove; + W8 impulse; // remove? + W8 lightlevel; // light level the player is standing on + +} usercmd_t; + + + + + + +#endif /* __COMMON_H__ */ + diff --git a/wolf3d/newCode/env/common_utils.h b/wolf3d/newCode/env/common_utils.h new file mode 100644 index 0000000..e53f68e --- /dev/null +++ b/wolf3d/newCode/env/common_utils.h @@ -0,0 +1,62 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * common_utils.h: General Purpose Macros. + * + * Author: Michael Liebscher + * + */ + +#ifndef __COMMON_UTILS_H__ +#define __COMMON_UTILS_H__ + + + +/* + Make sure the following macros are defined. +*/ + +#ifndef __FILE__ + + #define __FILE__ "" + +#endif + +#ifndef __LINE__ + + #define __LINE__ 0L + +#endif + + + +/* + These function prefixes are used for figuring out which + functions are exported and which are not. +*/ + +#define PUBLIC /* Accessible outside this module */ +#define PRIVATE static /* Accessible only within this module */ + + + +#endif /* __COMMON_UTILS_H__ */ + diff --git a/wolf3d/newCode/env/console.c b/wolf3d/newCode/env/console.c new file mode 100644 index 0000000..52b7fd4 --- /dev/null +++ b/wolf3d/newCode/env/console.c @@ -0,0 +1,822 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * console.c: Console drawing and management. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +extern viddef_t viddef; +extern int consoleActive; + + +console_t con; + +float scr_conlines; +float scr_con_current; + +cvar_t *con_notifytime; +cvar_t *scr_conspeed; + + +#define MAXCMDLINE 256 + +char key_lines[ 32 ][ MAXCMDLINE ]; +int edit_line; +int key_linepos; + + +colour3_t colourconLGray = { 220, 220, 220 }; +colour3_t colourconLLGray = { 192, 192, 192 }; + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void DrawString( int x, int y, char *s ) +{ + Font_put_line( FONT0, x, y, s ); +} + +/* +----------------------------------------------------------------------------- + Function: Key_ClearTyping -Clear any keys that where typed. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +void Key_ClearTyping( void ) +{ + key_lines[ edit_line ][ 1 ] = 0; // clear any typing + key_linepos = 1; +} + +/* +----------------------------------------------------------------------------- + Function: Con_ToggleConsole_f -Get ready to enter console. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_ToggleConsole_f( void ) +{ + Key_ClearTyping(); + Con_ClearNotify(); +} + +/* +----------------------------------------------------------------------------- + Function: Con_Clear_f -Clear console text buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Zero sets con.text memory block. +----------------------------------------------------------------------------- +*/ +PRIVATE void Con_Clear_f( void ) +{ + memset( con.text, ' ', CON_TEXTSIZE ); +} + + +/* +----------------------------------------------------------------------------- + Function: Con_Dump_f -Save the console contents out to a file. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Con_Dump_f( void ) +{ + int length, x; + char *line; + FILE *f; + char buffer[1024]; + char name[MAX_OSPATH]; + + if( Cmd_Argc() != 2 ) + { + Com_Printf( "usage: conDump \n" ); + return; + } + + my_snprintf( name, sizeof( name ), "%s/%s.txt", FS_Gamedir(), Cmd_Argv( 1 ) ); + + Com_Printf( "Dumped console text to %s.\n", name ); + FS_CreatePath( name ); + f = fopen( name, "w" ); + if( ! f ) + { + Com_Printf( "ERROR: couldn't open.\n" ); + return; + } + + // skip empty lines + for( length = con.current - con.totallines + 1; length <= con.current; ++length ) + { + line = con.text + (length % con.totallines) * con.linewidth; + for( x = 0; x < con.linewidth; ++x ) + { + if( line[ x ] != ' ' ) + { + break; + } + } + + if( x != con.linewidth ) + { + break; + } + } + + // write the remaining lines + buffer[ con.linewidth ] = '\0'; + for( ; length <= con.current ; ++length ) + { + line = con.text + (length % con.totallines) * con.linewidth; + my_strlcpy( buffer, line, con.linewidth ); + for( x = con.linewidth - 1; x >= 0; --x ) + { + if( buffer[ x ] == ' ' ) + { + buffer[ x ] = '\0'; // NUL-terminate string + } + else + { + break; + } + } + for( x = 0; buffer[ x ]; ++x ) + { + buffer[ x ] &= 0x7f; + } + + fprintf( f, "%s\n", buffer ); + } + + fclose( f ); +} + +/* +----------------------------------------------------------------------------- + Function: Con_ClearNotify -Clear console con.times. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_ClearNotify( void ) +{ + int i; + + for( i = 0; i < NUM_CON_TIMES; ++i ) + { + con.times[ i ] = 0; + } +} + + +/* +----------------------------------------------------------------------------- + Function: Con_CheckResize -If the line width has changed, reformat the buffer. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_CheckResize( void ) +{ + int i, j, width, oldwidth, oldtotallines, numlines, numchars; + char tbuf[ CON_TEXTSIZE ]; + + width = (viddef.width >> 3) - 2; + + if( width == con.linewidth ) + { + return; + } + + if( width < 1 ) // video hasn't been initialized yet + { + width = 38; + con.linewidth = width; + con.totallines = CON_TEXTSIZE / con.linewidth; + memset( con.text, ' ', CON_TEXTSIZE ); + } + else + { + oldwidth = con.linewidth; + con.linewidth = width; + oldtotallines = con.totallines; + con.totallines = CON_TEXTSIZE / con.linewidth; + numlines = oldtotallines; + + if( con.totallines < numlines ) + { + numlines = con.totallines; + } + + numchars = oldwidth; + + if( con.linewidth < numchars ) + { + numchars = con.linewidth; + } + + memcpy( tbuf, con.text, CON_TEXTSIZE ); + memset( con.text, ' ', CON_TEXTSIZE ); + + for( i = 0; i < numlines; ++i ) + { + for( j = 0; j < numchars; ++j ) + { + con.text[(con.totallines - 1 - i) * con.linewidth + j] = + tbuf[((con.current - i + oldtotallines) % + oldtotallines) * oldwidth + j]; + } + } + + Con_ClearNotify(); + } + + con.current = con.totallines - 1; + con.display = con.current; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_Init( void ) +{ + con.linewidth = -1; + + Con_CheckResize(); + + Com_Printf( "Console Initialized\n" ); + +// +// register our commands +// + con_notifytime = Cvar_Get( "con_notifytime", "90", CVAR_INIT ); + scr_conspeed = Cvar_Get( "scr_conspeed", "90", CVAR_INIT ); + + Cmd_AddCommand( "toggleconsole", Con_ToggleConsole_f ); + Cmd_AddCommand( "clear", Con_Clear_f ); + Cmd_AddCommand( "conDump", Con_Dump_f ); + + con.initialized = true; +} + +/* +----------------------------------------------------------------------------- + Function: Con_Linefeed -Fill rest of line with spaces. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Con_Linefeed( void ) +{ + con.x = 0; + if( con.display == con.current ) + { + con.display++; + } + con.current++; + memset( &con.text[ (con.current % con.totallines) * con.linewidth ] + , ' ', con.linewidth ); +} + +/* +----------------------------------------------------------------------------- + Function: Con_Print -Print formatted message to the console. + + Parameters: txt -[in] Text message to print + + Returns: Nothing. + + Notes: + Handles cursor positioning, line wrapping, etc + All console printing must go through this in order to be logged to disk + If no console is visible, the text will appear at the top of the game window +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_Print( char *txt ) +{ + int y; + int c, wordlength; + static int cr; + int mask; + +#ifdef IPHONE + printf( "%s", txt ); +#endif + + if( ! con.initialized ) + { + return; + } + + if( txt[ 0 ] == 1 || txt[ 0 ] == 2 ) + { + mask = 128; // go to colored text + txt++; + } + else + { + mask = 0; + } + + + while( (c = *txt) ) + { + // count word length + for( wordlength = 0 ; wordlength < con.linewidth ; ++wordlength ) + { + if( txt[ wordlength ] <= ' ') + { + break; + } + } + + // word wrap + if( wordlength != con.linewidth && (con.x + wordlength > con.linewidth) ) + { + con.x = 0; + } + + txt++; + + if( cr ) + { + con.current--; + cr = false; + } + + + if( ! con.x ) + { + Con_Linefeed(); + // mark time for transparent overlay + if( con.current >= 0 ) + { + con.times[ con.current % NUM_CON_TIMES ] = iphoneFrameNum; + } + } + + switch( c ) + { + case '\n': + con.x = 0; + break; + + case '\r': + con.x = 0; + cr = 1; + break; + + default: // display character and advance + y = con.current % con.totallines; + con.text[ y * con.linewidth + con.x] = c | mask | con.ormask; + con.x++; + if( con.x >= con.linewidth ) + { + con.x = 0; + } + break; + } + + } +} + + +/* +----------------------------------------------------------------------------- + Function: Con_CenteredPrint -Print message that is centered on screen. + + Parameters: text -[in] Message string. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_CenteredPrint( const char *text ) +{ + int length; + char buffer[ 1024 ]; + + length = strlen( text ); + length = ( con.linewidth - length ) >> 1; + if( length < 0 ) + { + length = 0; + } + + memset( buffer, ' ', length ); + my_strlcpy( buffer + length, text, sizeof( buffer ) - length ); + my_strlcat( buffer, "\n", sizeof( buffer ) ); + Con_Print( buffer ); +} + + +/* +============================================================================== + + DRAWING + +============================================================================== +*/ + + +/* +----------------------------------------------------------------------------- + Function: Con_DrawInput -The input line scrolls horizontally if typing + goes beyond the right edge. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void Con_DrawInput( void ) +{ + int y; + int i; + char *text; + char buf[256]; + W16 heightfont, charwidth; + static char ccursor[ 2 ] = { ' ', '_' }; + + + heightfont = Font_GetSize( FONT0 ) + 4; + +#ifdef IPHONE + { + const char * GetCurrentCommandLine(); + extern int consoleActive; + + if ( consoleActive == 0 ) { + return; + } + strcpy( buf, GetCurrentCommandLine() ); + key_linepos = strlen( buf ); + buf[key_linepos+1] = 0; + text = buf; + } +#else + if( ClientStatic.key_dest != key_console ) + { + return; // don't draw anything (always draw if not active) + } + + text = key_lines[ edit_line ]; +#endif + +// add the cursor frame + text[ key_linepos ] = ccursor[ 0 + ((int)( iphoneFrameNum >> 3 ) & 1 ) ]; + +// fill out remainder with spaces + for( i = key_linepos + 1 ; i < con.linewidth ; ++i ) + { + text[ i ] = ' '; + } + +// prestep if horizontally scrolling + if( key_linepos >= con.linewidth ) + { + text += 1 + key_linepos - con.linewidth; + } + +// draw it + y = con.vislines - heightfont; + + charwidth = 8; + for( i = 0 ; i < con.linewidth ; ++i ) + { + charwidth += Font_put_character( FONT0, charwidth, con.vislines - 22, text[ i ] ); + } + +// remove cursor + key_lines[ edit_line ][ key_linepos ] = 0; +} + +/* +----------------------------------------------------------------------------- + Function: Con_DrawNotify -Draws the last few lines of output transparently + over the game top. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_DrawNotify( void ) +{ + int x, v; + int charwidth; + char *text; + int i; + int time; +// char *s; +// int skip; + W16 size; + + + Font_SetSize( FONT1, 1 ); + size = Font_GetSize( FONT1 ); + + Font_SetColour( FONT1, colourWhite ); + + v = 0; + for( i = con.current - NUM_CON_TIMES+1 ; i <= con.current ; ++i ) + { + if( i < 0 ) + { + continue; + } + + time = FloatToInt( con.times[ i % NUM_CON_TIMES ] ); + if( time == 0 ) + { + continue; + } + + time = iphoneFrameNum- time; + if( time > con_notifytime->value ) + { + continue; + } + + text = con.text + (i % con.totallines) * con.linewidth; + + charwidth = 0; + for( x = 0 ; x < con.linewidth ; ++x ) + { + charwidth += Font_put_character( FONT1, charwidth, v, text[ x ] ); + } + + v += size; + } + + Font_SetSize( FONT1, 2 ); + +} + + +/* +----------------------------------------------------------------------------- + Function: Con_DrawConsole -Draws the console. + + Parameters: frac -[in] Fraction of the screen the console will take up. + Range is 0.0 to 1.0 + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Con_DrawConsole( float frac ) +{ + int i, x, y; + int rows; + char *text; + int row; + W32 lines; + char version[ 64 ]; +// int w, h; + int heightfont, charwidth; + + lines = FloatToInt( viddef.height * frac ); + if( lines < 1 ) + { + return; + } + + + Font_SetSize( FONT0, 1 ); + Font_SetColour( FONT0, colourconLLGray ); + heightfont = Font_GetSize( FONT0 ); + + + + if( lines > viddef.height ) + { + lines = viddef.height; + } + +// +// Draw the background +// + R_Draw_Fill( 0, -viddef.height + lines, viddef.width, viddef.height, colourBlack ); + R_Draw_Fill( 0, lines-2, viddef.width, 2, colourconLGray ); + + +// SCR_AddDirtyPoint( 0, 0 ); +// SCR_AddDirtyPoint( viddef.width-1, lines-1 ); + + my_snprintf( version, sizeof( version ), "v%s", APP_VERSION ); + Font_SetColour( FONT0, colourGreen ); + Font_put_lineR2L( FONT0, viddef.width-20, lines - 2 - heightfont, version ); + Font_SetColour( FONT0, colourconLLGray ); + +// +// Draw the text +// + con.vislines = lines; + +#if 0 + + rows = (lines - 8) >> 3; // rows of text to draw + + y = lines - 24; + +#else + + rows = (lines - 22) >> 3; // rows of text to draw + + y = lines - 30; + +#endif + +// draw from the bottom up + if( con.display != con.current ) + { + // draw arrows to show the buffer is backscrolled + for( x = 0; x < con.linewidth; x += 4 ) + { + Font_put_character( FONT0, (x+1) << 3, y, '^' ); + } + + y -= heightfont; + rows--; + } + + row = con.display; + for( i = 0 ; i < rows ; ++i, y -= heightfont, --row ) + { + if( row < 0 ) + { + break; + } + + if( con.current - row >= con.totallines ) + { + break; // past scrollback wrap point + } + + text = con.text + (row % con.totallines) * con.linewidth; + + charwidth = 0; + for( x = 0; x < con.linewidth; ++x ) + { + charwidth += Font_put_character( FONT0, charwidth, y, text[ x ] ); + } + } + +// draw the input prompt, user text, and cursor if desired + Con_DrawInput(); + + Font_SetSize( FONT0, 2 ); +} + +/* + ----------------------------------------------------------------------------- + Function: Client_Screen_RunConsole -Figure out how the console should be + drawn. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + + ----------------------------------------------------------------------------- + */ +PUBLIC void Client_Screen_RunConsole( void ) +{ + if( scr_conlines < scr_con_current ) + { + scr_con_current -= scr_conspeed->value * iphoneFrameNum; + if( scr_conlines > scr_con_current ) + { + scr_con_current = scr_conlines; + } + + } + else if( scr_conlines > scr_con_current ) + { + scr_con_current += scr_conspeed->value * iphoneFrameNum; + if( scr_conlines < scr_con_current ) + { + scr_con_current = scr_conlines; + } + } + +} + +/* + ----------------------------------------------------------------------------- + Function: Client_Screen_DrawConsole -Draw the console on the screen. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + + ----------------------------------------------------------------------------- + */ +PUBLIC void Client_Screen_DrawConsole( void ) +{ + Con_CheckResize(); + + if( scr_con_current ) + { + Con_DrawConsole( scr_con_current ); + } + else + { + Con_DrawNotify(); + } +} + + + diff --git a/wolf3d/newCode/env/console.h b/wolf3d/newCode/env/console.h new file mode 100644 index 0000000..6134aaa --- /dev/null +++ b/wolf3d/newCode/env/console.h @@ -0,0 +1,86 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * console.h: Console drawing and management.. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by console.c. + +*/ + +#ifndef __CONSOLE_H__ +#define __CONSOLE_H__ + + +#define NUM_CON_TIMES 4 + +#define CON_TEXTSIZE 32768 + +typedef struct +{ + _boolean initialized; + + char text[CON_TEXTSIZE]; + int current; // line where next message will be printed + int x; // offset in current line for next print + int display; // bottom of console displays this line + + int ormask; // high bit mask for colored characters + + int linewidth; // characters across screen + int totallines; // total lines in console scrollback + + float cursorspeed; + + int vislines; + + float times[NUM_CON_TIMES]; // cls.realtime time the line was generated + // for transparent notify lines +} console_t; + +extern console_t con; + +extern void Con_DrawCharacter( int cx, int line, int num ); + +extern void Con_CheckResize( void ); +extern void Con_Init( void ); +extern void Con_DrawConsole( float frac ); +extern void Con_Print( char *txt ); +extern void Con_CenteredPrint( const char *text ); +extern void Con_DrawNotify( void ); +extern void Con_ClearNotify( void ); +extern void Con_ToggleConsole_f( void ); + +extern void Client_Screen_RunConsole( void ); +extern void Client_Screen_DrawConsole( void ); + +#endif /* __CONSOLE_H__ */ + diff --git a/wolf3d/newCode/env/cvar.c b/wolf3d/newCode/env/cvar.c new file mode 100644 index 0000000..da3125c --- /dev/null +++ b/wolf3d/newCode/env/cvar.c @@ -0,0 +1,765 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * cvar.c: Dynamic variable tracking. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +cvar_t *cvar_vars; + + +/* +----------------------------------------------------------------------------- + Function: Cvar_InfoValidate -String can not have / " ; + + Parameters: string -[in] String to validate. + + Returns: 1 if string is valid, otherwise 0; + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean Cvar_InfoValidate( const char *string ) +{ + if( strstr( string, "\\" ) ) + { + return false; + } + + if( strstr( string, "\"" ) ) + { + return false; + } + + if( strstr( string, ";" ) ) + { + return false; + } + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_FindVar -Return cvar; + + Parameters: var_name -[in] Name of cvar to lookup. + + Returns: NULL if cvar not found, otherwise returns the cvar. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE cvar_t *Cvar_FindVar( const char *var_name ) +{ + cvar_t *var; + W32 hashid; + + hashid = my_strhash( var_name ); + + for( var = cvar_vars ; var ; var = var->next ) + { + if( hashid == var->id ) + { + return var; + } + } + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_VariableValue -Get value of cvar. + + Parameters: var_name -[in] Name of cvar to get value. + + Returns: 0 if not found, other the value of the cvar. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC float Cvar_VariableValue( const char *var_name ) +{ + cvar_t *var; + + var = Cvar_FindVar( var_name ); + if( ! var ) + { + return 0; + } + + return (float)atof( var->string ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_VariableString -Get cvar variable as string. + + Parameters: var_name -[in] Name of cvar to get value. + + Returns: Blank string on error, otherwise value string. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cvar_VariableString( const char *var_name ) +{ + cvar_t *var; + + var = Cvar_FindVar( var_name ); + if( ! var ) + { + return ""; + } + + return var->string; +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_CompleteVariable -Complete cvar string name. + + Parameters: partial -[in] Partial name of string to look up. + + Returns: NULL if partial string not found, otherwise the complete + string name. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cvar_CompleteVariable( const char *partial ) +{ + cvar_t *cvar; + size_t len; + W32 hashid; + + len = strlen( partial ); + + if( ! len ) + { + return NULL; + } + +// +// Check exact match. +// + hashid = my_strhash( partial ); + + for( cvar = cvar_vars ; cvar ; cvar = cvar->next ) + { + if( hashid == cvar->id ) + { + return cvar->name; + } + } + +// +// Check partial match. +// + for( cvar = cvar_vars ; cvar ; cvar = cvar->next ) + { + if( ! strncmp( partial, cvar->name, len ) ) + { + return cvar->name; + } + } + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_Get -Get cvar structure. + + Parameters: + var_name -[in] the name of the cvar variable. + var_value -[in] string value of the cvar variable. + flags -[in] see CVARFlags for more information. + + Returns: NULL on error, otherwise valid pointer to cvar_t structure. + + Notes: + If the variable already exists, the value will not be set and + the flags will be or'ed. +----------------------------------------------------------------------------- +*/ +PUBLIC cvar_t *Cvar_Get( const char *var_name, const char *var_value, CVARFlags flags ) +{ + cvar_t *var; + + if( flags & (CVAR_USERINFO | CVAR_SERVERINFO) ) + { + if( ! Cvar_InfoValidate( var_name ) ) + { + Com_Printf( "invalid info cvar name\n" ); + return NULL; + } + } + + var = Cvar_FindVar( var_name ); + if( var ) + { + var->flags |= flags; + return var; + } + + if( ! var_value ) + { + return NULL; + } + + if( flags & (CVAR_USERINFO | CVAR_SERVERINFO) ) + { + if( ! Cvar_InfoValidate( var_value ) ) + { + Com_Printf( "invalid info cvar value\n" ); + return NULL; + } + } + + var = Z_Malloc( sizeof( *var ) ); + var->name = my_CopyString( var_name ); + var->string = my_CopyString( var_value ); + var->id = my_strhash( var_name ); + var->modified = true; + var->value = (float)atof( var->string ); + + // link the variable in + var->next = cvar_vars; + cvar_vars = var; + + var->flags = flags; + + return var; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE cvar_t *Cvar_Set2( const char *var_name, const char *value, _boolean force ) +{ + cvar_t *var; + + var = Cvar_FindVar( var_name ); + if( ! var ) + { // create it + return Cvar_Get( var_name, value, CVAR_INIT ); + } + + if( var->flags & (CVAR_USERINFO | CVAR_SERVERINFO) ) + { + if( ! Cvar_InfoValidate( value ) ) + { + Com_Printf( "invalid info cvar value\n" ); + return var; + } + } + + if( ! force ) + { + if( var->flags & CVAR_NOSET ) + { + Com_Printf( "%s is write protected.\n", var_name ); + return var; + } + + if( var->flags & CVAR_LATCH ) + { + if( var->latched_string ) + { + if( strcmp( value, var->latched_string ) == 0 ) + { + return var; + } + + Z_Free( var->latched_string ); + } + else + { + if( strcmp( value, var->string ) == 0 ) + { + return var; + } + } + return var; + } + } + else + { + if( var->latched_string ) + { + Z_Free( var->latched_string ); + var->latched_string = NULL; + } + } + + if( ! strcmp( value, var->string ) ) + { + return var; // not changed + } + + var->modified = true; + + if( var->flags & CVAR_USERINFO ) + { + userinfo_modified = true; // transmit at next oportunity + } + + Z_Free( var->string ); // free the old value string + + var->string = my_CopyString( value ); + var->value = (float)atof( var->string ); + + return var; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC cvar_t *Cvar_ForceSet( const char *var_name, const char *value ) +{ + return Cvar_Set2( var_name, value, true ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC cvar_t *Cvar_Set( const char *var_name, const char *value ) +{ + return Cvar_Set2( var_name, value, false ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC cvar_t *Cvar_FullSet( const char *var_name, const char *value, CVARFlags flags ) +{ + cvar_t *var; + + var = Cvar_FindVar( var_name ); + if( ! var ) + { // create it + return Cvar_Get( var_name, value, flags ); + } + + var->modified = true; + + if( var->flags & CVAR_USERINFO ) + { + userinfo_modified = true; // transmit at next oportunity + } + + Z_Free( var->string ); // free the old value string + + var->string = my_CopyString( value ); + var->value = (float)atof( var->string ); + var->flags = flags; + + return var; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cvar_SetValue( const char *var_name, float value ) +{ + char val[ 32 ]; + + if( value == (int)value ) + { + my_snprintf( val, sizeof( val ), "%i", (int)value ); + } + else + { + my_snprintf( val, sizeof( val ), "%f", value ); + } + + Cvar_Set( var_name, val ); +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_GetLatchedVars -Any variables with latched values will now + be updated + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cvar_GetLatchedVars( void ) +{ + cvar_t *var; + + for( var = cvar_vars ; var ; var = var->next ) + { + if( ! var->latched_string ) + { + continue; + } + + Z_Free( var->string ); + var->string = var->latched_string; + var->latched_string = NULL; + var->value = (float)atof(var->string); + } +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_Command -Handles variable inspection and changing from + the console. + + Parameters: Nothing. + + Returns: false if variable not found, otherwise true. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Cvar_Command( void ) +{ + cvar_t *v; + +// check variables + v = Cvar_FindVar( Cmd_Argv( 0 ) ); + if( ! v ) + { + return false; + } + +// perform a variable print or set + if( Cmd_Argc() == 1 ) + { + Com_Printf( "\"%s\" is \"%s\"\n", v->name, v->string ); + return true; + } + + Cvar_Set( v->name, Cmd_Argv( 1 ) ); + return true; +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_Set_f -Allows setting and defining of arbitrary cvars from console. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cvar_Set_f( void ) +{ + int c; + int flags; + + c = Cmd_Argc(); + if( c != 3 && c != 4 ) + { + Com_Printf( "usage: set [u / s]\n" ); + return; + } + + if( c == 4 ) + { + if( ! strcmp( Cmd_Argv( 3 ), "u" ) ) + { + flags = CVAR_USERINFO; + } + else if( ! strcmp( Cmd_Argv( 3 ), "s" ) ) + { + flags = CVAR_SERVERINFO; + } + else + { + Com_Printf( "flags can only be 'u' or 's'\n" ); + return; + } + Cvar_FullSet( Cmd_Argv( 1 ), Cmd_Argv( 2 ), flags ); + } + else + { + Cvar_Set( Cmd_Argv( 1 ), Cmd_Argv( 2 ) ); + } +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_WriteVariables -Appends lines containing "set variable value" + for all variables with the archive flag set + to true. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Cvar_WriteVariables( const char *path ) +{ + cvar_t *var; + char buffer[1024]; + FILE *f; + + f = fopen( path, "a" ); + for( var = cvar_vars ; var ; var = var->next ) + { + if( var->flags & CVAR_ARCHIVE ) + { + my_snprintf( buffer, sizeof( buffer ), "set %s \"%s\"\n", var->name, var->string ); + fprintf( f, "%s", buffer ); + } + } + fclose( f ); +} + +/* +----------------------------------------------------------------------------- + Function: Cvar_List_f -Print all cvars to the console. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cvar_List_f( void ) +{ + cvar_t *var; + int i; + + i = 0; + for( var = cvar_vars ; var ; var = var->next, ++i ) + { + if( var->flags & CVAR_ARCHIVE ) + { + Com_Printf ("*"); + } + else + { + Com_Printf (" "); + } + + + if( var->flags & CVAR_USERINFO ) + { + Com_Printf ("U"); + } + else + { + Com_Printf (" "); + } + + + if (var->flags & CVAR_SERVERINFO) + { + Com_Printf ("S"); + } + else + { + Com_Printf (" "); + } + + + if( var->flags & CVAR_NOSET ) + { + Com_Printf ("-"); + } + else if (var->flags & CVAR_LATCH) + { + Com_Printf ("L"); + } + else + { + Com_Printf (" "); + } + + Com_Printf (" %s \"%s\"\n", var->name, var->string); + } + + Com_Printf ("%i cvars\n", i); +} + + +PUBLIC _boolean userinfo_modified; + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE char *Cvar_BitInfo( int bit ) +{ + return NULL; +/* static char info[ MAX_INFO_STRING ]; + cvar_t *var; + + info[0] = 0; + + for (var = cvar_vars ; var ; var = var->next) + { + if (var->flags & bit) + Info_SetValueForKey (info, var->name, var->string); + } + return info; +*/ +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_Userinfo -Get CVAR_USERINFO cvars in a string. + + Parameters: Nothing. + + Returns: An info string containing all the CVAR_USERINFO cvars. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cvar_Userinfo( void ) +{ + return Cvar_BitInfo( CVAR_USERINFO ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_Serverinfo -Get CVAR_SERVERINFO cvars in a string. + + Parameters: Nothing. + + Returns: An info string containing all the CVAR_SERVERINFO cvars. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *Cvar_Serverinfo( void ) +{ + return Cvar_BitInfo( CVAR_SERVERINFO ); +} + + +/* +----------------------------------------------------------------------------- + Function: Cvar_Init -Initialize cvar console functions. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + + This is done so that we can read in archived cvars from cfg files. + Also to list all the cvar variables. +----------------------------------------------------------------------------- +*/ +PUBLIC void Cvar_Init( void ) +{ + Cmd_AddCommand( "set", Cvar_Set_f ); + Cmd_AddCommand( "listCvars", Cvar_List_f ); +} + diff --git a/wolf3d/newCode/env/cvar.h b/wolf3d/newCode/env/cvar.h new file mode 100644 index 0000000..aa41f2f --- /dev/null +++ b/wolf3d/newCode/env/cvar.h @@ -0,0 +1,162 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * cvar.h: Dynamic variable tracking. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + +Notes: + + Dynamic variable tracking. + + cvar_t variables are used to hold scalar or string variables + that can be changed or displayed at the console or prog code + as well as accessed directly in C code. + + The user can access cvars from the console in three ways: + r_draworder -prints the current value + r_draworder 0 -sets the current value to 0 + set r_draworder 0 -as above, but creates the cvar if not present + + Cvars are restricted from having the same names as commands to keep this + module from being ambiguous. + + This module is implemented by cvar.c + +*/ + +#ifndef __CVAR_H__ +#define __CVAR_H__ + + +#include "arch.h" + +#if 0 +typedef enum _CVARType +{ + CVAR_DEFAULT = BIT( 0 ), // Just create it with no flag value. + CVAR_BOOL = BIT( 0 ), // Set to cause it to be saved to vars.rc + CVAR_INT = BIT( 0 ), // Added to userinfo when changed. + CVAR_FLOAT = BIT( 0 ), // Added to serverinfo when changed. + CVAR_STRING = BIT( 0 ), // Don't allow change from console at all, + // but can be set from the command line. + + CVAR_LATCH = BIT( 0 ), // Save changes until server restart. + +} CVARType; +#endif + +typedef enum _CVARFlags +{ + CVAR_INIT = 0x0, // Just create it with no flag value. + CVAR_ARCHIVE = 0x1, // Set to cause it to be saved to vars.rc + CVAR_USERINFO = 0x2, // Added to userinfo when changed. + CVAR_SERVERINFO = 0x4, // Added to serverinfo when changed. + CVAR_NOSET = 0x8, // Don't allow change from console at all, + // but can be set from the command line. + + CVAR_LATCH = 0x10, // Save changes until server restart. + +} CVARFlags; + + +// nothing outside the Cvar_*() functions should modify these fields! +typedef struct cvar_s +{ + char *name; + char *string; + W32 id; + char *latched_string; // for CVAR_LATCH vars + int flags; + _boolean modified; // set each time the cvar is changed + float value; + + struct cvar_s *next; + +} cvar_t; + +extern cvar_t *cvar_vars; + + + +extern cvar_t *Cvar_Get( const char *var_name, const char *value, CVARFlags flags ); +// creates the variable if it doesn't exist, or returns the existing one +// if it exists, the value will not be changed, but flags will be ORed in +// that allows variables to be unarchived without needing bitflags + +extern cvar_t *Cvar_Set( const char *var_name, const char *value ); +// will create the variable if it doesn't exist + +extern cvar_t *Cvar_ForceSet( const char *var_name, const char *value ); +// will set the variable even if NOSET or LATCH + +extern cvar_t *Cvar_FullSet( const char *var_name, const char *value, CVARFlags flags ); + +extern void Cvar_SetValue( const char *var_name, float value ); +// expands value to a string and calls Cvar_Set + +extern float Cvar_VariableValue( const char *var_name ); +// returns 0 if not defined or non numeric + +extern char *Cvar_VariableString( const char *var_name ); +// returns an empty string if not defined + +extern char *Cvar_CompleteVariable( const char *partial ); +// attempts to match a partial variable name for command line completion +// returns NULL if nothing fits + +extern void Cvar_GetLatchedVars( void ); +// any CVAR_LATCHED variables that have been set will now take effect + +extern _boolean Cvar_Command( void ); +// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known +// command. Returns true if the command was a variable reference that +// was handled. (print or change) + +extern void Cvar_WriteVariables( const char *path ); +// appends lines containing "set variable value" for all variables +// with the archive flag set to true. + +extern void Cvar_Init( void ); + +extern char *Cvar_Userinfo( void ); +// returns an info string containing all the CVAR_USERINFO cvars + +extern char *Cvar_Serverinfo( void ); +// returns an info string containing all the CVAR_SERVERINFO cvars + +extern _boolean userinfo_modified; +// this is set each time a CVAR_USERINFO variable is changed +// so that the client knows to send it to the server + + +#endif /* __CVAR_H__ */ + diff --git a/wolf3d/newCode/env/fileio.c b/wolf3d/newCode/env/fileio.c new file mode 100644 index 0000000..1848e55 --- /dev/null +++ b/wolf3d/newCode/env/fileio.c @@ -0,0 +1,302 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + +// if true, use mmap instead of alloc and read +//#define USE_MMAP + +/* +----------------------------------------------------------------------------- + Function: FS_GetLoadedFilePointer() -Get file pointer. + + Parameters: + filestream -[in] Target file handle. + origin -[in] Pointer position + SEEK_SET -Beginning of file. + SEEK_CUR -Current position of file pointer. + SEEK_END -End of file. + + Returns: File pointer on success, otherwise NULL. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void *FS_GetLoadedFilePointer( filehandle_t *fhandle, W32 origin ) +{ + switch( origin ) + { + case SEEK_SET: + return( (void *)fhandle->ptrStart ); + + case SEEK_END: + return( (void *)fhandle->ptrEnd ); + + case SEEK_CUR: + return( (void *)fhandle->ptrCurrent ); + } + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: FS_GetFileSize() -Get the length of a file. + + Parameters: filestream -[in] Target file handle. + + Returns: The file length in bytes. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC SW32 FS_GetFileSize( filehandle_t *fhandle ) +{ + return fhandle->filesize; +} + +/* +----------------------------------------------------------------------------- + Function: FS_FileSeek() -Moves the file pointer to a specified location. + + Parameters: + fhandle -[in] Pointer to filehandle_t structure. + offset -[in] Number of bytes from origin + origin -[in] Initial position + SEEK_SET -Beginning of file. + SEEK_CUR -Current position of file pointer. + SEEK_END -End of file. + + Returns: If successful zero, otherwise a nonzero value. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W32 FS_FileSeek( filehandle_t *fhandle, SW32 offset, W32 origin ) +{ + switch( origin ) + { + case SEEK_SET: + if( offset < 0 || + offset > fhandle->filesize ) + { + return 1; + } + + fhandle->ptrCurrent = fhandle->ptrStart + offset; + break; + + case SEEK_END: + if( offset > 0 ) + { + return 1; + } + + // offset is negative + if( (fhandle->filesize + offset) < 0 ) + { + return 1; + } + + // offset is negative + fhandle->ptrCurrent = fhandle->ptrEnd + offset; + break; + + case SEEK_CUR: + if( offset < 0 ) + { + // offset is negative + if( ((fhandle->ptrCurrent - fhandle->ptrStart) + offset) < 0 ) + { + return 1; + } + } + + if( offset > 0 ) + { + if( offset > (fhandle->ptrEnd - fhandle->ptrCurrent) ) + { + return 1; + } + } + + fhandle->ptrCurrent += offset; + break; + + default: + return 1; + } + + return 0; +} + +/* +----------------------------------------------------------------------------- + Function: FS_FileTell() -Gets the current position of a file pointer. + + Parameters: fhandle -[in] Pointer to filehandle_t structure. + + Returns: If successful current file position, otherwise -1. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC SW32 FS_FileTell( filehandle_t *fhandle ) +{ + return( fhandle->ptrCurrent - fhandle->ptrStart ); +} + +/* +----------------------------------------------------------------------------- + Function: FS_CloseFile -Close file handle. + + Parameters: filestream -[in] Pointer to valid FILE structure. + + Returns: Nothing. + + Notes: Closes a file stream that was returned by FS_FOpenFile. + +----------------------------------------------------------------------------- +*/ +PUBLIC void FS_CloseFile( filehandle_t *fhandle ) +{ + if( fhandle->filedata ) + { +#ifdef USE_MMAP + if ( munmap( fhandle->filedata, fhandle->filesize ) != 0 ) { + assert( 0 ); + } +#else + free( fhandle->filedata ); +#endif + fhandle->filedata = NULL; + } + + Z_Free( fhandle ); +} + + +/* +----------------------------------------------------------------------------- + Function: FS_OpenFile -Open file from the file system. + +----------------------------------------------------------------------------- +*/ +PUBLIC filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes ) +{ + char netpath[ MAX_OSPATH ]; + filehandle_t *hFile; + const char *pathBase; + struct stat s; + int fd; + + +// +// Check for the file in the directory tree +// + if ( FlagsAndAttributes & FA_FILE_IPHONE_DOC_DIR ) { + extern char iphoneDocDirectory[1024]; + pathBase = iphoneDocDirectory; + my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename ); + } else { +// extern char iphoneAppDirectory[1024]; +// pathBase = iphoneAppDirectory; + pathBase = FS_Gamedir(); + my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename ); + } + + // high performance file mapping path, avoiding stdio + fd = open( netpath, O_RDONLY ); + if ( fd == -1 ) { + return NULL; + } + fstat( fd, &s ); + + hFile = Z_Malloc( sizeof( filehandle_t ) ); + memset( hFile, 0, sizeof( filehandle_t ) ); + + hFile->filesize = s.st_size; +#ifdef USE_MMAP + hFile->filedata = mmap( NULL, hFile->filesize, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0 ); + if ( (int)hFile->filedata == -1 ) { + Com_Printf( "mmap failed: %s\n", strerror( errno ) ); + assert( 0 ); + } +#else + hFile->filedata = malloc( hFile->filesize ); + read( fd, hFile->filedata, hFile->filesize ); +#endif + hFile->ptrStart = hFile->ptrCurrent = (PW8)hFile->filedata; + hFile->ptrEnd = (PW8)hFile->filedata + hFile->filesize; + hFile->bLoaded = true; + // mmap doesn't require the file to stay open + close( fd ); + return hFile; +} + + +/* +----------------------------------------------------------------------------- + Function: FS_ReadFile -Reads data from a stream. + + Parameters: buffer -[in/out] Storage location for data. + size -[in] Item size in bytes. + count -[in] Maximum number of items to be read. + fhandle -[in] Pointer to valid filehandle_t structure. + + Returns: On success number of full items actually read, otherwise -1. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC SW32 FS_ReadFile( void *buffer, W32 size, W32 count, filehandle_t *fhandle ) +{ + W8 *buf = (PW8)buffer; + W32 i; + + if( (size * count) > (fhandle->ptrEnd - fhandle->ptrCurrent) ) + { + SW32 read; + + read = (fhandle->ptrEnd - fhandle->ptrCurrent); + + for( i = 0 ; i < (fhandle->ptrEnd - fhandle->ptrCurrent) ; ++i ) + { + buf[ i ] = fhandle->ptrCurrent[ i ]; + } + + fhandle->ptrCurrent = fhandle->ptrEnd; + + return( read ); + } + else + { + for( i = 0 ; i < (size * count) ; ++i, fhandle->ptrCurrent++ ) + { + buf[ i ] = *fhandle->ptrCurrent; + } + + return( (size * count) / size ); + } + + /* should never get here */ + return -1; +} diff --git a/wolf3d/newCode/env/files.c b/wolf3d/newCode/env/files.c new file mode 100644 index 0000000..acd92e2 --- /dev/null +++ b/wolf3d/newCode/env/files.c @@ -0,0 +1,162 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * files.c: Interface to file i/o layer. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + + Notes: + + This module accesses data through a hierarchal file system, but the + contents of the file system can be transparently merged from several + sources. + + The "base directory" is the path to the directory holding the + executable and all game directories. The sys_* files pass this to + host_init in quakeparms_t->basedir. This can be overridden with the + "-basedir" command line parm to allow code debugging in a different + directory. The base directory is only used during file system + initialization. + + The "game directory" is the first tree on the search path and directory + that all generated files (save games, screen shots, demos, config + files) will be saved to. This can be overridden with the "-game" + command line parameter. The game directory can never be changed while + the application is executing. This is a precaution against having a + malicious server instruct clients to write files over areas they + shouldn't. + +*/ + +#include "../wolfiphone.h" + + + +PRIVATE char fs_gamedir[ MAX_OSPATH ]; + + + +/* +----------------------------------------------------------------------------- + Function: FS_Gamedir -Get root directory. + + Parameters: Nothing. + + Returns: String with the name of the root directory. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *FS_Gamedir( void ) +{ + return fs_gamedir; +} + + +/* +----------------------------------------------------------------------------- + Function: FS_ListFiles -List files. + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE char **FS_ListFiles( char *findname, int *numfiles, unsigned musthave, unsigned canthave ) +{ + char *s; + int nfiles = 0; + char **list = 0; + + s = FS_FindFirst( findname, musthave, canthave ); + while ( s ) + { + if ( s[strlen(s)-1] != '.' ) + nfiles++; + s = FS_FindNext( musthave, canthave ); + } + FS_FindClose (); + + if ( !nfiles ) + return NULL; + + nfiles++; // add space for a guard + *numfiles = nfiles; + + list = MM_MALLOC( sizeof( char * ) * nfiles ); + if( list == NULL ) + { + MM_OUTOFMEM( "list" ); + } + + memset( list, 0, sizeof( char * ) * nfiles ); + + s = FS_FindFirst( findname, musthave, canthave ); + nfiles = 0; + while( s ) + { + if( s[ strlen( s ) - 1 ] != '.' ) + { + list[ nfiles ] = strdup( s ); + + (void)my_strlwr( list[ nfiles ] ); + + nfiles++; + } + s = FS_FindNext( musthave, canthave ); + } + FS_FindClose(); + + return list; +} + + +/* +----------------------------------------------------------------------------- + Function: FS_InitFilesystem -Initialize file system. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void FS_InitFilesystem( void ) +{ + char *p; + p = getenv("CWD"); + sprintf( fs_gamedir, "%s/base", p ); +} diff --git a/wolf3d/newCode/env/filestring.c b/wolf3d/newCode/env/filestring.c new file mode 100644 index 0000000..d36603d --- /dev/null +++ b/wolf3d/newCode/env/filestring.c @@ -0,0 +1,161 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * filestring.c: Portable file path/name manipulation methods. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +/* +----------------------------------------------------------------------------- + Function: FS_CreatePath -Creates given path. + + Parameters: path -[in] Pointer to NULL terminated string that contains directory + path. + + Returns: Nothing. + + Notes: Creates any directories needed to store the given filename. + +----------------------------------------------------------------------------- +*/ +PUBLIC void FS_CreatePath( char *path ) +{ + char *ofs; + + for( ofs = path + 1; *ofs; ofs++ ) + { + if( *ofs == '/' ) + { // create the directory + *ofs = '\0'; + FS_CreateDirectory( path ); + *ofs = '/'; + } + } + +} + +PUBLIC void FS_FilePath( char *in, char *out ) +{ + char *s; + + s = in + strlen( in ) - 1; + + while( s != in && *s != '/' ) + { + s--; + } + + strncpy( out, in, s-in ); + out[ s - in ] = '\0'; // NUL-terminate string. +} + +PUBLIC char *FS_SkipPath( char *pathname ) +{ + char *last; + + last = pathname; + while( *pathname ) + { + if( *pathname == '/' ) + { + last = pathname + 1; + } + pathname++; + } + + return last; +} + +PUBLIC void FS_StripExtension( char *in, char *out ) +{ + while( *in && *in != '.' ) + { + *out++ = *in++; + } + + *out = '\0'; // NUL-terminate string. +} + +PUBLIC char *FS_FileExtension( char *in ) +{ + static char exten[ 8 ]; + int i; + + while( *in && *in != '.' ) + { + in++; + } + + if( ! *in ) + { + return ""; + } + + in++; + for( i = 0 ; i < 7 && *in ; i++, in++ ) + { + exten[ i ] = *in; + } + + exten[ i ] = '\0'; // NUL-terminate string. + + return exten; +} + +PUBLIC void FS_FileBase( char *in, char *out ) +{ + char *s, *s2; + + s = in + strlen( in ) - 1; + + while( s != in && *s != '.' ) + { + s--; + } + + for( s2 = s ; s2 != in && *s2 != '/' ; s2-- ) + { + ; + } + + if( s - s2 < 2 ) + { + out[ 0 ] = '\0'; // NUL-terminate string. + } + else + { + s--; + strncpy( out, s2 + 1, s - s2 ); + out[ s - s2 ] = '\0'; // NUL-terminate string. + } +} + + diff --git a/wolf3d/newCode/env/filestring.h b/wolf3d/newCode/env/filestring.h new file mode 100644 index 0000000..696fa1a --- /dev/null +++ b/wolf3d/newCode/env/filestring.h @@ -0,0 +1,55 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * filesystem.h: Interface to filesystem layer. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by filestring.c. + +*/ + +#ifndef __FILESTRING_H__ +#define __FILESTRING_H__ + + +extern void FS_CreatePath( char *path ); + +extern void FS_FilePath( char *in, char *out ); + +extern char *FS_SkipPath( char *pathname ); + +extern void FS_StripExtension( char *in, char *out ); + +extern char *FS_FileExtension( char *in ); + +extern void FS_FileBase( char *in, char *out ); + +#endif /* __FILESTRING_H__ */ diff --git a/wolf3d/newCode/env/filesystem.h b/wolf3d/newCode/env/filesystem.h new file mode 100644 index 0000000..59bde77 --- /dev/null +++ b/wolf3d/newCode/env/filesystem.h @@ -0,0 +1,134 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * filesystem.h: Interface to filesystem layer. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by files.c. + +*/ + +#ifndef __FILESYSTEM_H__ +#define __FILESYSTEM_H__ + +#define MAX_GAMEPATH 256 // max length of a game pathname +#define MAX_OSPATH 256 // max length of a filesystem pathname + + +extern void FS_InitFilesystem(void); +extern char *FS_Gamedir(void); + + + +///////////////////////////////////////////////////////////////////// +// +// PORTABLE FILE SYSTEM SERVICES +// +///////////////////////////////////////////////////////////////////// + +typedef struct +{ + FILE *hFile; + + /* Following is used when the file is loaded into memory */ + _boolean bLoaded; /* Was file loaded into memory? */ + W32 filesize; /* Size of file data in bytes */ + + W8 *ptrStart; /* pointer to start of file data block */ + W8 *ptrCurrent; /* pointer to current position in file data block */ + W8 *ptrEnd; /* pointer to end of file data block */ + + void *filedata; /* file data loaded into memory */ + +} filehandle_t; + + +/* Desired Access Flags */ +#define DA_GENERIC_READ 0x01 +#define DA_GENERIC_WRITE 0x02 + +/* Flags and Attributes */ +#define FA_FILE_FLAG_LOAD 0x01 +#define FA_FILE_FLAG_CACHE 0x02 +#define FA_FILE_IPHONE_DOC_DIR 0x04 + +extern filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes ); +extern void FS_CloseFile( filehandle_t *fhandle ); +// note: this can't be called from another DLL, due to MS libc issues + +extern SW32 FS_ReadFile( void *buffer, W32 size, W32 count, filehandle_t *fhandle ); + +extern SW32 FS_FileTell( filehandle_t *fhandle ); + +extern W32 FS_FileSeek( filehandle_t *fhandle, SW32 offset, W32 origin ); + +extern SW32 FS_GetFileSize( filehandle_t *fhandle ); + +extern void *FS_GetLoadedFilePointer( filehandle_t *fhandle, W32 origin ); + + + +extern void FS_CreatePath( char *path ); + +extern void FS_FilePath( char *in, char *out ); + +extern char *FS_SkipPath( char *pathname ); + +///////////////////////////////////////////////////////////////////// +// +// NON-PORTABLE FILE SYSTEM SERVICES +// +///////////////////////////////////////////////////////////////////// + +extern W8 FS_CreateDirectory( const char *dirname ); +extern W8 FS_ChangeCurrentDirectory( const char *path ); + +extern _boolean FS_DeleteFile( const char *filename ); +extern _boolean FS_RemoveDirectory( const char *pathname ); + +// directory/file attributes +#define FA_ARCH 0x01 +#define FA_HIDDEN 0x02 +#define FA_RDONLY 0x04 +#define FA_DIR 0x08 +#define FA_SYSTEM 0x10 + +// pass in an attribute mask of things you wish to REJECT +extern char *FS_FindFirst( const char *path, W32 musthave, W32 canthave ); +extern char *FS_FindNext( W32 musthave, W32 canthave ); +extern void FS_FindClose( void ); + + + + + +#endif /* __FILESYSTEM_H__ */ + diff --git a/wolf3d/newCode/env/font_manager.c b/wolf3d/newCode/env/font_manager.c new file mode 100644 index 0000000..b4bf57e --- /dev/null +++ b/wolf3d/newCode/env/font_manager.c @@ -0,0 +1,492 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * font_manager.c: Font management. + * + */ + + +#include "../wolfiphone.h" + +/* + + ! " # $ % & ' ( ) * + , - . / +0 1 2 3 4 5 6 7 8 9 : ; ( = ) ? +@ A B C D E F G H I J K L M N O +P Q R S T U V W X Y Z [ / ] ^ - +` a b c d e f g h i j k l m n o +p q r s t u v w x y z { | } ~ + +*/ + + +#define MAX_FONTS 4 +font_t *myfonts[ MAX_FONTS ]; +PRIVATE W32 num_fonts = 0; + + +typedef struct +{ + char *start, *end; + +} string_seg_t; + + +font_t *createFont( const char *filename ) +{ + font_t *temp_font; + char *datname; + filehandle_t *fp; + W32 size; + W32 i; + + if( num_fonts == (MAX_FONTS - 1) ) + { + Com_Printf( "[createFont]: No more font slots open\n" ); + + return NULL; + } + + + temp_font = Z_Malloc( sizeof( font_t ) ); + + temp_font->texfont = TM_FindTexture( filename, TT_Pic ); + if( NULL == temp_font->texfont ) + { + Com_Printf( "[createFont]: unable to open file (%s)\n", filename ); + + Z_Free( temp_font ); + + return NULL; + } + + memset( temp_font->nCharWidth, 0, sizeof( temp_font->nCharWidth ) ); + + datname = MM_MALLOC( strlen( filename ) + 1 ); + + FS_StripExtension( (char *)filename, datname ); + + my_strlcat( datname, ".dat", strlen( filename ) + 1 ); + + fp = FS_OpenFile( datname, 0 ); + if( NULL == fp ) + { + Com_Printf( "[createFont]: unable to open file (%s)\n", datname ); + + MM_FREE( datname ); + Z_Free( temp_font ); + + return NULL; + } + + size = FS_GetFileSize( fp ); + + // check header size + if( size < 10 ) + { + Com_Printf( "[createFont]: File (%s) has incorrect file length\n", datname ); + + MM_FREE( datname ); + Z_Free( temp_font ); + + FS_CloseFile( fp ); + + return NULL; + } + + + // Check sig of font dat file + + FS_ReadFile( &size, 1, 4, fp ); + + + FS_ReadFile( &temp_font->nMaxWidth, 1, 1, fp ); + FS_ReadFile( &temp_font->nMaxHeight, 1, 1, fp ); + + + FS_ReadFile( &size, 1, 4, fp ); + size = LittleLong( size ); + + if( size > 127 ) + { + Com_Printf( "[createFont]: File (%s) has incorrect Character Width array\n", datname ); + + MM_FREE( datname ); + Z_Free( temp_font ); + + FS_CloseFile( fp ); + + return NULL; + } + + FS_ReadFile( &temp_font->nCharWidth, 1, size, fp ); + + FS_CloseFile( fp ); + + + + + temp_font->nSize = 2; + temp_font->colour[ 3 ] = 255; + + temp_font->hFrac = (float)(temp_font->nMaxHeight / (float)temp_font->texfont->height); + temp_font->wFrac = (float)(temp_font->nMaxWidth / (float)temp_font->texfont->width); + + + + for( i = 0 ; i < MAX_FONTS ; ++i ) + { + if( ! myfonts[ i ] ) + { + break; + } + } + + if( i == (MAX_FONTS - 1) ) + { + Com_Printf( "[createFont]: No more font slots open\n" ); + + MM_FREE( datname ); + Z_Free( temp_font ); + + return NULL; + } + + myfonts[ i ] = temp_font; + + MM_FREE( datname ); + + + return temp_font; +} + +void Font_Init( void ) +{ + W32 i; + + for( i = 0 ; i < MAX_FONTS ; ++i ) + { + myfonts[ i ] = NULL; + } + + (void)createFont( "iphone/font1.tga" ); +// (void)createFont( "iphone/font2.tga" ); +} + +void Font_Shutdown( void ) +{ + +} + +void Font_GetMsgDimensions( FONTSELECT fs, const char *string, int *w, int *h ) +{ + int width = 0; + int mx = 0; + W16 scale; + int height; + + if( ! myfonts[ fs ] ) + { + *w = *h = 0; + + return; + } + + scale = myfonts[ fs ]->nMaxHeight * myfonts[ fs ]->nSize; + height = scale; + + while( *string ) + { + if( *string == '\n' ) + { + if( mx > width ) + { + width = mx; + } + + mx = 0; + height += scale; + ++string; + + continue; + } + + mx += myfonts[ fs ]->nCharWidth[ (*string)-32 ] * myfonts[ fs ]->nSize; + + ++string; + } + + if( mx > width ) + { + width = mx; + } + + *w = width; + *h = height; +} + +void Font_SetSize( FONTSELECT fs, W16 size ) +{ + if( myfonts[ fs ] ) + { + myfonts[ fs ]->nSize = size; + } +} + +W16 Font_GetSize( FONTSELECT fs ) +{ + if( myfonts[ fs ] ) + { + return( myfonts[ fs ]->nMaxHeight * myfonts[ fs ]->nSize ); + } + + return 0; +} + +void Font_SetColour( FONTSELECT fs, colour3_t c ) +{ + if( myfonts[ fs ] ) + { + myfonts[ fs ]->colour[ 0 ] = c[ 0 ]; + myfonts[ fs ]->colour[ 1 ] = c[ 1 ]; + myfonts[ fs ]->colour[ 2 ] = c[ 2 ]; + } +} + +extern void R_Draw_Character( int x, int y, int num, font_t *myfont ); + +void Font_put_line( FONTSELECT fs, int x, int y, const char *string ) +{ + int mx = x; + W16 scale; + + if( ! myfonts[ fs ] ) + { + return; + } + + scale = myfonts[ fs ]->nSize; + + while( *string ) + { + if( *string == '\n' ) + { + mx = x; + y += myfonts[ fs ]->nMaxHeight * scale; + ++string; + continue; + } + + R_Draw_Character( mx, y, *string, myfonts[ fs ] ); + mx += myfonts[ fs ]->nCharWidth[ (*string)-32 ] * scale; + ++string; + } +} + + +void Font_put_lineR2L( FONTSELECT fs, int x, int y, const char *string ) +{ + int mx = x; + unsigned int charindex; + unsigned int i; + + if( ! myfonts[ fs ] ) + { + return; + } + + for ( i = 0; i < strlen( string ); ++i ) + { + charindex = strlen( string ) - i - 1; + mx -= myfonts[ fs ]->nCharWidth[ string[ charindex ]-32 ] * myfonts[ fs ]->nSize; + + R_Draw_Character( mx, y, string[ charindex ], myfonts[ fs ] ); + } +} + +W16 Font_put_character( FONTSELECT fs, int x, int y, W16 num ) +{ + if( ! myfonts[ fs ] || num > 126 ) + { + return 0; + } + + R_Draw_Character( x, y, num, myfonts[ fs ] ); + + return( myfonts[ fs ]->nCharWidth[ num - 32 ] * myfonts[ fs ]->nSize ); +} + + +void Font_put_line_size( FONTSELECT fs, int x, int y, const char *start, const char *end ) +{ + int mx = x; + W16 scale; + + if( ! myfonts[ fs ] ) + { + return; + } + + scale = myfonts[ fs ]->nSize; + + while( start != end ) + { + R_Draw_Character( mx, y, *start, myfonts[ fs ] ); + mx += myfonts[ fs ]->nCharWidth[ (*start)-32 ] * scale; + ++start; + } + +} + + + +W8 Font_get_line( FONTSELECT fs, int line_width, string_seg_t *sst ) +{ + int x = 0, last_word_width = 0, last_word_spaces = 0; + int in_a_word = 0; + int t_words = 0; + int t_spaces = 0; + int chars_width = 0; + W16 scale; + const char *word_start = sst->start; + + + if( ! myfonts[ fs ] ) + { + return false; + } + + + scale = myfonts[ fs ]->nSize; + + + if( line_width < 0 ) + { + line_width = 1000000; + } + + + while( *sst->end != '\0' && *sst->end != '\n' ) + { + char c = *sst->end; + + int c_width = myfonts[ fs ]->nCharWidth[ c - 32 ] * scale; // FIX ME + + // we exceeded the space available for this line + if( x + c_width > line_width ) + { + if( in_a_word ) + { + chars_width = last_word_width; + sst->end = (char *)word_start; + t_spaces = last_word_spaces; + } + + return t_words ? true : false; + } + + + x += c_width; + + if( c != ' ' ) + { + if( ! in_a_word ) + { + last_word_width = chars_width; + word_start = sst->end; + } + + in_a_word = 1; + chars_width += c_width; + } + else + { + if( in_a_word ) + { + in_a_word = 0; + t_words++; + last_word_spaces = t_spaces; + } + + t_spaces++; + } + + ++sst->end; + } + + if( in_a_word ) + { + t_words++; + } + + if( *sst->end != '\0' && *sst->end == '\n' ) + { + ++sst->end; + } + + return t_words ? true : false; + +} + + +void Font_put_paragraph( FONTSELECT fs, short x, short y, + const char *string, + int space_between_lines, + int line_width_in_pixel ) +{ + string_seg_t sst; + sst.start = sst.end = (char *)string; + + if( ! myfonts[ fs ] ) + { + return; + } + + while( Font_get_line( fs, line_width_in_pixel, &sst ) ) + { + Font_put_line_size( fs, x, y, sst.start, sst.end ); + + if( *sst.end != '\0' && *sst.end == ' ' ) + { + sst.start = sst.end; + ++sst.start; + sst.end = sst.start; + } + else if( *sst.end != '\0' && *sst.end == '\n' ) + { + while( *sst.end == '\n' ) + { + ++sst.end; + y += Font_GetSize( fs ) + space_between_lines; + } + + sst.start = sst.end; + } + else + { + sst.start = sst.end; + } + + y += Font_GetSize( fs ) + space_between_lines; + } + +} + diff --git a/wolf3d/newCode/env/font_manager.h b/wolf3d/newCode/env/font_manager.h new file mode 100644 index 0000000..ac54886 --- /dev/null +++ b/wolf3d/newCode/env/font_manager.h @@ -0,0 +1,78 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * font_manager.h: Font management. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + +/* + Notes: + This module is implemented by font_manager.c. + +*/ + +#ifndef __FONT_MANAGER_H__ +#define __FONT_MANAGER_H__ + + +typedef enum { FONT0 = 0, FONT1, FONT2, FONT3 } FONTSELECT; + + + +typedef struct +{ + W8 nCharWidth[ 128 ]; /* width of each character */ + W8 nMaxWidth; /* box width */ + W8 nMaxHeight; /* box height */ + SW32 spacing; /* space between characters */ + W32 nSize; + float wFrac; + float hFrac; + colour4_t colour; /* Font colour */ + texture_t *texfont; + +} font_t; + + +extern void Font_Init( void ); +extern void Font_Shutdown( void ); + + +extern void Font_SetSize( FONTSELECT fs, W16 size ); +extern W16 Font_GetSize( FONTSELECT fs ); + +extern void Font_SetColour( FONTSELECT fs, colour3_t c ); + +extern void Font_put_line( FONTSELECT fs, int x, int y, const char *string ); +extern void Font_put_lineR2L( FONTSELECT fs, int x, int y, const char *string ); +extern W16 Font_put_character( FONTSELECT fs, int x, int y, W16 num ); + +extern void Font_put_paragraph( FONTSELECT fs, short x, short y, + const char *string, + int space_between_lines, + int line_width_in_pixel ); + +extern void Font_GetMsgDimensions( FONTSELECT fs, const char *string, int *w, int *h ); + +#endif /* __FONT_MANAGER_H__ */ diff --git a/wolf3d/newCode/env/glob.c b/wolf3d/newCode/env/glob.c new file mode 100644 index 0000000..02a68e1 --- /dev/null +++ b/wolf3d/newCode/env/glob.c @@ -0,0 +1,207 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + +/* Like glob_match, but match PATTERN against any final segment of TEXT. */ +static int glob_match_after_star( char *pattern, char *text ) +{ + register char *p = pattern, *t = text; + register char c, c1; + + while( (c = *p++) == '?' || c == '*' ) + { + if( c == '?' && *t++ == '\0' ) + { + return 0; + } + } + + if( c == '\0' ) + { + return 1; + } + + if( c == '\\' ) + { + c1 = *p; + } + else + { + c1 = c; + } + + while( 1 ) + { + if( (c == '[' || *t == c1) && glob_match( p - 1, t ) ) + { + return 1; + } + + if( *t++ == '\0' ) + { + return 0; + } + } +} + +/* Return nonzero if PATTERN has any special globbing chars in it. */ +static int glob_pattern_p( char *pattern ) +{ + register char *p = pattern; + register char c; + int open = 0; + + while( (c = *p++) != '\0' ) + { + switch( c ) + { + case '?': + case '*': + return 1; + + case '[': /* Only accept an open brace if there is a close */ + open++; /* brace to match it. Bracket expressions must be */ + continue; /* complete, according to Posix.2 */ + case ']': + if( open ) + { + return 1; + } + continue; + + case '\\': + if( *p++ == '\0' ) + { + return 0; + } + } + + } + + return 0; +} + +/* Match the pattern PATTERN against the string TEXT; + return 1 if it matches, 0 otherwise. + + A match means the entire string TEXT is used up in matching. + + In the pattern string, `*' matches any sequence of characters, + `?' matches any character, [SET] matches any character in the specified set, + [!SET] matches any character not in the specified set. + + A set is composed of characters or ranges; a range looks like + character hyphen character (as in 0-9 or A-Z). + [0-9a-zA-Z_] is the set of characters allowed in C identifiers. + Any other character in the pattern must be matched exactly. + + To suppress the special syntactic significance of any of `[]*?!-\', + and match the character exactly, precede it with a `\'. +*/ + +int glob_match(char *pattern, char *text) +{ + register char *p = pattern, *t = text; + register char c; + + while ((c = *p++) != '\0') + switch (c) { + case '?': + if (*t == '\0') + return 0; + else + ++t; + break; + + case '\\': + if (*p++ != *t++) + return 0; + break; + + case '*': + return glob_match_after_star(p, t); + + case '[': + { + register char c1 = *t++; + int invert; + + if (!c1) + return (0); + + invert = ((*p == '!') || (*p == '^')); + if (invert) + p++; + + c = *p++; + while (1) { + register char cstart = c, cend = c; + + if (c == '\\') { + cstart = *p++; + cend = cstart; + } + if (c == '\0') + return 0; + + c = *p++; + if (c == '-' && *p != ']') { + cend = *p++; + if (cend == '\\') + cend = *p++; + if (cend == '\0') + return 0; + c = *p++; + } + if (c1 >= cstart && c1 <= cend) + goto match; + if (c == ']') + break; + } + if (!invert) + return 0; + break; + + match: + /* Skip the rest of the [...] construct that already matched. */ + while (c != ']') { + if (c == '\0') + return 0; + c = *p++; + if (c == '\0') + return 0; + else if (c == '\\') + ++p; + } + if (invert) + return 0; + break; + } + + default: + if (c != *t++) + return 0; + } + + return *t == '\0'; +} + diff --git a/wolf3d/newCode/env/glob.h b/wolf3d/newCode/env/glob.h new file mode 100644 index 0000000..81f2c44 --- /dev/null +++ b/wolf3d/newCode/env/glob.h @@ -0,0 +1,22 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +extern int glob_match( char *pattern, char *text ); diff --git a/wolf3d/newCode/env/math.c b/wolf3d/newCode/env/math.c new file mode 100644 index 0000000..af0a7fb --- /dev/null +++ b/wolf3d/newCode/env/math.c @@ -0,0 +1,224 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * math.c: Math routines. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + + + + + +//////////////////////////// +// +// Square Root +// +//////////////////////////// + +/* +----------------------------------------------------------------------------- + Function: _sqrtf -Calculates the square root. + + Parameters: x -[in] Nonnegative floating-point value + + Returns: The square-root of x. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC float _sqrtf( float x ) +{ + return (float)sqrt( x ); +} + + +/* +----------------------------------------------------------------------------- + Function: _3DNow_Sqrt -Calculates the square root. + + Parameters: x -[in] Nonnegative floating-point value + + Returns: The square-root of x. + + Notes: 15-Bit Precision +----------------------------------------------------------------------------- +*/ +#if __i386__ + +PUBLIC float _3DNow_Sqrt( float x ) +{ + float root = 0.f; + +#if( _MSC_VER || __WATCOMC__ ) + + __asm + { + femms + movd mm0, x + pfrsqrt mm1, mm0 + punpckldq mm0, mm0 + pfmul mm0, mm1 + movd root, mm0 + femms + } + +#endif + + return root; +} + +/* +----------------------------------------------------------------------------- + Function: _SSE_Sqrt -Calculates the square root. + + Parameters: x -[in] Nonnegative floating-point value + + Returns: The square-root of x. + + Notes: +----------------------------------------------------------------------------- +*/ +float _SSE_Sqrt( float x ) +{ + float root = 0.f; + +#if( _MSC_VER || __WATCOMC__ ) + + __asm + { + sqrtss xmm0, x + movss root, xmm0 + } + + +#endif + + return root; +} + +#endif /* __i386__ */ + +//////////////////////////// +// +// End Square Root +// +//////////////////////////// + + +float (*pfSqrt)( float x ) = _sqrtf; + + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC int my_log2( int val ) +{ + int answer = 0; + while( ( val >>= 1 ) != 0 ) + { + answer++; + } + return answer; +} + +/* +----------------------------------------------------------------------------- + Function: CalcFov -Calculate the field of view. + + Parameters:fov_x -[in] Must be within 1 and 179 degrees. + width -[in] Width of viewing area. + height -[in] Height of viewing area. + + Returns: The field of view in degrees. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC float CalcFov( float fov_x, float width, float height ) +{ + if( fov_x < 1 || fov_x > 179 ) + { + Com_Error( ERR_DROP, "Bad fov: %f", fov_x ); + } + + return (float)RAD2DEG( atan( height / ( width / tan( fov_x / 360 * M_PI ) ) ) ) * 2; +} + +/* +----------------------------------------------------------------------------- + Function: MathLib_Init -Initialize optimized math routines. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void MathLib_Init( void ) +{ + Com_Printf( "Initializing Math Module\n" ); + +#if 0//__i386__ + + if( main_cpu_s.b3DNow ) + { +// pfSqrt = _3DNow_Sqrt; + + Com_Printf( "...using 3DNow!\n" ); + } + + if( main_cpu_s.bSSE ) + { +// pfSqrt = _SSE_Sqrt; + + Com_Printf( "...using SSE\n" ); + } + +#endif +} + + + + diff --git a/wolf3d/newCode/env/matrix.c b/wolf3d/newCode/env/matrix.c new file mode 100644 index 0000000..8f8e47c --- /dev/null +++ b/wolf3d/newCode/env/matrix.c @@ -0,0 +1,158 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * matrix.c: Matrix math routines. + * + * Author: Michael Liebscher + * + */ + + +#include "../wolfiphone.h" + +/* +----------------------------------------------------------------------------- + Function: Matrix3x3Multiply -Computes the product of two 3x3 matrices. + + Parameters: in1, in2 -[in] 3x3 matrices. + out -[out] result. + + Returns: Nothing + + Notes: + Product of two 3x3 matrices + ( a b c ) ( r u x ) ( ar + bs + ct au + bv + cw ax + by + cz ) + ( d e f ) ( s v y ) = ( dr + es + ft du + ev + fw dx + ey + fz ) + ( h i j ) ( t w z ) ( hr + hs + ht iu + iv + iw jx + jy + jz ) +----------------------------------------------------------------------------- +*/ +PUBLIC void Matrix3x3Multiply( mat3_t in1, mat3_t in2, mat3_t out ) +{ + out[0] = in1[0] * in2[0] + in1[1] * in2[3] + in1[2] * in2[6]; + out[1] = in1[0] * in2[1] + in1[1] * in2[4] + in1[2] * in2[7]; + out[2] = in1[0] * in2[2] + in1[1] * in2[5] + in1[2] * in2[8]; + + out[3] = in1[3] * in2[0] + in1[4] * in2[3] + in1[5] * in2[6]; + out[4] = in1[3] * in2[1] + in1[4] * in2[4] + in1[5] * in2[7]; + out[5] = in1[3] * in2[2] + in1[4] * in2[5] + in1[5] * in2[8]; + + out[6] = in1[6] * in2[0] + in1[7] * in2[3] + in1[8] * in2[6]; + out[7] = in1[6] * in2[1] + in1[7] * in2[4] + in1[8] * in2[7]; + out[8] = in1[6] * in2[2] + in1[7] * in2[5] + in1[8] * in2[8]; +} + +/* +----------------------------------------------------------------------------- + Function: MatrixIdentity -Set matrix to the identity matrix (unit matrix). + + Parameters: matrix -[in/out] 4x4 matrix. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void MatrixIdentity( mat4_t matrix ) +{ + matrix[ 0] = 1.0; matrix[ 1] = 0.0; matrix[ 2] = 0.0; matrix[ 3] = 0.0; + matrix[ 4] = 0.0; matrix[ 5] = 1.0; matrix[ 6] = 0.0; matrix[ 7] = 0.0; + matrix[ 8] = 0.0; matrix[ 9] = 0.0; matrix[10] = 1.0; matrix[11] = 0.0; + matrix[12] = 0.0; matrix[13] = 0.0; matrix[14] = 0.0; matrix[15] = 1.0; +} + +/* +----------------------------------------------------------------------------- + Function: MatrixInvert -Invert a matrix. + + Parameters: + in -[in] Input matrix + out -[out] Output matrix. + + + Returns: Nothing. + + Notes: Matrix MUST be orthonormal + +----------------------------------------------------------------------------- +*/ +PUBLIC void MatrixInvert( mat4_t in, mat4_t out ) +{ + // Transpose rotation + out[ 0] = in[ 0]; out[ 1] = in[ 4]; out[ 2] = in[ 8]; + out[ 4] = in[ 1]; out[ 5] = in[ 5]; out[ 6] = in[ 9]; + out[ 8] = in[ 2]; out[ 9] = in[ 6]; out[10] = in[10]; + + // Clear shearing terms + out[3] = 0.0f; out[7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; + + // Translation is minus the dot of translation and rotations + out[12] = -(in[12] * in[ 0]) - (in[13] * in[ 1]) - (in[14] * in[ 2]); + out[13] = -(in[12] * in[ 4]) - (in[13] * in[ 5]) - (in[14] * in[ 6]); + out[14] = -(in[12] * in[ 8]) - (in[13] * in[ 9]) - (in[14] * in[10]); +} + +/* +----------------------------------------------------------------------------- + Function: VectorMatrixMultiply -Multiply a vector by a matrix. + + Parameters: + vecIn -[in] Input vector. + m -[in] Input matrix. + vecOut -[out] Output vector. + + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void VectorMatrixMultiply( vec3_t vecIn, mat4_t m, vec3_t vecOut ) +{ + vecOut[0] = (vecIn[0] * m[ 0]) + (vecIn[1] * m[ 4]) + (vecIn[2] * m[ 8]) + m[12]; + vecOut[1] = (vecIn[0] * m[ 1]) + (vecIn[1] * m[ 5]) + (vecIn[2] * m[ 9]) + m[13]; + vecOut[2] = (vecIn[0] * m[ 2]) + (vecIn[1] * m[ 6]) + (vecIn[2] * m[10]) + m[14]; +} + +/* +----------------------------------------------------------------------------- + Function: VectorMatrix3x3Multiply -Multiply a vector by just the 3x3 portion + of a matrix. + + Parameters: + in -[in] Input vector. + m -[in] Input matrix. + out -[out] Output vector. + + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void VectorMatrix3x3Multiply( vec3_t in, mat4_t m, vec3_t out ) +{ + out[0] = (in[0] * m[ 0]) + (in[1] * m[ 4]) + (in[2] * m[ 8]); + out[1] = (in[0] * m[ 1]) + (in[1] * m[ 5]) + (in[2] * m[ 9]); + out[2] = (in[0] * m[ 2]) + (in[1] * m[ 6]) + (in[2] * m[10]); +} + diff --git a/wolf3d/newCode/env/matrix.h b/wolf3d/newCode/env/matrix.h new file mode 100644 index 0000000..8245b25 --- /dev/null +++ b/wolf3d/newCode/env/matrix.h @@ -0,0 +1,43 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * matrix.h: Matrix math routines. + * + * Author: Michael Liebscher + * + */ + +#ifndef __MATRIX_H__ +#define __MATRIX_H__ + +#include "vector.h" + +typedef float mat3_t[ 9 ]; // 3x3 matrix +typedef float mat4_t[ 16 ]; // 4x4 matrix + +extern void Matrix3x3Multiply( mat3_t in1, mat3_t in2, mat3_t out ) ; +extern void MatrixIdentity( mat4_t matrix ); +extern void MatrixInvert( mat4_t in, mat4_t out ); +extern void VectorMatrixMultiply( vec3_t vecIn, mat4_t m, vec3_t vecOut ); +extern void VectorMatrix3x3Multiply( vec3_t vecIn, mat4_t m, vec3_t vecOut ); + + +#endif /* __MATRIX_H__ */ diff --git a/wolf3d/newCode/env/memory.c b/wolf3d/newCode/env/memory.c new file mode 100644 index 0000000..b8af11a --- /dev/null +++ b/wolf3d/newCode/env/memory.c @@ -0,0 +1,193 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * memory.c: Memory allocation module. + * + * Author: Michael Liebscher + * + */ + +#include "../wolfiphone.h" + + + +#ifndef DEBUG_MEMORY + + #define DEBUG_MEMORY 0 + +#endif + + +/* +----------------------------------------------------------------------------- + Function: Memory_malloc -Allocates memory blocks. + + Parameters: size -[in] Bytes to allocate. + + Returns: + Void pointer to the allocated space on success, or NULL if + there is insufficient memory available. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void *Memory_malloc( size_t size ) +{ + void *ptr; + ptr = malloc( size ); + + if( ptr != NULL ) + { + +#if DEBUG_MEMORY + + Com_DPrintf( "[Memory_malloc]: %p size:%ld\n", ptr, size ); + +#endif + + return ptr; + } + + + Com_DPrintf( "[Memory_malloc]: Could not allocate %d bytes\n", size ); + + return NULL; +} + + +/* +----------------------------------------------------------------------------- + Function: Memory_calloc -Allocates an array in memory with elements + initialized to 0. + + Parameters: + num -[in] Number of elements. + size -[in] Bytes to allocate. + + Returns: + Void pointer to the allocated space on success, or NULL if + there is insufficient memory available. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void *Memory_calloc( size_t num, size_t size ) +{ + void *ptr; + ptr = calloc( num, size ); + + if( ptr != NULL ) + { + +#if DEBUG_MEMORY + + Com_DPrintf( "[Memory_calloc]: %p size:%ld num:%ld\n", ptr, size, num ); + +#endif + + return ptr; + } + + Com_DPrintf( "[Memory_calloc]: Could not allocate %d objects of size %d\n", num, size ); + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: Memory_realloc -Reallocate memory blocks. + + Parameters: + memblock -[in] Pointer to previously allocated memory block. + size -[in] Bytes to allocate. + + Returns: + A void pointer to the reallocated (and possibly moved) memory + block. The return value is NULL if the size is zero and the + buffer argument is not NULL, or if there is not enough + available memory to expand the block to the given size. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void *Memory_realloc( void *memblock, size_t size ) +{ + void *ptr; + + ptr = realloc( memblock, size ); + + if( ptr != NULL ) + { + +#if DEBUG_MEMORY + + Com_DPrintf( "[Memory_realloc]: %p size:%ld\n", ptr, size ); + +#endif + + return ptr; + } + + Com_DPrintf( "[Memory_realloc]: Could not reallocate %d bytes\n", size ); + + return NULL; +} + + +/* +----------------------------------------------------------------------------- + Function: Memory_free -Deallocates or frees a memory block. + + Parameters: + memblock -[in] Previously allocated memory block to be freed. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Memory_free( void *memblock ) +{ + if( memblock ) + { + +#if DEBUG_MEMORY + + Com_DPrintf( "[Memory_free]: %p\n", memblock ); + +#endif + + free( memblock ); + } +} + + +PUBLIC void Memory_outofmem( const char *name, const char *file, W32 line ) +{ + + Com_Error( ERR_FATAL, "%s:%ld failed allocation for \"%s\"\n", + file, line, name ); + +} diff --git a/wolf3d/newCode/env/memory.h b/wolf3d/newCode/env/memory.h new file mode 100644 index 0000000..861c8e1 --- /dev/null +++ b/wolf3d/newCode/env/memory.h @@ -0,0 +1,57 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * memory.h: Memory allocation manager. + * + * Author: Michael Liebscher + * + */ + +/* + Notes: + This module is implemented by memory.c. + +*/ + +#ifndef __MEMORY_H__ +#define __MEMORY_H__ + + +// Use the macros +extern void *Memory_malloc( size_t size ); +extern void *Memory_calloc( size_t num, size_t size ); +extern void *Memory_realloc( void *memblock, size_t size ); +extern void Memory_free( void *memblock ); + +extern void Memory_outofmem( const char *name, const char *file, W32 line ); + +#define MM_MALLOC( size ) Memory_malloc( (size) ) +#define MM_CALLOC( num, size ) Memory_calloc( (num), (size) ) +#define MM_REALLOC( memblock, size ) Memory_realloc( (memblock), (size) ) + +#define MM_FREE( memblock ) { Memory_free( (memblock) ); ((memblock)) = NULL; } + +#define MM_OUTOFMEM( name ) Memory_outofmem( (name), __FILE__, __LINE__ ) + + + + +#endif /* __MEMORY_H__ */ diff --git a/wolf3d/newCode/env/mymath.h b/wolf3d/newCode/env/mymath.h new file mode 100644 index 0000000..42507b4 --- /dev/null +++ b/wolf3d/newCode/env/mymath.h @@ -0,0 +1,95 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * mymath.h: Math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __MYMATH_H__ +#define __MYMATH_H__ + + + +typedef int fixed4_t; +typedef int fixed8_t; +typedef int fixed16_t; + + +#define PITCH 0 /* up / down */ +#define YAW 1 /* left / right */ +#define ROLL 2 /* fall over */ + + +#ifndef M_PI + + #define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h + +#endif + + + +#ifndef ABS + + #define ABS( x ) ( (x) < 0 ? -(x) : (x) ) + +#endif + + + +#define nanmask ( 255 << 23 ) + +#define IS_NAN( x ) ( ( (*(int *) &x ) & nanmask ) == nanmask ) + + + +/* Use RINT() instead of rint() */ +#ifdef __GNUC__ + + #define RINT( x ) rint( x ) + +#else + + #define RINT( x ) floor( (x) + 0.5 ) + +#endif + + + + +extern void MathLib_Init( void ); + +extern int my_log2( int val ); + +extern float (*pfSqrt)( float x ); + +extern float CalcFov( float fov_x, float width, float height ); + + + +#endif /* __MYMATH_H__ */ + diff --git a/wolf3d/newCode/env/myopengl.h b/wolf3d/newCode/env/myopengl.h new file mode 100644 index 0000000..83a9304 --- /dev/null +++ b/wolf3d/newCode/env/myopengl.h @@ -0,0 +1,872 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * MyOpenGL.h: OpenGL Interface + * + * Author: Michael Liebscher + * + */ + +/* + Notes: + + This module is implemented by opengl_win.c. + +*/ + +#ifndef __MYOPENGL_H__ +#define __MYOPENGL_H__ + +#ifdef _WIN32 + + #define WIN32_LEAN_AND_MEAN 1 + #include + +#endif + +#ifdef IPHONE +#include +#include +#else +#include +#endif + + +#ifdef __unix__ + + #include + +#endif + + +extern int OpenGL_Init( const char *dllname ); +extern void OpenGL_Shutdown( void ); + + + +#ifndef APIENTRY + + #define APIENTRY + +#endif + +#ifndef APIENTRYP + + #define APIENTRYP APIENTRY * + +#endif + + +typedef GLvoid ( APIENTRYP GLACCUM )(GLenum op, GLfloat value); +typedef GLvoid ( APIENTRYP GLALPHAFUNC )(GLenum func, GLclampf ref); +typedef GLboolean ( APIENTRYP GLARETEXTURESRESIDENT )(GLsizei n, const GLuint *textures, GLboolean *residences); +typedef GLvoid ( APIENTRYP GLARRAYELEMENT )(GLint i); +typedef GLvoid ( APIENTRYP GLBEGIN )(GLenum mode); +typedef GLvoid ( APIENTRYP GLBINDTEXTURE )(GLenum target, GLuint texture); +typedef GLvoid ( APIENTRYP GLBITMAP )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +typedef GLvoid ( APIENTRYP GLBLENDFUNC )(GLenum sfactor, GLenum dfactor); +typedef GLvoid ( APIENTRYP GLCALLLIST )(GLuint list); +typedef GLvoid ( APIENTRYP GLCALLLISTS )(GLsizei n, GLenum type, const GLvoid *lists); +typedef GLvoid ( APIENTRYP GLCLEAR )(GLbitfield mask); +typedef GLvoid ( APIENTRYP GLCLEARACCUM )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef GLvoid ( APIENTRYP GLCLEARCOLOR )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef GLvoid ( APIENTRYP GLCLEARDEPTH )(GLclampd depth); +typedef GLvoid ( APIENTRYP GLCLEARINDEX )(GLfloat c); +typedef GLvoid ( APIENTRYP GLCLEARSTENCIL )(GLint s); +typedef GLvoid ( APIENTRYP GLCLIPPLANE )(GLenum plane, const GLdouble *equation); +typedef GLvoid ( APIENTRYP GLCOLOR3B )(GLbyte red, GLbyte green, GLbyte blue); +typedef GLvoid ( APIENTRYP GLCOLOR3BV )(const GLbyte *v); +typedef GLvoid ( APIENTRYP GLCOLOR3D )(GLdouble red, GLdouble green, GLdouble blue); +typedef GLvoid ( APIENTRYP GLCOLOR3DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLCOLOR3F )(GLfloat red, GLfloat green, GLfloat blue); +typedef GLvoid ( APIENTRYP GLCOLOR3FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLCOLOR3I )(GLint red, GLint green, GLint blue); +typedef GLvoid ( APIENTRYP GLCOLOR3IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLCOLOR3S )(GLshort red, GLshort green, GLshort blue); +typedef GLvoid ( APIENTRYP GLCOLOR3SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLCOLOR3UB )(GLubyte red, GLubyte green, GLubyte blue); +typedef GLvoid ( APIENTRYP GLCOLOR3UBV )(const GLubyte *v); +typedef GLvoid ( APIENTRYP GLCOLOR3UI )(GLuint red, GLuint green, GLuint blue); +typedef GLvoid ( APIENTRYP GLCOLOR3UIV )(const GLuint *v); +typedef GLvoid ( APIENTRYP GLCOLOR3US )(GLushort red, GLushort green, GLushort blue); +typedef GLvoid ( APIENTRYP GLCOLOR3USV )(const GLushort *v); +typedef GLvoid ( APIENTRYP GLCOLOR4B )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4BV )(const GLbyte *v); +typedef GLvoid ( APIENTRYP GLCOLOR4D )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLCOLOR4F )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLCOLOR4I )(GLint red, GLint green, GLint blue, GLint alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLCOLOR4S )(GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLCOLOR4UB )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4UBV )(const GLubyte *v); +typedef GLvoid ( APIENTRYP GLCOLOR4UI )(GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4UIV )(const GLuint *v); +typedef GLvoid ( APIENTRYP GLCOLOR4US )(GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef GLvoid ( APIENTRYP GLCOLOR4USV )(const GLushort *v); +typedef GLvoid ( APIENTRYP GLCOLORMASK )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef GLvoid ( APIENTRYP GLCOLORMATERIAL )(GLenum face, GLenum mode); +typedef GLvoid ( APIENTRYP GLCOLORPOINTER )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLCOPYPIXELS )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef GLvoid ( APIENTRYP GLCOPYTEXIMAGE1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +typedef GLvoid ( APIENTRYP GLCOPYTEXIMAGE2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef GLvoid ( APIENTRYP GLCOPYTEXSUBIMAGE1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef GLvoid ( APIENTRYP GLCOPYTEXSUBIMAGE2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLvoid ( APIENTRYP GLCULLFACE )(GLenum mode); +typedef GLvoid ( APIENTRYP GLDELETELISTS )(GLuint list, GLsizei range); +typedef GLvoid ( APIENTRYP GLDELETETEXTURES )(GLsizei n, const GLuint *textures); +typedef GLvoid ( APIENTRYP GLDEPTHFUNC )(GLenum func); +typedef GLvoid ( APIENTRYP GLDEPTHMASK )(GLboolean flag); +typedef GLvoid ( APIENTRYP GLDEPTHRANGE )(GLclampd zNear, GLclampd zFar); +typedef GLvoid ( APIENTRYP GLDISABLE )(GLenum cap); +typedef GLvoid ( APIENTRYP GLDISABLECLIENTSTATE )(GLenum array); +typedef GLvoid ( APIENTRYP GLDRAWARRAYS )(GLenum mode, GLint first, GLsizei count); +typedef GLvoid ( APIENTRYP GLDRAWBUFFER )(GLenum mode); +typedef GLvoid ( APIENTRYP GLDRAWELEMENTS )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef GLvoid ( APIENTRYP GLDRAWPIXELS )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLEDGEFLAG )(GLboolean flag); +typedef GLvoid ( APIENTRYP GLEDGEFLAGPOINTER )(GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLEDGEFLAGV )(const GLboolean *flag); +typedef GLvoid ( APIENTRYP GLENABLE )(GLenum cap); +typedef GLvoid ( APIENTRYP GLENABLECLIENTSTATE )(GLenum array); +typedef GLvoid ( APIENTRYP GLEND )(void); +typedef GLvoid ( APIENTRYP GLENDLIST )(void); +typedef GLvoid ( APIENTRYP GLEVALCOORD1D )(GLdouble u); +typedef GLvoid ( APIENTRYP GLEVALCOORD1DV )(const GLdouble *u); +typedef GLvoid ( APIENTRYP GLEVALCOORD1F )(GLfloat u); +typedef GLvoid ( APIENTRYP GLEVALCOORD1FV )(const GLfloat *u); +typedef GLvoid ( APIENTRYP GLEVALCOORD2D )(GLdouble u, GLdouble v); +typedef GLvoid ( APIENTRYP GLEVALCOORD2DV )(const GLdouble *u); +typedef GLvoid ( APIENTRYP GLEVALCOORD2F )(GLfloat u, GLfloat v); +typedef GLvoid ( APIENTRYP GLEVALCOORD2FV )(const GLfloat *u); +typedef GLvoid ( APIENTRYP GLEVALMESH1 )(GLenum mode, GLint i1, GLint i2); +typedef GLvoid ( APIENTRYP GLEVALMESH2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef GLvoid ( APIENTRYP GLEVALPOINT1 )(GLint i); +typedef GLvoid ( APIENTRYP GLEVALPOINT2 )(GLint i, GLint j); +typedef GLvoid ( APIENTRYP GLFEEDBACKBUFFER )(GLsizei size, GLenum type, GLfloat *buffer); +typedef GLvoid ( APIENTRYP GLFINISH )(void); +typedef GLvoid ( APIENTRYP GLFLUSH )(void); +typedef GLvoid ( APIENTRYP GLFOGF )(GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLFOGFV )(GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLFOGI )(GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLFOGIV )(GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLFRONTFACE )(GLenum mode); +typedef GLvoid ( APIENTRYP GLFRUSTUM )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef GLuint ( APIENTRYP GLGENLISTS )(GLsizei range); +typedef GLvoid ( APIENTRYP GLGENTEXTURES )(GLsizei n, GLuint *textures); +typedef GLvoid ( APIENTRYP GLGETBOOLEANV )(GLenum pname, GLboolean *params); +typedef GLvoid ( APIENTRYP GLGETCLIPPLANE )(GLenum plane, GLdouble *equation); +typedef GLvoid ( APIENTRYP GLGETDOUBLEV )(GLenum pname, GLdouble *params); +typedef GLenum ( APIENTRYP GLGETERROR )(void); +typedef GLvoid ( APIENTRYP GLGETFLOATV )(GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETINTEGERV )(GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLGETLIGHTFV )(GLenum light, GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETLIGHTIV )(GLenum light, GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLGETMAPDV )(GLenum target, GLenum query, GLdouble *v); +typedef GLvoid ( APIENTRYP GLGETMAPFV )(GLenum target, GLenum query, GLfloat *v); +typedef GLvoid ( APIENTRYP GLGETMAPIV )(GLenum target, GLenum query, GLint *v); +typedef GLvoid ( APIENTRYP GLGETMATERIALFV )(GLenum face, GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETMATERIALIV )(GLenum face, GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLGETPIXELMAPFV )(GLenum map, GLfloat *values); +typedef GLvoid ( APIENTRYP GLGETPIXELMAPUIV )(GLenum map, GLuint *values); +typedef GLvoid ( APIENTRYP GLGETPIXELMAPUSV )(GLenum map, GLushort *values); +typedef GLvoid ( APIENTRYP GLGETPOINTERV )(GLenum pname, GLvoid* *params); +typedef GLvoid ( APIENTRYP GLGETPOLYGONSTIPPLE )(GLubyte *mask); +typedef const GLubyte * ( APIENTRYP GLGETSTRING )(GLenum name); +typedef GLvoid ( APIENTRYP GLGETTEXENVFV )(GLenum target, GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETTEXENVIV )(GLenum target, GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLGETTEXGENDV )(GLenum coord, GLenum pname, GLdouble *params); +typedef GLvoid ( APIENTRYP GLGETTEXGENFV )(GLenum coord, GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETTEXGENIV )(GLenum coord, GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLGETTEXIMAGE )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLGETTEXPARAMETERFV )(GLenum target, GLenum pname, GLfloat *params); +typedef GLvoid ( APIENTRYP GLGETTEXPARAMETERIV )(GLenum target, GLenum pname, GLint *params); +typedef GLvoid ( APIENTRYP GLHINT )(GLenum target, GLenum mode); +typedef GLvoid ( APIENTRYP GLINDEXMASK )(GLuint mask); +typedef GLvoid ( APIENTRYP GLINDEXPOINTER )(GLenum type, GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLINDEXD )(GLdouble c); +typedef GLvoid ( APIENTRYP GLINDEXDV )(const GLdouble *c); +typedef GLvoid ( APIENTRYP GLINDEXF )(GLfloat c); +typedef GLvoid ( APIENTRYP GLINDEXFV )(const GLfloat *c); +typedef GLvoid ( APIENTRYP GLINDEXI )(GLint c); +typedef GLvoid ( APIENTRYP GLINDEXIV )(const GLint *c); +typedef GLvoid ( APIENTRYP GLINDEXS )(GLshort c); +typedef GLvoid ( APIENTRYP GLINDEXSV )(const GLshort *c); +typedef GLvoid ( APIENTRYP GLINDEXUB )(GLubyte c); +typedef GLvoid ( APIENTRYP GLINDEXUBV )(const GLubyte *c); +typedef GLvoid ( APIENTRYP GLINITNAMES )(void); +typedef GLvoid ( APIENTRYP GLINTERLEAVEDARRAYS )(GLenum format, GLsizei stride, const GLvoid *pointer); +typedef GLboolean ( APIENTRYP GLISENABLED )(GLenum cap); +typedef GLboolean ( APIENTRYP GLISLIST )(GLuint list); +typedef GLboolean ( APIENTRYP GLISTEXTURE )(GLuint texture); +typedef GLvoid ( APIENTRYP GLLIGHTMODELF )(GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLLIGHTMODELFV )(GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLLIGHTMODELI )(GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLLIGHTMODELIV )(GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLLIGHTF )(GLenum light, GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLLIGHTFV )(GLenum light, GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLLIGHTI )(GLenum light, GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLLIGHTIV )(GLenum light, GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLLINESTIPPLE )(GLint factor, GLushort pattern); +typedef GLvoid ( APIENTRYP GLLINEWIDTH )(GLfloat width); +typedef GLvoid ( APIENTRYP GLLISTBASE )(GLuint base); +typedef GLvoid ( APIENTRYP GLLOADIDENTITY )(void); +typedef GLvoid ( APIENTRYP GLLOADMATRIXD )(const GLdouble *m); +typedef GLvoid ( APIENTRYP GLLOADMATRIXF )(const GLfloat *m); +typedef GLvoid ( APIENTRYP GLLOADNAME )(GLuint name); +typedef GLvoid ( APIENTRYP GLLOGICOP )(GLenum opcode); +typedef GLvoid ( APIENTRYP GLMAP1D )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef GLvoid ( APIENTRYP GLMAP1F )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef GLvoid ( APIENTRYP GLMAP2D )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef GLvoid ( APIENTRYP GLMAP2F )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +typedef GLvoid ( APIENTRYP GLMAPGRID1D )(GLint un, GLdouble u1, GLdouble u2); +typedef GLvoid ( APIENTRYP GLMAPGRID1F )(GLint un, GLfloat u1, GLfloat u2); +typedef GLvoid ( APIENTRYP GLMAPGRID2D )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef GLvoid ( APIENTRYP GLMAPGRID2F )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef GLvoid ( APIENTRYP GLMATERIALF )(GLenum face, GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLMATERIALFV )(GLenum face, GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLMATERIALI )(GLenum face, GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLMATERIALIV )(GLenum face, GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLMATRIXMODE )(GLenum mode); +typedef GLvoid ( APIENTRYP GLMULTMATRIXD )(const GLdouble *m); +typedef GLvoid ( APIENTRYP GLMULTMATRIXF )(const GLfloat *m); +typedef GLvoid ( APIENTRYP GLNEWLIST )(GLuint list, GLenum mode); +typedef GLvoid ( APIENTRYP GLNORMAL3B )(GLbyte nx, GLbyte ny, GLbyte nz); +typedef GLvoid ( APIENTRYP GLNORMAL3BV )(const GLbyte *v); +typedef GLvoid ( APIENTRYP GLNORMAL3D )(GLdouble nx, GLdouble ny, GLdouble nz); +typedef GLvoid ( APIENTRYP GLNORMAL3DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLNORMAL3F )(GLfloat nx, GLfloat ny, GLfloat nz); +typedef GLvoid ( APIENTRYP GLNORMAL3FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLNORMAL3I )(GLint nx, GLint ny, GLint nz); +typedef GLvoid ( APIENTRYP GLNORMAL3IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLNORMAL3S )(GLshort nx, GLshort ny, GLshort nz); +typedef GLvoid ( APIENTRYP GLNORMAL3SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLNORMALPOINTER )(GLenum type, GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLORTHO )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef GLvoid ( APIENTRYP GLPASSTHROUGH )(GLfloat token); +typedef GLvoid ( APIENTRYP GLPIXELMAPFV )(GLenum map, GLsizei mapsize, const GLfloat *values); +typedef GLvoid ( APIENTRYP GLPIXELMAPUIV )(GLenum map, GLsizei mapsize, const GLuint *values); +typedef GLvoid ( APIENTRYP GLPIXELMAPUSV )(GLenum map, GLsizei mapsize, const GLushort *values); +typedef GLvoid ( APIENTRYP GLPIXELSTOREF )(GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLPIXELSTOREI )(GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLPIXELTRANSFERF )(GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLPIXELTRANSFERI )(GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLPIXELZOOM )(GLfloat xfactor, GLfloat yfactor); +typedef GLvoid ( APIENTRYP GLPOINTSIZE )(GLfloat size); +typedef GLvoid ( APIENTRYP GLPOLYGONMODE )(GLenum face, GLenum mode); +typedef GLvoid ( APIENTRYP GLPOLYGONOFFSET )(GLfloat factor, GLfloat units); +typedef GLvoid ( APIENTRYP GLPOLYGONSTIPPLE )(const GLubyte *mask); +typedef GLvoid ( APIENTRYP GLPOPATTRIB )(void); +typedef GLvoid ( APIENTRYP GLPOPCLIENTATTRIB )(void); +typedef GLvoid ( APIENTRYP GLPOPMATRIX )(void); +typedef GLvoid ( APIENTRYP GLPOPNAME )(void); +typedef GLvoid ( APIENTRYP GLPRIORITIZETEXTURES )(GLsizei n, const GLuint *textures, const GLclampf *priorities); +typedef GLvoid ( APIENTRYP GLPUSHATTRIB )(GLbitfield mask); +typedef GLvoid ( APIENTRYP GLPUSHCLIENTATTRIB )(GLbitfield mask); +typedef GLvoid ( APIENTRYP GLPUSHMATRIX )(void); +typedef GLvoid ( APIENTRYP GLPUSHNAME )(GLuint name); +typedef GLvoid ( APIENTRYP GLRASTERPOS2D )(GLdouble x, GLdouble y); +typedef GLvoid ( APIENTRYP GLRASTERPOS2DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS2F )(GLfloat x, GLfloat y); +typedef GLvoid ( APIENTRYP GLRASTERPOS2FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS2I )(GLint x, GLint y); +typedef GLvoid ( APIENTRYP GLRASTERPOS2IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS2S )(GLshort x, GLshort y); +typedef GLvoid ( APIENTRYP GLRASTERPOS2SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS3D )(GLdouble x, GLdouble y, GLdouble z); +typedef GLvoid ( APIENTRYP GLRASTERPOS3DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS3F )(GLfloat x, GLfloat y, GLfloat z); +typedef GLvoid ( APIENTRYP GLRASTERPOS3FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS3I )(GLint x, GLint y, GLint z); +typedef GLvoid ( APIENTRYP GLRASTERPOS3IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS3S )(GLshort x, GLshort y, GLshort z); +typedef GLvoid ( APIENTRYP GLRASTERPOS3SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS4D )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef GLvoid ( APIENTRYP GLRASTERPOS4DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS4F )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef GLvoid ( APIENTRYP GLRASTERPOS4FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS4I )(GLint x, GLint y, GLint z, GLint w); +typedef GLvoid ( APIENTRYP GLRASTERPOS4IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLRASTERPOS4S )(GLshort x, GLshort y, GLshort z, GLshort w); +typedef GLvoid ( APIENTRYP GLRASTERPOS4SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLREADBUFFER )(GLenum mode); +typedef GLvoid ( APIENTRYP GLREADPIXELS )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLRECTD )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef GLvoid ( APIENTRYP GLRECTDV )(const GLdouble *v1, const GLdouble *v2); +typedef GLvoid ( APIENTRYP GLRECTF )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef GLvoid ( APIENTRYP GLRECTFV )(const GLfloat *v1, const GLfloat *v2); +typedef GLvoid ( APIENTRYP GLRECTI )(GLint x1, GLint y1, GLint x2, GLint y2); +typedef GLvoid ( APIENTRYP GLRECTIV )(const GLint *v1, const GLint *v2); +typedef GLvoid ( APIENTRYP GLRECTS )(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef GLvoid ( APIENTRYP GLRECTSV )(const GLshort *v1, const GLshort *v2); +typedef GLint ( APIENTRYP GLRENDERMODE )(GLenum mode); +typedef GLvoid ( APIENTRYP GLROTATED )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef GLvoid ( APIENTRYP GLROTATEF )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef GLvoid ( APIENTRYP GLSCALED )(GLdouble x, GLdouble y, GLdouble z); +typedef GLvoid ( APIENTRYP GLSCALEF )(GLfloat x, GLfloat y, GLfloat z); +typedef GLvoid ( APIENTRYP GLSCISSOR )(GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLvoid ( APIENTRYP GLSELECTBUFFER )(GLsizei size, GLuint *buffer); +typedef GLvoid ( APIENTRYP GLSHADEMODEL )(GLenum mode); +typedef GLvoid ( APIENTRYP GLSTENCILFUNC )(GLenum func, GLint ref, GLuint mask); +typedef GLvoid ( APIENTRYP GLSTENCILMASK )(GLuint mask); +typedef GLvoid ( APIENTRYP GLSTENCILOP )(GLenum fail, GLenum zfail, GLenum zpass); +typedef GLvoid ( APIENTRYP GLTEXCOORD1D )(GLdouble s); +typedef GLvoid ( APIENTRYP GLTEXCOORD1DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD1F )(GLfloat s); +typedef GLvoid ( APIENTRYP GLTEXCOORD1FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD1I )(GLint s); +typedef GLvoid ( APIENTRYP GLTEXCOORD1IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD1S )(GLshort s); +typedef GLvoid ( APIENTRYP GLTEXCOORD1SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD2D )(GLdouble s, GLdouble t); +typedef GLvoid ( APIENTRYP GLTEXCOORD2DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD2F )(GLfloat s, GLfloat t); +typedef GLvoid ( APIENTRYP GLTEXCOORD2FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD2I )(GLint s, GLint t); +typedef GLvoid ( APIENTRYP GLTEXCOORD2IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD2S )(GLshort s, GLshort t); +typedef GLvoid ( APIENTRYP GLTEXCOORD2SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD3D )(GLdouble s, GLdouble t, GLdouble r); +typedef GLvoid ( APIENTRYP GLTEXCOORD3DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD3F )(GLfloat s, GLfloat t, GLfloat r); +typedef GLvoid ( APIENTRYP GLTEXCOORD3FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD3I )(GLint s, GLint t, GLint r); +typedef GLvoid ( APIENTRYP GLTEXCOORD3IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD3S )(GLshort s, GLshort t, GLshort r); +typedef GLvoid ( APIENTRYP GLTEXCOORD3SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD4D )(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef GLvoid ( APIENTRYP GLTEXCOORD4DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD4F )(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef GLvoid ( APIENTRYP GLTEXCOORD4FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD4I )(GLint s, GLint t, GLint r, GLint q); +typedef GLvoid ( APIENTRYP GLTEXCOORD4IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLTEXCOORD4S )(GLshort s, GLshort t, GLshort r, GLshort q); +typedef GLvoid ( APIENTRYP GLTEXCOORD4SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLTEXCOORDPOINTER )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLTEXENVF )(GLenum target, GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLTEXENVFV )(GLenum target, GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLTEXENVI )(GLenum target, GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLTEXENVIV )(GLenum target, GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLTEXGEND )(GLenum coord, GLenum pname, GLdouble param); +typedef GLvoid ( APIENTRYP GLTEXGENDV )(GLenum coord, GLenum pname, const GLdouble *params); +typedef GLvoid ( APIENTRYP GLTEXGENF )(GLenum coord, GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLTEXGENFV )(GLenum coord, GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLTEXGENI )(GLenum coord, GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLTEXGENIV )(GLenum coord, GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLTEXIMAGE1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLTEXIMAGE2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLTEXPARAMETERF )(GLenum target, GLenum pname, GLfloat param); +typedef GLvoid ( APIENTRYP GLTEXPARAMETERFV )(GLenum target, GLenum pname, const GLfloat *params); +typedef GLvoid ( APIENTRYP GLTEXPARAMETERI )(GLenum target, GLenum pname, GLint param); +typedef GLvoid ( APIENTRYP GLTEXPARAMETERIV )(GLenum target, GLenum pname, const GLint *params); +typedef GLvoid ( APIENTRYP GLTEXSUBIMAGE1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLTEXSUBIMAGE2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLvoid ( APIENTRYP GLTRANSLATED )(GLdouble x, GLdouble y, GLdouble z); +typedef GLvoid ( APIENTRYP GLTRANSLATEF )(GLfloat x, GLfloat y, GLfloat z); +typedef GLvoid ( APIENTRYP GLVERTEX2D )(GLdouble x, GLdouble y); +typedef GLvoid ( APIENTRYP GLVERTEX2DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLVERTEX2F )(GLfloat x, GLfloat y); +typedef GLvoid ( APIENTRYP GLVERTEX2FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLVERTEX2I )(GLint x, GLint y); +typedef GLvoid ( APIENTRYP GLVERTEX2IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLVERTEX2S )(GLshort x, GLshort y); +typedef GLvoid ( APIENTRYP GLVERTEX2SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLVERTEX3D )(GLdouble x, GLdouble y, GLdouble z); +typedef GLvoid ( APIENTRYP GLVERTEX3DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLVERTEX3F )(GLfloat x, GLfloat y, GLfloat z); +typedef GLvoid ( APIENTRYP GLVERTEX3FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLVERTEX3I )(GLint x, GLint y, GLint z); +typedef GLvoid ( APIENTRYP GLVERTEX3IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLVERTEX3S )(GLshort x, GLshort y, GLshort z); +typedef GLvoid ( APIENTRYP GLVERTEX3SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLVERTEX4D )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef GLvoid ( APIENTRYP GLVERTEX4DV )(const GLdouble *v); +typedef GLvoid ( APIENTRYP GLVERTEX4F )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef GLvoid ( APIENTRYP GLVERTEX4FV )(const GLfloat *v); +typedef GLvoid ( APIENTRYP GLVERTEX4I )(GLint x, GLint y, GLint z, GLint w); +typedef GLvoid ( APIENTRYP GLVERTEX4IV )(const GLint *v); +typedef GLvoid ( APIENTRYP GLVERTEX4S )(GLshort x, GLshort y, GLshort z, GLshort w); +typedef GLvoid ( APIENTRYP GLVERTEX4SV )(const GLshort *v); +typedef GLvoid ( APIENTRYP GLVERTEXPOINTER )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef GLvoid ( APIENTRYP GLVIEWPORT )(GLint x, GLint y, GLsizei width, GLsizei height); + + +//GLACCUM pfglAccum; +GLALPHAFUNC pfglAlphaFunc; +GLARETEXTURESRESIDENT pfglAreTexturesResident; +//GLARRAYELEMENT pfglArrayElement; +GLBEGIN pfglBegin; +GLBINDTEXTURE pfglBindTexture; +//GLBITMAP pfglBitmap; +GLBLENDFUNC pfglBlendFunc; +GLCALLLIST pfglCallList; +GLCALLLISTS pfglCallLists; +GLCLEAR pfglClear; +//GLCLEARACCUM pfglClearAccum; +GLCLEARCOLOR pfglClearColor; +GLCLEARDEPTH pfglClearDepth; +//GLCLEARINDEX pfglClearIndex; +//GLCLEARSTENCIL pfglClearStencil; +//GLCLIPPLANE pfglClipPlane; +GLCOLOR3B pfglColor3b; +GLCOLOR3BV pfglColor3bv; +GLCOLOR3D pfglColor3d; +GLCOLOR3DV pfglColor3dv; +GLCOLOR3F pfglColor3f; +GLCOLOR3FV pfglColor3fv; +GLCOLOR3I pfglColor3i; +GLCOLOR3IV pfglColor3iv; +GLCOLOR3S pfglColor3s; +GLCOLOR3SV pfglColor3sv; +GLCOLOR3UB pfglColor3ub; +GLCOLOR3UBV pfglColor3ubv; +GLCOLOR3UI pfglColor3ui; +GLCOLOR3UIV pfglColor3uiv; +GLCOLOR3US pfglColor3us; +GLCOLOR3USV pfglColor3usv; +GLCOLOR4B pfglColor4b; +GLCOLOR4BV pfglColor4bv; +GLCOLOR4D pfglColor4d; +GLCOLOR4DV pfglColor4dv; +GLCOLOR4F pfglColor4f; +GLCOLOR4FV pfglColor4fv; +GLCOLOR4I pfglColor4i; +GLCOLOR4IV pfglColor4iv; +GLCOLOR4S pfglColor4s; +GLCOLOR4SV pfglColor4sv; +GLCOLOR4UB pfglColor4ub; +GLCOLOR4UBV pfglColor4ubv; +GLCOLOR4UI pfglColor4ui; +GLCOLOR4UIV pfglColor4uiv; +GLCOLOR4US pfglColor4us; +GLCOLOR4USV pfglColor4usv; +GLCOLORMASK pfglColorMask; +GLCOLORMATERIAL pfglColorMaterial; +GLCOLORPOINTER pfglColorPointer; +GLCOPYPIXELS pfglCopyPixels; +GLCOPYTEXIMAGE1D pfglCopyTexImage1D; +GLCOPYTEXIMAGE2D pfglCopyTexImage2D; +GLCOPYTEXSUBIMAGE1D pfglCopyTexSubImage1D; +GLCOPYTEXSUBIMAGE2D pfglCopyTexSubImage2D; +GLCULLFACE pfglCullFace; +GLDELETELISTS pfglDeleteLists; +GLDELETETEXTURES pfglDeleteTextures; +GLDEPTHFUNC pfglDepthFunc; +GLDEPTHMASK pfglDepthMask; +GLDEPTHRANGE pfglDepthRange; +GLDISABLE pfglDisable; +GLDISABLECLIENTSTATE pfglDisableClientState; +GLDRAWARRAYS pfglDrawArrays; +GLDRAWBUFFER pfglDrawBuffer; +GLDRAWELEMENTS pfglDrawElements; +GLDRAWPIXELS pfglDrawPixels; +GLEDGEFLAG pfglEdgeFlag; +GLEDGEFLAGPOINTER pfglEdgeFlagPointer; +GLEDGEFLAGV pfglEdgeFlagv; +GLENABLE pfglEnable; +GLENABLECLIENTSTATE pfglEnableClientState; +GLEND pfglEnd; +GLENDLIST pfglEndList; +GLEVALCOORD1D pfglEvalCoord1d; +GLEVALCOORD1DV pfglEvalCoord1dv; +GLEVALCOORD1F pfglEvalCoord1f; +GLEVALCOORD1FV pfglEvalCoord1fv; +GLEVALCOORD2D pfglEvalCoord2d; +GLEVALCOORD2DV pfglEvalCoord2dv; +GLEVALCOORD2F pfglEvalCoord2f; +GLEVALCOORD2FV pfglEvalCoord2fv; +GLEVALMESH1 pfglEvalMesh1; +GLEVALMESH2 pfglEvalMesh2; +GLEVALPOINT1 pfglEvalPoint1; +GLEVALPOINT2 pfglEvalPoint2; +GLFEEDBACKBUFFER pfglFeedbackBuffer; +GLFINISH pfglFinish; +GLFLUSH pfglFlush; +GLFOGF pfglFogf; +GLFOGFV pfglFogfv; +GLFOGI pfglFogi; +GLFOGIV pfglFogiv; +GLFRONTFACE pfglFrontFace; +GLFRUSTUM pfglFrustum; +GLGENLISTS pfglGenLists; +GLGENTEXTURES pfglGenTextures; +GLGETBOOLEANV pfglGetBooleanv; +GLGETCLIPPLANE pfglGetClipPlane; +GLGETDOUBLEV pfglGetDoublev; +GLGETERROR pfglGetError; +GLGETFLOATV pfglGetFloatv; +GLGETINTEGERV pfglGetIntegerv; +GLGETLIGHTFV pfglGetLightfv; +GLGETLIGHTIV pfglGetLightiv; +GLGETMAPDV pfglGetMapdv; +GLGETMAPFV pfglGetMapfv; +GLGETMAPIV pfglGetMapiv; +GLGETMATERIALFV pfglGetMaterialfv; +GLGETMATERIALIV pfglGetMaterialiv; +GLGETPIXELMAPFV pfglGetPixelMapfv; +GLGETPIXELMAPUIV pfglGetPixelMapuiv; +GLGETPIXELMAPUSV pfglGetPixelMapusv; +GLGETPOINTERV pfglGetPointerv; +GLGETPOLYGONSTIPPLE pfglGetPolygonStipple; +GLGETSTRING pfglGetString; +GLGETTEXENVFV pfglGetTexEnvfv; +GLGETTEXENVIV pfglGetTexEnviv; +GLGETTEXGENDV pfglGetTexGendv; +GLGETTEXGENFV pfglGetTexGenfv; +GLGETTEXGENIV pfglGetTexGeniv; +GLGETTEXIMAGE pfglGetTexImage; +GLGETTEXPARAMETERFV pfglGetTexParameterfv; +GLGETTEXPARAMETERIV pfglGetTexParameteriv; +GLHINT pfglHint; +GLINDEXMASK pfglIndexMask; +GLINDEXPOINTER pfglIndexPointer; +GLINDEXD pfglIndexd; +GLINDEXDV pfglIndexdv; +GLINDEXF pfglIndexf; +GLINDEXFV pfglIndexfv; +GLINDEXI pfglIndexi; +GLINDEXIV pfglIndexiv; +GLINDEXS pfglIndexs; +GLINDEXSV pfglIndexsv; +GLINDEXUB pfglIndexub; +GLINDEXUBV pfglIndexubv; +GLINITNAMES pfglInitNames; +GLINTERLEAVEDARRAYS pfglInterleavedArrays; +GLISENABLED pfglIsEnabled; +GLISLIST pfglIsList; +GLISTEXTURE pfglIsTexture; +GLLIGHTMODELF pfglLightModelf; +GLLIGHTMODELFV pfglLightModelfv; +GLLIGHTMODELI pfglLightModeli; +GLLIGHTMODELIV pfglLightModeliv; +GLLIGHTF pfglLightf; +GLLIGHTFV pfglLightfv; +GLLIGHTI pfglLighti; +GLLIGHTIV pfglLightiv; +GLLINESTIPPLE pfglLineStipple; +GLLINEWIDTH pfglLineWidth; +GLLISTBASE pfglListBase; +GLLOADIDENTITY pfglLoadIdentity; +GLLOADMATRIXD pfglLoadMatrixd; +GLLOADMATRIXF pfglLoadMatrixf; +GLLOADNAME pfglLoadName; +GLLOGICOP pfglLogicOp; +GLMAP1D pfglMap1d; +GLMAP1F pfglMap1f; +GLMAP2D pfglMap2d; +GLMAP2F pfglMap2f; +GLMAPGRID1D pfglMapGrid1d; +GLMAPGRID1F pfglMapGrid1f; +GLMAPGRID2D pfglMapGrid2d; +GLMAPGRID2F pfglMapGrid2f; +GLMATERIALF pfglMaterialf; +GLMATERIALFV pfglMaterialfv; +GLMATERIALI pfglMateriali; +GLMATERIALIV pfglMaterialiv; +GLMATRIXMODE pfglMatrixMode; +GLMULTMATRIXD pfglMultMatrixd; +GLMULTMATRIXF pfglMultMatrixf; +GLNEWLIST pfglNewList; +GLNORMAL3B pfglNormal3b; +GLNORMAL3BV pfglNormal3bv; +GLNORMAL3D pfglNormal3d; +GLNORMAL3DV pfglNormal3dv; +GLNORMAL3F pfglNormal3f; +GLNORMAL3FV pfglNormal3fv; +GLNORMAL3I pfglNormal3i; +GLNORMAL3IV pfglNormal3iv; +GLNORMAL3S pfglNormal3s; +GLNORMAL3SV pfglNormal3sv; +GLNORMALPOINTER pfglNormalPointer; +GLORTHO pfglOrtho; +GLPASSTHROUGH pfglPassThrough; +GLPIXELMAPFV pfglPixelMapfv; +GLPIXELMAPUIV pfglPixelMapuiv; +GLPIXELMAPUSV pfglPixelMapusv; +GLPIXELSTOREF pfglPixelStoref; +GLPIXELSTOREI pfglPixelStorei; +GLPIXELTRANSFERF pfglPixelTransferf; +GLPIXELTRANSFERI pfglPixelTransferi; +GLPIXELZOOM pfglPixelZoom; +GLPOINTSIZE pfglPointSize; +GLPOLYGONMODE pfglPolygonMode; +GLPOLYGONOFFSET pfglPolygonOffset; +GLPOLYGONSTIPPLE pfglPolygonStipple; +GLPOPATTRIB pfglPopAttrib; +GLPOPCLIENTATTRIB pfglPopClientAttrib; +GLPOPMATRIX pfglPopMatrix; +GLPOPNAME pfglPopName; +GLPRIORITIZETEXTURES pfglPrioritizeTextures; +GLPUSHATTRIB pfglPushAttrib; +GLPUSHCLIENTATTRIB pfglPushClientAttrib; +GLPUSHMATRIX pfglPushMatrix; +GLPUSHNAME pfglPushName; +GLRASTERPOS2D pfglRasterPos2d; +GLRASTERPOS2DV pfglRasterPos2dv; +GLRASTERPOS2F pfglRasterPos2f; +GLRASTERPOS2FV pfglRasterPos2fv; +GLRASTERPOS2I pfglRasterPos2i; +GLRASTERPOS2IV pfglRasterPos2iv; +GLRASTERPOS2S pfglRasterPos2s; +GLRASTERPOS2SV pfglRasterPos2sv; +GLRASTERPOS3D pfglRasterPos3d; +GLRASTERPOS3DV pfglRasterPos3dv; +GLRASTERPOS3F pfglRasterPos3f; +GLRASTERPOS3FV pfglRasterPos3fv; +GLRASTERPOS3I pfglRasterPos3i; +GLRASTERPOS3IV pfglRasterPos3iv; +GLRASTERPOS3S pfglRasterPos3s; +GLRASTERPOS3SV pfglRasterPos3sv; +GLRASTERPOS4D pfglRasterPos4d; +GLRASTERPOS4DV pfglRasterPos4dv; +GLRASTERPOS4F pfglRasterPos4f; +GLRASTERPOS4FV pfglRasterPos4fv; +GLRASTERPOS4I pfglRasterPos4i; +GLRASTERPOS4IV pfglRasterPos4iv; +GLRASTERPOS4S pfglRasterPos4s; +GLRASTERPOS4SV pfglRasterPos4sv; +GLREADBUFFER pfglReadBuffer; +GLREADPIXELS pfglReadPixels; +GLRECTD pfglRectd; +GLRECTDV pfglRectdv; +GLRECTF pfglRectf; +GLRECTFV pfglRectfv; +GLRECTI pfglRecti; +GLRECTIV pfglRectiv; +GLRECTS pfglRects; +GLRECTSV pfglRectsv; +GLRENDERMODE pfglRenderMode; +GLROTATED pfglRotated; +GLROTATEF pfglRotatef; +GLSCALED pfglScaled; +GLSCALEF pfglScalef; +GLSCISSOR pfglScissor; +GLSELECTBUFFER pfglSelectBuffer; +GLSHADEMODEL pfglShadeModel; +GLSTENCILFUNC pfglStencilFunc; +GLSTENCILMASK pfglStencilMask; +GLSTENCILOP pfglStencilOp; +GLTEXCOORD1D pfglTexCoord1d; +GLTEXCOORD1DV pfglTexCoord1dv; +GLTEXCOORD1F pfglTexCoord1f; +GLTEXCOORD1FV pfglTexCoord1fv; +GLTEXCOORD1I pfglTexCoord1i; +GLTEXCOORD1IV pfglTexCoord1iv; +GLTEXCOORD1S pfglTexCoord1s; +GLTEXCOORD1SV pfglTexCoord1sv; +GLTEXCOORD2D pfglTexCoord2d; +GLTEXCOORD2DV pfglTexCoord2dv; +GLTEXCOORD2F pfglTexCoord2f; +GLTEXCOORD2FV pfglTexCoord2fv; +GLTEXCOORD2I pfglTexCoord2i; +GLTEXCOORD2IV pfglTexCoord2iv; +GLTEXCOORD2S pfglTexCoord2s; +GLTEXCOORD2SV pfglTexCoord2sv; +GLTEXCOORD3D pfglTexCoord3d; +GLTEXCOORD3DV pfglTexCoord3dv; +GLTEXCOORD3F pfglTexCoord3f; +GLTEXCOORD3FV pfglTexCoord3fv; +GLTEXCOORD3I pfglTexCoord3i; +GLTEXCOORD3IV pfglTexCoord3iv; +GLTEXCOORD3S pfglTexCoord3s; +GLTEXCOORD3SV pfglTexCoord3sv; +GLTEXCOORD4D pfglTexCoord4d; +GLTEXCOORD4DV pfglTexCoord4dv; +GLTEXCOORD4F pfglTexCoord4f; +GLTEXCOORD4FV pfglTexCoord4fv; +GLTEXCOORD4I pfglTexCoord4i; +GLTEXCOORD4IV pfglTexCoord4iv; +GLTEXCOORD4S pfglTexCoord4s; +GLTEXCOORD4SV pfglTexCoord4sv; +GLTEXCOORDPOINTER pfglTexCoordPointer; +GLTEXENVF pfglTexEnvf; +GLTEXENVFV pfglTexEnvfv; +GLTEXENVI pfglTexEnvi; +GLTEXENVIV pfglTexEnviv; +GLTEXGEND pfglTexGend; +GLTEXGENDV pfglTexGendv; +GLTEXGENF pfglTexGenf; +GLTEXGENFV pfglTexGenfv; +GLTEXGENI pfglTexGeni; +GLTEXGENIV pfglTexGeniv; +GLTEXIMAGE1D pfglTexImage1D; +GLTEXIMAGE2D pfglTexImage2D; +GLTEXPARAMETERF pfglTexParameterf; +GLTEXPARAMETERFV pfglTexParameterfv; +GLTEXPARAMETERI pfglTexParameteri; +GLTEXPARAMETERIV pfglTexParameteriv; +GLTEXSUBIMAGE1D pfglTexSubImage1D; +GLTEXSUBIMAGE2D pfglTexSubImage2D; +GLTRANSLATED pfglTranslated; +GLTRANSLATEF pfglTranslatef; +GLVERTEX2D pfglVertex2d; +GLVERTEX2DV pfglVertex2dv; +GLVERTEX2F pfglVertex2f; +GLVERTEX2FV pfglVertex2fv; +GLVERTEX2I pfglVertex2i; +GLVERTEX2IV pfglVertex2iv; +GLVERTEX2S pfglVertex2s; +GLVERTEX2SV pfglVertex2sv; +GLVERTEX3D pfglVertex3d; +GLVERTEX3DV pfglVertex3dv; +GLVERTEX3F pfglVertex3f; +GLVERTEX3FV pfglVertex3fv; +GLVERTEX3I pfglVertex3i; +GLVERTEX3IV pfglVertex3iv; +GLVERTEX3S pfglVertex3s; +GLVERTEX3SV pfglVertex3sv; +GLVERTEX4D pfglVertex4d; +GLVERTEX4DV pfglVertex4dv; +GLVERTEX4F pfglVertex4f; +GLVERTEX4FV pfglVertex4fv; +GLVERTEX4I pfglVertex4i; +GLVERTEX4IV pfglVertex4iv; +GLVERTEX4S pfglVertex4s; +GLVERTEX4SV pfglVertex4sv; +GLVERTEXPOINTER pfglVertexPointer; +GLVIEWPORT pfglViewport; + + + +#ifdef _WIN32 + + +typedef BOOL (WINAPI *WGLCOPYCONTEXT)(HGLRC, HGLRC, UINT); +typedef HGLRC (WINAPI *WGLCREATECONTEXT)(HDC); +typedef HGLRC (WINAPI *WGLCREATELAYERCONTEXT)(HDC, int); +typedef BOOL (WINAPI *WGLDELETECONTEXT)(HGLRC); +typedef BOOL (WINAPI *WGLDESCRIBELAYERPLANE)(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR); +typedef HGLRC (WINAPI *WGLGETCURRENTCONTEXT)(VOID); +typedef HDC (WINAPI *WGLGETCURRENTDC)(VOID); +typedef int (WINAPI *WGLGETLAYERPALETTEENTRIES)(HDC, int, int, int, COLORREF *); +typedef PROC (WINAPI *WGLGETPROCADDRESS)(LPCSTR); +typedef BOOL (WINAPI *WGLMAKECURRENT)(HDC, HGLRC); +typedef BOOL (WINAPI *WGLREALIZELAYERPALETTE)(HDC, int, BOOL); +typedef int (WINAPI *WGLSETLAYERPALETTEENTRIES)(HDC, int, int, int, CONST COLORREF *); +typedef BOOL (WINAPI *WGLSHARELISTS)(HGLRC, HGLRC); +typedef BOOL (WINAPI *WGLSWAPLAYERBUFFERS)(HDC, UINT); +typedef BOOL (WINAPI *WGLUSEFONTBITMAPS)(HDC, DWORD, DWORD, DWORD); +typedef BOOL (WINAPI *WGLUSEFONTOUTLINES)(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + + +WGLCOPYCONTEXT pfwglCopyContext; +WGLCREATECONTEXT pfwglCreateContext; +WGLCREATELAYERCONTEXT pfwglCreateLayerContext; +WGLDELETECONTEXT pfwglDeleteContext; +WGLDESCRIBELAYERPLANE pfwglDescribeLayerPlane; +WGLGETCURRENTCONTEXT pfwglGetCurrentContext; +WGLGETCURRENTDC pfwglGetCurrentDC; +WGLGETLAYERPALETTEENTRIES pfwglGetLayerPaletteEntries; +WGLGETPROCADDRESS pfwglGetProcAddress; +WGLMAKECURRENT pfwglMakeCurrent; +WGLREALIZELAYERPALETTE pfwglRealizeLayerPalette; +WGLSETLAYERPALETTEENTRIES pfwglSetLayerPaletteEntries; +WGLSHARELISTS pfwglShareLists; +WGLSWAPLAYERBUFFERS pfwglSwapLayerBuffers; +WGLUSEFONTBITMAPS pfwglUseFontBitmaps; +WGLUSEFONTOUTLINES pfwglUseFontOutlines; + + +typedef int ( WINAPI *WGLCHOOSEPIXELFORMAT )(HDC, CONST PIXELFORMATDESCRIPTOR *); +typedef int ( WINAPI *WGLDESCRIBEPIXELFORMAT) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); +typedef int ( WINAPI *WGLGETPIXELFORMAT)(HDC); +typedef BOOL ( WINAPI *WGLSETPIXELFORMAT)(HDC, int, CONST PIXELFORMATDESCRIPTOR *); +typedef BOOL ( WINAPI *WGLSWAPBUFFERS)(HDC); + + +WGLCHOOSEPIXELFORMAT pfwglChoosePixelFormat; +WGLDESCRIBEPIXELFORMAT pfwglDescribePixelFormat; +WGLGETPIXELFORMAT pfwglGetPixelFormat; +WGLSETPIXELFORMAT pfwglSetPixelFormat; +WGLSWAPBUFFERS pfwglSwapBuffers; + + + +typedef BOOL (WINAPI *WGLSWAPINTERVALEXT)( int ); +typedef int (WINAPI *WGLGETSWAPINTERVALEXT)( void ); + +WGLSWAPINTERVALEXT pfwglSwapIntervalEXT; +WGLGETSWAPINTERVALEXT pfwglGetSwapIntervalEXT; + + +void *(WINAPI *pfwglAllocateMemoryNV)( GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority ); +void *(WINAPI *pfwglFreeMemoryNV)( void *pointer ); + + + +#ifndef HPBUFFERARB + + DECLARE_HANDLE( HPBUFFERARB ); + +#endif + +HPBUFFERARB (WINAPI *pfwglCreatePbufferARB)( HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList ); +HDC (WINAPI *pfwglGetPbufferDCARB)( HPBUFFERARB hPbuffer ); +int (WINAPI *pfwglReleasePbufferDCARB)( HPBUFFERARB hPbuffer, HDC hDC ); +BOOL (WINAPI *pfwglDestroyPbufferARB)(HPBUFFERARB hPbuffer); +BOOL (WINAPI *pfwglQueryPbufferARB)( HPBUFFERARB hPbuffer, int iAttribute, int *piValue ); + + +BOOL (WINAPI *pfwglGetPixelFormatAttribivARB)( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL (WINAPI *pfwglGetPixelFormatAttribfvARB)( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL (WINAPI *pfwglChoosePixelFormatARB)( HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + + +#endif /* _WIN32 */ + +#ifdef __unix__ + +// Local function in dll +extern void *pfwglGetProcAddress( const char *symbol ); + + +void *(*pfwglAllocateMemoryNV)( GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority ); +void *(*pfwglFreeMemoryNV)( void *pointer ); + + +// GLX Functions +XVisualInfo * (*pfglXChooseVisual)( Display *dpy, int screen, int *attribList ); +void (*pfglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask ); +GLXContext (*pfglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct ); +GLXPixmap (*pfglXCreateGLXPixmap)( Display *dpy, XVisualInfo *vis, Pixmap pixmap ); +void (*pfglXDestroyContext)( Display *dpy, GLXContext ctx ); +void (*pfglXDestroyGLXPixmap)( Display *dpy, GLXPixmap pix ); +int (*pfglXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value ); +GLXContext (*pfglXGetCurrentContext)( void ); +GLXDrawable (*pfglXGetCurrentDrawable)( void ); +Bool (*pfglXIsDirect)( Display *dpy, GLXContext ctx ); +Bool (*pfglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx); +Bool (*pfglXQueryExtension)( Display *dpy, int *errorBase, int *eventBase ); +Bool (*pfglXQueryVersion)( Display *dpy, int *major, int *minor ); +void (*pfglXSwapBuffers)( Display *dpy, GLXDrawable drawable ); +void (*pfglXUseXFont)( Font font, int first, int count, int listBase ); +void (*pfglXWaitGL)( void ); +void (*pfglXWaitX)( void ); + +#endif /* __unix__ */ + + + + + +#endif /* __MYOPENGL_H__ */ diff --git a/wolf3d/newCode/env/myopengl_extension.h b/wolf3d/newCode/env/myopengl_extension.h new file mode 100644 index 0000000..79c26f3 --- /dev/null +++ b/wolf3d/newCode/env/myopengl_extension.h @@ -0,0 +1,716 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * myopengl_extension.h: Interface to OpenGL extensions. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + +/* + + Notes: + + This module is implemented by opengl_extenstion.c + +*/ + + +#ifndef __MYOPENGL_EXTENSION_H__ +#define __MYOPENGL_EXTENSION_H__ + + +#ifdef IPHONE +#include +#include +#else +#include +#include "GL/glext.h" +#endif + + +#ifndef APIENTRY + + #define APIENTRY + +#endif + +#ifndef APIENTRYP + + #define APIENTRYP APIENTRY * + +#endif + + + +/////////////////////////////////////////////////////////////////////////////// +// +// OpenGL Extensions +// +/////////////////////////////////////////////////////////////////////////////// + + +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 + +#ifdef __sgi +#define GL_SHARED_TEXTURE_PALETTE_EXT GL_TEXTURE_COLOR_TABLE_SGI +#else +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 + +#ifndef WGL_ARB_pixel_format + #define WGL_ARB_pixel_format 1 + #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 + #define WGL_DRAW_TO_WINDOW_ARB 0x2001 + #define WGL_DRAW_TO_BITMAP_ARB 0x2002 + #define WGL_ACCELERATION_ARB 0x2003 + #define WGL_NEED_PALETTE_ARB 0x2004 + #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 + #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 + #define WGL_SWAP_METHOD_ARB 0x2007 + #define WGL_NUMBER_OVERLAYS_ARB 0x2008 + #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 + #define WGL_TRANSPARENT_ARB 0x200A + #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 + #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 + #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 + #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A + #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B + #define WGL_SHARE_DEPTH_ARB 0x200C + #define WGL_SHARE_STENCIL_ARB 0x200D + #define WGL_SHARE_ACCUM_ARB 0x200E + #define WGL_SUPPORT_GDI_ARB 0x200F + #define WGL_SUPPORT_OPENGL_ARB 0x2010 + #define WGL_DOUBLE_BUFFER_ARB 0x2011 + #define WGL_STEREO_ARB 0x2012 + #define WGL_PIXEL_TYPE_ARB 0x2013 + #define WGL_COLOR_BITS_ARB 0x2014 + #define WGL_RED_BITS_ARB 0x2015 + #define WGL_RED_SHIFT_ARB 0x2016 + #define WGL_GREEN_BITS_ARB 0x2017 + #define WGL_GREEN_SHIFT_ARB 0x2018 + #define WGL_BLUE_BITS_ARB 0x2019 + #define WGL_BLUE_SHIFT_ARB 0x201A + #define WGL_ALPHA_BITS_ARB 0x201B + #define WGL_ALPHA_SHIFT_ARB 0x201C + #define WGL_ACCUM_BITS_ARB 0x201D + #define WGL_ACCUM_RED_BITS_ARB 0x201E + #define WGL_ACCUM_GREEN_BITS_ARB 0x201F + #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 + #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 + #define WGL_DEPTH_BITS_ARB 0x2022 + #define WGL_STENCIL_BITS_ARB 0x2023 + #define WGL_AUX_BUFFERS_ARB 0x2024 + + #define WGL_NO_ACCELERATION_ARB 0x2025 + #define WGL_GENERIC_ACCELERATION_ARB 0x2026 + #define WGL_FULL_ACCELERATION_ARB 0x2027 + + #define WGL_SWAP_EXCHANGE_ARB 0x2028 + #define WGL_SWAP_COPY_ARB 0x2029 + #define WGL_SWAP_UNDEFINED_ARB 0x202A + + #define WGL_TYPE_RGBA_ARB 0x202B + #define WGL_TYPE_COLORINDEX_ARB 0x202C +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pbuffer + #define WGL_ARB_pbuffer 1 + #define WGL_DRAW_TO_PBUFFER_ARB 0x202D + #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E + #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F + #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 + #define WGL_PBUFFER_LARGEST_ARB 0x2033 + #define WGL_PBUFFER_WIDTH_ARB 0x2034 + #define WGL_PBUFFER_HEIGHT_ARB 0x2035 + #define WGL_PBUFFER_LOST_ARB 0x2036 +#endif + + + + + + + + + + +/* + ----------------------- + ARB_MultiTexture + ----------------------- +*/ +void (APIENTRYP pfglActiveTextureARB) (GLenum); +void (APIENTRYP pfglClientActiveTextureARB) (GLenum); +void (APIENTRYP pfglMultiTexCoord1dARB) (GLenum, GLdouble); +void (APIENTRYP pfglMultiTexCoord1dvARB) (GLenum, const GLdouble *); +void (APIENTRYP pfglMultiTexCoord1fARB) (GLenum, GLfloat); +void (APIENTRYP pfglMultiTexCoord1fvARB) (GLenum, const GLfloat *); +void (APIENTRYP pfglMultiTexCoord1iARB) (GLenum, GLint); +void (APIENTRYP pfglMultiTexCoord1ivARB) (GLenum, const GLint *); +void (APIENTRYP pfglMultiTexCoord1sARB) (GLenum, GLshort); +void (APIENTRYP pfglMultiTexCoord1svARB) (GLenum, const GLshort *); +void (APIENTRYP pfglMultiTexCoord2dARB) (GLenum, GLdouble, GLdouble); +void (APIENTRYP pfglMultiTexCoord2dvARB) (GLenum, const GLdouble *); +void (APIENTRYP pfglMultiTexCoord2fARB) (GLenum, GLfloat, GLfloat); +void (APIENTRYP pfglMultiTexCoord2fvARB) (GLenum, const GLfloat *); +void (APIENTRYP pfglMultiTexCoord2iARB) (GLenum, GLint, GLint); +void (APIENTRYP pfglMultiTexCoord2ivARB) (GLenum, const GLint *); +void (APIENTRYP pfglMultiTexCoord2sARB) (GLenum, GLshort, GLshort); +void (APIENTRYP pfglMultiTexCoord2svARB) (GLenum, const GLshort *); +void (APIENTRYP pfglMultiTexCoord3dARB) (GLenum, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglMultiTexCoord3dvARB) (GLenum, const GLdouble *); +void (APIENTRYP pfglMultiTexCoord3fARB) (GLenum, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglMultiTexCoord3fvARB) (GLenum, const GLfloat *); +void (APIENTRYP pfglMultiTexCoord3iARB) (GLenum, GLint, GLint, GLint); +void (APIENTRYP pfglMultiTexCoord3ivARB) (GLenum, const GLint *); +void (APIENTRYP pfglMultiTexCoord3sARB) (GLenum, GLshort, GLshort, GLshort); +void (APIENTRYP pfglMultiTexCoord3svARB) (GLenum, const GLshort *); +void (APIENTRYP pfglMultiTexCoord4dARB) (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglMultiTexCoord4dvARB) (GLenum, const GLdouble *); +void (APIENTRYP pfglMultiTexCoord4fARB) (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglMultiTexCoord4fvARB) (GLenum, const GLfloat *); +void (APIENTRYP pfglMultiTexCoord4iARB) (GLenum, GLint, GLint, GLint, GLint); +void (APIENTRYP pfglMultiTexCoord4ivARB) (GLenum, const GLint *); +void (APIENTRYP pfglMultiTexCoord4sARB) (GLenum, GLshort, GLshort, GLshort, GLshort); +void (APIENTRYP pfglMultiTexCoord4svARB) (GLenum, const GLshort *); + + +/* + ----------------------- + ARB_TransposeMatrix + ----------------------- +*/ +void (APIENTRYP pfglLoadTransposeMatrixfARB) (const GLfloat *); +void (APIENTRYP pfglLoadTransposeMatrixdARB) (const GLdouble *); +void (APIENTRYP pfglMultTransposeMatrixfARB) (const GLfloat *); +void (APIENTRYP pfglMultTransposeMatrixdARB) (const GLdouble *); + + +/* + ----------------------- + ARB_MultiSample + ----------------------- +*/ +void (APIENTRYP pfglSampleCoverageARB) (GLclampf, GLboolean); + + +/* + ----------------------- + ARB_TextureCompression + ----------------------- +*/ +void (APIENTRYP pfglCompressedTexImage3DARB) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +void (APIENTRYP pfglCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +void (APIENTRYP pfglCompressedTexImage1DARB) (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +void (APIENTRYP pfglCompressedTexSubImage3DARB) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglCompressedTexSubImage2DARB) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglCompressedTexSubImage1DARB) (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglGetCompressedTexImageARB) (GLenum, GLint, GLvoid *); + + +/* + ----------------------- + ARB_PointParameters + ----------------------- +*/ +void (APIENTRYP pfglPointParameterfARB) (GLenum, GLfloat); +void (APIENTRYP pfglPointParameterfvARB) (GLenum, const GLfloat *); + + +/* + ----------------------- + ARB_VertexBlend + ----------------------- +*/ +void (APIENTRYP pfglWeightbvARB) (GLint, const GLbyte *); +void (APIENTRYP pfglWeightsvARB) (GLint, const GLshort *); +void (APIENTRYP pfglWeightivARB) (GLint, const GLint *); +void (APIENTRYP pfglWeightfvARB) (GLint, const GLfloat *); +void (APIENTRYP pfglWeightdvARB) (GLint, const GLdouble *); +void (APIENTRYP pfglWeightubvARB) (GLint, const GLubyte *); +void (APIENTRYP pfglWeightusvARB) (GLint, const GLushort *); +void (APIENTRYP pfglWeightuivARB) (GLint, const GLuint *); +void (APIENTRYP pfglWeightPointerARB) (GLint, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglVertexBlendARB) (GLint); + + +/* + ----------------------- + ARB_MatrixPalette + ----------------------- +*/ +void (APIENTRYP pfglCurrentPaletteMatrixARB) (GLint); +void (APIENTRYP pfglMatrixIndexubvARB) (GLint, const GLubyte *); +void (APIENTRYP pfglMatrixIndexusvARB) (GLint, const GLushort *); +void (APIENTRYP pfglMatrixIndexuivARB) (GLint, const GLuint *); +void (APIENTRYP pfglMatrixIndexPointerARB) (GLint, GLenum, GLsizei, const GLvoid *); + + +/* + ------------------------------ + ARB_VertexProgram + ------------------------------ +*/ +void (APIENTRYP pfglVertexAttrib1dARB) (GLuint, GLdouble); +void (APIENTRYP pfglVertexAttrib1dvARB) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib1fARB) (GLuint, GLfloat); +void (APIENTRYP pfglVertexAttrib1fvARB) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib1sARB) (GLuint, GLshort); +void (APIENTRYP pfglVertexAttrib1svARB) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib2dARB) (GLuint, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib2dvARB) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib2fARB) (GLuint, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib2fvARB) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib2sARB) (GLuint, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib2svARB) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib3dARB) (GLuint, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib3dvARB) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib3fARB) (GLuint, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib3fvARB) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib3sARB) (GLuint, GLshort, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib3svARB) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib4NbvARB) (GLuint, const GLbyte *); +void (APIENTRYP pfglVertexAttrib4NivARB) (GLuint, const GLint *); +void (APIENTRYP pfglVertexAttrib4NsvARB) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib4NubARB) (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +void (APIENTRYP pfglVertexAttrib4NubvARB) (GLuint, const GLubyte *); +void (APIENTRYP pfglVertexAttrib4NuivARB) (GLuint, const GLuint *); +void (APIENTRYP pfglVertexAttrib4NusvARB) (GLuint, const GLushort *); +void (APIENTRYP pfglVertexAttrib4bvARB) (GLuint, const GLbyte *); +void (APIENTRYP pfglVertexAttrib4dARB) (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib4dvARB) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib4fvARB) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib4ivARB) (GLuint, const GLint *); +void (APIENTRYP pfglVertexAttrib4sARB) (GLuint, GLshort, GLshort, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib4svARB) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib4ubvARB) (GLuint, const GLubyte *); +void (APIENTRYP pfglVertexAttrib4uivARB) (GLuint, const GLuint *); +void (APIENTRYP pfglVertexAttrib4usvARB) (GLuint, const GLushort *); +void (APIENTRYP pfglVertexAttribPointerARB) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +void (APIENTRYP pfglEnableVertexAttribArrayARB) (GLuint); +void (APIENTRYP pfglDisableVertexAttribArrayARB) (GLuint); +void (APIENTRYP pfglProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglBindProgramARB) (GLenum, GLuint); +void (APIENTRYP pfglDeleteProgramsARB) (GLsizei, const GLuint *); +void (APIENTRYP pfglGenProgramsARB) (GLsizei, GLuint *); +void (APIENTRYP pfglProgramEnvParameter4dARB) (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglProgramEnvParameter4dvARB) (GLenum, GLuint, const GLdouble *); +void (APIENTRYP pfglProgramEnvParameter4fARB) (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglProgramEnvParameter4fvARB) (GLenum, GLuint, const GLfloat *); +void (APIENTRYP pfglProgramLocalParameter4dARB) (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglProgramLocalParameter4dvARB) (GLenum, GLuint, const GLdouble *); +void (APIENTRYP pfglProgramLocalParameter4fARB) (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglProgramLocalParameter4fvARB) (GLenum, GLuint, const GLfloat *); +void (APIENTRYP pfglGetProgramEnvParameterdvARB) (GLenum, GLuint, GLdouble *); +void (APIENTRYP pfglGetProgramEnvParameterfvARB) (GLenum, GLuint, GLfloat *); +void (APIENTRYP pfglGetProgramLocalParameterdvARB) (GLenum, GLuint, GLdouble *); +void (APIENTRYP pfglGetProgramLocalParameterfvARB) (GLenum, GLuint, GLfloat *); +void (APIENTRYP pfglGetProgramivARB) (GLenum, GLenum, GLint *); +void (APIENTRYP pfglGetProgramStringARB) (GLenum, GLenum, GLvoid *); +void (APIENTRYP pfglGetVertexAttribdvARB) (GLuint, GLenum, GLdouble *); +void (APIENTRYP pfglGetVertexAttribfvARB) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetVertexAttribivARB) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetVertexAttribPointervARB) (GLuint, GLenum, GLvoid* *); +GLboolean (APIENTRYP pfglIsProgramARB) (GLuint); + + +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ + + +/* + ------------------------------ + ARB_VertexBufferObject + ------------------------------ +*/ +void (APIENTRYP pfglBindBufferARB) (GLenum, GLuint); +void (APIENTRYP pfglDeleteBuffersARB) (GLsizei, const GLuint *); +void (APIENTRYP pfglGenBuffersARB) (GLsizei, GLuint *); +GLboolean (APIENTRYP pfglIsBufferARB) (GLuint); +void (APIENTRYP pfglBufferDataARB) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +void (APIENTRYP pfglBufferSubDataARB) (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +void (APIENTRYP pfglGetBufferSubDataARB) (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLvoid* (APIENTRYP pfglMapBufferARB) (GLenum, GLenum); +GLboolean (APIENTRYP pfglUnmapBufferARB) (GLenum); +void (APIENTRYP pfglGetBufferParameterivARB) (GLenum, GLenum, GLint *); +void (APIENTRYP pfglGetBufferPointervARB) (GLenum, GLenum, GLvoid* *); + + +/* + ------------------------------ + ARB_OcclusionQuery + ------------------------------ +*/ +void (APIENTRYP pfglGenQueriesARB) (GLsizei, GLuint *); +void (APIENTRYP pfglDeleteQueriesARB) (GLsizei, const GLuint *); +GLboolean (APIENTRYP pfglIsQueryARB) (GLuint); +void (APIENTRYP pfglBeginQueryARB) (GLenum, GLuint); +void (APIENTRYP pfglEndQueryARB) (GLenum); +void (APIENTRYP pfglGetQueryivARB) (GLenum, GLenum, GLint *); +void (APIENTRYP pfglGetQueryObjectivARB) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetQueryObjectuivARB) (GLuint, GLenum, GLuint *); + + +/* + ------------------------------ + ARB_ShaderObjects + ------------------------------ +*/ +void (APIENTRYP pfglDeleteObjectARB) (GLhandleARB); +GLhandleARB (APIENTRYP pfglGetHandleARB) (GLenum); +void (APIENTRYP pfglDetachObjectARB) (GLhandleARB, GLhandleARB); +GLhandleARB (APIENTRYP pfglCreateShaderObjectARB) (GLenum); +void (APIENTRYP pfglShaderSourceARB) (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +void (APIENTRYP pfglCompileShaderARB) (GLhandleARB); +GLhandleARB (APIENTRYP pfglCreateProgramObjectARB) (void); +void (APIENTRYP pfglAttachObjectARB) (GLhandleARB, GLhandleARB); +void (APIENTRYP pfglLinkProgramARB) (GLhandleARB); +void (APIENTRYP pfglUseProgramObjectARB) (GLhandleARB); +void (APIENTRYP pfglValidateProgramARB) (GLhandleARB); +void (APIENTRYP pfglUniform1fARB) (GLint, GLfloat); +void (APIENTRYP pfglUniform2fARB) (GLint, GLfloat, GLfloat); +void (APIENTRYP pfglUniform3fARB) (GLint, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglUniform4fARB) (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglUniform1iARB) (GLint, GLint); +void (APIENTRYP pfglUniform2iARB) (GLint, GLint, GLint); +void (APIENTRYP pfglUniform3iARB) (GLint, GLint, GLint, GLint); +void (APIENTRYP pfglUniform4iARB) (GLint, GLint, GLint, GLint, GLint); +void (APIENTRYP pfglUniform1fvARB) (GLint, GLsizei, const GLfloat *); +void (APIENTRYP pfglUniform2fvARB) (GLint, GLsizei, const GLfloat *); +void (APIENTRYP pfglUniform3fvARB) (GLint, GLsizei, const GLfloat *); +void (APIENTRYP pfglUniform4fvARB) (GLint, GLsizei, const GLfloat *); +void (APIENTRYP pfglUniform1ivARB) (GLint, GLsizei, const GLint *); +void (APIENTRYP pfglUniform2ivARB) (GLint, GLsizei, const GLint *); +void (APIENTRYP pfglUniform3ivARB) (GLint, GLsizei, const GLint *); +void (APIENTRYP pfglUniform4ivARB) (GLint, GLsizei, const GLint *); +void (APIENTRYP pfglUniformMatrix2fvARB) (GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRYP pfglUniformMatrix3fvARB) (GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRYP pfglUniformMatrix4fvARB) (GLint, GLsizei, GLboolean, const GLfloat *); +void (APIENTRYP pfglGetObjectParameterfvARB) (GLhandleARB, GLenum, GLfloat *); +void (APIENTRYP pfglGetObjectParameterivARB) (GLhandleARB, GLenum, GLint *); +void (APIENTRYP pfglGetInfoLogARB) (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +void (APIENTRYP pfglGetAttachedObjectsARB) (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLint (APIENTRYP pfglGetUniformLocationARB) (GLhandleARB, const GLcharARB *); +void (APIENTRYP pfglGetActiveUniformARB) (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +void (APIENTRYP pfglGetUniformfvARB) (GLhandleARB, GLint, GLfloat *); +void (APIENTRYP pfglGetUniformivARB) (GLhandleARB, GLint, GLint *); +void (APIENTRYP pfglGetShaderSourceARB) (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); + + +/* + ------------------------------ + ARB_VertexShader + ------------------------------ +*/ +void (APIENTRYP pfglBindAttribLocationARB) (GLhandleARB, GLuint, const GLcharARB *); +void (APIENTRYP pfglGetActiveAttribARB) (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLint (APIENTRYP pfglGetAttribLocationARB) (GLhandleARB, const GLcharARB *); + + +/* + ----------------------- + EXT_BlendColor + ----------------------- +*/ +void (APIENTRYP pfglBlendColorEXT) (GLclampf, GLclampf, GLclampf, GLclampf); + + +/* + ------------------------- + EXT_CompiledVertexArray + ------------------------- +*/ +void ( APIENTRYP pfglLockArraysEXT) ( GLint, GLsizei ); +void ( APIENTRYP pfglUnlockArraysEXT) ( void ); + + +/* + ----------------------- + EXT_SecondaryColor + ----------------------- +*/ +void (APIENTRYP pfglSecondaryColor3bEXT) (GLbyte, GLbyte, GLbyte); +void (APIENTRYP pfglSecondaryColor3bvEXT) (const GLbyte *); +void (APIENTRYP pfglSecondaryColor3dEXT) (GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglSecondaryColor3dvEXT) (const GLdouble *); +void (APIENTRYP pfglSecondaryColor3fEXT) (GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglSecondaryColor3fvEXT) (const GLfloat *); +void (APIENTRYP pfglSecondaryColor3iEXT) (GLint, GLint, GLint); +void (APIENTRYP pfglSecondaryColor3ivEXT) (const GLint *); +void (APIENTRYP pfglSecondaryColor3sEXT) (GLshort, GLshort, GLshort); +void (APIENTRYP pfglSecondaryColor3svEXT) (const GLshort *); +void (APIENTRYP pfglSecondaryColor3ubEXT) (GLubyte, GLubyte, GLubyte); +void (APIENTRYP pfglSecondaryColor3ubvEXT) (const GLubyte *); +void (APIENTRYP pfglSecondaryColor3uiEXT) (GLuint, GLuint, GLuint); +void (APIENTRYP pfglSecondaryColor3uivEXT) (const GLuint *); +void (APIENTRYP pfglSecondaryColor3usEXT) (GLushort, GLushort, GLushort); +void (APIENTRYP pfglSecondaryColor3usvEXT) (const GLushort *); +void (APIENTRYP pfglSecondaryColorPointerEXT) (GLint, GLenum, GLsizei, const GLvoid *); + + +/* + ----------------------- + EXT_VertexShader + ----------------------- +*/ +void (APIENTRYP pfglBeginVertexShaderEXT) (void); +void (APIENTRYP pfglEndVertexShaderEXT) (void); +void (APIENTRYP pfglBindVertexShaderEXT) (GLuint); +GLuint (APIENTRYP pfglGenVertexShadersEXT) (GLuint); +void (APIENTRYP pfglDeleteVertexShaderEXT) (GLuint); +void (APIENTRYP pfglShaderOp1EXT) (GLenum, GLuint, GLuint); +void (APIENTRYP pfglShaderOp2EXT) (GLenum, GLuint, GLuint, GLuint); +void (APIENTRYP pfglShaderOp3EXT) (GLenum, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglSwizzleEXT) (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +void (APIENTRYP pfglWriteMaskEXT) (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +void (APIENTRYP pfglInsertComponentEXT) (GLuint, GLuint, GLuint); +void (APIENTRYP pfglExtractComponentEXT) (GLuint, GLuint, GLuint); +GLuint (APIENTRYP pfglGenSymbolsEXT) (GLenum, GLenum, GLenum, GLuint); +void (APIENTRYP pfglSetInvariantEXT) (GLuint, GLenum, const GLvoid *); +void (APIENTRYP pfglSetLocalConstantEXT) (GLuint, GLenum, const GLvoid *); +void (APIENTRYP pfglVariantbvEXT) (GLuint, const GLbyte *); +void (APIENTRYP pfglVariantsvEXT) (GLuint, const GLshort *); +void (APIENTRYP pfglVariantivEXT) (GLuint, const GLint *); +void (APIENTRYP pfglVariantfvEXT) (GLuint, const GLfloat *); +void (APIENTRYP pfglVariantdvEXT) (GLuint, const GLdouble *); +void (APIENTRYP pfglVariantubvEXT) (GLuint, const GLubyte *); +void (APIENTRYP pfglVariantusvEXT) (GLuint, const GLushort *); +void (APIENTRYP pfglVariantuivEXT) (GLuint, const GLuint *); +void (APIENTRYP pfglVariantPointerEXT) (GLuint, GLenum, GLuint, const GLvoid *); +void (APIENTRYP pfglEnableVariantClientStateEXT) (GLuint); +void (APIENTRYP pfglDisableVariantClientStateEXT) (GLuint); +GLuint (APIENTRYP pfglBindLightParameterEXT) (GLenum, GLenum); +GLuint (APIENTRYP pfglBindMaterialParameterEXT) (GLenum, GLenum); +GLuint (APIENTRYP pfglBindTexGenParameterEXT) (GLenum, GLenum, GLenum); +GLuint (APIENTRYP pfglBindTextureUnitParameterEXT) (GLenum, GLenum); +GLuint (APIENTRYP pfglBindParameterEXT) (GLenum); +GLboolean (APIENTRYP pfglIsVariantEnabledEXT) (GLuint, GLenum); +void (APIENTRYP pfglGetVariantBooleanvEXT) (GLuint, GLenum, GLboolean *); +void (APIENTRYP pfglGetVariantIntegervEXT) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetVariantFloatvEXT) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetVariantPointervEXT) (GLuint, GLenum, GLvoid* *); +void (APIENTRYP pfglGetInvariantBooleanvEXT) (GLuint, GLenum, GLboolean *); +void (APIENTRYP pfglGetInvariantIntegervEXT) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetInvariantFloatvEXT) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetLocalConstantBooleanvEXT) (GLuint, GLenum, GLboolean *); +void (APIENTRYP pfglGetLocalConstantIntegervEXT) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetLocalConstantFloatvEXT) (GLuint, GLenum, GLfloat *); + + +/* + ----------------------- + EXT_VertexWeighting + ----------------------- +*/ +void (APIENTRYP pfglVertexWeightfEXT) (GLfloat); +void (APIENTRYP pfglVertexWeightfvEXT) (const GLfloat *); +void (APIENTRYP pfglVertexWeightPointerEXT) (GLsizei, GLenum, GLsizei, const GLvoid *); + + + +////////////////////////////////// +// +// nVidia Extensions +// +////////////////////////////////// + + + +/* + ----------------------- + NV_Fence + ----------------------- +*/ +void (APIENTRYP pfglDeleteFencesNV) (GLsizei, const GLuint *); +void (APIENTRYP pfglGenFencesNV) (GLsizei, GLuint *); +GLboolean (APIENTRYP pfglIsFenceNV) (GLuint); +GLboolean (APIENTRYP pfglTestFenceNV) (GLuint); +void (APIENTRYP pfglGetFenceivNV) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglFinishFenceNV) (GLuint); +void (APIENTRYP pfglSetFenceNV) (GLuint, GLenum); + + +/* + ----------------------- + NV_VertexArrayRange + ----------------------- +*/ +void (APIENTRYP pfglFlushVertexArrayRangeNV) (void); +void (APIENTRYP pfglVertexArrayRangeNV) (GLsizei, const GLvoid *); + + +/* + ----------------------- + NV_VertexProgram + ----------------------- +*/ +GLboolean (APIENTRYP pfglAreProgramsResidentNV) (GLsizei, const GLuint *, GLboolean *); +void (APIENTRYP pfglBindProgramNV) (GLenum, GLuint); +void (APIENTRYP pfglDeleteProgramsNV) (GLsizei, const GLuint *); +void (APIENTRYP pfglExecuteProgramNV) (GLenum, GLuint, const GLfloat *); +void (APIENTRYP pfglGenProgramsNV) (GLsizei, GLuint *); +void (APIENTRYP pfglGetProgramParameterdvNV) (GLenum, GLuint, GLenum, GLdouble *); +void (APIENTRYP pfglGetProgramParameterfvNV) (GLenum, GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetProgramivNV) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetProgramStringNV) (GLuint, GLenum, GLubyte *); +void (APIENTRYP pfglGetTrackMatrixivNV) (GLenum, GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetVertexAttribdvNV) (GLuint, GLenum, GLdouble *); +void (APIENTRYP pfglGetVertexAttribfvNV) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetVertexAttribivNV) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglGetVertexAttribPointervNV) (GLuint, GLenum, GLvoid* *); +GLboolean (APIENTRYP pfglIsProgramNV) (GLuint); +void (APIENTRYP pfglLoadProgramNV) (GLenum, GLuint, GLsizei, const GLubyte *); +void (APIENTRYP pfglProgramParameter4dNV) (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglProgramParameter4dvNV) (GLenum, GLuint, const GLdouble *); +void (APIENTRYP pfglProgramParameter4fNV) (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglProgramParameter4fvNV) (GLenum, GLuint, const GLfloat *); +void (APIENTRYP pfglProgramParameters4dvNV) (GLenum, GLuint, GLuint, const GLdouble *); +void (APIENTRYP pfglProgramParameters4fvNV) (GLenum, GLuint, GLuint, const GLfloat *); +void (APIENTRYP pfglRequestResidentProgramsNV) (GLsizei, const GLuint *); +void (APIENTRYP pfglTrackMatrixNV) (GLenum, GLuint, GLenum, GLenum); +void (APIENTRYP pfglVertexAttribPointerNV) (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +void (APIENTRYP pfglVertexAttrib1dNV) (GLuint, GLdouble); +void (APIENTRYP pfglVertexAttrib1dvNV) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib1fNV) (GLuint, GLfloat); +void (APIENTRYP pfglVertexAttrib1fvNV) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib1sNV) (GLuint, GLshort); +void (APIENTRYP pfglVertexAttrib1svNV) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib2dNV) (GLuint, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib2dvNV) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib2fNV) (GLuint, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib2fvNV) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib2sNV) (GLuint, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib2svNV) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib3dNV) (GLuint, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib3dvNV) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib3fNV) (GLuint, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib3fvNV) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib3sNV) (GLuint, GLshort, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib3svNV) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib4dNV) (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +void (APIENTRYP pfglVertexAttrib4dvNV) (GLuint, const GLdouble *); +void (APIENTRYP pfglVertexAttrib4fNV) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRYP pfglVertexAttrib4fvNV) (GLuint, const GLfloat *); +void (APIENTRYP pfglVertexAttrib4sNV) (GLuint, GLshort, GLshort, GLshort, GLshort); +void (APIENTRYP pfglVertexAttrib4svNV) (GLuint, const GLshort *); +void (APIENTRYP pfglVertexAttrib4ubNV) (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +void (APIENTRYP pfglVertexAttrib4ubvNV) (GLuint, const GLubyte *); +void (APIENTRYP pfglVertexAttribs1dvNV) (GLuint, GLsizei, const GLdouble *); +void (APIENTRYP pfglVertexAttribs1fvNV) (GLuint, GLsizei, const GLfloat *); +void (APIENTRYP pfglVertexAttribs1svNV) (GLuint, GLsizei, const GLshort *); +void (APIENTRYP pfglVertexAttribs2dvNV) (GLuint, GLsizei, const GLdouble *); +void (APIENTRYP pfglVertexAttribs2fvNV) (GLuint, GLsizei, const GLfloat *); +void (APIENTRYP pfglVertexAttribs2svNV) (GLuint, GLsizei, const GLshort *); +void (APIENTRYP pfglVertexAttribs3dvNV) (GLuint, GLsizei, const GLdouble *); +void (APIENTRYP pfglVertexAttribs3fvNV) (GLuint, GLsizei, const GLfloat *); +void (APIENTRYP pfglVertexAttribs3svNV) (GLuint, GLsizei, const GLshort *); +void (APIENTRYP pfglVertexAttribs4dvNV) (GLuint, GLsizei, const GLdouble *); +void (APIENTRYP pfglVertexAttribs4fvNV) (GLuint, GLsizei, const GLfloat *); +void (APIENTRYP pfglVertexAttribs4svNV) (GLuint, GLsizei, const GLshort *); +void (APIENTRYP pfglVertexAttribs4ubvNV) (GLuint, GLsizei, const GLubyte *); + + +////////////////////////////////// +// +// ATI Extensions +// +////////////////////////////////// + +/* + ------------------------------ + ATI_EnvmapBumpmap + ------------------------------ +*/ +void (APIENTRYP pfglTexBumpParameterivATI) (GLenum, const GLint *); +void (APIENTRYP pfglTexBumpParameterfvATI) (GLenum, const GLfloat *); +void (APIENTRYP pfglGetTexBumpParameterivATI) (GLenum, GLint *); +void (APIENTRYP pfglGetTexBumpParameterfvATI) (GLenum, GLfloat *); + + +/* + ------------------------------ + ATI_FragmentShader + ------------------------------ +*/ +GLuint (APIENTRYP pfglGenFragmentShadersATI) (GLuint); +void (APIENTRYP pfglBindFragmentShaderATI) (GLuint); +void (APIENTRYP pfglDeleteFragmentShaderATI) (GLuint); +void (APIENTRYP pfglBeginFragmentShaderATI) (void); +void (APIENTRYP pfglEndFragmentShaderATI) (void); +void (APIENTRYP pfglPassTexCoordATI) (GLuint, GLuint, GLenum); +void (APIENTRYP pfglSampleMapATI) (GLuint, GLuint, GLenum); +void (APIENTRYP pfglColorFragmentOp1ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglColorFragmentOp2ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglColorFragmentOp3ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglAlphaFragmentOp1ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglAlphaFragmentOp2ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglAlphaFragmentOp3ATI) (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +void (APIENTRYP pfglSetFragmentShaderConstantATI) (GLuint, const GLfloat *); + +/* + ------------------------------ + ATI_VertexArrayObject + ------------------------------ +*/ +GLuint (APIENTRYP pfglNewObjectBufferATI) (GLsizei, const GLvoid *, GLenum); +GLboolean (APIENTRYP pfglIsObjectBufferATI) (GLuint); +void (APIENTRYP pfglUpdateObjectBufferATI) (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +void (APIENTRYP pfglGetObjectBufferfvATI) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetObjectBufferivATI) (GLuint, GLenum, GLint *); +void (APIENTRYP pfglFreeObjectBufferATI) (GLuint); +void (APIENTRYP pfglArrayObjectATI) (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +void (APIENTRYP pfglGetArrayObjectfvATI) (GLenum, GLenum, GLfloat *); +void (APIENTRYP pfglGetArrayObjectivATI) (GLenum, GLenum, GLint *); +void (APIENTRYP pfglVariantArrayObjectATI) (GLuint, GLenum, GLsizei, GLuint, GLuint); +void (APIENTRYP pfglGetVariantArrayObjectfvATI) (GLuint, GLenum, GLfloat *); +void (APIENTRYP pfglGetVariantArrayObjectivATI) (GLuint, GLenum, GLint *); + + + + +/* + ------------------------------ + ATI_MapObjectBuffer + ------------------------------ +*/ +GLvoid* (APIENTRYP pfglMapObjectBufferATI) (GLuint); +void (APIENTRYP pfglUnmapObjectBufferATI) (GLuint); + + + + + + + + + +#endif /* __MYOPENGL_EXTENSION_H__ */ diff --git a/wolf3d/newCode/env/num_type.h b/wolf3d/newCode/env/num_type.h new file mode 100644 index 0000000..169716c --- /dev/null +++ b/wolf3d/newCode/env/num_type.h @@ -0,0 +1,48 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + + num_type.h: System dependant float/double to integer conversions. + + + */ + + +#ifndef __NUM_TYPE_H__ +#define __NUM_TYPE_H__ + +#include "arch.h" + + + +#define BIT( x ) ( 1 << (x) ) + + + + +#define FloatToInt( a ) (SW32)(a) +#define DoubleToInt( a ) (SW32)(a) + + + + + +#endif /* __NUM_TYPE_H__ */ diff --git a/wolf3d/newCode/env/oggfile.c b/wolf3d/newCode/env/oggfile.c new file mode 100644 index 0000000..98dec77 --- /dev/null +++ b/wolf3d/newCode/env/oggfile.c @@ -0,0 +1,154 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + +filehandle_t *fh; + +PRIVATE size_t ovc_read( void *ptr, size_t size, size_t nmemb, void *dataSource ) +{ + if( ! size || ! nmemb ) + { + return 0; + } + + return FS_ReadFile( ptr, size, nmemb, fh ); +} + +PRIVATE int ovc_seek( void *dataSource, ogg_int64_t offset, int whence ) +{ + return FS_FileSeek( fh, offset, whence ); +} + +PRIVATE int ovc_close( void *dataSource ) +{ + return 0; +} + +PRIVATE long ovc_tell( void *dataSource ) +{ + return FS_FileTell( fh ); +} + + + +/* +----------------------------------------------------------------------------- + Function: LoadOggInfo -Load ogg file. + + Parameters: filename -[in] Name of wav file to load. + wav -[out] wav data. + info -[out] wav sound info. + + Returns: True if file loaded, otherwise false. + + Notes: Caller is responsible for freeing wav data by calling Z_Free. + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean LoadOggInfo( const char *filename, W8 **wav, soundInfo_t *info ) +{ + W8 *data; + int size; + int dummy; + char *newFilename; + int len; + OggVorbis_File vorbisFile; + vorbis_info vorbisInfo; + ov_callbacks vorbisCallbacks = {ovc_read, ovc_seek, ovc_close, ovc_tell}; + int ret; + + newFilename = strdup( filename ); + + len = strlen( newFilename ); + if ( len < 5 || strcmp( newFilename + len - 4, ".wav" ) ) { + free( newFilename ); + return false; + } + + newFilename[ len - 3 ] = 'o'; + newFilename[ len - 2 ] = 'g'; + newFilename[ len - 1 ] = 'g'; + + fh = FS_OpenFile( newFilename, 0 ); + if( ! fh ) + { + free( newFilename ); + return false; + } + + if( (ret = ov_open_callbacks( fh, &vorbisFile, NULL, 0, vorbisCallbacks )) < 0 ) { + free( newFilename ); + return false; + } + + vorbisInfo = *ov_info( &vorbisFile, -1 ); + if( vorbisInfo.channels != 1 && vorbisInfo.channels != 2 ) + { + Com_Printf( "Only mono and stereo OGG files supported (%s)\n", newFilename ); + free( newFilename ); + return false; + } + + info->channels = vorbisInfo.channels; + info->sample_rate = vorbisInfo.rate; + info->sample_size = 2; + +#define BUFFER_SIZE ( 128 * 1024 ) + + data = (W8 *)malloc( BUFFER_SIZE ); + size = 0; + + while( size < BUFFER_SIZE ) + { + int read = 0; + read = ov_read( &vorbisFile, (char *)data + size, BUFFER_SIZE - size, &dummy ); + if( read == 0 ) + { + break; + } + + if( read <= 0 ) + { + Com_Printf( "Only mono and stereo OGG files supported (%s)\n", newFilename ); + free( newFilename ); + return false; + } + + size += read; + } + + info->samples = size / ( info->channels * info->sample_size ); + + Com_Printf("Loaded %s: channels=%d, sample_rate=%d, sample_size=%d, samples=%d. \n", newFilename, info->channels, info->sample_rate, info->sample_size, info->samples ); + free( newFilename ); + + *wav = (W8 *)Z_Malloc( size ); + memcpy(*wav, data, size ); + free( data ); + + + FS_CloseFile( fh ); + + return true; +} + diff --git a/wolf3d/newCode/env/oggfile.h b/wolf3d/newCode/env/oggfile.h new file mode 100644 index 0000000..ff0e648 --- /dev/null +++ b/wolf3d/newCode/env/oggfile.h @@ -0,0 +1,29 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#ifndef __LOADERS_OGGFILE_H__ +#define __LOADERS_OGGFILE_H__ + +extern _boolean LoadOggInfo( const char *filename, W8 **wav, soundInfo_t *info ); + +#endif /* __LOADERS_OGGFILE_H__ */ diff --git a/wolf3d/newCode/env/openal_binding.c b/wolf3d/newCode/env/openal_binding.c new file mode 100644 index 0000000..968db79 --- /dev/null +++ b/wolf3d/newCode/env/openal_binding.c @@ -0,0 +1,335 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * openal_binding.c: Interface to OpenAL library. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + + +#include "../wolfiphone.h" + + +#ifdef _WIN32 + + HINSTANCE hinstOpenAL; + +#elif __unix__ + + void *OpenALLib; + +#elif IPHONE + + void *OpenALLib; + // from here on in this file, behave like unix + #define __unix__ 1 + +#else + + #error "Please define interface to OpenAL library!" + +#endif + + +/* +----------------------------------------------------------------------------- + Function: OpenAL_Shutdown -Shutdown interface to OpenAL. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Unloads the specified Dynamic Link Library then NULLs out all the + proc pointers. + +----------------------------------------------------------------------------- +*/ +PUBLIC void OpenAL_Shutdown( void ) +{ + +#ifdef _WIN32 + + if( hinstOpenAL ) + { + FreeLibrary( hinstOpenAL ); + hinstOpenAL = NULL; + } + + hinstOpenAL = NULL; + +#elif __unix__ + + if( OpenALLib ) + { + dlclose( OpenALLib ); + OpenALLib = NULL; + } + + OpenALLib = NULL; + +#else + + #error "Please define interface to OpenAL library!" + +#endif + + + pfalcCloseDevice = NULL; + pfalcCreateContext = NULL; + pfalcDestroyContext = NULL; + pfalcGetContextsDevice = NULL; + pfalcGetCurrentContext = NULL; + pfalcGetEnumValue = NULL; + pfalcGetError = NULL; + pfalcGetIntegerv = NULL; + pfalcGetProcAddress = NULL; + pfalcGetString = NULL; + pfalcIsExtensionPresent = NULL; + pfalcMakeContextCurrent = NULL; + pfalcOpenDevice = NULL; + pfalcProcessContext = NULL; + pfalcSuspendContext = NULL; + + + pfalGenBuffers = NULL; + pfalDeleteBuffers = NULL; + pfalIsBuffer = NULL; + pfalBufferData = NULL; + pfalGetBufferf = NULL; + pfalGetBufferi = NULL; + pfalEnable = NULL; + pfalDisable = NULL; + pfalDopplerFactor = NULL; + pfalDopplerVelocity = NULL; + pfalDistanceModel = NULL; + pfalGetBoolean = NULL; + pfalGetBooleanv = NULL; + pfalGetDouble = NULL; + pfalGetDoublev = NULL; + pfalGetFloat = NULL; + pfalGetFloatv = NULL; + pfalGetInteger = NULL; + pfalGetIntegerv = NULL; + pfalGetEnumValue = NULL; + pfalGetError = NULL; + pfalGetProcAddress = NULL; + pfalGetString = NULL; + pfalIsExtensionPresent = NULL; + pfalIsEnabled = NULL; + pfalListenerf = NULL; + pfalListener3f = NULL; + pfalListenerfv = NULL; + pfalListeneri = NULL; + pfalGetListenerf = NULL; + pfalGetListener3f = NULL; + pfalGetListenerfv = NULL; + pfalGetListeneri = NULL; + pfalGenSources = NULL; + pfalDeleteSources = NULL; + pfalIsSource = NULL; + pfalSourcef = NULL; + pfalSourcefv = NULL; + pfalSource3f = NULL; + pfalSourcei = NULL; + pfalGetSourcef = NULL; + pfalGetSource3f = NULL; + pfalGetSourcefv = NULL; + pfalGetSourcei = NULL; + pfalSourcePlay = NULL; + pfalSourcePlayv = NULL; + pfalSourcePause = NULL; + pfalSourcePausev = NULL; + pfalSourceStop = NULL; + pfalSourceStopv = NULL; + pfalSourceRewind = NULL; + pfalSourceRewindv = NULL; + pfalSourceQueueBuffers = NULL; + pfalSourceUnqueueBuffers = NULL; + +} + + + +#ifdef _WIN32 + + #define GPA( a ) GetProcAddress( hinstOpenAL, a ) + +#elif __unix__ + + #define GPA( a ) dlsym( OpenALLib, a ) + +#else + + #error "Please define interface to OpenAL library!" + +#endif + + + + + +/* +----------------------------------------------------------------------------- + Function: OpenAL_Init -Setup interface to OpenAL. + + Parameters: dllname -[in] Name of the OpenAL dynamic link library. + + Returns: true on success, otherwise false. + + Notes: + This is responsible for binding our al function pointers to + the appropriate OpenAL stuff. In Windows this means doing a + LoadLibrary and a bunch of calls to GetProcAddress. On other + operating systems we need to do the right thing, whatever that + might be. + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean OpenAL_Init( const char *dllname ) +{ + +#ifdef _WIN32 + + char buffer[ 1024 ], *ptr; + + SearchPath( NULL, dllname, NULL, sizeof( buffer ) - 1, buffer, &ptr ); + + Com_Printf( "...calling LoadLibrary( %s ): ", buffer ); + + if( ( hinstOpenAL = LoadLibrary( dllname ) ) == 0 ) + { + char *buf = NULL; + + Com_Printf( "failed\n" ); + + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + (LPTSTR) &buf, 0, NULL ); + + Com_Printf( "%s\n", buf ); + + return false; + } + +#elif __unix__ + + Com_Printf( "...calling dlopen( %s ): ", dllname ); + + if( ( OpenALLib = dlopen( dllname, RTLD_LAZY | RTLD_GLOBAL ) ) == 0 ) + { + Com_Printf( "failed\n" ); + + Com_Printf( "%s\n", dlerror() ); + + return false; + } + +#else + + #error "Please define interface to OpenAL library!" + +#endif + + + Com_Printf( "succeeded\n" ); + + + if( ! (pfalcCloseDevice = (ALCCLOSEDEVICE)GPA( "alcCloseDevice" )) ) return false; + if( ! (pfalcCreateContext = (ALCCREATECONTEXT)GPA( "alcCreateContext" )) ) return false; + if( ! (pfalcDestroyContext = (ALCDESTROYCONTEXT)GPA( "alcDestroyContext" )) ) return false; + if( ! (pfalcGetContextsDevice = (ALCGETCONTEXTSDEVICE)GPA( "alcGetContextsDevice" )) ) return false; + if( ! (pfalcGetCurrentContext = (ALCGETCURRENTCONTEXT)GPA( "alcGetCurrentContext" )) ) return false; + if( ! (pfalcGetEnumValue = (ALCGETENUMVALUE)GPA( "alcGetEnumValue" )) ) return false; + if( ! (pfalcGetError = (ALCGETERROR)GPA( "alcGetError" )) ) return false; + if( ! (pfalcGetIntegerv = (ALCGETINTEGERV)GPA( "alcGetIntegerv" )) ) return false; + if( ! (pfalcGetProcAddress = (ALCGETPROCADDRESS)GPA( "alcGetProcAddress" )) ) return false; + if( ! (pfalcGetString = (ALCGETSTRING)GPA( "alcGetString" )) ) return false; + if( ! (pfalcIsExtensionPresent = (ALCISEXTENSIONPRESENT)GPA( "alcIsExtensionPresent" )) ) return false; + if( ! (pfalcMakeContextCurrent = (ALCMAKECONTEXTCURRENT)GPA( "alcMakeContextCurrent" )) ) return false; + if( ! (pfalcOpenDevice = (ALCOPENDEVICE)GPA( "alcOpenDevice" )) ) return false; + if( ! (pfalcProcessContext = (ALCPROCESSCONTEXT)GPA( "alcProcessContext" )) ) return false; + if( ! (pfalcSuspendContext = (ALCSUSPENDCONTEXT)GPA( "alcSuspendContext" )) ) return false; + + + if( ! (pfalGenBuffers = (ALGENBUFFERS)GPA("alGenBuffers")) ) return false; + if( ! (pfalDeleteBuffers = (ALDELETEBUFFERS)GPA("alDeleteBuffers")) ) return false; + if( ! (pfalIsBuffer = (ALISBUFFER)GPA("alIsBuffer")) ) return false; + if( ! (pfalBufferData = (ALBUFFERDATA)GPA("alBufferData")) ) return false; + if( ! (pfalGetBufferf = (ALGETBUFFERF)GPA("alGetBufferf")) ) return false; + if( ! (pfalGetBufferi = (ALGETBUFFERI)GPA("alGetBufferi")) ) return false; + if( ! (pfalEnable = (ALENABLE)GPA("alEnable")) ) return false; + if( ! (pfalDisable = (ALDISABLE)GPA("alDisable")) ) return false; + if( ! (pfalDopplerFactor = (ALDOPPLERFACTOR)GPA("alDopplerFactor")) ) return false; + if( ! (pfalDopplerVelocity = (ALDOPPLERVELOCITY)GPA("alDopplerVelocity")) ) return false; + if( ! (pfalDistanceModel = (ALDISTANCEMODEL)GPA("alDistanceModel")) ) return false; + if( ! (pfalGetBoolean = (ALGETBOOLEAN)GPA("alGetBoolean")) ) return false; + if( ! (pfalGetBooleanv = (ALGETBOOLEANV)GPA("alGetBooleanv")) ) return false; + if( ! (pfalGetDouble = (ALGETDOUBLE)GPA("alGetDouble")) ) return false; + if( ! (pfalGetDoublev = (ALGETDOUBLEV)GPA("alGetDoublev")) ) return false; + if( ! (pfalGetFloat = (ALGETFLOAT)GPA("alGetFloat")) ) return false; + if( ! (pfalGetFloatv = (ALGETFLOATV)GPA("alGetFloatv")) ) return false; + if( ! (pfalGetInteger = (ALGETINTEGER)GPA("alGetInteger")) ) return false; + if( ! (pfalGetIntegerv = (ALGETINTEGERV)GPA("alGetIntegerv")) ) return false; + if( ! (pfalGetEnumValue = (ALGETENUMVALUE)GPA("alGetEnumValue")) ) return false; + if( ! (pfalGetError = (ALGETERROR)GPA("alGetError")) ) return false; + if( ! (pfalGetProcAddress = (ALGETPROCADDRESS)GPA("alGetProcAddress")) ) return false; + if( ! (pfalGetString = (ALGETSTRING)GPA("alGetString")) ) return false; + if( ! (pfalIsExtensionPresent = (ALISEXTENSIONPRESENT)GPA("alIsExtensionPresent")) ) return false; + if( ! (pfalIsEnabled = (ALISENABLED)GPA("alIsEnabled")) ) return false; + if( ! (pfalListenerf = (ALLISTENERF)GPA("alListenerf")) ) return false; + if( ! (pfalListener3f = (ALLISTENER3F)GPA("alListener3f")) ) return false; + if( ! (pfalListenerfv = (ALLISTENERFV)GPA("alListenerfv")) ) return false; + if( ! (pfalListeneri = (ALLISTENERI)GPA("alListeneri")) ) return false; + if( ! (pfalGetListenerf = (ALGETLISTENERF)GPA("alGetListenerf")) ) return false; + if( ! (pfalGetListener3f = (ALGETLISTENER3F)GPA("alGetListener3f")) ) return false; + if( ! (pfalGetListenerfv = (ALGETLISTENERFV)GPA("alGetListenerfv")) ) return false; + if( ! (pfalGetListeneri = (ALGETLISTENERI)GPA("alGetListeneri")) ) return false; + if( ! (pfalGenSources = (ALGENSOURCES)GPA("alGenSources")) ) return false; + if( ! (pfalDeleteSources = (ALDELETESOURCES)GPA("alDeleteSources")) ) return false; + if( ! (pfalIsSource = (ALISSOURCE)GPA("alIsSource")) ) return false; + if( ! (pfalSourcef = (ALSOURCEF)GPA("alSourcef")) ) return false; + if( ! (pfalSourcefv = (ALSOURCEFV)GPA("alSourcefv")) ) return false; + if( ! (pfalSource3f = (ALSOURCE3F)GPA("alSource3f")) ) return false; + if( ! (pfalSourcei = (ALSOURCEI)GPA("alSourcei")) ) return false; + if( ! (pfalGetSourcef = (ALGETSOURCEF)GPA("alGetSourcef")) ) return false; + if( ! (pfalGetSource3f = (ALGETSOURCE3F)GPA("alGetSource3f")) ) return false; + if( ! (pfalGetSourcefv = (ALGETSOURCEFV)GPA("alGetSourcefv")) ) return false; + if( ! (pfalGetSourcei = (ALGETSOURCEI)GPA("alGetSourcei")) ) return false; + if( ! (pfalSourcePlay = (ALSOURCEPLAY)GPA("alSourcePlay")) ) return false; + if( ! (pfalSourcePlayv = (ALSOURCEPLAYV)GPA("alSourcePlayv")) ) return false; + if( ! (pfalSourcePause = (ALSOURCEPAUSE)GPA("alSourcePause")) ) return false; + if( ! (pfalSourcePausev = (ALSOURCEPAUSEV)GPA("alSourcePausev")) ) return false; + if( ! (pfalSourceStop = (ALSOURCESTOP)GPA("alSourceStop")) ) return false; + if( ! (pfalSourceStopv = (ALSOURCESTOPV)GPA("alSourceStopv")) ) return false; + if( ! (pfalSourceRewind = (ALSOURCEREWIND)GPA("alSourceRewind")) ) return false; + if( ! (pfalSourceRewindv = (ALSOURCEREWINDV)GPA("alSourceRewindv")) ) return false; + if( ! (pfalSourceQueueBuffers = (ALSOURCEQUEUEBUFFERS)GPA("alSourceQueueBuffers")) ) return false; + if( ! (pfalSourceUnqueueBuffers = (ALSOURCEUNQUEUEBUFFERS)GPA("alSourceUnqueueBuffers")) ) return false; + + + return true; + +} + diff --git a/wolf3d/newCode/env/openal_binding.h b/wolf3d/newCode/env/openal_binding.h new file mode 100644 index 0000000..ba88024 --- /dev/null +++ b/wolf3d/newCode/env/openal_binding.h @@ -0,0 +1,186 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * openal_binding.h: Interface to OpenAL library. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + + +#ifndef __OPENAL_BINDING_H__ +#define __OPENAL_BINDING_H__ + +extern _boolean OpenAL_Init( const char *dllname ); +extern void OpenAL_Shutdown( void ); + + + +typedef ALCAPI ALCvoid ( * ALCCLOSEDEVICE)(ALCdevice *pDevice); +typedef ALCAPI ALCcontext*( * ALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrList); +typedef ALCAPI ALCvoid ( * ALCDESTROYCONTEXT)(ALCcontext *context); +typedef ALCAPI ALCdevice* ( * ALCGETCONTEXTSDEVICE)(ALCcontext *pContext); +typedef ALCAPI ALCcontext * ( * ALCGETCURRENTCONTEXT)(ALCvoid); +typedef ALCAPI ALCenum ( * ALCGETENUMVALUE)(ALCdevice *device, const ALCubyte *enumName); +typedef ALCAPI ALCenum ( * ALCGETERROR)(ALCdevice *device); +typedef ALCAPI ALCvoid ( * ALCGETINTEGERV)(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data); +typedef ALCAPI ALCvoid * ( * ALCGETPROCADDRESS)(ALCdevice *device, const ALCubyte *funcName); +typedef ALCAPI const ALCubyte* ( * ALCGETSTRING)(ALCdevice *device,ALCenum param); +typedef ALCAPI ALCboolean ( * ALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCubyte *extName); +typedef ALCAPI ALCboolean ( * ALCMAKECONTEXTCURRENT)(ALCcontext *context); +typedef ALCAPI ALCdevice* ( * ALCOPENDEVICE)(const ALCubyte *deviceName); +typedef ALCAPI ALCvoid ( * ALCPROCESSCONTEXT)(ALCcontext *pContext); +typedef ALCAPI ALCvoid ( * ALCSUSPENDCONTEXT)(ALCcontext *pContext); + + + +typedef ALCAPI ALvoid ( * ALGENBUFFERS)(ALsizei n, ALuint* bufferNames); +typedef ALCAPI ALvoid ( * ALDELETEBUFFERS)(ALsizei n, const ALuint* bufferNames); +typedef ALCAPI ALboolean ( * ALISBUFFER)(ALuint bufferName); +typedef ALCAPI ALvoid ( * ALBUFFERDATA)(ALuint bufferName, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq); +typedef ALCAPI ALvoid ( * ALGETBUFFERF)(ALuint bufferName, ALenum param, ALfloat* value); +typedef ALCAPI ALvoid ( * ALGETBUFFERI)(ALuint bufferName, ALenum param, ALint* value); +typedef ALCAPI ALvoid ( * ALENABLE)(ALenum capability); +typedef ALCAPI ALvoid ( * ALDISABLE)(ALenum capability); +typedef ALCAPI ALvoid ( * ALDOPPLERFACTOR)(ALfloat value); +typedef ALCAPI ALvoid ( * ALDOPPLERVELOCITY)(ALfloat value); +typedef ALCAPI ALvoid ( * ALDISTANCEMODEL)(ALenum value); +typedef ALCAPI ALboolean ( * ALGETBOOLEAN)(ALenum param); +typedef ALCAPI ALvoid ( * ALGETBOOLEANV)(ALenum param, ALboolean* data); +typedef ALCAPI ALdouble ( * ALGETDOUBLE)(ALenum param); +typedef ALCAPI ALvoid ( * ALGETDOUBLEV)(ALenum param, ALdouble* data); +typedef ALCAPI ALfloat ( * ALGETFLOAT)(ALenum param); +typedef ALCAPI ALvoid ( * ALGETFLOATV)(ALenum param, ALfloat* data); +typedef ALCAPI ALint ( * ALGETINTEGER)(ALenum param); +typedef ALCAPI ALvoid ( * ALGETINTEGERV)(ALenum param, ALint* data); +typedef ALCAPI ALenum ( * ALGETENUMVALUE)(const ALubyte* ename); +typedef ALCAPI ALenum ( * ALGETERROR)(ALvoid); +typedef ALCAPI ALvoid* ( * ALGETPROCADDRESS)(const ALubyte* fname); +typedef ALCAPI const ALubyte* ( * ALGETSTRING)(ALenum param); +typedef ALCAPI ALboolean ( * ALISEXTENSIONPRESENT)(const ALubyte* ename); +typedef ALCAPI ALboolean ( * ALISENABLED)(ALenum capability); +typedef ALCAPI ALvoid ( * ALLISTENERF)(ALenum param, ALfloat value); +typedef ALCAPI ALvoid ( * ALLISTENER3F)(ALenum param, ALfloat v1, ALfloat v2, ALfloat v3); +typedef ALCAPI ALvoid ( * ALLISTENERFV)(ALenum param, const ALfloat* values); +typedef ALCAPI ALvoid ( * ALLISTENERI)(ALenum param, ALint value); +typedef ALCAPI ALvoid ( * ALGETLISTENERF)(ALenum param, ALfloat* value); +typedef ALCAPI ALvoid ( * ALGETLISTENER3F)(ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3); +typedef ALCAPI ALvoid ( * ALGETLISTENERFV)(ALenum param, ALfloat* values); +typedef ALCAPI ALvoid ( * ALGETLISTENERI)(ALenum param, ALint* value); +typedef ALCAPI ALvoid ( * ALGENSOURCES)(ALsizei n, ALuint* sourceNames); +typedef ALCAPI ALvoid ( * ALDELETESOURCES)(ALsizei n, const ALuint* sourceNames); +typedef ALCAPI ALboolean ( * ALISSOURCE)(ALuint sourceName); +typedef ALCAPI ALvoid ( * ALSOURCEF)(ALuint sourceName, ALenum param, ALfloat value); +typedef ALCAPI ALvoid ( * ALSOURCEFV)(ALuint sourceName, ALenum param, const ALfloat* values); +typedef ALCAPI ALvoid ( * ALSOURCE3F)(ALuint sourceName, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3); +typedef ALCAPI ALvoid ( * ALSOURCEI)(ALuint sourceName, ALenum param, ALint value); +typedef ALCAPI ALvoid ( * ALGETSOURCEF)(ALuint sourceName, ALenum param, ALfloat* value); +typedef ALCAPI ALvoid ( * ALGETSOURCE3F)(ALuint sourceName, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3); +typedef ALCAPI ALvoid ( * ALGETSOURCEFV)(ALuint sourceName, ALenum param, ALfloat* values); +typedef ALCAPI ALvoid ( * ALGETSOURCEI)(ALuint sourceName, ALenum param, ALint* value); +typedef ALCAPI ALvoid ( * ALSOURCEPLAY)(ALuint sourceName); +typedef ALCAPI ALvoid ( * ALSOURCEPLAYV)(ALsizei n, const ALuint* sourceNames); +typedef ALCAPI ALvoid ( * ALSOURCEPAUSE)(ALuint sourceName); +typedef ALCAPI ALvoid ( * ALSOURCEPAUSEV)(ALsizei n, const ALuint* sourceNames); +typedef ALCAPI ALvoid ( * ALSOURCESTOP)(ALuint sourceName); +typedef ALCAPI ALvoid ( * ALSOURCESTOPV)(ALsizei n, const ALuint* sourceNames); +typedef ALCAPI ALvoid ( * ALSOURCEREWIND)(ALuint sourceName); +typedef ALCAPI ALvoid ( * ALSOURCEREWINDV)(ALsizei n, const ALuint* sourceNames); +typedef ALCAPI ALvoid ( * ALSOURCEQUEUEBUFFERS)(ALuint sourceName, ALsizei n, const ALuint* buffers); +typedef ALCAPI ALvoid ( * ALSOURCEUNQUEUEBUFFERS)(ALuint sourceName, ALsizei n, ALuint* buffers); + + + +ALCCLOSEDEVICE pfalcCloseDevice; +ALCCREATECONTEXT pfalcCreateContext; +ALCDESTROYCONTEXT pfalcDestroyContext; +ALCGETCONTEXTSDEVICE pfalcGetContextsDevice; +ALCGETCURRENTCONTEXT pfalcGetCurrentContext; +ALCGETENUMVALUE pfalcGetEnumValue; +ALCGETERROR pfalcGetError; +ALCGETINTEGERV pfalcGetIntegerv; +ALCGETPROCADDRESS pfalcGetProcAddress; +ALCGETSTRING pfalcGetString; +ALCISEXTENSIONPRESENT pfalcIsExtensionPresent; +ALCMAKECONTEXTCURRENT pfalcMakeContextCurrent; +ALCOPENDEVICE pfalcOpenDevice; +ALCPROCESSCONTEXT pfalcProcessContext; +ALCSUSPENDCONTEXT pfalcSuspendContext; + +ALGENBUFFERS pfalGenBuffers; +ALDELETEBUFFERS pfalDeleteBuffers; +ALISBUFFER pfalIsBuffer; +ALBUFFERDATA pfalBufferData; +ALGETBUFFERF pfalGetBufferf; +ALGETBUFFERI pfalGetBufferi; +ALENABLE pfalEnable; +ALDISABLE pfalDisable; +ALDOPPLERFACTOR pfalDopplerFactor; +ALDOPPLERVELOCITY pfalDopplerVelocity; +ALDISTANCEMODEL pfalDistanceModel; +ALGETBOOLEAN pfalGetBoolean; +ALGETBOOLEANV pfalGetBooleanv; +ALGETDOUBLE pfalGetDouble; +ALGETDOUBLEV pfalGetDoublev; +ALGETFLOAT pfalGetFloat; +ALGETFLOATV pfalGetFloatv; +ALGETINTEGER pfalGetInteger; +ALGETINTEGERV pfalGetIntegerv; +ALGETENUMVALUE pfalGetEnumValue; +ALGETERROR pfalGetError; +ALGETPROCADDRESS pfalGetProcAddress; +ALGETSTRING pfalGetString; +ALISEXTENSIONPRESENT pfalIsExtensionPresent; +ALISENABLED pfalIsEnabled; +ALLISTENERF pfalListenerf; +ALLISTENER3F pfalListener3f; +ALLISTENERFV pfalListenerfv; +ALLISTENERI pfalListeneri; +ALGETLISTENERF pfalGetListenerf; +ALGETLISTENER3F pfalGetListener3f; +ALGETLISTENERFV pfalGetListenerfv; +ALGETLISTENERI pfalGetListeneri; +ALGENSOURCES pfalGenSources; +ALDELETESOURCES pfalDeleteSources; +ALISSOURCE pfalIsSource; +ALSOURCEF pfalSourcef; +ALSOURCEFV pfalSourcefv; +ALSOURCE3F pfalSource3f; +ALSOURCEI pfalSourcei; +ALGETSOURCEF pfalGetSourcef; +ALGETSOURCE3F pfalGetSource3f; +ALGETSOURCEFV pfalGetSourcefv; +ALGETSOURCEI pfalGetSourcei; +ALSOURCEPLAY pfalSourcePlay; +ALSOURCEPLAYV pfalSourcePlayv; +ALSOURCEPAUSE pfalSourcePause; +ALSOURCEPAUSEV pfalSourcePausev; +ALSOURCESTOP pfalSourceStop; +ALSOURCESTOPV pfalSourceStopv; +ALSOURCEREWIND pfalSourceRewind; +ALSOURCEREWINDV pfalSourceRewindv; +ALSOURCEQUEUEBUFFERS pfalSourceQueueBuffers; +ALSOURCEUNQUEUEBUFFERS pfalSourceUnqueueBuffers; + + + +#endif /* __OPENAL_BINDING_H__ */ diff --git a/wolf3d/newCode/env/openal_main.c b/wolf3d/newCode/env/openal_main.c new file mode 100644 index 0000000..dd26477 --- /dev/null +++ b/wolf3d/newCode/env/openal_main.c @@ -0,0 +1,244 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * openal_main.c: Interface to Sound Device. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + +#include "../wolfiphone.h" + + +#ifdef _WIN32 + + #define OPENAL_DLL_NAME "openal32.dll" + +#elif __unix__ + + #define OPENAL_DLL_NAME "libopenal.so" + +#elif IPHONE + +#define OPENAL_DLL_NAME "/System/Library/Frameworks/OpenAL.framework/OpenAL" + +#else + + #error "Please define OPENAL_DLL_NAME" + +#endif + +PRIVATE ALCcontext *Context; +PRIVATE ALCdevice *Device; + + +cvar_t *s_driver; +cvar_t *s_device; + + +char *deviceList; +char *sound_devices[ 12 ]; + +W16 numSoundDevices, numDefaultSoundDevice; + + + +/* +----------------------------------------------------------------------------- + Function: Sound_Device_getDeviceList -Get OpenAL device list. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_Device_getDeviceList( void ) +{ + char deviceName[ 256 ]; + + my_strlcpy( deviceName, s_device->string, sizeof( deviceName ) ); + if( pfalcIsExtensionPresent( NULL, (ALubyte*)"ALC_ENUMERATION_EXT") == AL_TRUE ) + { + // try out enumeration extension + deviceList = (char *)pfalcGetString( NULL, ALC_DEVICE_SPECIFIER ); + for( numSoundDevices = 0 ; numSoundDevices < 12 ; ++numSoundDevices ) + { + sound_devices[ numSoundDevices ] = NULL; + } + + for( numSoundDevices = 0 ; numSoundDevices < 12 ; ++numSoundDevices ) + { + sound_devices[ numSoundDevices ] = deviceList; + if( strcmp( sound_devices[ numSoundDevices ], deviceName ) == 0 ) + { + numDefaultSoundDevice = numSoundDevices; + } + deviceList += strlen( deviceList ); + if( deviceList[ 0 ] == 0 ) + { + if( deviceList[ 1 ] == 0 ) + { + break; + } + else + { + deviceList += 1; + } + } + + } // End for numSoundDevices = 0 ; numSoundDevices < 12 ; ++numSoundDevices + } + +} + + +/* +----------------------------------------------------------------------------- + Function: Sound_Device_Register -Register OpenAL cvars. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_Device_Register( void ) +{ + s_driver = Cvar_Get( "s_driver", OPENAL_DLL_NAME, CVAR_ARCHIVE ); + s_device = Cvar_Get( "s_device", "", CVAR_LATCH | CVAR_ARCHIVE ); +} + +/* +----------------------------------------------------------------------------- + Function: Sound_Device_Setup -Setup OpenAL sound device. + + Parameters: Nothing. + + Returns: true on success, otherwise false. + + Notes: Call Sound_Device_Shutdown() when you are done. +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Sound_Device_Setup( void ) +{ + Com_Printf( "...Initializing OpenAL subsystem\n" ); + + Sound_Device_Register(); + + // Initialize our OpenAL dynamic bindings + if( ! OpenAL_Init( s_driver->string ) ) + { + Com_Printf( "[%s]: Dynamic binding of (%s) failed\n", "openal_main.c", s_driver->string ); + + goto failed; + } + + + Sound_Device_getDeviceList(); + + + Device = pfalcOpenDevice( (ALCubyte *)( (s_device->string[ 0 ]) ? s_device->string : NULL ) ); + if( Device == NULL ) + { + Com_Printf( "Failed to Initialize OpenAL\n" ); + + goto failed; + } + + // Create context(s) + Context = pfalcCreateContext( Device, NULL ); + if( Context == NULL ) + { + Com_Printf( "Failed to initialize OpenAL\n" ); + + goto failed; + } + + + + // Set active context + pfalcGetError( Device ); + pfalcMakeContextCurrent( Context ); + if( pfalcGetError( Device ) != ALC_NO_ERROR ) + { + Com_Printf( "Failed to Make Context Current\n" ); + + goto failed; + } + + return true; + + + +failed: + + OpenAL_Shutdown(); + + if( Context ) + { + pfalcDestroyContext( Context ); + Context = NULL; + } + + if( Device ) + { + pfalcCloseDevice( Device ); + Device = NULL; + } + + return false; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_Device_Shutdown -Shutdown OpenAL sound device. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_Device_Shutdown( void ) +{ + if( Context ) + { + pfalcMakeContextCurrent( NULL ); + pfalcDestroyContext( Context ); + + Context = NULL; + } + + if( Device ) + { + pfalcCloseDevice( Device ); + + Device = NULL; + } + + OpenAL_Shutdown(); +} + diff --git a/wolf3d/newCode/env/opengl_draw.c b/wolf3d/newCode/env/opengl_draw.c new file mode 100644 index 0000000..ccec2b8 --- /dev/null +++ b/wolf3d/newCode/env/opengl_draw.c @@ -0,0 +1,339 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * opengl_draw.c: OpenGL drawing routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + + +#include "../wolfiphone.h" + +texture_t *draw_chars; + +//extern _boolean scrap_dirty; +//void Scrap_Upload (void); + + + +/* +----------------------------------------------------------------------------- + Function: R_Draw_Char -Draw ASCII character to the screen. + + Parameters: x -[in] x-coordinate. + y -[in] y-coordinate. + num -[in] ASCII character value. + myfont -[in] Valid pointer to font_t structure. + + Returns: Nothing. + + Notes: + It can be clipped to the top of the screen to allow the console to be + smoothly scrolled off. + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Character( int x, int y, int num, font_t *myfont ) +{ + int row, col; + int scale, sh; // scaled width, height + float frow, fcol; + + num &= 255; + + if( (num & 127) == 32 ) + { + return; // space + } + + if( y <= -myfont->nMaxHeight ) + { + return; // totally off screen + } + + scale = myfont->nSize; + sh = myfont->nMaxHeight; + + row = (num >> 4) - 2; + col = num & 15; + + frow = row * myfont->hFrac; + fcol = col * myfont->wFrac; + + + pfglColor4ubv( myfont->colour ); + + pfglEnable( GL_BLEND ); + + + R_Bind( myfont->texfont->texnum ); + + + pfglBegin( GL_QUADS ); + + + pfglTexCoord2f( fcol, frow ); + pfglVertex2i( x, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow ); + pfglVertex2i( x+myfont->nMaxWidth*scale, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow+myfont->hFrac ); + pfglVertex2i( x+myfont->nMaxWidth*scale, (y+sh*scale) ); + + pfglTexCoord2f( fcol, frow+myfont->hFrac ); + pfglVertex2i( x, (y+sh*scale) ); + + + + pfglEnd(); + + pfglDisable( GL_BLEND ); + pfglColor3f( 1, 1, 1 ); +} + + +/* +----------------------------------------------------------------------------- + Function: R_Draw_StretchPic -Draw stretched image to the screen. + + Parameters: x -[in] x-coordinate. + y -[in] y-coordinate. + w -[in] width of region. + h -[in] height of region. + pic -[in] Image filename to stretch. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_StretchPic( int x, int y, int w, int h, const char *pic ) +{ + texture_t *gl; + + gl = TM_FindTexture( pic, TT_Pic ); + if( ! gl ) + { + Com_Printf( "Can't find pic: %s\n", pic ); + return; + } + +// if( scrap_dirty ) +// Scrap_Upload(); + + + R_Bind( gl->texnum ); + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0.0f, 0.0f ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1.0f, 0.0f ); pfglVertex2i( x+w, y ); + pfglTexCoord2f( 1.0f, 1.0f ); pfglVertex2i( x+w, y+h ); + pfglTexCoord2f( 0.0f, 1.0f ); pfglVertex2i( x, y+h ); + + pfglEnd(); +} + + +/* +----------------------------------------------------------------------------- + Function: R_Draw_Pic -Draw image to the screen. + + Parameters: x -[in] x-coordinate. + y -[in] y-coordinate. + pic -[in] Image filename to draw. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Pic( int x, int y, const char *pic ) +{ + texture_t *tex; + + tex = TM_FindTexture( pic, TT_Pic ); + if( ! tex ) + { + Com_Printf( "Can't find pic: %s\n", pic ); + return; + } +// if( scrap_dirty ) +// Scrap_Upload(); + + + + R_Bind( tex->texnum ); + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0.0, 0.0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1.0, 0.0 ); pfglVertex2i( x + tex->width, y ); + pfglTexCoord2f( 1.0, 1.0 ); pfglVertex2i( x + tex->width, y + tex->height ); + pfglTexCoord2f( 0.0, 1.0 ); pfglVertex2i( x, y + tex->height ); + + pfglEnd(); + +} + + + +/* +----------------------------------------------------------------------------- + Function: R_Draw_Tile -Tile image on the screen. + + Parameters: x -[in] x-coordinate. + y -[in] y-coordinate. + w -[in] width of region. + h -[in] height of region. + pic -[in] Image filename to draw. + + Returns: Nothing. + + Notes: + This repeats a tile graphic to fill a region on the screen. +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Tile( int x, int y, int w, int h, const char *pic ) +{ + texture_t *image; + + image = TM_FindTexture( pic, TT_Wall ); + if( ! image ) + { + Com_Printf( "Can't find pic: %s\n", pic ); + return; + } + + + R_Bind( image->texnum ); + + pfglBegin( GL_QUADS ); + + + pfglTexCoord2i( x/image->upload_width, y/image->upload_height); + pfglVertex2i( x, y ); + + pfglTexCoord2i( (x + w)/image->upload_width, y/image->upload_height); + pfglVertex2i( x + w, y ); + + pfglTexCoord2i( (x+w)/image->upload_width, (y+h)/image->upload_height); + pfglVertex2i( x + w, y + h ); + + pfglTexCoord2i( x/image->upload_width, (y+h)/image->upload_height ); + pfglVertex2i( x, y + h ); + + + pfglEnd (); + +} + + +/* +----------------------------------------------------------------------------- + Function: R_Draw_Fill -Fills a box of pixels with a single color. + + Parameters: x -[in] x-coordinate. + y -[in] y-coordinate. + w -[in] width of region. + h -[in] height of region. + c -[in] Colour to fill region. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Fill( int x, int y, int w, int h, colour3_t c ) +{ + qglScissor( x, 320-(y+h), w, h ); + qglEnable( GL_SCISSOR_TEST ); + qglClearColor( c[0] / 255.0f, c[1] / 255.0f, c[2] / 255.0f, 1.0f ); + qglClear( GL_COLOR_BUFFER_BIT ); + qglDisable( GL_SCISSOR_TEST ); +} + +PUBLIC void R_Draw_Blend( int x, int y, int w, int h, colour4_t c ) +{ + pfglDisable( GL_TEXTURE_2D ); + pfglColor4ubv( c ); + + pfglBegin( GL_QUADS ); + + pfglVertex2i( x, y ); + pfglVertex2i( x+w, y ); + pfglVertex2i( x+w, y+h ); + pfglVertex2i( x, y+h ); + + pfglEnd(); + + pfglColor3f( 1, 1, 1 ); + pfglEnable( GL_TEXTURE_2D ); +} + +/* +----------------------------------------------------------------------------- + Function: R_Draw_Line -Draw a line on the screen. + + Parameters: nXStart -[in] x-coordinate of starting point. + nYStart -[in] y-coordinate of starting point. + nXEnd -[in] x-coordinate of ending point. + nYEnd -[in] y-coordinate of ending point. + c -[in] Colour value. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Line( int nXStart, int nYStart, int nXEnd, int nYEnd, int width, colour3_t c ) +{ + pfglDisable( GL_TEXTURE_2D ); + + + pfglColor3ubv( c ); + + + pfglLineWidth( (float)width ); + + pfglBegin( GL_LINES ); + + pfglVertex2i( nXStart, nYStart ); + pfglVertex2i( nXEnd, nYEnd ); + + pfglEnd(); + + pfglColor3f( 1, 1, 1 ); + pfglEnable( GL_TEXTURE_2D ); +} + + diff --git a/wolf3d/newCode/env/opengl_extension.c b/wolf3d/newCode/env/opengl_extension.c new file mode 100644 index 0000000..7c3b654 --- /dev/null +++ b/wolf3d/newCode/env/opengl_extension.c @@ -0,0 +1,1024 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * myopengl_extension.c: Interface to OpenGL extensions. + * + * Author: Michael Liebscher + * Date: 2004 + * + */ + +/* + + This module implements the binding of OpenGL extensions + to our function pointers. + + To use this module call the function GL_ConfigExtensions(). + +*/ + +#include + +#include "myopengl.h" +#include "opengl_local.h" +#include "myopengl_extension.h" +#include "../../common/common_utils.h" +#include "../../common/common.h" + + + + /* Implemented here */ + + +// Define what you require here. +// If hardware does not meet these defines, then extension load will fail. +#define MY_MAX_ARB_TEXTURESTAGES 4 + +#define MY_GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTR 128 +#define MY_GL_MAX_VERTEX_SHADER_LOCALS_EXT 68 +#define MY_GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 2 +#define MY_GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 97 +#define MY_GL_MAX_VERTEX_SHADER_VARIANTS_EXT 4 + + + + +GL_Extensions gl_ext; + + + +////////////////////////////// +// +// ARB Functions +// +////////////////////////////// + +PRIVATE W8 ConfigARBMultiTexture( const char *glext ) +{ + if( strstr( glext, "GL_ARB_multitexture" ) == NULL ) + { + Com_Printf( "...GL_ARB_multitexture not found\n" ); + return 0; + } + + if( ! (pfglActiveTextureARB = ( void * )pfwglGetProcAddress( "glActiveTextureARB" )) ) return 0; + if( ! (pfglClientActiveTextureARB = ( void * )pfwglGetProcAddress("glClientActiveTextureARB")))return 0; + + if( ! (pfglMultiTexCoord1sARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1sARB" ))) return 0; + if( ! (pfglMultiTexCoord1iARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1iARB" ))) return 0; + if( ! (pfglMultiTexCoord1fARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1fARB" ))) return 0; + if( ! (pfglMultiTexCoord1dARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1dARB" ))) return 0; + if( ! (pfglMultiTexCoord2sARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2sARB" ))) return 0; + if( ! (pfglMultiTexCoord2iARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2iARB" ))) return 0; + if( ! (pfglMultiTexCoord2fARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2fARB" ))) return 0; + if( ! (pfglMultiTexCoord2dARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2dARB" ))) return 0; + if( ! (pfglMultiTexCoord3sARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3sARB" ))) return 0; + if( ! (pfglMultiTexCoord3iARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3iARB" ))) return 0; + if( ! (pfglMultiTexCoord3fARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3fARB" ))) return 0; + if( ! (pfglMultiTexCoord3dARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3dARB" ))) return 0; + if( ! (pfglMultiTexCoord4sARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4sARB" ))) return 0; + if( ! (pfglMultiTexCoord4iARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4iARB" ))) return 0; + if( ! (pfglMultiTexCoord4fARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4fARB" ))) return 0; + if( ! (pfglMultiTexCoord4dARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4dARB" ))) return 0; + + if( ! (pfglMultiTexCoord1svARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1svARB" ))) return 0; + if( ! (pfglMultiTexCoord1ivARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1ivARB" ))) return 0; + if( ! (pfglMultiTexCoord1fvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1fvARB" ))) return 0; + if( ! (pfglMultiTexCoord1dvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord1dvARB" ))) return 0; + if( ! (pfglMultiTexCoord2svARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2svARB" ))) return 0; + if( ! (pfglMultiTexCoord2ivARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2ivARB" ))) return 0; + if( ! (pfglMultiTexCoord2fvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2fvARB" ))) return 0; + if( ! (pfglMultiTexCoord2dvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord2dvARB" ))) return 0; + if( ! (pfglMultiTexCoord3svARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3svARB" ))) return 0; + if( ! (pfglMultiTexCoord3ivARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3ivARB" ))) return 0; + if( ! (pfglMultiTexCoord3fvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3fvARB" ))) return 0; + if( ! (pfglMultiTexCoord3dvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord3dvARB" ))) return 0; + if( ! (pfglMultiTexCoord4svARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4svARB" ))) return 0; + if( ! (pfglMultiTexCoord4ivARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4ivARB" ))) return 0; + if( ! (pfglMultiTexCoord4fvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4fvARB" ))) return 0; + if( ! (pfglMultiTexCoord4dvARB = ( void * )pfwglGetProcAddress( "glMultiTexCoord4dvARB" ))) return 0; + + + Com_Printf( "...enabling GL_ARB_multitexture\n" ); + + return 1; +} + + +PRIVATE W8 ConfigARBTextureCompression( const char *glext ) +{ + if( strstr( glext, "GL_ARB_texture_compression" ) == NULL ) + { + Com_Printf( "...GL_ARB_texture_compression not found\n" ); + return 0; + } + + if( ! (pfglCompressedTexImage3DARB = ( void * )pfwglGetProcAddress( "glCompressedTexImage3DARB" ))) return 0; + if( ! (pfglCompressedTexImage2DARB = ( void * )pfwglGetProcAddress( "glCompressedTexImage2DARB" ))) return 0; + if( ! (pfglCompressedTexImage1DARB = ( void * )pfwglGetProcAddress( "glCompressedTexImage1DARB" ))) return 0; + if( ! (pfglCompressedTexSubImage3DARB = ( void * )pfwglGetProcAddress( "glCompressedTexSubImage3DARB" ))) return 0; + if( ! (pfglCompressedTexSubImage2DARB = ( void * )pfwglGetProcAddress( "glCompressedTexSubImage2DARB" ))) return 0; + if( ! (pfglCompressedTexSubImage1DARB = ( void * )pfwglGetProcAddress( "glCompressedTexSubImage1DARB" ))) return 0; + if( ! (pfglGetCompressedTexImageARB = ( void * )pfwglGetProcAddress( "glGetCompressedTexImageARB" ))) return 0; + + Com_Printf( "...enabling GL_ARB_texture_compression\n" ); + + return 1; +} + + +PRIVATE W8 CheckARBTextureCubeMap( const char *glext ) +{ + if( strstr( glext, "GL_ARB_texture_cube_map" ) == NULL ) + { + Com_Printf( "...GL_ARB_texture_cube_map not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_ARB_texture_cube_map\n" ); + + return 1; +} + +PRIVATE W8 ConfigARBVertexProgram( const char *glext ) +{ + if( strstr( glext, "GL_ARB_vertex_program" ) == NULL ) + { + return 0; + } + + if( ! (pfglVertexAttrib1sARB = ( void * )pfwglGetProcAddress("glVertexAttrib1sARB"))) return 0; + if( ! (pfglVertexAttrib1fARB = ( void * )pfwglGetProcAddress("glVertexAttrib1fARB"))) return 0; + if( ! (pfglVertexAttrib1dARB = ( void * )pfwglGetProcAddress("glVertexAttrib1dARB"))) return 0; + if( ! (pfglVertexAttrib2sARB = ( void * )pfwglGetProcAddress("glVertexAttrib2sARB"))) return 0; + if( ! (pfglVertexAttrib2fARB = ( void * )pfwglGetProcAddress("glVertexAttrib2fARB"))) return 0; + if( ! (pfglVertexAttrib2dARB = ( void * )pfwglGetProcAddress("glVertexAttrib2dARB"))) return 0; + if( ! (pfglVertexAttrib3sARB = ( void * )pfwglGetProcAddress("glVertexAttrib3sARB"))) return 0; + if( ! (pfglVertexAttrib3fARB = ( void * )pfwglGetProcAddress("glVertexAttrib3fARB"))) return 0; + if( ! (pfglVertexAttrib3dARB = ( void * )pfwglGetProcAddress("glVertexAttrib3dARB"))) return 0; + if( ! (pfglVertexAttrib4sARB = ( void * )pfwglGetProcAddress("glVertexAttrib4sARB"))) return 0; + if( ! (pfglVertexAttrib4fARB = ( void * )pfwglGetProcAddress("glVertexAttrib4fARB"))) return 0; + if( ! (pfglVertexAttrib4dARB = ( void * )pfwglGetProcAddress("glVertexAttrib4dARB"))) return 0; + if( ! (pfglVertexAttrib4NubARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NubARB"))) return 0; + if( ! (pfglVertexAttrib1svARB = ( void * )pfwglGetProcAddress("glVertexAttrib1svARB"))) return 0; + if( ! (pfglVertexAttrib1fvARB = ( void * )pfwglGetProcAddress("glVertexAttrib1fvARB"))) return 0; + if( ! (pfglVertexAttrib1dvARB = ( void * )pfwglGetProcAddress("glVertexAttrib1dvARB"))) return 0; + if( ! (pfglVertexAttrib2svARB = ( void * )pfwglGetProcAddress("glVertexAttrib2svARB"))) return 0; + if( ! (pfglVertexAttrib2fvARB = ( void * )pfwglGetProcAddress("glVertexAttrib2fvARB"))) return 0; + if( ! (pfglVertexAttrib2dvARB = ( void * )pfwglGetProcAddress("glVertexAttrib2dvARB"))) return 0; + if( ! (pfglVertexAttrib3svARB = ( void * )pfwglGetProcAddress("glVertexAttrib3svARB"))) return 0; + if( ! (pfglVertexAttrib3fvARB = ( void * )pfwglGetProcAddress("glVertexAttrib3fvARB"))) return 0; + if( ! (pfglVertexAttrib3dvARB = ( void * )pfwglGetProcAddress("glVertexAttrib3dvARB"))) return 0; + if( ! (pfglVertexAttrib4bvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4bvARB"))) return 0; + if( ! (pfglVertexAttrib4svARB = ( void * )pfwglGetProcAddress("glVertexAttrib4svARB"))) return 0; + if( ! (pfglVertexAttrib4ivARB = ( void * )pfwglGetProcAddress("glVertexAttrib4ivARB"))) return 0; + if( ! (pfglVertexAttrib4ubvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4ubvARB"))) return 0; + if( ! (pfglVertexAttrib4usvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4usvARB"))) return 0; + if( ! (pfglVertexAttrib4uivARB = ( void * )pfwglGetProcAddress("glVertexAttrib4uivARB"))) return 0; + if( ! (pfglVertexAttrib4fvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4fvARB"))) return 0; + if( ! (pfglVertexAttrib4dvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4dvARB"))) return 0; + if( ! (pfglVertexAttrib4NbvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NbvARB"))) return 0; + if( ! (pfglVertexAttrib4NsvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NsvARB"))) return 0; + if( ! (pfglVertexAttrib4NivARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NivARB"))) return 0; + if( ! (pfglVertexAttrib4NubvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NubvARB"))) return 0; + if( ! (pfglVertexAttrib4NusvARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NusvARB"))) return 0; + if( ! (pfglVertexAttrib4NuivARB = ( void * )pfwglGetProcAddress("glVertexAttrib4NuivARB"))) return 0; + if( ! (pfglVertexAttribPointerARB = ( void * )pfwglGetProcAddress("glVertexAttribPointerARB"))) return 0; + if( ! (pfglEnableVertexAttribArrayARB = ( void * )pfwglGetProcAddress("glEnableVertexAttribArrayARB"))) return 0; + if( ! (pfglDisableVertexAttribArrayARB = ( void * )pfwglGetProcAddress("glDisableVertexAttribArrayARB"))) return 0; + if( ! (pfglProgramStringARB = ( void * )pfwglGetProcAddress("glProgramStringARB"))) return 0; + if( ! (pfglBindProgramARB = ( void * )pfwglGetProcAddress("glBindProgramARB"))) return 0; + if( ! (pfglDeleteProgramsARB = ( void * )pfwglGetProcAddress("glDeleteProgramsARB"))) return 0; + if( ! (pfglGenProgramsARB = ( void * )pfwglGetProcAddress("glGenProgramsARB"))) return 0; + if( ! (pfglProgramEnvParameter4fARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4fARB"))) return 0; + if( ! (pfglProgramEnvParameter4dARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4dARB"))) return 0; + if( ! (pfglProgramEnvParameter4fvARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4fvARB"))) return 0; + if( ! (pfglProgramEnvParameter4dvARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4dvARB"))) return 0; + if( ! (pfglProgramLocalParameter4fARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4fARB"))) return 0; + if( ! (pfglProgramLocalParameter4dARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4dARB"))) return 0; + if( ! (pfglProgramLocalParameter4fvARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4fvARB"))) return 0; + if( ! (pfglProgramLocalParameter4dvARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4dvARB"))) return 0; + if( ! (pfglGetProgramEnvParameterfvARB = ( void * )pfwglGetProcAddress("glGetProgramEnvParameterfvARB"))) return 0; + if( ! (pfglGetProgramEnvParameterdvARB = ( void * )pfwglGetProcAddress("glGetProgramEnvParameterdvARB"))) return 0; + if( ! (pfglGetProgramLocalParameterfvARB = ( void * )pfwglGetProcAddress("glGetProgramLocalParameterfvARB"))) return 0; + if( ! (pfglGetProgramLocalParameterdvARB = ( void * )pfwglGetProcAddress("glGetProgramLocalParameterdvARB"))) return 0; + if( ! (pfglGetProgramivARB = ( void * )pfwglGetProcAddress("glGetProgramivARB"))) return 0; + if( ! (pfglGetProgramStringARB = ( void * )pfwglGetProcAddress("glGetProgramStringARB"))) return 0; + if( ! (pfglGetVertexAttribdvARB = ( void * )pfwglGetProcAddress("glGetVertexAttribdvARB"))) return 0; + if( ! (pfglGetVertexAttribfvARB = ( void * )pfwglGetProcAddress("glGetVertexAttribfvARB"))) return 0; + if( ! (pfglGetVertexAttribivARB = ( void * )pfwglGetProcAddress("glGetVertexAttribivARB"))) return 0; + if( ! (pfglGetVertexAttribPointervARB = ( void * )pfwglGetProcAddress("glGetVertexAttribPointervARB"))) return 0; + if( ! (pfglIsProgramARB = ( void * )pfwglGetProcAddress("glIsProgramARB"))) return 0; + + Com_Printf( "...enabling GL_ARB_vertex_program\n" ); + + return 1; +} + + +//////////////////////////////////////////////////////////// + + + + +////////////////////////////// +// +// EXT Functions +// +////////////////////////////// + + +PRIVATE W8 CheckEXTTextureCompressionS3TC( const char *glext ) +{ + if( strstr( glext, "GL_EXT_texture_compression_s3tc" ) == NULL ) + { + Com_Printf( "...GL_EXT_texture_compression_s3tc not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_EXT_texture_compression_s3tc\n" ); + + return 1; +} + +PRIVATE W8 CheckEXTTextureEnvCombine( const char *glext ) +{ + if( strstr( glext, "GL_EXT_texture_env_combine" ) == NULL ) + { + Com_Printf( "...GL_EXT_texture_env_combine not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_EXT_texture_env_combine\n" ); + + return 1; +} + + + +PRIVATE W8 ConfigEXTSecondaryColor( const char *glext ) +{ + if( strstr( glext, "GL_EXT_secondary_color" ) == NULL ) + { + Com_Printf( "...GL_EXT_secondary_color not found\n" ); + return 0; + } + + + if( ! (pfglSecondaryColor3bEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3bEXT"))) return 0; + if( ! (pfglSecondaryColor3bvEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3bvEXT"))) return 0; + if( ! (pfglSecondaryColor3dEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3dEXT"))) return 0; + if( ! (pfglSecondaryColor3dvEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3dvEXT"))) return 0; + if( ! (pfglSecondaryColor3fEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3fEXT"))) return 0; + if( ! (pfglSecondaryColor3fvEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3fvEXT"))) return 0; + if( ! (pfglSecondaryColor3iEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3iEXT"))) return 0; + if( ! (pfglSecondaryColor3ivEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3ivEXT"))) return 0; + if( ! (pfglSecondaryColor3sEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3sEXT"))) return 0; + if( ! (pfglSecondaryColor3svEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3svEXT"))) return 0; + if( ! (pfglSecondaryColor3ubEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3ubEXT"))) return 0; + if( ! (pfglSecondaryColor3ubvEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3ubvEXT"))) return 0; + if( ! (pfglSecondaryColor3uiEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3uiEXT"))) return 0; + if( ! (pfglSecondaryColor3uivEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3uivEXT"))) return 0; + if( ! (pfglSecondaryColor3usEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3usEXT"))) return 0; + if( ! (pfglSecondaryColor3usvEXT = ( void * )pfwglGetProcAddress("glSecondaryColor3usvEXT"))) return 0; + if( ! (pfglSecondaryColorPointerEXT = ( void * )pfwglGetProcAddress("glSecondaryColorPointerEXT"))) return 0; + + Com_Printf( "...enabling GL_EXT_secondary_color\n" ); + + return 1; +} + +PRIVATE W8 ConfigEXTBlendColor( const char *glext ) +{ + if( strstr( glext, "GL_EXT_blend_color" ) == NULL ) + { + Com_Printf( "...GL_EXT_blend_color not found\n" ); + return 0; + } + + if( ! (pfglBlendColorEXT = (void *)pfwglGetProcAddress( "glBlendColorEXT" ))) return 0; + + Com_Printf( "...enabling GL_EXT_blend_color\n" ); + + return 1; +} + +PRIVATE W8 ConfigEXTVertexShader( const char *glext ) +{ + GLint glnum; + + if( strstr( glext, "GL_EXT_vertex_shader" ) == NULL ) + { + return 0; + } + + if( ! (pfglBeginVertexShaderEXT = ( void * )pfwglGetProcAddress("glBeginVertexShaderEXT"))) return 0; + if( ! (pfglEndVertexShaderEXT = ( void * )pfwglGetProcAddress("glEndVertexShaderEXT"))) return 0; + if( ! (pfglBindVertexShaderEXT = ( void * )pfwglGetProcAddress("glBindVertexShaderEXT"))) return 0; + if( ! (pfglGenVertexShadersEXT = ( void * )pfwglGetProcAddress("glGenVertexShadersEXT"))) return 0; + if( ! (pfglDeleteVertexShaderEXT = ( void * )pfwglGetProcAddress("glDeleteVertexShaderEXT"))) return 0; + if( ! (pfglShaderOp1EXT = ( void * )pfwglGetProcAddress("glShaderOp1EXT"))) return 0; + if( ! (pfglShaderOp2EXT = ( void * )pfwglGetProcAddress("glShaderOp2EXT"))) return 0; + if( ! (pfglShaderOp3EXT = ( void * )pfwglGetProcAddress("glShaderOp3EXT"))) return 0; + if( ! (pfglSwizzleEXT = ( void * )pfwglGetProcAddress("glSwizzleEXT"))) return 0; + if( ! (pfglWriteMaskEXT = ( void * )pfwglGetProcAddress("glWriteMaskEXT"))) return 0; + if( ! (pfglInsertComponentEXT = ( void * )pfwglGetProcAddress("glInsertComponentEXT"))) return 0; + if( ! (pfglExtractComponentEXT = ( void * )pfwglGetProcAddress("glExtractComponentEXT"))) return 0; + if( ! (pfglGenSymbolsEXT = ( void * )pfwglGetProcAddress("glGenSymbolsEXT"))) return 0; + if( ! (pfglSetInvariantEXT = ( void * )pfwglGetProcAddress("glSetInvariantEXT"))) return 0; + if( ! (pfglSetLocalConstantEXT = ( void * )pfwglGetProcAddress("glSetLocalConstantEXT"))) return 0; + if( ! (pfglVariantPointerEXT = ( void * )pfwglGetProcAddress("glVariantPointerEXT"))) return 0; + if( ! (pfglEnableVariantClientStateEXT = ( void * )pfwglGetProcAddress("glEnableVariantClientStateEXT"))) return 0; + if( ! (pfglDisableVariantClientStateEXT = ( void * )pfwglGetProcAddress("glDisableVariantClientStateEXT"))) return 0; + if( ! (pfglBindLightParameterEXT = ( void * )pfwglGetProcAddress("glBindLightParameterEXT"))) return 0; + if( ! (pfglBindMaterialParameterEXT = ( void * )pfwglGetProcAddress("glBindMaterialParameterEXT"))) return 0; + if( ! (pfglBindTexGenParameterEXT = ( void * )pfwglGetProcAddress("glBindTexGenParameterEXT"))) return 0; + if( ! (pfglBindTextureUnitParameterEXT = ( void * )pfwglGetProcAddress("glBindTextureUnitParameterEXT"))) return 0; + if( ! (pfglBindParameterEXT = ( void * )pfwglGetProcAddress("glBindParameterEXT"))) return 0; + if( ! (pfglIsVariantEnabledEXT = ( void * )pfwglGetProcAddress("glIsVariantEnabledEXT"))) return 0; + if( ! (pfglGetVariantBooleanvEXT = ( void * )pfwglGetProcAddress("glGetVariantBooleanvEXT"))) return 0; + if( ! (pfglGetVariantIntegervEXT = ( void * )pfwglGetProcAddress("glGetVariantIntegervEXT"))) return 0; + if( ! (pfglGetVariantFloatvEXT = ( void * )pfwglGetProcAddress("glGetVariantFloatvEXT"))) return 0; + if( ! (pfglGetVariantPointervEXT = ( void * )pfwglGetProcAddress("glGetVariantPointervEXT"))) return 0; + if( ! (pfglGetInvariantBooleanvEXT = ( void * )pfwglGetProcAddress("glGetInvariantBooleanvEXT"))) return 0; + if( ! (pfglGetInvariantIntegervEXT = ( void * )pfwglGetProcAddress("glGetInvariantIntegervEXT"))) return 0; + if( ! (pfglGetInvariantFloatvEXT = ( void * )pfwglGetProcAddress("glGetInvariantFloatvEXT"))) return 0; + if( ! (pfglGetLocalConstantBooleanvEXT = ( void * )pfwglGetProcAddress("glGetLocalConstantBooleanvEXT"))) return 0; + if( ! (pfglGetLocalConstantIntegervEXT = ( void * )pfwglGetProcAddress("glGetLocalConstantIntegervEXT"))) return 0; + if( ! (pfglGetLocalConstantFloatvEXT = ( void * )pfwglGetProcAddress("glGetLocalConstantFloatvEXT"))) return 0; + +// +// Checks to see if hardware is able to run our stuff +// + pfglGetIntegerv( GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT, &glnum ); + if( glnum < MY_GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTR ) + { + return 0; + } + + + pfglGetIntegerv( GL_MAX_VERTEX_SHADER_LOCALS_EXT, &glnum ); + if( glnum < MY_GL_MAX_VERTEX_SHADER_LOCALS_EXT ) + { + Com_Printf( "...Some vertex programs may fail to load" ); + return 0; + } + + + pfglGetIntegerv( GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT, &glnum ); + if( glnum < MY_GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT ) + { + return 0; + } + + + pfglGetIntegerv( GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT, &glnum ); + if( glnum < MY_GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT ) + { + return 0; + } + + + pfglGetIntegerv( GL_MAX_VERTEX_SHADER_VARIANTS_EXT, &glnum ); + if( glnum < MY_GL_MAX_VERTEX_SHADER_VARIANTS_EXT ) + { + return 0; + } + + + Com_Printf( "...enabling GL_EXT_vertex_shader\n" ); + + return 1; +} + + +PRIVATE W8 ConfigEXTVertexWeighting( const char *glext ) +{ + if( strstr( glext, "GL_EXT_vertex_weighting" ) == NULL ) + { + Com_Printf( "...GL_EXT_vertex_weighting not found\n" ); + return 0; + } + + + if( ! (pfglVertexWeightfEXT = ( void * )pfwglGetProcAddress( "glVertexWeightfEXT" ))) return 0; + if( ! (pfglVertexWeightfvEXT = ( void * )pfwglGetProcAddress( "glVertexWeightfvEXT" ))) return 0; + if( ! (pfglVertexWeightPointerEXT = ( void * )pfwglGetProcAddress( "glVertexWeightPointerEXT" ))) return 0; + + Com_Printf( "...enabling GL_EXT_vertex_weighting\n" ); + + return 1; +} + +PRIVATE W8 CheckEXTTextureFilterAnisotropic( const char *glext ) +{ + if( strstr( glext, "GL_EXT_texture_filter_anisotropic" ) == NULL ) + { + Com_Printf( "...GL_EXT_texture_filter_anisotropic not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_EXT_texture_filter_anisotropic\n" ); + + return 1; +} + +//////////////////////////////////////////////////////////// + + + + + +////////////////////////////// +// +// Nvidia Functions +// +////////////////////////////// + +PRIVATE W8 ConfigNVVertexArrayRange( const char *glext ) +{ + // Test if VAR is present. + if( strstr( glext, "GL_NV_vertex_array_range" ) == NULL ) + { + return 0; + } + + // Test if Fence + if( strstr( glext, "GL_NV_fence" ) == NULL ) + { + return 0; + } + + + // Setup Vertex Array Range + if( ! (pfglFlushVertexArrayRangeNV = ( void * )pfwglGetProcAddress("glFlushVertexArrayRangeNV")))return 0; + if( ! (pfglVertexArrayRangeNV = ( void * )pfwglGetProcAddress("glVertexArrayRangeNV")))return 0; + +#ifdef _WIN32 + + if( ! (pfwglAllocateMemoryNV = ( void * )pfwglGetProcAddress("wglAllocateMemoryNV"))) return 0; + if( ! (pfwglFreeMemoryNV = ( void * )pfwglGetProcAddress("wglFreeMemoryNV"))) return 0; + +#elif __unix__ + + if( ! (pfwglAllocateMemoryNV = ( void * )pfwglGetProcAddress( "glXAllocateMemoryNV" ))) return 0; + if( ! (pfwglFreeMemoryNV = ( void * )pfwglGetProcAddress( "glXFreeMemoryNV" ))) return 0; + +#else + + #error "Please define OS interface to GL_NV_vertex_array_range" + +#endif + + + // Setup fence + if( ! (pfglDeleteFencesNV = ( void * )pfwglGetProcAddress( "glDeleteFencesNV" ))) return 0; + if( ! (pfglGenFencesNV = ( void * )pfwglGetProcAddress( "glGenFencesNV" ))) return 0; + if( ! (pfglIsFenceNV = ( void * )pfwglGetProcAddress( "glIsFenceNV" ))) return 0; + if( ! (pfglTestFenceNV = ( void * )pfwglGetProcAddress( "glTestFenceNV" ))) return 0; + if( ! (pfglGetFenceivNV = ( void * )pfwglGetProcAddress( "glGetFenceivNV" ))) return 0; + if( ! (pfglFinishFenceNV = ( void * )pfwglGetProcAddress( "glFinishFenceNV" ))) return 0; + if( ! (pfglSetFenceNV = ( void * )pfwglGetProcAddress( "glSetFenceNV" ))) return 0; + + Com_Printf( "...enabling GL_NV_vertex_array_range & GL_NV_fence\n" ); + + return 1; +} + +PRIVATE W8 CheckNVVertexArrayRange2( const char *glext ) +{ + if( strstr( glext, "GL_NV_vertex_array_range2" ) == NULL ) + { + Com_Printf( "...GL_NV_vertex_array_range2 not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_NV_vertex_array_range2\n" ); + + return 1; +} + +PRIVATE W8 CheckNVTextureEnvCombine4( const char *glext ) +{ + if( strstr( glext, "GL_NV_texture_env_combine4") == NULL ) + { + Com_Printf( "...GL_NV_texture_env_combine4 not found\n" ); + return 0; + } + + Com_Printf( "...enabling GL_NV_texture_env_combine4\n" ); + + return 1; +} + +PRIVATE W8 ConfigNVVertexProgram( const char *glext ) +{ + if( strstr( glext, "GL_NV_vertex_program" ) == NULL ) + return 0; + + + if( ! (pfglAreProgramsResidentNV = ( void * )pfwglGetProcAddress("glAreProgramsResidentNV"))) return 0; + if( ! (pfglBindProgramNV = ( void * )pfwglGetProcAddress("glBindProgramNV"))) return 0; + if( ! (pfglDeleteProgramsNV = ( void * )pfwglGetProcAddress("glDeleteProgramsNV"))) return 0; + if( ! (pfglExecuteProgramNV = ( void * )pfwglGetProcAddress("glExecuteProgramNV"))) return 0; + if( ! (pfglGenProgramsNV = ( void * )pfwglGetProcAddress("glGenProgramsNV"))) return 0; + if( ! (pfglGetProgramParameterdvNV = ( void * )pfwglGetProcAddress("glGetProgramParameterdvNV"))) return 0; + if( ! (pfglGetProgramParameterfvNV = ( void * )pfwglGetProcAddress("glGetProgramParameterfvNV"))) return 0; + if( ! (pfglGetProgramivNV = ( void * )pfwglGetProcAddress("glGetProgramivNV"))) return 0; + if( ! (pfglGetProgramStringNV = ( void * )pfwglGetProcAddress("glGetProgramStringNV"))) return 0; + if( ! (pfglGetTrackMatrixivNV = ( void * )pfwglGetProcAddress("glGetTrackMatrixivNV"))) return 0; + if( ! (pfglGetVertexAttribdvNV = ( void * )pfwglGetProcAddress("glGetVertexAttribdvNV"))) return 0; + if( ! (pfglGetVertexAttribfvNV = ( void * )pfwglGetProcAddress("glGetVertexAttribfvNV"))) return 0; + if( ! (pfglGetVertexAttribivNV = ( void * )pfwglGetProcAddress("glGetVertexAttribivNV"))) return 0; + if( ! (pfglGetVertexAttribPointervNV = ( void * )pfwglGetProcAddress("glGetVertexAttribPointervNV"))) return 0; + if( ! (pfglIsProgramNV = ( void * )pfwglGetProcAddress("glIsProgramNV"))) return 0; + if( ! (pfglLoadProgramNV = ( void * )pfwglGetProcAddress("glLoadProgramNV"))) return 0; + if( ! (pfglProgramParameter4dNV = ( void * )pfwglGetProcAddress("glProgramParameter4dNV"))) return 0; + if( ! (pfglProgramParameter4dvNV = ( void * )pfwglGetProcAddress("glProgramParameter4dvNV"))) return 0; + if( ! (pfglProgramParameter4fNV = ( void * )pfwglGetProcAddress("glProgramParameter4fNV"))) return 0; + if( ! (pfglProgramParameter4fvNV = ( void * )pfwglGetProcAddress("glProgramParameter4fvNV"))) return 0; + if( ! (pfglProgramParameters4dvNV = ( void * )pfwglGetProcAddress("glProgramParameters4dvNV"))) return 0; + if( ! (pfglProgramParameters4fvNV = ( void * )pfwglGetProcAddress("glProgramParameters4fvNV"))) return 0; + if( ! (pfglRequestResidentProgramsNV = ( void * )pfwglGetProcAddress("glRequestResidentProgramsNV"))) return 0; + if( ! (pfglTrackMatrixNV = ( void * )pfwglGetProcAddress("glTrackMatrixNV"))) return 0; + if( ! (pfglVertexAttribPointerNV = ( void * )pfwglGetProcAddress("glVertexAttribPointerNV"))) return 0; + if( ! (pfglVertexAttrib1dNV = ( void * )pfwglGetProcAddress("glVertexAttrib1dNV"))) return 0; + if( ! (pfglVertexAttrib1dvNV = ( void * )pfwglGetProcAddress("glVertexAttrib1dvNV"))) return 0; + if( ! (pfglVertexAttrib1fNV = ( void * )pfwglGetProcAddress("glVertexAttrib1fNV"))) return 0; + if( ! (pfglVertexAttrib1fvNV = ( void * )pfwglGetProcAddress("glVertexAttrib1fvNV"))) return 0; + if( ! (pfglVertexAttrib1sNV = ( void * )pfwglGetProcAddress("glVertexAttrib1sNV"))) return 0; + if( ! (pfglVertexAttrib1svNV = ( void * )pfwglGetProcAddress("glVertexAttrib1svNV"))) return 0; + if( ! (pfglVertexAttrib2dNV = ( void * )pfwglGetProcAddress("glVertexAttrib2dNV"))) return 0; + if( ! (pfglVertexAttrib2dvNV = ( void * )pfwglGetProcAddress("glVertexAttrib2dvNV"))) return 0; + if( ! (pfglVertexAttrib2fNV = ( void * )pfwglGetProcAddress("glVertexAttrib2fNV"))) return 0; + if( ! (pfglVertexAttrib2fvNV = ( void * )pfwglGetProcAddress("glVertexAttrib2fvNV"))) return 0; + if( ! (pfglVertexAttrib2sNV = ( void * )pfwglGetProcAddress("glVertexAttrib2sNV"))) return 0; + if( ! (pfglVertexAttrib2svNV = ( void * )pfwglGetProcAddress("glVertexAttrib2svNV"))) return 0; + if( ! (pfglVertexAttrib3dNV = ( void * )pfwglGetProcAddress("glVertexAttrib3dNV"))) return 0; + if( ! (pfglVertexAttrib3dvNV = ( void * )pfwglGetProcAddress("glVertexAttrib3dvNV"))) return 0; + if( ! (pfglVertexAttrib3fNV = ( void * )pfwglGetProcAddress("glVertexAttrib3fNV"))) return 0; + if( ! (pfglVertexAttrib3fvNV = ( void * )pfwglGetProcAddress("glVertexAttrib3fvNV"))) return 0; + if( ! (pfglVertexAttrib3sNV = ( void * )pfwglGetProcAddress("glVertexAttrib3sNV"))) return 0; + if( ! (pfglVertexAttrib3svNV = ( void * )pfwglGetProcAddress("glVertexAttrib3svNV"))) return 0; + if( ! (pfglVertexAttrib4dNV = ( void * )pfwglGetProcAddress("glVertexAttrib4dNV"))) return 0; + if( ! (pfglVertexAttrib4dvNV = ( void * )pfwglGetProcAddress("glVertexAttrib4dvNV"))) return 0; + if( ! (pfglVertexAttrib4fNV = ( void * )pfwglGetProcAddress("glVertexAttrib4fNV"))) return 0; + if( ! (pfglVertexAttrib4fvNV = ( void * )pfwglGetProcAddress("glVertexAttrib4fvNV"))) return 0; + if( ! (pfglVertexAttrib4sNV = ( void * )pfwglGetProcAddress("glVertexAttrib4sNV"))) return 0; + if( ! (pfglVertexAttrib4svNV = ( void * )pfwglGetProcAddress("glVertexAttrib4svNV"))) return 0; + if( ! (pfglVertexAttrib4ubvNV = ( void * )pfwglGetProcAddress("glVertexAttrib4ubvNV"))) return 0; + if( ! (pfglVertexAttribs1dvNV = ( void * )pfwglGetProcAddress("glVertexAttribs1dvNV"))) return 0; + if( ! (pfglVertexAttribs1fvNV = ( void * )pfwglGetProcAddress("glVertexAttribs1fvNV"))) return 0; + if( ! (pfglVertexAttribs1svNV = ( void * )pfwglGetProcAddress("glVertexAttribs1svNV"))) return 0; + if( ! (pfglVertexAttribs2dvNV = ( void * )pfwglGetProcAddress("glVertexAttribs2dvNV"))) return 0; + if( ! (pfglVertexAttribs2fvNV = ( void * )pfwglGetProcAddress("glVertexAttribs2fvNV"))) return 0; + if( ! (pfglVertexAttribs2svNV = ( void * )pfwglGetProcAddress("glVertexAttribs2svNV"))) return 0; + if( ! (pfglVertexAttribs3dvNV = ( void * )pfwglGetProcAddress("glVertexAttribs3dvNV"))) return 0; + if( ! (pfglVertexAttribs3fvNV = ( void * )pfwglGetProcAddress("glVertexAttribs3fvNV"))) return 0; + if( ! (pfglVertexAttribs3svNV = ( void * )pfwglGetProcAddress("glVertexAttribs3svNV"))) return 0; + if( ! (pfglVertexAttribs4dvNV = ( void * )pfwglGetProcAddress("glVertexAttribs4dvNV"))) return 0; + if( ! (pfglVertexAttribs4fvNV = ( void * )pfwglGetProcAddress("glVertexAttribs4fvNV"))) return 0; + if( ! (pfglVertexAttribs4svNV = ( void * )pfwglGetProcAddress("glVertexAttribs4svNV"))) return 0; + if( ! (pfglVertexAttribs4ubvNV = ( void * )pfwglGetProcAddress("glVertexAttribs4ubvNV"))) return 0; + + + Com_Printf( "...enabling GL_NV_vertex_program\n" ); + + return 1; +} + + + + + +PRIVATE W8 CheckNVTextureShader( const char *glext ) +{ + if( strstr( glext, "GL_NV_texture_shader" ) == NULL ) + { + return 0; + } + + Com_Printf( "...enabling GL_NV_texture_shader\n" ); + + return 1; +} + +//////////////////////////////////////////////////////////// + + +////////////////////////////// +// +// ATI Functions +// +////////////////////////////// + + +PRIVATE W8 ConfigATIVertexArrayObject( const char *glext ) +{ + if( strstr( glext, "GL_ATI_vertex_array_object" ) == NULL ) + { + return 0; + } + + if( ! (pfglBlendColorEXT = ( void * )pfwglGetProcAddress("glBlendColorEXT"))) return 0; + if( ! (pfglNewObjectBufferATI = ( void * )pfwglGetProcAddress("glNewObjectBufferATI"))) return 0; + if( ! (pfglIsObjectBufferATI = ( void * )pfwglGetProcAddress("glIsObjectBufferATI"))) return 0; + if( ! (pfglUpdateObjectBufferATI = ( void * )pfwglGetProcAddress("glUpdateObjectBufferATI"))) return 0; + if( ! (pfglGetObjectBufferfvATI = ( void * )pfwglGetProcAddress("glGetObjectBufferfvATI"))) return 0; + if( ! (pfglGetObjectBufferivATI = ( void * )pfwglGetProcAddress("glGetObjectBufferivATI"))) return 0; + + if( ! (pfglFreeObjectBufferATI = ( void * )pfwglGetProcAddress("glFreeObjectBufferATI"))) return 0; + + if( ! (pfglArrayObjectATI = ( void * )pfwglGetProcAddress("glArrayObjectATI"))) return 0; + if( ! (pfglGetArrayObjectfvATI = ( void * )pfwglGetProcAddress("glGetArrayObjectfvATI"))) return 0; + if( ! (pfglGetArrayObjectivATI = ( void * )pfwglGetProcAddress("glGetArrayObjectivATI"))) return 0; + if( ! (pfglVariantArrayObjectATI = ( void * )pfwglGetProcAddress("glVariantArrayObjectATI"))) return 0; + if( ! (pfglGetVariantArrayObjectfvATI = ( void * )pfwglGetProcAddress("glGetVariantArrayObjectfvATI"))) return 0; + if( ! (pfglGetVariantArrayObjectivATI = ( void * )pfwglGetProcAddress("glGetVariantArrayObjectivATI"))) return 0; + + Com_Printf( "...enabling GL_ATI_vertex_array_object\n" ); + + return 1; +} + + +PRIVATE W8 ConfigATIMapObjectBuffer( const char *glext ) +{ + if( strstr( glext, "GL_ATI_map_object_buffer" ) == NULL ) + { + return 0; + } + + if( ! (pfglMapObjectBufferATI = ( void * )pfwglGetProcAddress("glMapObjectBufferATI"))) return 0; + if( ! (pfglUnmapObjectBufferATI = ( void * )pfwglGetProcAddress("glUnmapObjectBufferATI"))) return 0; + + Com_Printf( "...enabling GL_ATI_map_object_buffer\n" ); + + return 1; +} + + + + +PRIVATE W8 ConfigATIFragmentShader( const char *glext ) +{ + if( strstr( glext, "GL_ATI_fragment_shader" ) == NULL ) + { + return 0; + } + + if( ! (pfglGenFragmentShadersATI = ( void * )pfwglGetProcAddress("glGenFragmentShadersATI"))) return 0; + if( ! (pfglBindFragmentShaderATI = ( void * )pfwglGetProcAddress("glBindFragmentShaderATI"))) return 0; + if( ! (pfglDeleteFragmentShaderATI = ( void * )pfwglGetProcAddress("glDeleteFragmentShaderATI"))) return 0; + if( ! (pfglBeginFragmentShaderATI = ( void * )pfwglGetProcAddress("glBeginFragmentShaderATI"))) return 0; + if( ! (pfglEndFragmentShaderATI = ( void * )pfwglGetProcAddress("glEndFragmentShaderATI"))) return 0; + if( ! (pfglPassTexCoordATI = ( void * )pfwglGetProcAddress("glPassTexCoordATI"))) return 0; + if( ! (pfglSampleMapATI = ( void * )pfwglGetProcAddress("glSampleMapATI"))) return 0; + if( ! (pfglColorFragmentOp1ATI = ( void * )pfwglGetProcAddress("glColorFragmentOp1ATI"))) return 0; + if( ! (pfglColorFragmentOp2ATI = ( void * )pfwglGetProcAddress("glColorFragmentOp2ATI"))) return 0; + if( ! (pfglColorFragmentOp3ATI = ( void * )pfwglGetProcAddress("glColorFragmentOp3ATI"))) return 0; + if( ! (pfglAlphaFragmentOp1ATI = ( void * )pfwglGetProcAddress("glAlphaFragmentOp1ATI"))) return 0; + if( ! (pfglAlphaFragmentOp2ATI = ( void * )pfwglGetProcAddress("glAlphaFragmentOp2ATI"))) return 0; + if( ! (pfglAlphaFragmentOp3ATI = ( void * )pfwglGetProcAddress("glAlphaFragmentOp3ATI"))) return 0; + if( ! (pfglSetFragmentShaderConstantATI = ( void * )pfwglGetProcAddress("glSetFragmentShaderConstantATI"))) return 0; + + Com_Printf( "...enabling GL_ATI_fragment_shader\n" ); + + return 1; +} + +PRIVATE W8 CheckATITextureEnvCombine3( const char *glext ) +{ + if( strstr( glext, "GL_ATI_texture_env_combine3" ) == NULL ) + { + return 0; + } + + Com_Printf( "...enabling GL_ATI_texture_env_combine3\n" ); + + return 1; +} + + +PRIVATE W8 CheckATIXTextureEnvRoute(const char *glext) +{ + if( strstr( glext, "GL_ATIX_texture_env_route" ) == NULL ) + { + return 0; + } + + Com_Printf( "...enabling GL_ATIX_texture_env_route\n" ); + + return 1; +} + + +PRIVATE W8 ConfigATIEnvMapBumpMap( const char *glext ) +{ + if( strstr( glext, "GL_ATI_envmap_bumpmap" ) == NULL ) + { + return 0; + } + + if( ! (pfglTexBumpParameterivATI = ( void * ) pfwglGetProcAddress("glTexBumpParameterivATI"))) return 0; + if( ! (pfglTexBumpParameterfvATI = ( void * ) pfwglGetProcAddress("glTexBumpParameterfvATI"))) return 0; + if( ! (pfglGetTexBumpParameterivATI = ( void * ) pfwglGetProcAddress("glGetTexBumpParameterivATI"))) return 0; + if( ! (pfglGetTexBumpParameterfvATI = ( void * ) pfwglGetProcAddress("glGetTexBumpParameterfvATI"))) return 0; + + Com_Printf( "...enabling GL_ATI_envmap_bumpmap\n" ); + + return 1; +} +/* +PRIVATE W8 ConfigARBFragmentProgram( const char *glext ) +{ + if( strstr( glext, "GL_ARB_fragment_program" ) == NULL ) + { + return 0; + } + + if( ! (pfglProgramStringARB = ( void * )pfwglGetProcAddress("glProgramStringARB"))) return 0; + if( ! (pfglBindProgramARB = ( void * )pfwglGetProcAddress("glBindProgramARB"))) return 0; + if( ! (pfglDeleteProgramsARB = ( void * )pfwglGetProcAddress("glDeleteProgramsARB"))) return 0; + if( ! (pfglGenProgramsARB = ( void * )pfwglGetProcAddress("glGenProgramsARB"))) return 0; + if( ! (pfglProgramEnvParameter4dARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4dARB"))) return 0; + if( ! (pfglProgramEnvParameter4dvARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4dvARB"))) return 0; + if( ! (pfglProgramEnvParameter4fARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4fARB"))) return 0; + if( ! (pfglProgramEnvParameter4fvARB = ( void * )pfwglGetProcAddress("glProgramEnvParameter4fvARB"))) return 0; + if( ! (pfglGetProgramLocalParameter4dARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4dARB"))) return 0; + if( ! (pfglGetProgramLocalParameter4dvARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4dvARB"))) return 0; + if( ! (pfglGetProgramLocalParameter4fARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4fARB"))) return 0; + if( ! (pfglGetProgramLocalParameter4fvARB = ( void * )pfwglGetProcAddress("glProgramLocalParameter4fvARB"))) return 0; + if( ! (pfglGetProgramEnvParameterdvARB = ( void * )pfwglGetProcAddress("glGetProgramEnvParameterdvARB"))) return 0; + if( ! (pfglGetProgramEnvParameterfvARB = ( void * )pfwglGetProcAddress("glGetProgramEnvParameterfvARB"))) return 0; + if( ! (pfglGetProgramLocalParameterdvARB = ( void * )pfwglGetProcAddress("glGetProgramLocalParameterdvARB"))) return 0; + if( ! (pfglGetProgramLocalParameterfvARB = ( void * )pfwglGetProcAddress("glGetProgramLocalParameterfvARB"))) return 0; + if( ! (pfglGetProgramivARB = ( void * )pfwglGetProcAddress("glGetProgramivARB"))) return 0; + if( ! (pfglGetProgramStringARB = ( void * )pfwglGetProcAddress("glGetProgramStringARB"))) return 0; + if( ! (pfglIsProgramARB = ( void * )pfwglGetProcAddress("glIsProgramARB"))) return 0; + + return 1; +} + + +PRIVATE W8 ConfigARBVertexBufferObject( const char *glext ) +{ + if( strstr( glext, "GL_ARB_vertex_buffer_object" ) == NULL ) + return 0; + + if( ! (pfglBindBufferARB = ( void * )pfwglGetProcAddress("glBindBufferARB"))) return 0; + if( ! (pfglDeleteBuffersARB = ( void * )pfwglGetProcAddress("glDeleteBuffersARB"))) return 0; + if( ! (pfglGenBuffersARB = ( void * )pfwglGetProcAddress("glGenBuffersARB"))) return 0; + if( ! (pfglIsBufferARB = ( void * )pfwglGetProcAddress("glIsBufferARB"))) return 0; + if( ! (pfglBufferDataARB = ( void * )pfwglGetProcAddress("glBufferDataARB"))) return 0; + if( ! (pfglBufferSubDataARB = ( void * )pfwglGetProcAddress("glBufferSubDataARB"))) return 0; + if( ! (pfglGetBufferSubDataARB = ( void * )pfwglGetProcAddress("glGetBufferSubDataARB"))) return 0; + if( ! (pfglMapBufferARB = ( void * )pfwglGetProcAddress("glMapBufferARB"))) return 0; + if( ! (pfglUnmapBufferARB = ( void * )pfwglGetProcAddress("glUnmapBufferARB"))) return 0; + if( ! (pfglGetBufferParameterivARB = ( void * )pfwglGetProcAddress("glGetBufferParameterivARB"))) return 0; + if( ! (pfglGetBufferPointervARB = ( void * )pfwglGetProcAddress("glGetBufferPointervARB"))) return 0; + + return 1; +}*/ + + + + +#ifdef _WIN32 + +PRIVATE W8 ConfigWGLARBPBuffer( const char *glext ) +{ + if( strstr( glext, "WGL_ARB_pbuffer" ) == NULL ) + { + Com_Printf( "...WGL_ARB_pbuffer not found\n" ); + return 0; + } + + if( ! (pfwglCreatePbufferARB = ( void * )pfwglGetProcAddress( "wglCreatePbufferARB" ))) return 0; + if( ! (pfwglGetPbufferDCARB = ( void * )pfwglGetProcAddress( "wglGetPbufferDCARB" ))) return 0; + if( ! (pfwglReleasePbufferDCARB = ( void * )pfwglGetProcAddress( "wglReleasePbufferDCARB" ))) return 0; + if( ! (pfwglDestroyPbufferARB = ( void * )pfwglGetProcAddress( "wglDestroyPbufferARB" ))) return 0; + if( ! (pfwglQueryPbufferARB = ( void * )pfwglGetProcAddress( "wglQueryPbufferARB" ))) return 0; + + Com_Printf( "...enabling WGL_ARB_pbuffer\n" ); + + return 1; +} + + +PRIVATE W8 ConfigWGLARBPixelFormat ( const char *glext ) +{ + if( strstr( glext, "WGL_ARB_pixel_format" ) == NULL ) + { + Com_Printf( "...WGL_ARB_pixel_format not found\n" ); + return 0; + } + + if( ! (pfwglGetPixelFormatAttribivARB = ( void * )pfwglGetProcAddress( "wglGetPixelFormatAttribivARB" ))) return 0; + if( ! (pfwglGetPixelFormatAttribfvARB = ( void * )pfwglGetProcAddress( "wglGetPixelFormatAttribfvARB" ))) return 0; + if( ! (pfwglChoosePixelFormatARB = ( void * )pfwglGetProcAddress( "wglChoosePixelFormatARB" ))) return 0; + + Com_Printf( "...enabling WGL_ARB_pixel_format\n" ); + + return 1; +} + +PRIVATE W8 ConfigWGLEXTSwapControl( const char *glext ) +{ + if( strstr( glext, "WGL_EXT_swap_control" ) == NULL ) + { + Com_Printf( "...WGL_EXT_swap_control not found\n" ); + return 0; + } + + if( ! (pfwglSwapIntervalEXT = (WGLSWAPINTERVALEXT)pfwglGetProcAddress( "wglSwapIntervalEXT" ) ) ) return 0; + if( ! (pfwglGetSwapIntervalEXT = (WGLGETSWAPINTERVALEXT)pfwglGetProcAddress( "wglGetSwapIntervalEXT" ) ) ) return 0; + + Com_Printf( "...enabling WGL_EXT_swap_control\n" ); + + return 1; +} + +#endif /* _WIN32 */ + + + + + + + + + + +/* +----------------------------------------------------------------------------- + Function: GL_ConfigExtensions - + + Parameters: glext -[in] Pointer to string containing the gl extension names. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void GL_ConfigExtensions( const char *glext ) +{ + GLint ntext; + + + memset( &gl_ext, 0, sizeof( GL_Extensions ) ); + + gl_ext.ARBMultiTexture = ConfigARBMultiTexture( glext ); + if( gl_ext.ARBMultiTexture ) + { + pfglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &ntext ); + + // There could be more than MY_MAX_ARB_TEXTURESTAGES, but we only + // require MY_MAX_ARB_TEXTURESTAGES texture stages so take min. + gl_ext.nTextureStages = ( ntext < ( (GLint)MY_MAX_ARB_TEXTURESTAGES) ? ntext : MY_MAX_ARB_TEXTURESTAGES ); + } + + + gl_ext.EXTTextureFilterAnisotropic = CheckEXTTextureFilterAnisotropic( glext ); + if( gl_ext.EXTTextureFilterAnisotropic ) + { + pfglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_ext.nMaxAnisotropy ); + + if( gl_ext.nMaxAnisotropy < 2.0f ) + { + gl_ext.nMaxAnisotropy = 0; + } + + } + + + gl_ext.EXTTextureEnvCombine = CheckEXTTextureEnvCombine( glext ); + + + gl_ext.ARBTextureCompression = ConfigARBTextureCompression( glext ); + + + gl_ext.EXTTextureCompressionS3TC = (gl_ext.ARBTextureCompression && CheckEXTTextureCompressionS3TC( glext ) ); + + + gl_ext.ARBTextureCubeMap = CheckARBTextureCubeMap( glext ); + + + gl_ext.EXTSecondaryColor = ConfigEXTSecondaryColor( glext ); + + + gl_ext.EXTBlendColor = ConfigEXTBlendColor( glext ); + + + // nVidia extensions + // ----------------- + + + gl_ext.NVVertexArrayRange = ConfigNVVertexArrayRange( glext ); + if( gl_ext.NVVertexArrayRange ) + { + GLint nverts; + pfglGetIntegerv( (GLenum)GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV, &nverts ); + gl_ext.NVVertexArrayRangeMaxVertex = nverts; + } + + + gl_ext.EXTVertexWeighting = ConfigEXTVertexWeighting( glext ); + + + gl_ext.NVVertexArrayRange2 = CheckNVVertexArrayRange2( glext ); + if( gl_ext.NVVertexArrayRange2 ) + { + // VBHard swap without flush of the VAR. + gl_ext.NVStateVARWithoutFlush = GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV; + } + else + { + // VBHard with unusefull flush of the VAR. + gl_ext.NVStateVARWithoutFlush = GL_VERTEX_ARRAY_RANGE_NV; + } + + + gl_ext.NVTextureEnvCombine4 = CheckNVTextureEnvCombine4( glext ); + + + if( ! gl_ext.DisableHardwareVertexProgram ) + { + gl_ext.NVVertexProgram = ConfigNVVertexProgram( glext ); + gl_ext.EXTVertexShader = ConfigEXTVertexShader( glext ); + gl_ext.ARBVertexProgram= ConfigARBVertexProgram( glext ); + } + else + { + gl_ext.NVVertexProgram = false; + gl_ext.EXTVertexShader = false; + gl_ext.ARBVertexProgram = false; + } + + + gl_ext.NVTextureShader = CheckNVTextureShader( glext ); + if( gl_ext.NVVertexProgram && ! gl_ext.NVTextureShader ) + { + // if GL_NV_texture_shader is not here, + // then we are not on a GeForce3. + gl_ext.NVVertexProgramEmulated = true; + } + + + // ATI extensions + // -------------- + + gl_ext.ATIVertexArrayObject = ConfigATIVertexArrayObject( glext ); + gl_ext.ATIMapObjectBuffer = ConfigATIMapObjectBuffer( glext ); + + + gl_ext.ATITextureEnvCombine3 = CheckATITextureEnvCombine3( glext ); + + gl_ext.ATIXTextureEnvRoute = CheckATIXTextureEnvRoute( glext ); + + gl_ext.ATIEnvMapBumpMap = ConfigATIEnvMapBumpMap( glext ); + +// gl_ext.ATIFragmentShader = setupATIFragmentShader( glext ); + + + + + + +#ifdef _WIN32 + + + ConfigWGLARBPBuffer( glext ); + + + ConfigWGLARBPixelFormat( glext ); + + + ConfigWGLEXTSwapControl( glext ); + + +#endif + + + + +} diff --git a/wolf3d/newCode/env/opengl_local.h b/wolf3d/newCode/env/opengl_local.h new file mode 100644 index 0000000..3102bcf --- /dev/null +++ b/wolf3d/newCode/env/opengl_local.h @@ -0,0 +1,256 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifndef __OPENGL_LOCAL_H__ +#define __OPENGL_LOCAL_H__ + +extern int glMaxTexSize; // maximum texture size + + +//=================================================================== + + +extern void GL_SetDefaultState( void ); +extern void GL_UpdateSwapInterval( void ); + +extern float gldepthmin, gldepthmax; + + + +//==================================================== + + + +extern int gl_filter_min, gl_filter_max; + +// +// view origin +// +extern vec3_t vup; +extern vec3_t vpn; +extern vec3_t vright; +extern vec3_t r_origin; + +// +// screen size info +// +//extern refdef_t r_newrefdef; +extern int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2; + +extern cvar_t *r_norefresh; +extern cvar_t *r_lefthand; +extern cvar_t *r_speeds; +extern cvar_t *r_novis; +extern cvar_t *r_nocull; + + +extern cvar_t *gl_vertex_arrays; + +extern cvar_t *gl_ext_swapinterval; +extern cvar_t *gl_ext_palettedtexture; +extern cvar_t *gl_ext_multitexture; +extern cvar_t *gl_ext_pointparameters; +extern cvar_t *gl_ext_compiled_vertex_array; + + +extern cvar_t *gl_nosubimage; +extern cvar_t *gl_bitdepth; +extern cvar_t *gl_mode; +extern cvar_t *gl_lightmap; +extern cvar_t *gl_shadows; +extern cvar_t *gl_dynamic; +extern cvar_t *gl_nobind; +extern cvar_t *gl_round_down; +extern cvar_t *gl_picmip; +extern cvar_t *gl_skymip; +extern cvar_t *gl_showtris; +extern cvar_t *gl_finish; +extern cvar_t *gl_ztrick; +extern cvar_t *gl_clear; +extern cvar_t *gl_cull; +extern cvar_t *gl_poly; +extern cvar_t *gl_texsort; +extern cvar_t *gl_polyblend; +extern cvar_t *gl_flashblend; +extern cvar_t *gl_lightmaptype; +extern cvar_t *gl_modulate; +extern cvar_t *gl_playermip; +extern cvar_t *gl_drawbuffer; +extern cvar_t *gl_driver; +extern cvar_t *gl_swapinterval; +extern cvar_t *gl_texturemode; +extern cvar_t *gl_saturatelighting; + +extern cvar_t *r_fullscreen; +extern cvar_t *vid_gamma; + +extern cvar_t *intensity; + +extern int gl_lightmap_format; +extern int gl_solid_format; +extern int gl_alpha_format; +extern int gl_tex_alpha_format; + + + + +extern void R_Bind( int texnum ); +extern void R_MBind( GLenum target, int texnum ); +extern void R_TexEnv( GLenum value ); +extern void R_EnableMultitexture( _boolean enable ); +extern void R_SelectTexture( GLenum ); + + +//==================================================================== + + +extern int registration_sequence; + + + +typedef struct +{ + const char *renderer_string; + const char *vendor_string; + const char *version_string; + const char *extensions_string; + _boolean Version_1_2; + +} glconfig_t; + +typedef struct +{ + float inverse_intensity; + _boolean fullscreen; + + int prev_mode; + + int lightmap_textures; + + int currenttextures[2]; + int currenttmu; + + +} glstate_t; + +extern glconfig_t gl_config; +extern glstate_t gl_state; + + +////////////////////////////////////////////////////// + + +typedef struct +{ + _boolean ARBMultiTexture; + int nTextureStages; // Number of texture stages supported + _boolean EXTTextureEnvCombine; + + _boolean EXTTextureFilterAnisotropic; + float nMaxAnisotropy; + // NB: Fence extension is not here, because NVVertexArrayRange is false if GL_NV_fence is not here. + _boolean NVVertexArrayRange; + int NVVertexArrayRangeMaxVertex; + _boolean EXTTextureCompressionS3TC; + _boolean EXTVertexWeighting; + _boolean EXTSeparateSpecularColor; + _boolean NVTextureEnvCombine4; + _boolean ARBTextureCubeMap; + _boolean NVVertexProgram; + _boolean EXTVertexShader; + _boolean NVTextureShader; + // true if NVVertexProgram and if we know that VP is emulated + _boolean NVVertexProgramEmulated; + _boolean EXTSecondaryColor; + _boolean EXTBlendColor; + // NVVertexArrayRange2. + _boolean NVVertexArrayRange2; + // equal to GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV if possible, or GL_VERTEX_ARRAY_RANGE_NV + int NVStateVARWithoutFlush; + + /* WGL ARB Extensions */ + _boolean WGLARBPBuffer; + _boolean WGLARBPixelFormat; + _boolean WGLEXTSwapControl; + + /* ATI Extensions */ + _boolean ATIVertexArrayObject; + _boolean ATIMapObjectBuffer; + _boolean ATITextureEnvCombine3; + _boolean ATIEnvMapBumpMap; + _boolean ATIFragmentShader; + _boolean ATIXTextureEnvRoute; + + /* ARB Extensions */ + _boolean ARBTextureCompression; + _boolean ARBFragmentProgram; + _boolean ARBVertexBufferObject; + _boolean ARBVertexProgram; + + /* Disable Hardware feature */ + _boolean DisableHardwareVertexProgram; + _boolean DisableHardwareTextureShader; + +} GL_Extensions; + +extern GL_Extensions gl_ext; + + +extern void GL_ConfigExtensions( const char *glext ); + +extern void MYgluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ); + + +extern void PrintGLError( W32 err, const char *from ); + + + + +/* +==================================================================== + +IMPLEMENTATION SPECIFIC FUNCTIONS + +==================================================================== +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +void GLimp_BeginFrame(); +void GLimp_EndFrame( void ); +_boolean GLimp_Init( void *hinstance, void *hWnd ); +void GLimp_Shutdown( void ); +int GLimp_SetMode( int *pwidth, int *pheight, int mode, _boolean fullscreen ); +void GLimp_AppActivate( _boolean active ); + +#ifdef __cplusplus +} +#endif + + + + + + + + +#endif /* __OPENGL_LOCAL_H__ */ diff --git a/wolf3d/newCode/env/opengl_main.c b/wolf3d/newCode/env/opengl_main.c new file mode 100644 index 0000000..61eae74 --- /dev/null +++ b/wolf3d/newCode/env/opengl_main.c @@ -0,0 +1,497 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + + +viddef_t viddef; + +float gldepthmin, gldepthmax; + +glconfig_t gl_config; +glstate_t gl_state; + + + + + +// +// view origin +// +vec3_t vup; +vec3_t vpn; +vec3_t vright; +vec3_t r_origin; + +cvar_t *r_norefresh; +cvar_t *r_speeds; +cvar_t *r_novis; +cvar_t *r_nocull; +cvar_t *r_lefthand; + + +cvar_t *gl_nosubimage; + + +cvar_t *gl_vertex_arrays; + + + +cvar_t *gl_ext_swapinterval; +cvar_t *gl_ext_palettedtexture; +cvar_t *gl_ext_multitexture; +cvar_t *gl_ext_pointparameters; +cvar_t *gl_ext_compiled_vertex_array; + +//cvar_t *gl_ext_TextureCompressionS3TC; + +cvar_t *gl_bitdepth; +cvar_t *gl_drawbuffer; +cvar_t *gl_driver; +cvar_t *gl_lightmap; +cvar_t *gl_shadows; +cvar_t *gl_mode; +cvar_t *gl_dynamic; +cvar_t *gl_modulate; +cvar_t *gl_nobind; +cvar_t *gl_round_down; +cvar_t *gl_picmip; +cvar_t *gl_skymip; +cvar_t *gl_showtris; +cvar_t *gl_ztrick; +cvar_t *gl_finish; +cvar_t *gl_clear; +cvar_t *gl_cull; +cvar_t *gl_polyblend; +cvar_t *gl_flashblend; +cvar_t *gl_playermip; +cvar_t *gl_saturatelighting; +cvar_t *gl_swapinterval; +cvar_t *gl_texturemode; + +cvar_t *r_fullscreen; +cvar_t *vid_gamma; +cvar_t *r_ref; + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void MYgluPerspective( GLdouble fovy, GLdouble aspect, + GLdouble zNear, GLdouble zFar ) +{ + GLdouble xmin, xmax, ymin, ymax; + + ymax = zNear * tan( fovy * M_PI / 360.0 ); + ymin = -ymax; + + xmin = ymin * aspect; + xmax = ymax * aspect; + + xmin += -( 2 * 0 ) / zNear; + xmax += -( 2 * 0 ) / zNear; + + pfglFrustum( xmin, xmax, ymin, ymax, zNear, zFar ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void R_ScreenShot_f( void ) +{ + W8 *buffer; + char picname[ 80 ]; + char checkname[ MAX_OSPATH ]; + int i; + FILE *f; + + // create the scrnshots directory if it doesn't exist + my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot", FS_Gamedir() ); + FS_CreateDirectory( checkname ); + +// +// find a file name to save it to +// + my_strlcpy( picname, "scrn00.tga", sizeof( picname ) ); + + for( i = 0 ; i <= 99 ; ++i ) + { + picname[ 4 ] = i / 10 + '0'; + picname[ 5 ] = i % 10 + '0'; + my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot/%s", FS_Gamedir(), picname ); + f = fopen( checkname, "rb" ); + if( ! f ) + { + break; // file doesn't exist + } + + fclose( f ); + } + + if( i == 100 ) + { + Com_Printf( "R_ScreenShot_f: Couldn't create a file\n" ); + return; + } + + + buffer = MM_MALLOC( viddef.width * viddef.height * 3 ); + + + pfglReadPixels( 0, 0, viddef.width, viddef.height, GL_RGB, GL_UNSIGNED_BYTE, buffer ); + + + WriteTGA( checkname, 24, viddef.width, viddef.height, buffer, 1, 1 ); + + + MM_FREE( buffer ); + Com_Printf( "Wrote %s\n", picname ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void R_Strings_f( void ) +{ + Com_Printf( "GL_VENDOR: %s\n", gl_config.vendor_string ); + Com_Printf( "GL_RENDERER: %s\n", gl_config.renderer_string ); + Com_Printf( "GL_VERSION: %s\n", gl_config.version_string ); + Com_Printf( "GL_EXTENSIONS: %s\n", gl_config.extensions_string ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void R_Register( void ) +{ + gl_round_down = Cvar_Get ("gl_round_down", "1", CVAR_INIT); + + r_lefthand = Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE ); + r_norefresh = Cvar_Get ("r_norefresh", "0", CVAR_INIT); + r_novis = Cvar_Get ("r_novis", "0", CVAR_INIT); + r_nocull = Cvar_Get ("r_nocull", "0", CVAR_INIT); + r_speeds = Cvar_Get ("r_speeds", "0", CVAR_INIT); + + + gl_nosubimage = Cvar_Get( "gl_nosubimage", "0", CVAR_INIT ); + + + gl_modulate = Cvar_Get ("gl_modulate", "1", CVAR_ARCHIVE ); + gl_bitdepth = Cvar_Get( "gl_bitdepth", "0", CVAR_INIT ); + gl_mode = Cvar_Get( "gl_mode", "0", CVAR_ARCHIVE ); + gl_lightmap = Cvar_Get ("gl_lightmap", "0", CVAR_INIT); + gl_dynamic = Cvar_Get ("gl_dynamic", "1", CVAR_INIT); + gl_nobind = Cvar_Get ("gl_nobind", "0", CVAR_INIT); + gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_INIT); + gl_skymip = Cvar_Get ("gl_skymip", "0", CVAR_INIT); + gl_showtris = Cvar_Get( "gl_showtris", "0", CVAR_INIT ); + gl_ztrick = Cvar_Get( "gl_ztrick", "0", CVAR_INIT ); + gl_finish = Cvar_Get( "gl_finish", "0", CVAR_ARCHIVE ); + gl_clear = Cvar_Get( "gl_clear", "0", CVAR_INIT ); + gl_cull = Cvar_Get( "gl_cull", "1", CVAR_INIT ); + gl_polyblend = Cvar_Get( "gl_polyblend", "1", CVAR_INIT ); + gl_flashblend = Cvar_Get( "gl_flashblend", "0", CVAR_INIT ); + gl_playermip = Cvar_Get( "gl_playermip", "0", CVAR_INIT ); + gl_driver = Cvar_Get( "gl_driver", OPENGL_DLL_NAME, CVAR_ARCHIVE ); + + gl_vertex_arrays = Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE ); + + gl_ext_swapinterval = Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE ); + gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); + gl_ext_multitexture = Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE ); + gl_ext_pointparameters = Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE ); + gl_ext_compiled_vertex_array = Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE ); + + gl_drawbuffer = Cvar_Get( "gl_drawbuffer", "GL_BACK", CVAR_INIT ); + gl_swapinterval = Cvar_Get( "gl_swapinterval", "1", CVAR_ARCHIVE ); + +// gl_saturatelighting = Cvar_Get( "gl_saturatelighting", "0", CVAR_INIT ); + + r_fullscreen = Cvar_Get( "r_fullscreen", "0", CVAR_ARCHIVE ); + vid_gamma = Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE ); + r_ref = Cvar_Get( "r_ref", "gl", CVAR_ARCHIVE ); + + Cmd_AddCommand( "screenshot", R_ScreenShot_f ); + Cmd_AddCommand( "r_strings", R_Strings_f ); +} + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Init() +{ + char renderer_buffer[ 1000 ]; + char vendor_buffer[ 1000 ]; + int err; + int a, b; + + + Com_Printf( "\n------ Display Initialization ------\n" ); + + Com_Printf( "Initializing OpenGL Subsystem\n" ); + + R_Register(); + + // set our "safe" modes + gl_state.prev_mode = 0; + + viddef.width = 480; + viddef.height = 320; + + // get various GL strings + gl_config.vendor_string = (char *)pfglGetString( GL_VENDOR ); + Com_Printf( "GL_VENDOR: %s\n", gl_config.vendor_string ); + + gl_config.renderer_string = (char *)pfglGetString( GL_RENDERER ); + Com_Printf( "GL_RENDERER: %s\n", gl_config.renderer_string ); + + gl_config.version_string = (char *)pfglGetString( GL_VERSION ); + Com_Printf( "GL_VERSION: %s\n", gl_config.version_string ); + + gl_config.extensions_string = (char *)pfglGetString( GL_EXTENSIONS ); + Com_Printf( "GL_EXTENSIONS: %s\n", gl_config.extensions_string ); + + my_strlcpy( renderer_buffer, gl_config.renderer_string, sizeof( renderer_buffer ) ); + (void)my_strlwr( renderer_buffer ); + + my_strlcpy( vendor_buffer, gl_config.vendor_string, sizeof( vendor_buffer ) ); + (void)my_strlwr( vendor_buffer ); + + + sscanf( gl_config.version_string, "%d.%d", &a, &b ); + if( a >= 1 && b >= 2 ) + { + gl_config.Version_1_2 = true; + } + + pfglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glMaxTexSize ); + Com_Printf( "GL_MAX_TEXTURE_SIZE: %d\n", glMaxTexSize); + + GL_SetDefaultState(); + + TM_Init(); + Font_Init(); + + err = pfglGetError(); + if( err != GL_NO_ERROR ) + { + Com_Printf( "glGetError() = 0x%x\n", err ); + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Shutdown( void ) +{ +// Cmd_RemoveCommand ("modellist"); +// Cmd_RemoveCommand ("screenshot"); +// Cmd_RemoveCommand ("imagelist"); +// Cmd_RemoveCommand ("gl_strings"); + +// Mod_FreeAll (); + + TM_Shutdown(); + + /* + ** shut down OS specific OpenGL stuff like contexts, etc. + */ + GLimp_Shutdown(); + + /* + ** shutdown our OpenGL subsystem + */ +#ifndef IPHONE + OpenGL_Shutdown(); +#endif +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void R_EndFrame( void ) +{ + GLimp_EndFrame(); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void R_AppActivate( _boolean active ) +{ + GLimp_AppActivate( active ); +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void GL_UpdateSwapInterval( void ) +{ + if ( gl_swapinterval->modified ) + { + gl_swapinterval->modified = false; + +#ifdef _WIN32 + + if ( pfwglSwapIntervalEXT ) + { + pfwglSwapIntervalEXT( FloatToInt( gl_swapinterval->value ) ); + } + +#endif + + } +} + + + +/* +----------------------------------------------------------------------------- + Function: PrintGLError -Print OpenGL error message. + + Parameters: err -[in] Error code. + from -[in] function name that produced the error. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void PrintGLError( W32 err, const char *from ) +{ + if( err == GL_NO_ERROR ) + { + return; + } + + if( from != "" ) + { + Com_Printf( "\n\n\nGL Error: %s\n", from ); + } + + switch( err ) + { + case GL_NO_ERROR: + Com_Printf( "GL_NO_ERROR:\nNo error has been recorded. The value of this symbolic constant is guaranteed to be zero.\n" ); + break; + + case GL_INVALID_ENUM: + Com_Printf( "GL_INVALID_ENUM:\nAn unacceptable value is specified for an enumerated argument. The offending function is ignored, having no side effect other than to set the error flag.\n" ); + break; + + case GL_INVALID_VALUE: + Com_Printf( "GL_INVALID_VALUE:\nA numeric argument is out of range. The offending function is ignored, having no side effect other than to set the error flag.\n" ); + break; + + case GL_INVALID_OPERATION: + Com_Printf( "GL_INVALID_OPERATION:\nThe specified operation is not allowed in the current state. The offending function is ignored, having no side effect other than to set the error flag.\n" ); + break; + + case GL_STACK_OVERFLOW: + Com_Printf( "GL_STACK_OVERFLOW:\nThis function would cause a stack overflow. The offending function is ignored, having no side effect other than to set the error flag.\n" ); + break; + + case GL_STACK_UNDERFLOW: + Com_Printf( "GL_STACK_UNDERFLOW:\nThis function would cause a stack underflow. The offending function is ignored, having no side effect other than to set the error flag.\n" ); + break; + + case GL_OUT_OF_MEMORY: + Com_Printf( "GL_OUT_OF_MEMORY:\nThere is not enough memory left to execute the function. The state of OpenGL is undefined, except for the state of the error flags, after this error is recorded.\n" ); + break; + + default: + Com_Printf( "Unknown GL error flag 0x%x\n", err ); + } +} diff --git a/wolf3d/newCode/env/opengl_texture.c b/wolf3d/newCode/env/opengl_texture.c new file mode 100644 index 0000000..eabeb77 --- /dev/null +++ b/wolf3d/newCode/env/opengl_texture.c @@ -0,0 +1,253 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * opengl_texture.c: OpenGL Texture Manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +int currentTextures[ 4 ]; +int currenttmu; + +int glMaxTexSize; + +// *************************************************************************** + +// *************************************************************************** + + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_DeleteTexture( unsigned int texnum ) +{ + pfglDeleteTextures( 1, &texnum ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_TexEnv( GLenum mode ) +{ + static int lastmodes[ 4 ] = { -1, -1, -1, -1 }; + + if ( mode != lastmodes[ currenttmu ] ) + { + pfglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode ); + lastmodes[ currenttmu ] = mode; + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_SelectTexture( GLenum texture ) +{ + int tmu; + +#ifndef IPHONE + if( ! pfglActiveTextureARB ) + { + return; + } +#endif + + if( texture == GL_TEXTURE0 ) + { + tmu = 0; + } + else if( texture == GL_TEXTURE1 ) + { + tmu = 1; + } + else if( texture == GL_TEXTURE2 ) + { + tmu = 2; + } + else + { + tmu = 3; + } + + if( tmu == currenttmu ) + { + return; + } + + + currenttmu = tmu; + + pfglActiveTextureARB( texture ); + pfglClientActiveTextureARB( texture ); + +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Bind( int texnum ) +{ + // Is this texture already bound + if( currentTextures[ currenttmu ] == texnum ) + { + return; + } + + currentTextures[ currenttmu ] = texnum; + + pfglBindTexture( GL_TEXTURE_2D, texnum ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_MBind( GLenum target, int texnum ) +{ + R_SelectTexture( target ); + + if( target == GL_TEXTURE0 ) + { + if ( currentTextures[ 0 ] == texnum ) + { + return; + } + } + else if( target == GL_TEXTURE1 ) + { + if( currentTextures[ 1 ] == texnum ) + { + return; + } + } + else if( target == GL_TEXTURE2 ) + { + if( currentTextures[ 2 ] == texnum ) + { + return; + } + } + else + { + if( currentTextures[ 3 ] == texnum ) + { + return; + } + } + + R_Bind( texnum ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_EnableMultitexture( _boolean enable ) +{ +#ifndef IPHONE + if( ! pfglActiveTextureARB ) + { + return; + } +#endif + + if( enable ) + { + R_SelectTexture( GL_TEXTURE1 ); + pfglEnable( GL_TEXTURE_2D ); + R_TexEnv( GL_REPLACE ); + } + else + { + R_SelectTexture( GL_TEXTURE1 ); + pfglDisable( GL_TEXTURE_2D ); + R_TexEnv( GL_REPLACE ); + } + + R_SelectTexture( GL_TEXTURE0 ); + R_TexEnv( GL_REPLACE ); + +} + diff --git a/wolf3d/newCode/env/random_number.c b/wolf3d/newCode/env/random_number.c new file mode 100644 index 0000000..7256694 --- /dev/null +++ b/wolf3d/newCode/env/random_number.c @@ -0,0 +1,107 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * random_number.c: Wolfenstein3-D random number generator. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + + +#include "../wolfiphone.h" + +/* This is just John Carmack's table driven pseudo-random number generator */ + +W32 rndtable[] = { + 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, + 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36, + 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188, + 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224, + 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242, + 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0, + 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235, + 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113, + 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75, + 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196, + 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113, + 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241, + 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224, + 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, + 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226, + 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, + 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, + 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136, + 120, 163, 236, 249 +}; + +W32 rndindex = 0; + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void US_InitRndT( int randomize ) +{ + if( randomize ) + { + rndindex = time( NULL ) & 0xFF; + } + else + { + rndindex = 0; + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC int US_RndT( void ) +{ + rndindex++; + rndindex &= 0xFF; + + return rndtable[ rndindex ]; +} + + diff --git a/wolf3d/newCode/env/random_number.h b/wolf3d/newCode/env/random_number.h new file mode 100644 index 0000000..6fae19d --- /dev/null +++ b/wolf3d/newCode/env/random_number.h @@ -0,0 +1,48 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * mymath.h: Math routines. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __RANDOM_NUMBER_H__ +#define __RANDOM_NUMBER_H__ + + +#define random() ( (rand() & 0x7fff) / ((float)0x7fff) ) +#define crandom() ( 2.0 * (random() - 0.5) ) + + +extern void US_InitRndT( int randomize ); +extern int US_RndT( void ); + + + + + +#endif /* __RANDOM_NUMBER_H__ */ diff --git a/wolf3d/newCode/env/renderer.h b/wolf3d/newCode/env/renderer.h new file mode 100644 index 0000000..f0fe712 --- /dev/null +++ b/wolf3d/newCode/env/renderer.h @@ -0,0 +1,107 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * renderer.h: Interface to graphics API. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + + Notes: + + This module communicates with the graphics API. The API can be any graphics + API, e.g OpenGL, DirectX, SDL, GDI, etc; as long as the functions listed in + this header are implemented. + +*/ + +#ifndef __RENDERER_H__ +#define __RENDERER_H__ + + +#ifdef _WIN32 + + #define OPENGL_DLL_NAME "opengl32.dll" + +#elif __unix__ + + #define OPENGL_DLL_NAME "libGL.so.1" + +#elif IPHONE + + #define OPENGL_DLL_NAME "not applicable" + +#else + + #error "Define OPENGL_DLL_NAME" + +#endif + + + + + +typedef enum +{ + rserr_ok, + + rserr_invalid_fullscreen, + rserr_invalid_mode, + + rserr_unknown + +} rserr_t; + + +extern int registration_sequence; + +extern void R_Init( void ); +extern void R_Shutdown( void ); + +extern void R_BeginRegistration( const char *model ); +extern void R_BeginFrame( void ); +extern void R_EndFrame( void ); + +extern void R_AppActivate( _boolean active ); +extern void R_SwapBuffers( int ); +extern void R_SetPalette( const unsigned char *palette); + + +extern void R_DeleteTexture( unsigned int texnum ); + + +extern void R_Draw_Pic( int x, int y, const char *name ); +extern void R_Draw_StretchPic( int x, int y, int w, int h, const char *name ); +extern void R_Draw_Character( int x, int y, int num, font_t *myfont ); +extern void R_Draw_Tile( int x, int y, int w, int h, const char *name ); +extern void R_Draw_Fill( int x, int y, int w, int h, colour3_t c ); +extern void R_Draw_Line( int nXStart, int nYStart, int nXEnd, int nYEnd, int width, colour3_t c ); + + +#endif /* __RENDERER_H__ */ diff --git a/wolf3d/newCode/env/share.c b/wolf3d/newCode/env/share.c new file mode 100644 index 0000000..26b2da2 --- /dev/null +++ b/wolf3d/newCode/env/share.c @@ -0,0 +1,189 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + + +char com_token[128]; + + + + +/* +============================================================================ + + BYTE ORDER FUNCTIONS + +============================================================================ +*/ + + + +/* +----------------------------------------------------------------------------- + Function: va() -Does a varargs printf into a temp buffer, so I don't need to + have varargs versions of all text functions. + + Parameters: format -[in] Format-control string. + ... -[in] Optional arguments. + + Returns: Formatted string. + + Notes: + If format string is longer than 1024 it will be truncated. +----------------------------------------------------------------------------- +*/ +PUBLIC char *va( char *format, ... ) +{ + va_list argptr; + static char string[ 1024 ]; + + va_start( argptr, format ); + (void)vsnprintf( string, sizeof( string ), format, argptr ); + va_end( argptr ); + + string[ sizeof( string ) - 1 ] = '\0'; + + return string; +} + + +/* +----------------------------------------------------------------------------- + Function: COM_Parse() -Parse a token out of a string. + + Parameters: data_p -[in] String to parse. + + Returns: On success it will return the token string, otherwise it will + return "". + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC char *COM_Parse( char **data_p ) +{ + int c; + int len; + char *data; + + data = *data_p; + len = 0; + com_token[ 0 ] = 0; + + if( ! data ) + { + *data_p = NULL; + return ""; + } + +// skip whitespace +skipwhite: + while( (c = *data) <= ' ') + { + if( c == 0 ) + { + *data_p = NULL; + return ""; + } + data++; + } + +// skip // comments + if( c == '/' && data[ 1 ] == '/' ) + { + while( *data && *data != '\n' ) + { + data++; + } + goto skipwhite; + } + +// handle quoted strings specially + if( c == '\"' ) + { + data++; + while( 1 ) + { + c = *data++; + if( c == '\"' || ! c ) + { + com_token[ len ] = 0; + *data_p = data; + return com_token; + } + if( len < MAX_TOKEN_CHARS ) + { + com_token[ len ] = c; + len++; + } + } + } + +// parse a regular word + do + { + if( len < MAX_TOKEN_CHARS ) + { + com_token[ len ] = c; + len++; + } + data++; + c = *data; + + } while( c > 32 ); + + if( len == MAX_TOKEN_CHARS ) + { +// Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); + len = 0; + } + com_token[ len ] = 0; + + *data_p = data; + + return com_token; +} + + +/* +----------------------------------------------------------------------------- + Function: Com_PageInMemory() + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +int paged_total; + +PUBLIC void Com_PageInMemory( PW8 buffer, int size ) +{ + int i; + + for( i = size - 1 ; i > 0 ; i -= 4096 ) + { + paged_total += buffer[ i ]; + } +} + diff --git a/wolf3d/newCode/env/sound.c b/wolf3d/newCode/env/sound.c new file mode 100644 index 0000000..9332e79 --- /dev/null +++ b/wolf3d/newCode/env/sound.c @@ -0,0 +1,791 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * sound.c: + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Acknowledgement: + * Portion of this code was derived from Quake II Evolved. + * + */ + +#include "../wolfiphone.h" + + +#define MAX_PLAYSOUNDS 128 + +#define MAX_CHANNELS 64 + +PRIVATE playSound_t s_playSounds[ MAX_PLAYSOUNDS ]; +PRIVATE playSound_t s_freePlaySounds; +PRIVATE playSound_t s_pendingPlaySounds; + +PRIVATE channel_t s_channels[ MAX_CHANNELS ]; +PRIVATE int s_numChannels; + +PRIVATE listener_t s_listener; + +PRIVATE int s_frameCount; + +PRIVATE _boolean s_activeApp; + +_boolean sound_initialized = false; + +cvar_t *s_initSound; +cvar_t *s_masterVolume; +cvar_t *s_sfxVolume; +cvar_t *s_musicVolume; +cvar_t *s_minDistance; +cvar_t *s_maxDistance; +cvar_t *s_rolloffFactor; +cvar_t *s_dopplerFactor; +cvar_t *s_dopplerVelocity; + + + +///////////////////////////////////////////////////////////////////// +// +// Sound Channels +// +///////////////////////////////////////////////////////////////////// + + +/* +----------------------------------------------------------------------------- + Function: Sound_AllocChannels -Allocate sound channels. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_AllocChannels( void ) +{ + channel_t *ch; + int i; + + for( i = 0, ch = s_channels ; i < MAX_CHANNELS ; ++i, ++ch ) + { + pfalGenSources( 1, &ch->sourceName ); + + if( pfalGetError() != AL_NO_ERROR ) + { + break; + } + + s_numChannels++; + } +} + +/* +----------------------------------------------------------------------------- + Function: Sound_FreeChannels -Free sound channels. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_FreeChannels( void ) +{ + channel_t *ch; + int i; + + for( i = 0, ch = s_channels; i < s_numChannels; i++, ch++) + { + pfalDeleteSources( 1, &ch->sourceName ); + + memset( ch, 0, sizeof( *ch ) ); + } + + s_numChannels = 0; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_FreeChannels -Free sound channels. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE int Sound_ChannelState( channel_t *ch ) +{ + int state; + + pfalGetSourcei( ch->sourceName, AL_SOURCE_STATE, &state ); + + return state; +} + + +PRIVATE void Sound_PlayChannel( channel_t *ch, sfx_t *sfx ) +{ + ch->sfx = sfx; + + pfalSourcei( ch->sourceName, AL_BUFFER, sfx->bufferNum ); + pfalSourcei( ch->sourceName, AL_LOOPING, ch->loopSound ); + pfalSourcei( ch->sourceName, AL_SOURCE_RELATIVE, AL_FALSE ); + pfalSourcePlay( ch->sourceName ); +} + + +PRIVATE void Sound_StopChannel( channel_t *ch ) +{ + ch->sfx = NULL; + + pfalSourceStop( ch->sourceName ); + pfalSourcei( ch->sourceName, AL_BUFFER, 0 ); +#ifdef IPHONE + // OpenAL on the iphone doesn't seem to stop sounds properly. + // Maybe regenning the source will work... + pfalDeleteSources( 1, &ch->sourceName ); + pfalGenSources( 1, &ch->sourceName ); +#endif +} + + +PRIVATE void Sound_SpatializeChannel( channel_t *ch ) +{ +// vec3_t position, velocity; + + // Update position and velocity + if( ch->entNum == 0 || ! ch->distanceMult ) + { + pfalSourcefv( ch->sourceName, AL_POSITION, s_listener.position ); + pfalSourcefv( ch->sourceName, AL_VELOCITY, s_listener.velocity ); + } + else + { + if( ch->fixedPosition ) + { + pfalSource3f( ch->sourceName, AL_POSITION, ch->position[1], ch->position[2], -ch->position[0] ); + pfalSource3f( ch->sourceName, AL_VELOCITY, 0, 0, 0 ); + } +/* else + { + if( ch->loopSound ) + { + Client_GetEntitySoundSpatialization( ch->loopNum, position, velocity ); + } + else + { + Client_GetEntitySoundSpatialization( ch->entNum, position, velocity ); + } + + pfalSource3f( ch->sourceName, AL_POSITION, position[1], position[2], -position[0] ); + pfalSource3f( ch->sourceName, AL_VELOCITY, velocity[1], velocity[2], -velocity[0] ); + } +*/ + } + + // Update min/max distance + if( ch->distanceMult ) + { + pfalSourcef( ch->sourceName, AL_REFERENCE_DISTANCE, s_minDistance->value * ch->distanceMult ); + } + else + { + pfalSourcef( ch->sourceName, AL_REFERENCE_DISTANCE, s_maxDistance->value ); + } + + pfalSourcef( ch->sourceName, AL_MAX_DISTANCE, s_maxDistance->value ); + + // Update volume and rolloff factor + pfalSourcef( ch->sourceName, AL_GAIN, s_sfxVolume->value * ch->volume ); + pfalSourcef( ch->sourceName, AL_ROLLOFF_FACTOR, s_rolloffFactor->value ); +} + + +/* +----------------------------------------------------------------------------- + Function: Sound_PickChannel - + + Parameters: + + Returns: + + Notes: + Tries to find a free channel, or tries to replace an active channel. +----------------------------------------------------------------------------- +*/ +PUBLIC channel_t *Sound_PickChannel( W32 entNum, W32 entChannel ) +{ + channel_t *ch; + int i; + int firstToDie = -1; + int oldestTime = iphoneFrameNum; + + for( i = 0, ch = s_channels ; i < s_numChannels ; ++i, ++ch ) + { + // Don't let game sounds override streaming sounds + if( ch->streaming ) + { + continue; + } + + // Check if this channel is active + if( ! ch->sfx ) + { + // Free channel + firstToDie = i; + break; + } + + // Channel 0 never overrides + if( entChannel != 0 && (ch->entNum == entNum && ch->entChannel == entChannel ) ) + { + // Always override sound from same entity + firstToDie = i; + break; + } + + // Replace the oldest sound + if( ch->startTime < oldestTime ) + { + oldestTime = ch->startTime; + firstToDie = i; + } + } + + if( firstToDie == -1 ) + { + return NULL; + } + + ch = &s_channels[ firstToDie ]; + + ch->entNum = entNum; + ch->entChannel = entChannel; + ch->startTime = iphoneFrameNum; + + // Make sure this channel is stopped + Sound_StopChannel( ch ); + + return ch; +} + +///////////////////////////////////////////////////////////////////// +// End of Sound Channels +///////////////////////////////////////////////////////////////////// + + +/* +----------------------------------------------------------------------------- + Function: Sound_AddLoopingSounds - + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Entities with a a->sound field will generate looping sounds that are + automatically started and stopped as the entities are sent to the + client. +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_AddLoopingSounds( void ) +{ + +} + + + +PRIVATE playSound_t *Sound_AllocPlaySound( void ) +{ + playSound_t *ps; + + ps = s_freePlaySounds.next; + if( ps == &s_freePlaySounds ) + { + return NULL; // No free playSounds + } + + ps->prev->next = ps->next; + ps->next->prev = ps->prev; + + return ps; +} + + +PRIVATE void Sound_FreePlaySound( playSound_t *ps ) +{ + ps->prev->next = ps->next; + ps->next->prev = ps->prev; + + // Add to free list + ps->next = s_freePlaySounds.next; + s_freePlaySounds.next->prev = ps; + ps->prev = &s_freePlaySounds; + s_freePlaySounds.next = ps; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_IssuePlaySounds - + + Parameters: + + Returns: Nothing. + + Notes: + Take the next playsound and begin it on the channel. + This is never called directly by Sound_StartSound*, but only by the update loop. +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_IssuePlaySounds( void ) +{ + playSound_t *ps; + channel_t *ch; + + while( 1 ) + { + ps = s_pendingPlaySounds.next; + if( ps == &s_pendingPlaySounds ) + { + break; // No more pending playSounds + } + + if( ps->beginTime > iphoneFrameNum ) + { + break; // No more pending playSounds this frame + } + + // Pick a channel and start the sound effect + ch = Sound_PickChannel( ps->entNum, ps->entChannel ); + if( ! ch ) + { + if( ps->sfx->name[ 0 ] == '#' ) + Com_DPrintf( "Dropped sound %s\n", &ps->sfx->name[1]); + else + Com_DPrintf( "Dropped sound sound/%s\n", ps->sfx->name); + + Sound_FreePlaySound( ps ); + continue; + } + + ch->loopSound = false; + ch->fixedPosition = ps->fixedPosition; + vectorCopy( ps->position, ch->position ); + ch->volume = ps->volume; + + if( ps->attenuation != ATTN_NONE ) + { + ch->distanceMult = 1.0f / ps->attenuation; + } + else + { + ch->distanceMult = 0.0; + } + + Sound_SpatializeChannel( ch ); + + Sound_PlayChannel( ch, ps->sfx ); + + // Free the playSound + Sound_FreePlaySound( ps ); + } +} + + +/* +----------------------------------------------------------------------------- + Function: Sound_StartSound - + + Parameters: + + Returns: Nothing. + + Notes: + Validates the parms and queues the sound up. + If origin is NULL, the sound will be dynamically sourced from the + entity. + entChannel 0 will never override a playing sound. +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StartSound( const vec3_t position, int entNum, int entChannel, sfx_t *sfx, float volume, float attenuation, int timeOfs ) +{ + playSound_t *ps, *sort; + + if( ! sound_initialized ) + { + return; + } + + if( ! sfx ) + { + return; + } + + + // Make sure the sound is loaded + if( ! Sound_LoadSound( sfx ) ) + { + return; + } + + // Allocate a playSound + ps = Sound_AllocPlaySound(); + if( ! ps ) + { + if( sfx->name[0] == '#' ) + Com_DPrintf( "Dropped sound %s\n", &sfx->name[1] ); + else + Com_DPrintf( "Dropped sound sound/%s\n", sfx->name); + + return; + } + + ps->sfx = sfx; + ps->entNum = entNum; + ps->entChannel = entChannel; + + if( position ) + { + ps->fixedPosition = true; + vectorCopy( position, ps->position ); + } + else + { + ps->fixedPosition = false; + } + + ps->volume = volume; + ps->attenuation = attenuation; + ps->beginTime = iphoneFrameNum; + + // Sort into the pending playSounds list + for( sort = s_pendingPlaySounds.next ; sort != &s_pendingPlaySounds && sort->beginTime < ps->beginTime ; sort = sort->next ) + { + ; + } + + ps->next = sort; + ps->prev = sort->prev; + + ps->next->prev = ps; + ps->prev->next = ps; +} + + +PUBLIC void Sound_StartLocalSound( const char *filename ) +{ + sfx_t *sfx; + + if( ! sound_initialized ) + { + return; + } + + sfx = Sound_RegisterSound( filename ); + if( ! sfx ) + { + Com_Printf( "Sound_StartLocalSound: could not cache (%s)\n", filename ); + return; + } + + Sound_StartSound( NULL, 0, 0, sfx, 1, ATTN_NONE, 0 ); +} + + +PUBLIC void Sound_StopAllSounds( void ) +{ + channel_t *ch; + int i; + + if( ! sound_initialized ) + { + return; + } + + // Clear all the playSounds + memset( s_playSounds, 0, sizeof( s_playSounds ) ); + + s_freePlaySounds.next = s_freePlaySounds.prev = &s_freePlaySounds; + s_pendingPlaySounds.next = s_pendingPlaySounds.prev = &s_pendingPlaySounds; + + for( i = 0 ; i < MAX_PLAYSOUNDS ; ++i ) + { + s_playSounds[ i ].prev = &s_freePlaySounds; + s_playSounds[ i ].next = s_freePlaySounds.next; + s_playSounds[ i ].prev->next = &s_playSounds[ i ]; + s_playSounds[ i ].next->prev = &s_playSounds[ i ]; + } + + // Stop all the channels + for( i = 0, ch = s_channels ; i < s_numChannels ; ++i, ++ch ) + { + if( ! ch->sfx ) + { + continue; + } + + Sound_StopChannel( ch ); + } + + // Reset frame count + s_frameCount = 0; +} + + +/* +----------------------------------------------------------------------------- + Function: Sound_Update - + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Called once each time through the main loop. +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_Update( const vec3_t position, const vec3_t velocity, const vec3_t at, const vec3_t up) +{ + channel_t *ch; + int i, total = 0; + + if( ! sound_initialized ) + { + return; + } + + // Bump frame count + s_frameCount++; + + // Set up listener + vectorSet( s_listener.position, position[1], position[2], -position[0] ); + vectorSet( s_listener.velocity, velocity[1], velocity[2], -velocity[0] ); + vectorSet( &s_listener.orientation[0], at[1], -at[2], -at[0] ); + vectorSet( &s_listener.orientation[3], up[1], -up[2], -up[0] ); + + pfalListenerfv( AL_POSITION, s_listener.position ); + pfalListenerfv( AL_VELOCITY, s_listener.velocity ); + pfalListenerfv( AL_ORIENTATION, s_listener.orientation ); + pfalListenerf( AL_GAIN, (s_activeApp) ? s_masterVolume->value : 0.0); + + // Set state + pfalDistanceModel( AL_INVERSE_DISTANCE_CLAMPED ); + + pfalDopplerFactor( s_dopplerFactor->value ); + pfalDopplerVelocity( s_dopplerVelocity->value ); + + // Stream background track + Sound_StreamBGTrack(); + + // Add looping sounds + Sound_AddLoopingSounds(); + + // Issue playSounds + Sound_IssuePlaySounds(); + + // Update spatialization for all sounds + for( i = 0, ch = s_channels ; i < s_numChannels ; ++i, ++ch ) + { + if( ! ch->sfx ) + { + continue; // Not active + } + + // Check for stop + if( ch->loopSound ) + { + if( ch->loopFrame != s_frameCount ) + { + Sound_StopChannel( ch ); + + continue; + } + } + else + { + if( Sound_ChannelState(ch) == AL_STOPPED ) + { + Sound_StopChannel( ch ); + + continue; + } + } + + // Respatialize channel + Sound_SpatializeChannel( ch ); + + total++; + } + + +} + + +PUBLIC void Sound_Activate( _boolean active ) +{ + s_activeApp = active; + + if( ! sound_initialized ) + { + return; + } + + pfalListenerf( AL_GAIN, ( active ) ? s_masterVolume->value : 0.0 ); + +} + + +///////////////////////////////////////////////////////////////////// +// +// Console Commands +// +///////////////////////////////////////////////////////////////////// + +PRIVATE void Sound_Play_f( void ) +{ + + int i = 1; + char name[ MAX_GAMEPATH ]; + + if( Cmd_Argc() == 1 ) + { + Com_Printf( "Usage: play \n" ); + return; + } + + while( i < Cmd_Argc() ) + { + my_strlcpy( name, Cmd_Argv( i ), sizeof( name ) ); + + Sound_StartLocalSound( name ); + + i++; + } +} + +PRIVATE void Sound_StopSound_f( void ) +{ + Sound_StopAllSounds(); +} + + +/* +----------------------------------------------------------------------------- + Function: Sound_Restart_f -Console function to restart the sound module. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + Restart the sound subsystem so it can pick up new parameters and flush + all sounds. +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_Restart_f( void ) +{ + Sound_Shutdown(); + Sound_Init(); +} + +///////////////////////////////////////////////////////////////////// +// End of Console Commands +///////////////////////////////////////////////////////////////////// + + +extern void Sound_SoundList_f( void ); + + +PRIVATE void Sound_Register( void ) +{ + s_initSound = Cvar_Get( "s_initSound", "1", CVAR_INIT ); + s_masterVolume = Cvar_Get( "s_masterVolume", "1.0", CVAR_ARCHIVE ); + s_sfxVolume = Cvar_Get( "s_sfxVolume", "1.0", CVAR_ARCHIVE ); + s_musicVolume = Cvar_Get( "s_musicVolume", "1.0", CVAR_ARCHIVE ); + s_minDistance = Cvar_Get( "s_minDistance", "0.0", CVAR_ARCHIVE ); + s_maxDistance = Cvar_Get( "s_maxDistance", "1.0", CVAR_ARCHIVE ); + s_rolloffFactor = Cvar_Get( "s_rolloffFactor", "1.0", CVAR_ARCHIVE ); + s_dopplerFactor = Cvar_Get( "s_dopplerFactor", "1.0", CVAR_ARCHIVE ); + s_dopplerVelocity = Cvar_Get( "s_dopplerVelocity", "0.0", CVAR_ARCHIVE ); + + Cmd_AddCommand( "play", Sound_Play_f ); + Cmd_AddCommand( "stopsound", Sound_StopSound_f ); + Cmd_AddCommand( "listSounds", Sound_SoundList_f ); + Cmd_AddCommand( "snd_restart", Sound_Restart_f ); +} + + +PUBLIC void Sound_Init( void ) +{ + Com_Printf( "\n------- Sound Initialization -------\n" ); + + + Sound_Register(); + + + if( ! Sound_Device_Setup() ) + { + Com_Printf( "------------------------------------\n" ); + return; + } + + sound_initialized = true; + + Sound_AllocChannels(); + Sound_StopAllSounds(); + + + Com_Printf( "------------------------------------\n" ); +} + + +PUBLIC void Sound_Shutdown( void ) +{ + Cmd_RemoveCommand( "play" ); + Cmd_RemoveCommand( "stopsound" ); + Cmd_RemoveCommand( "listSounds" ); + Cmd_RemoveCommand( "snd_restart" ); + + if( ! sound_initialized ) + { + return; + } + + Sound_FreeSounds(); + Sound_FreeChannels(); + + Sound_Device_Shutdown(); + + sound_initialized = false; +} diff --git a/wolf3d/newCode/env/sound.h b/wolf3d/newCode/env/sound.h new file mode 100644 index 0000000..92a25f4 --- /dev/null +++ b/wolf3d/newCode/env/sound.h @@ -0,0 +1,94 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * sound.h: + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Acknowledgement: + * Portion of this code was derived from Quake II Evolved. + * + */ + +#ifndef __SOUND_H__ +#define __SOUND_H__ + +// Sound channels +// Channel 0 never willingly overrides +// Other channels (1-7) always override a playing sound on that channel +#define CHAN_AUTO 0 +#define CHAN_WEAPON 1 +#define CHAN_VOICE 2 +#define CHAN_ITEM 3 +#define CHAN_BODY 4 + +// Modifier flags +#define CHAN_NO_PHS_ADD 8 // Send to all clients, not just ones in PHS (ATTN 0 will also do this) +#define CHAN_RELIABLE 16 // Send by reliable message, not datagram + +// Sound attenuation values +#define ATTN_NONE 0 // Full volume the entire level +#define ATTN_NORM 1 +#define ATTN_IDLE 2 +#define ATTN_STATIC 3 // Diminish very rapidly with distance + + +extern cvar_t *s_device; +extern cvar_t *s_masterVolume; +extern cvar_t *s_sfxVolume; +extern cvar_t *s_musicVolume; + +extern char *sound_devices[ 12 ]; +extern W16 numSoundDevices; +extern W16 numDefaultSoundDevice; + +extern W8 sound_initialized; + +extern void Sound_Init( void ); +extern void Sound_Shutdown( void ); + +extern void Sound_Update( const vec3_t position, const vec3_t velocity, const vec3_t at, const vec3_t up); + +extern void Sound_Activate( _boolean active ); + +extern channel_t *Sound_PickChannel( W32 entNum, W32 entChannel ); + +extern sfx_t *Sound_RegisterSound( const char *name ); +extern void Sound_StartLocalSound( const char *filename ); + +extern void Sound_StreamBGTrack( void ); +extern void Sound_StartStreaming( void ); +extern void Sound_StopStreaming( void ); +extern void Sound_StartBGTrack( const char *introTrack, const char *loopTrack ); +extern void Sound_StopBGTrack( void ); + +extern void Sound_StartSound( const vec3_t position, int entNum, int entChannel, sfx_t *sfx, float volume, float attenuation, int timeOfs ); + +extern void Sound_StopAllSounds( void ); + + +#endif /* __SOUND_H__ */ diff --git a/wolf3d/newCode/env/sound_local.h b/wolf3d/newCode/env/sound_local.h new file mode 100644 index 0000000..94246a8 --- /dev/null +++ b/wolf3d/newCode/env/sound_local.h @@ -0,0 +1,112 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * sound_local.h: + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Acknowledgement: + * Portion of this code was derived from Quake II Evolved. + * + */ + + +#ifndef __SOUND_LOCAL_H__ +#define __SOUND_LOCAL_H__ + + +typedef struct sfx_s +{ + char name[ MAX_GAMEPATH ]; + _boolean defaulted; + _boolean loaded; + + int samples; + int rate; + unsigned format; /* Sound samples: format specifier */ + unsigned bufferNum; + + struct sfx_s *nextHash; + +} sfx_t; + +// A playSound will be generated by each call to S_StartSound. +// When the mixer reaches playSound->beginTime, the playSound will be +// assigned to a channel. +typedef struct playSound_s +{ + struct playSound_s *prev, *next; + sfx_t *sfx; + int entNum; + int entChannel; + _boolean fixedPosition; // Use position instead of fetching entity's origin + vec3_t position; // Only use if fixedPosition is set + float volume; + float attenuation; + int beginTime; // Begin at this time + +} playSound_t; + +typedef struct +{ + _boolean streaming; + sfx_t *sfx; // NULL if unused + int entNum; // To allow overriding a specific sound + int entChannel; + int startTime; // For overriding oldest sounds + _boolean loopSound; // Looping sound + int loopNum; // Looping entity number + int loopFrame; // For stopping looping sounds + _boolean fixedPosition; // Use position instead of fetching entity's origin + vec3_t position; // Only use if fixedPosition is set + float volume; + float distanceMult; + unsigned sourceName; // OpenAL sourceName + +} channel_t; + +typedef struct +{ + vec3_t position; + vec3_t velocity; + float orientation[ 6 ]; + +} listener_t; + + + +// extern void Sound_SoundList_f( void ); +extern _boolean Sound_LoadSound( sfx_t *sfx ); +extern sfx_t *Sound_FindSound( const char *name ); +extern void Sound_FreeSounds( void ); + +extern _boolean Sound_Device_Setup( void ); +extern void Sound_Device_Shutdown( void ); + + +#endif /* __SOUND_LOCAL_H__ */ + diff --git a/wolf3d/newCode/env/sound_sfx_id.c b/wolf3d/newCode/env/sound_sfx_id.c new file mode 100644 index 0000000..99e5155 --- /dev/null +++ b/wolf3d/newCode/env/sound_sfx_id.c @@ -0,0 +1,314 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * sound_sfx_id.c: + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + * Acknowledgement: + * Portion of this code was derived from Quake II Evolved. + * + */ + +#include "../wolfiphone.h" + + + +#define SFX_HASHSIZE 256 + +#define MAX_SFX 1024 + +PRIVATE sfx_t *s_sfxHash[ SFX_HASHSIZE ]; +PRIVATE sfx_t *s_sfx[ MAX_SFX ]; +PRIVATE int s_numSfx; + + +PRIVATE _boolean s_registering = false; +PRIVATE W32 s_registration_sequence = 0; + + + + +void Sound_SoundList_f( void ) +{ + +} + + + +/* +----------------------------------------------------------------------------- + Function: Sound_UploadSound -Upload sound data to buffer. + + Parameters: data -[in] Sound data. + sample_size -[in] Sound sample size. + channels -[in] Number of sound channels. + sfx -[in] valid pointer to sfx_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_UploadSound( W8 *data, int sample_size, int channels, sfx_t *sfx ) +{ + int size; + + // Calculate buffer size + size = sfx->samples * sample_size * channels; + + // Set buffer format + if( sample_size == 2 ) + { + if( channels == 2 ) + { + sfx->format = AL_FORMAT_STEREO16; + } + else + { + sfx->format = AL_FORMAT_MONO16; + } + + // Upload the sound + pfalGenBuffers( 1, &sfx->bufferNum ); + pfalBufferData( sfx->bufferNum, sfx->format, data, size, sfx->rate ); + } + else + { + /* + We upsample the sound to 16 bit here because the iphone + pops at the beginning and end of buffers with 8 bit. -Cass + (Brian Harris wants to be acknowledeged for helping find + this workaround.) + */ + short *d = (short *)malloc( size * 2 ); + for ( int i = 0; i < size; i++ ) { + d[i] = ((short)data[i] - 128) * 256; + } + if( channels == 2 ) + { + sfx->format = AL_FORMAT_STEREO16; + } + else + { + sfx->format = AL_FORMAT_MONO16; + } + + // Upload the sound + pfalGenBuffers( 1, &sfx->bufferNum ); + pfalBufferData( sfx->bufferNum, sfx->format, d, size * 2, sfx->rate ); + free( d ); + } +} + +/* +----------------------------------------------------------------------------- + Function: Sound_LoadSound -Load sound data. + + Parameters: sfx -[in] Pointer to valid sfx_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Sound_LoadSound( sfx_t *sfx ) +{ + char name[ MAX_GAMEPATH ]; + W8 *data; + soundInfo_t info; + + if( sfx->name[ 0 ] == '*' ) + { + return false; + } + + // See if still in memory + if( sfx->loaded ) + { + return true; + } + + my_strlcpy( name, sfx->name, sizeof( name ) ); + + + if( ! LoadWavInfo( name, &data, &info ) ) + { + if ( ! LoadOggInfo( name, &data, &info ) ) { + sfx->defaulted = true; + + Com_Printf( "Could not find sound (%s)\n", name ); + + return false; + } + } + + sfx->loaded = true; + sfx->samples = info.samples; + sfx->rate = info.sample_rate; + + Sound_UploadSound( data, info.sample_size, info.channels, sfx ); + + Z_Free( data ); + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_FindSound -Load sound data. + + Parameters: sfx -[in] Pointer to valid sfx_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC sfx_t *Sound_FindSound( const char *name ) +{ + sfx_t *sfx; + unsigned hashKey; + + if( ! name || ! name[ 0 ] ) + { + Com_Printf( "Sound_FindSound: NULL sound name\n" ); + + return NULL; + } + + if( strlen( name ) >= MAX_GAMEPATH ) + { + Com_Printf( "Sound_FindSound: sound name exceeds MAX_GAMEPATH\n"); + + return NULL; + } + + // See if already loaded + hashKey = (my_strhash( name ) % SFX_HASHSIZE); + + for( sfx = s_sfxHash[ hashKey ] ; sfx ; sfx = sfx->nextHash ) + { + if( ! my_stricmp( sfx->name, name ) ) + { + return sfx; + } + } + + // Create a new sfx_t + if( s_numSfx == MAX_SFX ) + { + Com_Printf( "Sound_FindSound: MAX_SFX hit\n" ); + + return NULL; + } + + s_sfx[ s_numSfx++ ] = sfx = Z_Malloc( sizeof( sfx_t ) ); + + my_strlcpy( sfx->name, name, sizeof( sfx->name ) ); + + // Add to hash table + sfx->nextHash = s_sfxHash[ hashKey ]; + s_sfxHash[ hashKey ] = sfx; + + return sfx; +} + + +PUBLIC void Sound_BeginRegistration( void ) +{ + s_registration_sequence++; + s_registering = true; +} + +PUBLIC sfx_t *Sound_RegisterSound( const char *name ) +{ + sfx_t *sfx; + + if( ! sound_initialized ) + { + return NULL; + } + + if( g_version->value == 1 ) + { + char tempname[ 256 ]; + + my_snprintf( tempname, sizeof( tempname ), "sod%s", name ); + + sfx = Sound_FindSound( tempname ); + } + else + { + sfx = Sound_FindSound( name ); + } + + if( ! s_registering ) + { + Sound_LoadSound( sfx ); + } + + return sfx; +} + +PUBLIC void Sound_EndRegistration( void ) +{ + + s_registering = false; +} + + + + + + +void Sound_FreeSounds( void ) +{ + sfx_t *sfx; + int i; + + // Stop all sounds + Sound_StopAllSounds(); + + // Free all sounds + for( i = 0 ; i < s_numSfx ; ++i ) + { + sfx = s_sfx[ i ]; + + pfalDeleteBuffers( 1, &sfx->bufferNum ); + + Z_Free( sfx ); + } + + memset( s_sfxHash, 0, sizeof( s_sfxHash ) ); + memset( s_sfx, 0, sizeof( s_sfx ) ); + + s_numSfx = 0; +} diff --git a/wolf3d/newCode/env/sound_stream.c b/wolf3d/newCode/env/sound_stream.c new file mode 100644 index 0000000..567c948 --- /dev/null +++ b/wolf3d/newCode/env/sound_stream.c @@ -0,0 +1,516 @@ +/* + + Copyright (C) 2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * sound_stream.c: Sound Stream manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Quake II Evolved. + * + */ + +#include "../wolfiphone.h" + + +typedef struct +{ + char introName[ MAX_GAMEPATH ]; + char loopName[ MAX_GAMEPATH ]; + _boolean looping; + + filehandle_t *hFile; + + + int start; + int rate; + unsigned format; + void *vorbisFile; + +} musicTrack_t; + + +// anything greater than 1<<13 caused crashes on iphone OS 2.1 (on a 3G iphone) +#define BUFFER_SIZE (1<<13) + +PRIVATE musicTrack_t bgTrack; + +PRIVATE channel_t *s_streamingChannel; + + +extern void Sound_StopBGTrack( void ); + + + +/* +----------------------------------------------------------------------------- + Function: ovc_read -OGG read Callback. Reads data from a stream. + + Parameters: + ptr -[in] Storage location for data. + size -[in] Item size in bytes. + nmemb -[in] Maximum number of items to be read. + datasource -[in] music track data structure. + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE size_t ovc_read( void *ptr, size_t size, size_t nmemb, void *datasource ) +{ + musicTrack_t *track = (musicTrack_t *)datasource; + + + if( ! size || ! nmemb ) + { + return 0; + } + + + return FS_ReadFile( ptr, size, nmemb, track->hFile ); +} + +/* +----------------------------------------------------------------------------- + Function: ovc_read -OGG seek Callback. Moves the file pointer to a specified + location. + + Parameters: + datasource -[in] music track data structure. + offset -[in] Number of bytes from whence. + whence -[in] Initial position. + + + Returns: + If successful, fseek returns 0. Otherwise, it returns a nonzero + value. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE int ovc_seek( void *datasource, ogg_int64_t offset, int whence ) +{ + musicTrack_t *track = (musicTrack_t *)datasource; + + return FS_FileSeek( track->hFile, offset, whence ); +} + +/* +----------------------------------------------------------------------------- + Function: ovc_close -OGG close Callback. Closes a stream. + + Parameters: datasource -[in] music track data structure. + + Returns: 0 if the stream is successfully closed, otherwise nonzero. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE int ovc_close( void *datasource ) +{ + return 0; +} + +/* +----------------------------------------------------------------------------- + Function: ovc_tell -OGG tell Callback. Gets the current position of a file + pointer. + + Parameters: datasource -[in] music track data structure. + + Returns: The current file position. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE long ovc_tell( void *datasource ) +{ + musicTrack_t *track = (musicTrack_t *)datasource; + + return FS_FileTell( track->hFile ); +} + +/* +----------------------------------------------------------------------------- + Function: Sound_OpenBGTrack -OGG read Callback. + + Parameters: + name -[in] File name to open. + track -[in/out] Music track data structure. + + Returns: False on error, otherwise true. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean Sound_OpenBGTrack( const char *name, musicTrack_t *track ) +{ + OggVorbis_File *vorbisFile; + vorbis_info *vorbisInfo; + ov_callbacks vorbisCallbacks = {ovc_read, ovc_seek, ovc_close, ovc_tell}; + int ret; + extern cvar_t *music; + + if ( music->value == 0 ) { + return 0; + } + + track->hFile = FS_OpenFile( name, 0 ); + if( ! track->hFile ) + { + return false; + } + + + track->vorbisFile = vorbisFile = Z_Malloc( sizeof( OggVorbis_File ) ); + + if( (ret = ov_open_callbacks( track, vorbisFile, NULL, 0, vorbisCallbacks )) < 0 ) + { + switch( ret ) + { + case OV_EREAD: + Com_DPrintf( "A read from media returned an error.(%s)\n", name ); + break; + case OV_ENOTVORBIS: + Com_DPrintf( "Bitstream is not Vorbis data.(%s)\n", name ); + break; + case OV_EVERSION: + Com_DPrintf( "Vorbis version mismatch.(%s)\n", name ); + break; + case OV_EBADHEADER: + Com_DPrintf( "Invalid Vorbis bitstream header.(%s)\n", name ); + break; + case OV_EFAULT: + Com_DPrintf( "Internal logic fault; indicates a bug or heap/stack corruption.(%s)\n", name ); + break; + + } + Com_DPrintf( "Could not open OGG stream (%s)\n", name ); + + return false; + } + + vorbisInfo = ov_info( vorbisFile, -1 ); + if( vorbisInfo->channels != 1 && vorbisInfo->channels != 2 ) + { + Com_DPrintf( "Only mono and stereo OGG files supported (%s)\n", name ); + + return false; + } + + track->start = ov_raw_tell( vorbisFile ); + track->rate = vorbisInfo->rate; + track->format = (vorbisInfo->channels == 2) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_CloseBGTrack -Close out background music track. + + Parameters: track -[in] Music track to close. + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void Sound_CloseBGTrack( musicTrack_t *track ) +{ + if( track->vorbisFile ) + { + ov_clear( track->vorbisFile ); + + Z_Free( track->vorbisFile ); + track->vorbisFile = NULL; + } + + if( track->hFile ) + { + FS_CloseFile( track->hFile ); + } +} + +/* +----------------------------------------------------------------------------- + Function: Sound_StreamBGTrack -Called each frame to update streaming music + track. + + Parameters: Nothing + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StreamBGTrack( void ) +{ + + W8 data[BUFFER_SIZE]; + int processed, queued, state; + int size, read, dummy; + unsigned buffer; + + if( ! s_musicVolume->value ) + { + return; + } + + if( ! s_streamingChannel ) + { + return; + } + + // Unqueue and delete any processed buffers + pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_PROCESSED, &processed ); + if( processed > 0 ) + { + while (processed--) + { + pfalSourceUnqueueBuffers( s_streamingChannel->sourceName, 1, &buffer ); + pfalDeleteBuffers( 1, &buffer ); + } + } + + // Make sure we always have at least 4 buffers in the queue + pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_QUEUED, &queued ); + while( queued < 4 ) + { + size = 0; + + // Stream from disk + while( size < BUFFER_SIZE ) + { + read = ov_read( bgTrack.vorbisFile, (char *)data + size, BUFFER_SIZE - size, &dummy ); + if( read == 0 ) + { + // End of file + if( ! bgTrack.looping) + { + // Close the intro track + Sound_CloseBGTrack( &bgTrack ); + + // Open the loop track + if( ! Sound_OpenBGTrack( bgTrack.loopName, &bgTrack ) ) + { + Sound_StopBGTrack(); + return; + } + + bgTrack.looping = true; + } + + // Restart the track, skipping over the header + ov_raw_seek( bgTrack.vorbisFile, (ogg_int64_t)bgTrack.start ); + + // Try streaming again + read = ov_read( bgTrack.vorbisFile, (char *)data + size, BUFFER_SIZE - size, &dummy ); + } + + if( read <= 0 ) + { + // An error occurred + Sound_StopBGTrack(); + return; + } + + size += read; + } + + // Upload and queue the new buffer + pfalGenBuffers( 1, &buffer ); + pfalBufferData( buffer, bgTrack.format, data, size, bgTrack.rate ); + pfalSourceQueueBuffers( s_streamingChannel->sourceName, 1, &buffer ); + + queued++; + } + + // Update volume + pfalSourcef( s_streamingChannel->sourceName, AL_GAIN, s_musicVolume->value ); + + // If not playing, then do so + pfalGetSourcei( s_streamingChannel->sourceName, AL_SOURCE_STATE, &state ); + if( state != AL_PLAYING ) + { + pfalSourcePlay(s_streamingChannel->sourceName); + } +} + +/* +----------------------------------------------------------------------------- + Function: Sound_StartStreaming -Start streaming background music track. + + Parameters: Nothing + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StartStreaming( void ) +{ + if( ! sound_initialized ) + { + return; + } + + if( s_streamingChannel ) + { + return; + } + + s_streamingChannel = Sound_PickChannel( 0, 0 ); + if( ! s_streamingChannel ) + { + return; + } + + s_streamingChannel->streaming = true; + + // hmmm... + pfalDeleteSources( 1, &s_streamingChannel->sourceName ); + pfalGenSources( 1, &s_streamingChannel->sourceName ); + + // Set up the source + pfalSourcei( s_streamingChannel->sourceName, AL_BUFFER, 0 ); + pfalSourcei( s_streamingChannel->sourceName, AL_LOOPING, AL_FALSE ); + pfalSourcei( s_streamingChannel->sourceName, AL_SOURCE_RELATIVE, AL_TRUE ); + pfalSourcefv( s_streamingChannel->sourceName, AL_POSITION, vec3_origin ); + pfalSourcefv( s_streamingChannel->sourceName, AL_VELOCITY, vec3_origin ); + pfalSourcef( s_streamingChannel->sourceName, AL_REFERENCE_DISTANCE, 1.0 ); + pfalSourcef( s_streamingChannel->sourceName, AL_MAX_DISTANCE, 1.0 ); + pfalSourcef( s_streamingChannel->sourceName, AL_ROLLOFF_FACTOR, 0.0 ); +} + +/* +----------------------------------------------------------------------------- + Function: Sound_StopStreaming -Stop playing streaming music track. + + Parameters: Nothing + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StopStreaming( void ) +{ + int processed; + unsigned buffer; + + if( ! sound_initialized ) + { + return; + } + + if( ! s_streamingChannel ) + { + return; + } + + s_streamingChannel->streaming = false; + + + pfalSourceStop( s_streamingChannel->sourceName ); + + pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_PROCESSED, &processed ); + if( processed > 0 ) + { + while( processed-- ) + { + pfalSourceUnqueueBuffers( s_streamingChannel->sourceName, 1, &buffer ); + pfalDeleteBuffers( 1, &buffer ); + } + } + + pfalSourcei( s_streamingChannel->sourceName, AL_BUFFER, 0 ); + + // hmmm... + pfalDeleteSources( 1, &s_streamingChannel->sourceName ); + pfalGenSources( 1, &s_streamingChannel->sourceName ); + + s_streamingChannel = NULL; +} + +/* +----------------------------------------------------------------------------- + Function: Sound_StartBGTrack -Play background music track. + + Parameters: + introTrack -[in] File name of intro track. + loopTrack -[in] File name of loop track. + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StartBGTrack( const char *introTrack, const char *loopTrack ) +{ + if( ! sound_initialized ) + { + return; + } + + Sound_StopBGTrack(); + + + my_strlcpy( bgTrack.introName, introTrack, sizeof( bgTrack.introName ) ); + my_strlcpy( bgTrack.loopName, loopTrack, sizeof( bgTrack.loopName) ); + + Sound_StartStreaming(); + + if( ! Sound_OpenBGTrack( bgTrack.introName, &bgTrack ) ) + { + Sound_StopBGTrack(); + return; + } + + Sound_StreamBGTrack(); +} + +/* +----------------------------------------------------------------------------- + Function: Sound_StopBGTrack -Stop playing background track. + + Parameters: Nothing + + Returns: Nothing + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sound_StopBGTrack( void ) +{ + if( ! sound_initialized ) + { + return; + } + + Sound_StopStreaming(); + + Sound_CloseBGTrack( &bgTrack ); + + memset( &bgTrack, 0, sizeof( musicTrack_t ) ); +} diff --git a/wolf3d/newCode/env/texture_manager.c b/wolf3d/newCode/env/texture_manager.c new file mode 100644 index 0000000..815c855 --- /dev/null +++ b/wolf3d/newCode/env/texture_manager.c @@ -0,0 +1,1379 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + Copyright (C) 1995 Spencer Kimball and Peter Mattis. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * texture_manager.c: Texture manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from + * The GIMP (an image manipulation program) and was originally + * written by Spencer Kimball and Peter Mattis. + * + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +PRIVATE texture_t ttextures[ MAX_TEXTURES ]; +PRIVATE int numttextures; + +PRIVATE texture_t *r_notexture; // use for bad textures + +cvar_t *gl_round_down; + +int registration_sequence; +W32 texture_registration_sequence; + +extern int currentTextures[ 4 ]; +extern int currenttmu; +extern int glMaxTexSize; + +PRIVATE INLINECALL GLenum WrapToGL( TWrapMode mode ) +{ + if( mode == Repeat ) + { + return GL_REPEAT; + } + else + { + return GL_CLAMP_TO_EDGE; + } +} + +PRIVATE INLINECALL GLenum MagFilterToGL( TMagFilter MagFilter ) +{ + switch( MagFilter ) + { + case Nearest: + return GL_NEAREST; + + case Linear: + return GL_LINEAR; + + default: + break; + } + + return GL_LINEAR; +} + + + +PRIVATE INLINECALL GLenum MinFilterToGL( _boolean MipMap, TMinFilter MinFilter ) +{ + if( MipMap ) + { + switch( MinFilter ) + { + case NearestMipMapOff: + return GL_NEAREST; + + case NearestMipMapNearest: + return GL_NEAREST_MIPMAP_NEAREST; + + case NearestMipMapLinear: + return GL_NEAREST_MIPMAP_LINEAR; + + case LinearMipMapOff: + return GL_LINEAR; + + case LinearMipMapNearest: + return GL_LINEAR_MIPMAP_NEAREST; + + case LinearMipMapLinear: + return GL_LINEAR_MIPMAP_LINEAR; + + default: + break; + } + } + else + { + switch( MinFilter ) + { + case NearestMipMapOff: + case NearestMipMapNearest: + case NearestMipMapLinear: + return GL_NEAREST; + + case LinearMipMapOff: + case LinearMipMapNearest: + case LinearMipMapLinear: + return GL_LINEAR; + + default: + break; + } + } + + return GL_LINEAR; +} + + +/* +----------------------------------------------------------------------------- + Function: TM_TextureList_f -Console function to list loaded textures. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_TextureList_f( void ) +{ + int i; + texture_t *image; + int texels; + const char *palstrings[ 2 ] = + { + "RGB", + "PAL" + }; + + Com_Printf( "------------------\n" ); + texels = 0; + + for( i = 0, image = ttextures ; i < numttextures ; ++i, ++image ) + { + if( image->texnum <= 0 ) + continue; + + texels += image->upload_width * image->upload_height; + + switch( image->type ) + { + case TT_Sprite: + Com_Printf( "S" ); + break; + + case TT_Wall: + Com_Printf( "W" ); + break; + + case TT_Pic: + Com_Printf( "P" ); + break; + + default: + Com_Printf( " " ); + break; + } + + Com_Printf( " %3i %3i %s: %s\n", + image->upload_width, image->upload_height, palstrings[ 0 ], image->name ); + } + + Com_Printf( "Total texel count (not counting mipmaps): %i\n", texels ); + +} + +texture_t *TM_AllocateTexture( const char *name ) { + texture_t *tex; + int i; + + assert( strlen( name ) < sizeof( tex->name ) ); + + // find a free texture_t space + for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex ) + { + if( ! tex->texnum ) + { + break; + } + } + + if( i == numttextures ) + { + if( numttextures == MAX_TEXTURES ) + { + Com_DPrintf( "MAX_TEXTURES reached\n" ); + return r_notexture; + } + + numttextures++; + } + tex = &ttextures[ i ]; + memset( tex, 0, sizeof( *tex ) ); + my_strlcpy( tex->name, name, MAX_GAMEPATH ); + tex->registration_sequence = texture_registration_sequence; + + // don't let R_Bind skip the next bind call + currentTextures[ currenttmu ] = -1; + + pfglGenTextures( 1, &tex->texnum ); + pfglBindTexture( GL_TEXTURE_2D, tex->texnum ); + + return tex; +} + +/* +----------------------------------------------------------------------------- + Function: TM_LoadTexture -Load raw image into video memory. + + Parameters: + name -[in] Name of texture image. + data -[in] Raw pixel data in the format described by PixelFormat. + width -[in] Width of image in pixels. + height -[in] Height of image in pixels. + type -[in] + PixelFormat [in] + + Returns: Pointer to filled out texture_t structure. + + Notes: Any texture that was not touched on this registration sequence will be freed. +----------------------------------------------------------------------------- +*/ +PUBLIC texture_t *TM_LoadTexture( const char *name, W8 *data, int width, int height, texturetype_t type, W16 bytes ) +{ + texture_t *tex; + W8 *scaled; + W16 scaled_width, scaled_height; + + tex = TM_AllocateTexture( name ); + + tex->width = width; + tex->height = height; + tex->type = type; + tex->bytes = bytes; + + switch( type ) + { + case TT_Pic: + tex->MipMap = false; + tex->WrapS = Clamp; + tex->WrapT = Clamp; + tex->MinFilter = Nearest; + tex->MagFilter = NearestMipMapOff; + break; + + case TT_Wall: + tex->MipMap = true; + tex->WrapS = Repeat; + tex->WrapT = Repeat; +// tex->MinFilter = LinearMipMapLinear; + tex->MinFilter = LinearMipMapNearest; + tex->MagFilter = Linear; + break; + + default: + tex->WrapS = Repeat; + tex->WrapT = Repeat; + tex->MinFilter = Nearest; + tex->MagFilter = NearestMipMapOff; + break; + } + + + for( scaled_width = 1 ; scaled_width < tex->width ; scaled_width <<= 1 ) + { + ; + } + + if( gl_round_down->value && scaled_width > tex->width && tex->MipMap ) + { + scaled_width >>= 1; + } + + for( scaled_height = 1 ; scaled_height < tex->height ; scaled_height <<= 1 ) + { + ; + } + + if( gl_round_down->value && scaled_height > tex->height && tex->MipMap ) + { + scaled_height >>= 1; + } + + // let people sample down the world textures for speed + if( tex->MipMap ) + { + scaled_width >>= (int)gl_picmip->value; + scaled_height >>= (int)gl_picmip->value; + } + + // don't ever bother with > glMaxTexSize textures + if( scaled_width > glMaxTexSize ) + { + scaled_width = glMaxTexSize; + } + if( scaled_height > glMaxTexSize ) + { + scaled_height = glMaxTexSize; + } + + if( scaled_width < 1 ) + { + scaled_width = 1; + } + if( scaled_height < 1 ) + { + scaled_height = 1; + } + + tex->upload_width = scaled_width; + tex->upload_height = scaled_height; + + if( scaled_width == tex->width && scaled_height == tex->height ) + { + scaled = data; + } + else + { + scaled = Z_Malloc( scaled_width * scaled_height * tex->bytes ); + TM_ResampleTexture( data, tex->width, tex->height, scaled, scaled_width, scaled_height, tex->bytes, INTERPOLATION_NONE ); + } + + { + // upload base image + GLenum internalFormat[] = { GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; +#if 0 + GLenum externalFormat[] = { GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_5_5_1 }; + pfglTexImage2D( GL_TEXTURE_2D, 0, internalFormat[ tex->bytes ], scaled_width, scaled_height, 0, tex->bytes == 4 ? GL_RGBA : GL_RGB, externalFormat[ tex->bytes ], scaled ); +#else + pfglTexImage2D( GL_TEXTURE_2D, 0, internalFormat[ tex->bytes ], scaled_width, scaled_height, 0, tex->bytes == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, scaled ); +#endif + + + // upload mipmaps if required +#ifdef IPHONE + glGenerateMipmapOES( GL_TEXTURE_2D ); +#else + if( tex->MipMap ) + { + int miplevel = 0; + + while( TM_MipMap( scaled, &scaled_width, &scaled_height, tex->bytes ) ) + { + pfglTexImage2D( GL_TEXTURE_2D, ++miplevel, internalFormat[ tex->bytes ], scaled_width, scaled_height, 0, tex->bytes == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, scaled ); + } + } +#endif + } + + if ( scaled != data ) { + Z_Free( scaled ); + } + + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, WrapToGL( tex->WrapS ) ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, WrapToGL( tex->WrapT ) ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilterToGL( tex->MipMap, tex->MinFilter ) ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilterToGL( tex->MagFilter ) ); + +#ifdef IPHONE + if ( type == TT_Wall ) { + pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f ); + } else { + pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 ); + } +#endif + + + return tex; +} + + +/* +----------------------------------------------------------------------------- + Function: TM_FreeUnusedTextures -Free unused textures. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: Any texture that was not touched on this registration sequence will be freed. +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_FreeUnusedTextures( void ) +{ +#if 0 + int i; + texture_t *tex; + + // never free r_notexture texture + r_notexture->registration_sequence = texture_registration_sequence; + + for( i = 0, tex = ttextures ; i < numttextures ; ++i, ++tex ) + { + if( tex->registration_sequence == texture_registration_sequence ) + continue; // used this sequence + + if( ! tex->registration_sequence ) + continue; // free image_t slot + + if( tex->type == TT_Pic ) + continue; // don't free pics + + // free texture + R_DeleteTexture( tex->texnum ); + memset( tex, 0, sizeof( *tex ) ); + } +#endif +} + + +/* +----------------------------------------------------------------------------- + Function: TM_FindTexture -Find texture. + + Parameters: name -[in] Name of the texture to find. + type -[in] Type of texture (see texturetype_t). + + Returns: r_notexture if the texture is not found, otherwise it will + return a valid texture_t structure. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type ) +{ + texture_t *tex; + int i, len; + W8 *data; /* raw texture data */ + W16 width, height; /* width, height of texture */ + W16 bytes; + char digested[1024]; + filehandle_t *fh; + + if( ! name || ! *name ) + { + return r_notexture; + } + + // Check for file extension + len = strlen( name ); + if( len < 5 ) + { + return r_notexture; + } + + // look for it in the texture cache + for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex ) + { + if( ! strcmp( name, tex->name ) ) + { + tex->registration_sequence = texture_registration_sequence; + return tex; + } + } + + // + // load the texture from disk + // + data = NULL; + if( strcmp( name + len - 4, ".tga" ) ) { + return r_notexture; + } + + // look for the pre-digested 5551 version + strcpy( digested, name ); + strcpy( digested + len - 4, ".5551" ); + fh = FS_OpenFile( digested, 0 ); + if ( fh ) { + picHeader_t *ph = (picHeader_t *)fh->filedata; + int w = ph->uploadWidth; + int h = ph->uploadHeight; + int l = 0; + texture_t *tx = TM_AllocateTexture( name ); + tx->width = w; + tx->height = h; + tx->upload_width = w; + tx->upload_height = h; + tx->header = *ph; + unsigned short *s = (unsigned short *)(ph+1); + while( 1 ) { + pfglTexImage2D( GL_TEXTURE_2D, l, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, s ); + if ( w == 1 && h == 1 ) { + break; + } + l++; + s += w*h; + w >>= 1; + if ( w == 0 ) { + w = 1; + } + h >>= 1; + if ( h == 0 ) { + h = 1; + } + } + FS_CloseFile( fh ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); + pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + if ( type == TT_Wall ) { + pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f ); + } else { + pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 ); + } + return tx; + } + + // load a normal TGA + LoadTGA( name, &data, &width, &height, &bytes ); + if ( data ) { + tex = TM_LoadTexture( name, data, width, height, type, bytes ); + MM_FREE( data ); + return tex; + } + + // load a jpg + { + int jpgSize = 0; + W8 *jpgData; + void iPhoneLoadJPG( W8* jpegData, int jpegBytes, W8 **pic, W16 *width, W16 *height, W16 *bytes ); + // try jpeg if no tga exists + strcpy( digested, name ); + strcpy( digested + len - 4, ".jpg" ); + fh = FS_OpenFile( digested, 0 ); + if ( fh == NULL ) { + Com_Printf( "Failed to find texture %s\n", name ); + return r_notexture; + } + jpgSize = FS_GetFileSize( fh ); + jpgData = fh->ptrStart; + + iPhoneLoadJPG( jpgData, jpgSize, &data, &width, &height, &bytes ); + FS_CloseFile( fh ); + + if ( ! data ) { + free( jpgData ); + return r_notexture; + } + tex = TM_LoadTexture( name, data, width, height, type, bytes ); + MM_FREE( data ); + return tex; + } + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: TM_GetTextureSize -Find texture. + + Parameters:width -[out] Width of texture. + height -[out] Height of texture. + name -[in] Name of the texture to get dimensions of. + + + Returns: Nothing. + + Notes: If texture is not found, width and height are -1. +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_GetTextureSize( SW32 *width, SW32 *height, const char *name ) +{ + texture_t *tex; + + tex = TM_FindTexture( name, TT_Pic ); + if( ! tex ) + { + *width = *height = -1; + return; + } + + *width = tex->width; + *height = tex->height; +} + + + + + + + +/* Note: cubic function no longer clips result */ +PRIVATE INLINECALL double +cubic (double dx, + int jm1, + int j, + int jp1, + int jp2) +{ + /* Catmull-Rom - not bad */ + return (double) ((( ( - jm1 + 3 * j - 3 * jp1 + jp2 ) * dx + + ( 2 * jm1 - 5 * j + 4 * jp1 - jp2 ) ) * dx + + ( - jm1 + jp1 ) ) * dx + (j + j) ) / 2.0; +} + +_boolean pixel_region_has_alpha( int bytes ) +{ + if( bytes == 2 || bytes == 4 ) + { + return true; + } + else + { + return false; + } +} + + +PRIVATE void +expand_line( double *dest, + double *src, + int bytes, + int old_width, + int width ) +{ + double ratio; + int x,b; + int src_col; + double frac; + double *s; + + ratio = old_width / (double) width; + + /* we can overflow src's boundaries, so we expect our caller to have + allocated extra space for us to do so safely (see scale_region ()) */ + + /* this could be optimized much more by precalculating the coefficients for + each x */ + + for( x = 0; x < width; ++x ) + { + src_col = ((int) (x * ratio + 2.0 - 0.5)) - 2; + /* +2, -2 is there because (int) rounds towards 0 and we need + to round down */ + frac = (x * ratio - 0.5) - src_col; + s = &src[ src_col * bytes ]; + for( b = 0 ; b < bytes ; b++ ) + dest[ b ] = cubic( frac, (int)s[ b - bytes ], (int)s[ b ], (int)s[ b + bytes ], (int)s[ b + bytes * 2 ] ); + + dest += bytes; + } + +} + + +PRIVATE void +shrink_line( double *dest, + double *src, + int bytes, + int old_width, + int width ) +{ + int x; + int b; + double *srcp; + double *destp; + double accum[4]; + double slice; + const double avg_ratio = (double) width / old_width; + const double inv_width = 1.0 / width; + int slicepos; /* slice position relative to width */ + +#if 0 + + Com_DPrintf( "shrink_line bytes=%d old_width=%d width=%d interp=%d " + "avg_ratio=%f\n", + bytes, old_width, width, interp, avg_ratio); + +#endif + +// g_return_if_fail( bytes <= 4 ); + + /* This algorithm calculates the weighted average of pixel data that + each output pixel must receive, taking into account that it always + scales down, i.e. there's always more than one input pixel per each + output pixel. */ + + srcp = src; + destp = dest; + + slicepos = 0; + + /* Initialize accum to the first pixel slice. As there is no partial + pixel at start, that value is 0. The source data is interleaved, so + we maintain BYTES accumulators at the same time to deal with that + many channels simultaneously. */ + for( b = 0 ; b < bytes ; ++b ) + { + accum[ b ] = 0.0; + } + + for( x = 0 ; x < width ; x++ ) + { + /* Accumulate whole pixels. */ + do + { + for( b = 0 ; b < bytes ; b++ ) + accum[ b ] += *srcp++; + + slicepos += width; + } + while( slicepos < old_width ); + slicepos -= old_width; + + if( ! (slicepos < width)) + Com_Printf( "Assertion (slicepos < width) failed. Please report.\n" ); + + if( slicepos == 0 ) + { + /* Simplest case: we have reached a whole pixel boundary. Store + the average value per channel and reset the accumulators for + the next round. + + The main reason to treat this case separately is to avoid an + access to out-of-bounds memory for the first pixel. */ + for (b = 0; b < bytes; b++) + { + *destp++ = accum[b] * avg_ratio; + accum[b] = 0.0; + } + } + else + { + for( b = 0; b < bytes; b++ ) + { + /* We have accumulated a whole pixel per channel where just a + slice of it was needed. Subtract now the previous pixel's + extra slice. */ + slice = srcp[- bytes + b] * slicepos * inv_width; + *destp++ = (accum[b] - slice) * avg_ratio; + + /* That slice is the initial value for the next round. */ + accum[b] = slice; + } + } + } + + /* Sanity check: srcp should point to the next-to-last position, and + slicepos should be zero. */ + if( ! (srcp - src == old_width * bytes && slicepos == 0) ) + { + Com_Printf ("Assertion (srcp - src == old_width * bytes && slicepos == 0)" + " failed. Please report."); + } +} + +PRIVATE void pixel_region_get_row( W8 *src, int y, int width, W8 *tmp_src, int BytesPerPixel ) +{ + int i; + unsigned long k = 0; + unsigned char *scanline = tmp_src; + unsigned char *ptr = src; + + for( i = 0 ; i < (width * BytesPerPixel) ; ++i ) + { + scanline[ k++ ] = ptr[ y * width * BytesPerPixel + i ]; + } +} + +PRIVATE void pixel_region_set_row( W8 *dest, + int BytesPerPixel, + int y, + int width, + W8 *data ) +{ + int i; + unsigned long k = 0; + unsigned char *scanline = dest; + unsigned char *ptr = data; + + for( i = 0 ; i < (width * BytesPerPixel) ; ++i ) + { + scanline[ y * width * BytesPerPixel + i ] = ptr[ k++ ]; + } +} + +PRIVATE void +get_premultiplied_double_row( W8 *in, + int PRbytes, + int x, + int y, + int w, + double *row, + W8 *tmp_src, + int n ) +{ + int b; + int bytes = PRbytes; + + pixel_region_get_row( in, y, w, tmp_src, bytes ); + + if( pixel_region_has_alpha( bytes ) ) + { + /* premultiply the alpha into the double array */ + double *irow = row; + int alpha = bytes - 1; + double mod_alpha; + + for( x = 0; x < w; ++x ) + { + mod_alpha = tmp_src[ alpha ] / 255.0; + for( b = 0; b < alpha; ++b ) + { + irow[ b ] = mod_alpha * tmp_src[ b ]; + } + + irow[ b ] = tmp_src[ alpha ]; + irow += bytes; + tmp_src += bytes; + } + } + else /* no alpha */ + { + for( x = 0; x < w * bytes; ++x ) + { + row[ x ] = tmp_src[ x ]; + } + } + + /* set the off edge pixels to their nearest neighbor */ + for( b = 0; b < 2 * bytes; b++ ) + { + row[ b - 2 * bytes ] = row[ b % bytes ]; + } + + for( b = 0; b < bytes * 2; b++ ) + { + row[ b + w * bytes ] = row[ (w - 1) * bytes + b % bytes ]; + } +} + + +PRIVATE INLINECALL void +rotate_pointers( W8 **p, W32 n ) +{ + W32 i; + W8 *tmp; + + tmp = p[ 0 ]; + for( i = 0 ; i < n-1 ; i++ ) + { + p[ i ] = p[ i + 1 ]; + } + + p[ i ] = tmp; +} + +PRIVATE void +get_scaled_row( double **src, + int y, + int new_width, + double *row, + W8 *src_tmp, + W8 *srcPR, + int old_width, + int old_height, + int bytes ) +{ + /* get the necesary lines from the source image, scale them, + and put them into src[] */ + rotate_pointers( (unsigned char **)src, 4 ); + + if( y < 0 ) + { + y = 0; + } + + if( y < old_height ) + { + get_premultiplied_double_row( srcPR, bytes, 0, y, old_width, + row, src_tmp, 1 ); + if( new_width > old_width ) + { + expand_line( src[3], row, bytes, old_width, new_width ); + } + else if( old_width > new_width ) + { + shrink_line( src[3], row, bytes, old_width, new_width ); + } + else /* no scailing needed */ + { + memcpy( src[3], row, sizeof( double ) * new_width * bytes ); + } + } + else + { + memcpy( src[3], src[2], sizeof( double ) * new_width * bytes ); + } +} + + +/* +non-interpolating scale_region. + */ +PRIVATE void +scale_region_no_resample( W8 *in, int inwidth, int inheight, + W8 *out, int outwidth, int outheight, char bytes ) +{ + int *x_src_offsets; + int *y_src_offsets; + W8 *src; + W8 *dest; + int width, height, orig_width, orig_height; + int last_src_y; + int row_bytes; + int x, y, b; + + + orig_width = inwidth; + orig_height = inheight; + + width = outwidth; + height = outheight; + + + /* the data pointers... */ + x_src_offsets = (int *) MM_MALLOC( sizeof( int ) * width * bytes ); + y_src_offsets = (int *) MM_MALLOC( sizeof( int ) * height ); + src = (unsigned char *) MM_MALLOC( orig_width * bytes); + dest = (unsigned char *) MM_MALLOC( width * bytes); + + /* pre-calc the scale tables */ + for( b = 0; b < bytes; b++ ) + { + for( x = 0; x < width; x++ ) + { + x_src_offsets[ b + x * bytes ] = + b + bytes * ((x * orig_width + orig_width / 2) / width); + } + } + + for( y = 0; y < height; y++ ) + { + y_src_offsets[ y ] = (y * orig_height + orig_height / 2) / height; + } + + /* do the scaling */ + row_bytes = width * bytes; + last_src_y = -1; + for( y = 0; y < height; y++ ) + { + /* if the source of this line was the same as the source + * of the last line, there's no point in re-rescaling. + */ + if( y_src_offsets[ y ] != last_src_y ) + { + pixel_region_get_row( in, y_src_offsets[ y ], orig_width, src, bytes ); + //pixel_region_get_row( srcPR, 0, y_src_offsets[y], orig_width, src, 1 ); + for( x = 0 ; x < row_bytes ; x++ ) + { + dest[ x ] = src[ x_src_offsets[ x ] ]; + } + last_src_y = y_src_offsets[ y ]; + } + + pixel_region_set_row( out, bytes, y, width, dest ); + } + + MM_FREE( x_src_offsets ); + MM_FREE( y_src_offsets ); + MM_FREE( src ); + MM_FREE( dest ); +} + + +/* +----------------------------------------------------------------------------- + Function: TM_ResampleTexture -Resize texture. + + Parameters: + in -[in] Original texture data. + inwidth -[in] Original width of texture in pixels. + inheight -[in] Original height of texture in pixels. + out -[in/out] Resized texture data. + outwidth -[in] New width of texture in pixels. + outheight -[in] New height of texture in pixels. + bytes -[in] Number of bytes per pixel. + interpolation -[in] see InterpolationType + + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_ResampleTexture( W8 *in, int inwidth, int inheight, W8 *out, int outwidth, int outheight, W8 bytes, InterpolationType interpolation ) +{ + double *src[ 4 ]; + W8 *src_tmp; + W8 *dest; + double *row, *accum; + int b; + int width, height; + int orig_width, orig_height; + double y_rat; + int i; + int old_y = -4; + int new_y; + int x, y; + + + if( interpolation == INTERPOLATION_NONE ) + { + scale_region_no_resample( in, inwidth, inheight, out, outwidth, outheight, bytes ); + return; + } + + + orig_width = inwidth; + orig_height = inheight; + + width = outwidth; + height = outheight; + +#if 0 + + Com_DPrintf( "scale_region: (%d x %d) -> (%d x %d)\n", + orig_width, orig_height, width, height ); + +#endif + + /* find the ratios of old y to new y */ + y_rat = (double) orig_height / (double) height; + + + /* the data pointers... */ + for( i = 0 ; i < 4 ; ++i ) + { + src[ i ] = (double *) MM_MALLOC( sizeof( double ) * width * bytes ); + } + + dest = (PW8) MM_MALLOC( width * bytes); + + src_tmp = (PW8) MM_MALLOC( orig_width * bytes ); + + /* offset the row pointer by 2*bytes so the range of the array + is [-2*bytes] to [(orig_width + 2)*bytes] */ + row = (double *) MM_MALLOC( sizeof( double ) * (orig_width + 2 * 2) * bytes ); + row += bytes * 2; + + accum = (double *) MM_MALLOC( sizeof( double ) * width * bytes ); + + + /* Scale the selected region */ + + for( y = 0 ; y < height ; y++ ) + { + + if( height < orig_height ) + { + int max; + double frac; + const double inv_ratio = 1.0 / y_rat; + + if( y == 0 ) /* load the first row if this is the first time through */ + { + get_scaled_row( &src[0], 0, width, row, src_tmp, in, orig_width, orig_height, bytes ); + } + + new_y = (int)(y * y_rat); + frac = 1.0 - (y * y_rat - new_y); + for( x = 0 ; x < width * bytes; ++x ) + { + accum[x] = src[3][x] * frac; + } + + max = (int) ((y + 1) * y_rat) - new_y - 1; + + get_scaled_row( &src[ 0 ], ++new_y, width, row, src_tmp, in, orig_width, orig_height, bytes ); + + while( max > 0 ) + { + for( x = 0 ; x < width * bytes ; ++x ) + { + accum[x] += src[ 3 ][ x ]; + } + + get_scaled_row( &src[ 0 ], ++new_y, width, row, src_tmp, in, orig_width, orig_height, bytes ); + max--; + } + + frac = (y + 1) * y_rat - ((int) ((y + 1) * y_rat)); + for( x = 0 ; x < width * bytes ; ++x ) + { + accum[ x ] += frac * src[ 3 ][ x ]; + accum[ x ] *= inv_ratio; + } + } + else if( height > orig_height ) + { + double p0, p1, p2, p3; + double dy; + + new_y = (int)floor( y * y_rat - 0.5 ); + + while( old_y <= new_y ) + { + /* get the necesary lines from the source image, scale them, + and put them into src[] */ + get_scaled_row( &src[ 0 ], old_y + 2, width, row, src_tmp, in, orig_width, orig_height, bytes ); + old_y++; + } + + dy = (y * y_rat - 0.5) - new_y; + + p0 = cubic( dy, 1, 0, 0, 0 ); + p1 = cubic( dy, 0, 1, 0, 0 ); + p2 = cubic( dy, 0, 0, 1, 0 ); + p3 = cubic( dy, 0, 0, 0, 1 ); + + for( x = 0 ; x < width * bytes ; ++x ) + { + accum[ x ] = ( p0 * src[ 0 ][ x ] + p1 * src[ 1 ][ x ] + + p2 * src[ 2 ][ x ] + p3 * src[ 3 ][ x ] ); + } + + + } + else /* height == orig_height */ + { + get_scaled_row( &src[ 0 ], y, width, row, src_tmp, in, orig_width, orig_height, bytes ); + memcpy( accum, src[ 3 ], sizeof( double ) * width * bytes ); + } + + if( pixel_region_has_alpha( bytes ) ) + { + /* unmultiply the alpha */ + double inv_alpha; + double *p = accum; + int alpha = bytes - 1; + int result; + W8 *d = dest; + + for( x = 0 ; x < width ; ++x ) + { + if( p[ alpha ] > 0.001 ) + { + inv_alpha = 255.0 / p[ alpha ]; + for( b = 0 ; b < alpha ; b++ ) + { + result = RINT( inv_alpha * p[ b ] ); + if( result < 0 ) + { + d[ b ] = 0; + } + else if( result > 255 ) + { + d[ b ] = 255; + } + else + { + d[ b ] = result; + } + } + result = RINT( p[ alpha ] ); + if( result > 255 ) + { + d[ alpha ] = 255; + } + else + { + d[ alpha ] = result; + } + } + else /* alpha <= 0 */ + { + for( b = 0 ; b <= alpha ; ++b ) + { + d[ b ] = 0; + } + } + + d += bytes; + p += bytes; + } + } + else + { + int w = width * bytes; + + for( x = 0 ; x < w ; ++x ) + { + if( accum[ x ] < 0.0 ) + { + dest[ x ] = 0; + } + else if( accum[ x ] > 255.0 ) + { + dest[ x ] = 255; + } + else + { + dest[ x ] = RINT( accum[ x ] ); + } + } + } + pixel_region_set_row( out, bytes, y, width, dest ); + } + + /* free up temporary arrays */ + MM_FREE( accum ); + + for( i = 0 ; i < 4 ; ++i ) + { + MM_FREE( src[ i ] ); + } + + MM_FREE( src_tmp ); + MM_FREE( dest ); + + row -= 2 * bytes; + MM_FREE( row ); +} + + +/* +----------------------------------------------------------------------------- + Function: TM_MipMap -Generate MipMap. + + Parameters: + in -[in/out] Texture data. + width -[in] Width of texture in pixels. + height -[in] Height of texture in pixels. + + Returns: Nothing. + + Notes: Operates in place, quartering the size of the texture. +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean TM_MipMap( PW8 in, W16 *width, W16 *height, W16 bytes ) +{ + W16 new_width, new_height; + + if( *width == 1 && *height == 1 ) + { + return false; + } + + + if( *width < 2 ) + { + new_width = 1; + } + else + { + new_width = *width >> 1; + } + + if( *height < 2 ) + { + new_height = 1; + } + else + { + new_height = *height >> 1; + } + + TM_ResampleTexture( in, *width, *height, in, new_width, new_height, bytes, INTERPOLATION_CUBIC ); + + *width = new_width; + *height = new_height; + + return true; +} + + +/* +----------------------------------------------------------------------------- + Function: TM_Init -Initialize Texture Manager. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: Generates default texture. +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_Init( void ) +{ + W8 *ptr; + W8 *data; + int x, y; + + gl_round_down = Cvar_Get ("gl_round_down", "1", CVAR_INIT); + + texture_registration_sequence = 1; + +// create a checkerboard texture + data = MM_MALLOC( 16 * 16 * 4 ); + for( y = 0; y < 16; ++y ) + { + for( x = 0; x < 16; ++x ) + { + ptr = &data[ (y * 16 + x) * 4 ]; + if( (y < 8) ^ (x < 8) ) + { + ptr[ 0 ] = ptr[ 1 ] = ptr[ 2 ] = 0x00; + ptr[ 3 ] = 0xFF; + } + else + { + ptr[ 0 ] = ptr[ 1 ] = ptr[ 2 ] = 0xFF; + ptr[ 3 ] = 0xFF; + } + } + } + + r_notexture = TM_LoadTexture( "***r_notexture***", data, 16, 16, TT_Pic, 4 ); + + MM_FREE( data ); + + + Cmd_AddCommand( "listTextures", TM_TextureList_f ); + + +} + +/* +----------------------------------------------------------------------------- + Function: TM_Shutdown -Shutdown Texture Manager. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void TM_Shutdown( void ) +{ + int i; + texture_t *tex; + + for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex ) + { + if( ! tex->registration_sequence ) + { + continue; // free image_t slot + } + + // free texture + R_DeleteTexture( tex->texnum ); + memset( tex, 0, sizeof( *tex ) ); + } + + Cmd_RemoveCommand( "listTextures" ); +} + diff --git a/wolf3d/newCode/env/texture_manager.h b/wolf3d/newCode/env/texture_manager.h new file mode 100644 index 0000000..abc4d1b --- /dev/null +++ b/wolf3d/newCode/env/texture_manager.h @@ -0,0 +1,176 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + Copyright (C) 1995 Spencer Kimball and Peter Mattis. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * texture_manager.c: Texture manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from + * The GIMP (an image manipulation program) and was originally + * written by Spencer Kimball and Peter Mattis. + * + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __TEXTURE_MANAGER_H__ +#define __TEXTURE_MANAGER_H__ + +#define MAX_TEXTURES 1024 + + +typedef enum +{ + TT_Sprite, + TT_Wall, + TT_Pic, + + TextureTypeCount + +} texturetype_t; + +typedef enum +{ + Repeat = 0, + Clamp, + + WrapModeCount // Number of Wrap modes + +} TWrapMode; + +typedef enum +{ + Auto = 0, + RGBA8888, + RGBA4444, + RGBA5551, + RGB888, + RGB565, + DXTC1, + DXTC1Alpha, + DXTC3, + DXTC5, + Luminance, + Alpha, + AlphaLuminance, + DsDt, + + UpImageFormatCount // Number of Upload formats + +} TTexFormat; + +typedef enum +{ + Nearest = 0, + Linear, + + MagFilterCount // Number of Magnification filters + +} TMagFilter; + +typedef enum +{ + NearestMipMapOff = 0, + NearestMipMapNearest, + NearestMipMapLinear, + LinearMipMapOff, + LinearMipMapNearest, + LinearMipMapLinear, + + MinFilterCount // Number of Min filters + +} TMinFilter; + +// this is the header from the pre-digested binary files with sprite bounds +typedef struct { + int hasAlpha; + int srcWidth; + int srcHeight; + int uploadWidth; + int uploadHeight; + int numBounds; + int bounds[2][2][2]; +} picHeader_t; + + +typedef struct texture_s +{ + _boolean MipMap; + _boolean isTextureCube; + TTexFormat UploadFormat; + TWrapMode WrapS; + TWrapMode WrapT; + TWrapMode WrapR; + TMinFilter MinFilter; + TMagFilter MagFilter; + W32 registration_sequence; // 0 = free + W16 width, height; + W16 upload_width, upload_height; + unsigned int texnum; + W16 bytes; + texturetype_t type; + char name[ MAX_GAMEPATH ]; // game path, including extension + picHeader_t header; +} texture_t; + + + +typedef enum +{ + + INTERPOLATION_NONE, /* None (Fastest) */ + INTERPOLATION_LINEAR, /* Linear */ + INTERPOLATION_CUBIC /* Cubic (Best) */ + +} InterpolationType; + + +extern W32 texture_registration_sequence; + + + +extern void TM_Init( void ); +extern void TM_Shutdown( void ); + + +extern _boolean TM_MipMap( PW8 in, W16 *width, W16 *height, W16 bytes ); + +extern texture_t *wallTextures[1000]; +extern texture_t *spriteTextures[1000]; + +extern texture_t *TM_FindTexture( const char *name, texturetype_t type ); + +extern void TM_GetTextureSize( SW32 *width, SW32 *height, const char *name ); + +extern void TM_ResampleTexture( PW8 in, int inwidth, int inheight, PW8 out, int outwidth, int outheight, W8 bytes, InterpolationType interpolation ); + +extern void TM_FreeUnusedTextures( void ); + + + + + +#endif /* __TEXTURE_MANAGER_H__ */ diff --git a/wolf3d/newCode/env/tga.c b/wolf3d/newCode/env/tga.c new file mode 100644 index 0000000..82312db --- /dev/null +++ b/wolf3d/newCode/env/tga.c @@ -0,0 +1,783 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1995 Spencer Kimball and Peter Mattis + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * tga.h: Handle Targa file format. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from The GIMP -- an image manipulation + * program, and was originally written by Spencer Kimball and Peter Mattis. + * + */ + +/* + Notes: + +*/ + +#include "../wolfiphone.h" + + +#define TGA_HEADER_SIZE 18 + +#ifndef IPHONE +PRIVATE W8 *p_buf; // current pointer to tga data block +#endif + + + /* TRUEVISION-XFILE magic signature string */ +static W8 magic[ 18 ] = +{ + 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, 0x49, 0x4f, + 0x4e, 0x2d, 0x58, 0x46, 0x49, 0x4c, 0x45, 0x2e, 0x0 +}; + + +typedef struct _TargaHeader +{ + W8 idLength; + W8 colorMapType; + + W8 imageType; +/* Known image types. */ +#define TGA_TYPE_MAPPED 1 +#define TGA_TYPE_COLOR 2 +#define TGA_TYPE_GRAY 3 + + W8 imageCompression; +/* Only known compression is RLE */ +#define TGA_COMP_NONE 0 +#define TGA_COMP_RLE 1 + +/* Color Map Specification. */ + W16 colorMapIndex; + W16 colorMapLength; + W8 colorMapSize; + +/* Image Specification. */ + W16 xOrigin; + W16 yOrigin; + + W16 width; + W16 height; + + W8 bpp; + W8 bytes; + + W8 alphaBits; + W8 flipHoriz; + W8 flipVert; + +} TargaHeader; + + + +PRIVATE void flip_line( W8 *buffer, TargaHeader *info ) +{ + W8 temp; + W8 *alt; + SW32 x, s; + + alt = buffer + (info->bytes * (info->width - 1)); + + for( x = 0; x * 2 <= info->width; ++x ) + { + for( s = 0; s < info->bytes; ++s ) + { + temp = buffer[ s ]; + buffer[ s ] = alt[ s ]; + alt[ s ] = temp; + } + + buffer += info->bytes; + alt -= info->bytes; + } +} + +PRIVATE void upsample( W8 *dest, W8 *src, + W32 width, W32 bytes, W8 alphaBits ) +{ + W32 x; + + for( x = 0 ; x < width ; ++x ) + { + dest[0] = ((src[1] << 1) & 0xf8); + dest[0] += (dest[0] >> 5); + + dest[1] = ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6); + dest[1] += (dest[1] >> 5); + + dest[2] = ((src[0] << 3) & 0xf8); + dest[2] += (dest[2] >> 5); + + switch( alphaBits ) + { + case 1: + dest[ 3 ] = (src[ 1 ] & 0x80) ? 0 : 255; + dest += 4; + break; + + default: + dest += 3; + } + + src += bytes; + } +} + +PRIVATE void bgr2rgb( W8 *dest, W8 *src, + W32 width, W32 bytes, W32 alpha ) +{ + W32 x; + + if( alpha ) + { + for( x = 0 ; x < width ; ++x ) + { + *(dest++) = src[2]; + *(dest++) = src[1]; + *(dest++) = src[0]; + + *(dest++) = src[3]; + + src += bytes; + } + } + else + { + for( x = 0 ; x < width ; ++x ) + { + *(dest++) = src[2]; + *(dest++) = src[1]; + *(dest++) = src[0]; + + src += bytes; + } + } + + +} + +PRIVATE SW32 rle_read( filehandle_t *fp, W8 *buffer, + TargaHeader *info ) +{ + static SW32 repeat = 0; + static SW32 direct = 0; + static W8 sample[ 4 ]; + SW32 head; + W8 temphead; + SW32 x, k; + + for( x = 0; x < info->width; ++x ) + { + if( repeat == 0 && direct == 0 ) + { + FS_ReadFile( &temphead, 1, 1, fp ); + head = temphead; + + if( head >= 128 ) + { + repeat = head - 127; + + if( FS_ReadFile( sample, info->bytes, 1, fp ) < 1 ) + { + return EOF; + } + } + else + { + direct = head + 1; + } + } + + if( repeat > 0 ) + { + for( k = 0 ; k < info->bytes ; ++k ) + { + buffer[ k ] = sample[ k ]; + } + + repeat--; + } + else /* direct > 0 */ + { + if( FS_ReadFile( buffer, info->bytes, 1, fp ) < 1 ) + { + return EOF; + } + + direct--; + } + + buffer += info->bytes; + } + + return 0; +} + + +PRIVATE void read_line( filehandle_t *fp, + W8 *row, + W8 *buffer, + TargaHeader *info ) +{ + if( info->imageCompression == TGA_COMP_RLE ) + { + if( rle_read( fp, buffer, info ) == EOF ) + { + return; + } + } + else + { + FS_ReadFile( buffer, info->bytes, info->width, fp ); + } + + if( info->flipHoriz ) + { + flip_line( buffer, info ); + } + + if( info->imageType == TGA_TYPE_COLOR ) + { + if( info->bpp == 16 || info->bpp == 15 ) + { + upsample( row, buffer, info->width, info->bytes, info->alphaBits ); + } + else + { + bgr2rgb( row, buffer, info->width, info->bytes, info->bytes == 4 ? 1 : 0 ); + } + } + else + { + memcpy( row, buffer, info->width * info->bpp ); + } +} + + + +PUBLIC void LoadTGA( const char *filename, W8 **pic, W16 *width, W16 *height, W16 *bytes ) +{ + TargaHeader targa_header; + W8 header[ 18 ]; + W8 footer[ 26 ]; + W8 extension[ 495 ]; + W32 cmap_bytes; + SW32 offset; + W8 tga_cmap[4 * 256], gimp_cmap[3 * 256]; + W8 *buffer, *data, *row; + int i; + SW32 datalength; + filehandle_t *hFile; + + + + *pic = NULL; + +// +// Load the file +// + hFile = FS_OpenFile( filename, 0 ); + if( ! hFile ) + { + Com_DPrintf( "Could not open (%s) for reading\n", filename ); + + goto TGALOADFAILED; + } + + datalength = FS_GetFileSize( hFile ); + + if( ! FS_FileSeek( hFile, -26L, SEEK_END ) ) + { + /* Is file big enough for a footer? */ + if( FS_ReadFile( footer, sizeof( footer ), 1, hFile ) != 1 ) + { + Com_DPrintf( "Cannot read footer from (%s)\n" , filename ); + + goto TGALOADFAILED; + } + else if( memcmp( footer + 8, magic, sizeof( magic ) ) == 0 ) + { + /* Check the signature. */ + offset = footer[ 0 ] + (footer[ 1 ] * 256) + (footer[ 2 ] * 65536) + + (footer[ 3 ] * 16777216); + + if( offset != 0 ) + { + if( FS_FileSeek( hFile, offset, SEEK_SET ) || + FS_ReadFile( extension, sizeof( extension ), 1, hFile ) != 1 ) + { + Com_DPrintf( "Cannot read extension from '%s'\n", filename ); + + goto TGALOADFAILED; + } + + /* Eventually actually handle version 2 TGA here */ + + } + } + + } + + +// +// Get header information. +// + if( datalength < TGA_HEADER_SIZE ) + { + Com_Printf( "Could not read header from (%s)\n", filename ); + + goto TGALOADFAILED; + } + + if( FS_FileSeek( hFile, 0, SEEK_SET ) || + FS_ReadFile( header, sizeof( header ), 1, hFile ) != 1 ) + { + Com_Printf( "Cannot read header from (%s)\n", filename ); + + goto TGALOADFAILED; + } + + + + targa_header.idLength = header[ 0 ]; + targa_header.colorMapType = header[ 1 ]; + + switch( header[ 2 ] ) + { + case 1: + targa_header.imageType = TGA_TYPE_MAPPED; + targa_header.imageCompression = TGA_COMP_NONE; + break; + + case 2: + targa_header.imageType = TGA_TYPE_COLOR; + targa_header.imageCompression = TGA_COMP_NONE; + break; + + case 3: + targa_header.imageType = TGA_TYPE_GRAY; + targa_header.imageCompression = TGA_COMP_NONE; + break; + + + + case 9: + targa_header.imageType = TGA_TYPE_MAPPED; + targa_header.imageCompression = TGA_COMP_RLE; + break; + + case 10: + targa_header.imageType = TGA_TYPE_COLOR; + targa_header.imageCompression = TGA_COMP_RLE; + break; + + case 11: + targa_header.imageType = TGA_TYPE_GRAY; + targa_header.imageCompression = TGA_COMP_RLE; + break; + + + default: + targa_header.imageType = 0; + } + + targa_header.colorMapIndex = header[ 3 ] + header[ 4 ] * 256; + targa_header.colorMapLength = header[ 5 ] + header[ 6 ] * 256; + targa_header.colorMapSize = header[ 7 ]; + + targa_header.xOrigin = header[ 8 ] + header[ 9 ] * 256; + targa_header.yOrigin = header[ 10 ] + header[ 11 ] * 256; + targa_header.width = header[ 12 ] + header[ 13 ] * 256; + targa_header.height = header[ 14 ] + header[ 15 ] * 256; + + targa_header.bpp = header[ 16 ]; + targa_header.bytes = (targa_header.bpp + 7) / 8; + targa_header.alphaBits = header[ 17 ] & 0x0f; /* Just the low 4 bits */ + targa_header.flipHoriz = (header[ 17 ] & 0x10) ? 1 : 0; + targa_header.flipVert = (header[ 17 ] & 0x20) ? 0 : 1; + +// +// Analyze header information. +// + switch( targa_header.imageType ) + { + case TGA_TYPE_MAPPED: + if( targa_header.bpp != 8 ) + { + Com_DPrintf( "Unhandled sub-format in (%s)\n", filename ); + + goto TGALOADFAILED; + } + + goto TGALOADFAILED; + + break; + + case TGA_TYPE_COLOR: + if( targa_header.bpp != 15 && targa_header.bpp != 16 && targa_header.bpp != 24 + && targa_header.bpp != 32 ) + { + Com_DPrintf( "Unhandled sub-format in (%s)\n", filename ); + goto TGALOADFAILED; + } + break; + + case TGA_TYPE_GRAY: + if( targa_header.bpp != 8 && (targa_header.alphaBits != 8 || (targa_header.bpp != 16 && targa_header.bpp != 15 ))) + { + Com_DPrintf( "Unhandled sub-format in (%s)\n", filename ); + goto TGALOADFAILED; + } + + + goto TGALOADFAILED; + + + break; + + default: + Com_DPrintf( "Unknown image type for (%s)\n", filename ); + goto TGALOADFAILED; + + } /* end of switch targa_header.imageType */ + + /* Plausible but unhandled formats */ + if( targa_header.bytes * 8 != targa_header.bpp && ! (targa_header.bytes == 2 && targa_header.bpp == 15) ) + { + Com_DPrintf( "No support yet for TGA with these parameters\n" ); + + goto TGALOADFAILED; + } + + /* Check that we have a color map only when we need it. */ + if( targa_header.imageType == TGA_TYPE_MAPPED && targa_header.colorMapType != 1 ) + { + Com_DPrintf( "Indexed image has invalid color map type %d\n", + targa_header.colorMapType ); + + goto TGALOADFAILED; + } + else if( targa_header.imageType != TGA_TYPE_MAPPED && targa_header.colorMapType != 0 ) + { + Com_DPrintf( "Non-indexed image has invalid color map type %d\n", + targa_header.colorMapType ); + + goto TGALOADFAILED; + } + + /* Skip the image ID field. */ + if( targa_header.idLength && FS_FileSeek( hFile, targa_header.idLength, SEEK_CUR ) ) + { + Com_DPrintf( "File (%s) is truncated or corrupted\n", filename ); + + goto TGALOADFAILED; + } + + + + /* Handle colormap */ + if( targa_header.colorMapType == 1 ) + { + cmap_bytes = (targa_header.colorMapSize + 7 ) / 8; + if( cmap_bytes <= 4 && + FS_ReadFile( tga_cmap, targa_header.colorMapLength * cmap_bytes, 1, hFile ) == 1 ) + { + if( targa_header.colorMapSize == 32 ) + { + bgr2rgb( gimp_cmap, tga_cmap, targa_header.colorMapLength, cmap_bytes, 1); + } + else if( targa_header.colorMapSize == 24 ) + { + bgr2rgb( gimp_cmap, tga_cmap, targa_header.colorMapLength, cmap_bytes, 0); + } + else if( targa_header.colorMapSize == 16 || targa_header.colorMapSize == 15 ) + { + upsample( gimp_cmap, tga_cmap, targa_header.colorMapLength, cmap_bytes, targa_header.alphaBits); + } + + } + else + { + Com_DPrintf( "File (%s) is truncated or corrupted\n", filename ); + + goto TGALOADFAILED; + } + } + + + /* Allocate the data. */ + data = MM_MALLOC( targa_header.width * targa_header.height * targa_header.bytes ); + if( data == NULL ) + { + MM_OUTOFMEM( "data" ); + } + + buffer = (PW8) MM_MALLOC( targa_header.width * targa_header.bytes ); + if( buffer == NULL ) + { + MM_FREE( data ); + MM_OUTOFMEM( "buffer" ); + } + + if( targa_header.flipVert ) + { + for( i = targa_header.height-1 ; i >= 0 ; --i ) + { + row = data + (targa_header.width * targa_header.bytes * i); + read_line( hFile, row, buffer, &targa_header ); + } + } + else + { + for( i = 0 ; i < targa_header.height ; ++i ) + { + row = data + (targa_header.width * targa_header.bytes * i); + read_line( hFile, row, buffer, &targa_header ); + } + } + + + MM_FREE( buffer ); + + FS_CloseFile( hFile ); + + *pic = data; + *width = targa_header.width; + *height = targa_header.height; + *bytes = targa_header.bytes; + + return; + + + +TGALOADFAILED: + *pic = NULL; + *width = 0; + *height = 0; + *bytes = 0; + + if( hFile ) + { + FS_CloseFile( hFile ); + } + +} + +/* +----------------------------------------------------------------------------- + Function: rle_write -Run length encode scanline. + + Parameters: fp -[in] Pointer to valid FILE structure. + buffer -[in] Scanline data. + width -[in] Image scanline width. + bytes -[in] Bytes per pixel. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void rle_write( FILE *fp, + W8 *buffer, + W32 width, + W32 bytes ) +{ + SW32 repeat = 0; + SW32 direct = 0; + W8 *from = buffer; + W32 x; + + for( x = 1 ; x < width ; ++x ) + { + if( memcmp( buffer, buffer + bytes, bytes ) ) + { + /* next pixel is different */ + if( repeat ) + { + putc( 128 + repeat, fp ); + fwrite( from, bytes, 1, fp ); + from = buffer + bytes; /* point to first different pixel */ + repeat = 0; + direct = 0; + } + else + { + direct += 1; + } + } + else + { + /* next pixel is the same */ + if( direct ) + { + putc( direct - 1, fp ); + fwrite( from, bytes, direct, fp ); + from = buffer; /* point to first identical pixel */ + direct = 0; + repeat = 1; + } + else + { + repeat += 1; + } + } + + if( repeat == 128 ) + { + putc( 255, fp ); + fwrite( from, bytes, 1, fp ); + from = buffer + bytes; + direct = 0; + repeat = 0; + } + else if( direct == 128 ) + { + putc( 127, fp ); + fwrite( from, bytes, direct, fp ); + from = buffer + bytes; + direct = 0; + repeat = 0; + } + + buffer += bytes; + } + + if( repeat > 0 ) + { + putc( 128 + repeat, fp ); + fwrite( from, bytes, 1, fp ); + } + else + { + putc( direct, fp ); + fwrite( from, bytes, direct + 1, fp ); + } +} + + +/* +----------------------------------------------------------------------------- + Function: WriteTGA -Write targa image file. + + Parameters: filename -[in] Name of TGA file to save as. + bpp -[in] Bits per pixel. (16, 24 or 32). + width -[in] Width of image. + height -[in] Height of image. + Data -[in] Raw image data. + upsideDown -[in] Is the data upside down? 1 yes, 0 no. + rle -[in] Run Length encode? 1 yes, 0 no. + + Returns: 0 on error, otherwise 1. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W8 WriteTGA( const char *filename, W16 bpp, W16 width, W16 height, + void *Data, W8 upsideDown, W8 rle ) +{ + W16 i, x, y, BytesPerPixel; + W8 *scanline; + W8 header[ 18 ]; + FILE *filestream; + W8 *ptr = (PW8) Data; + W8 temp; + + BytesPerPixel = bpp >> 3; + + filestream = fopen( filename, "wb" ); + if( filestream == NULL ) + { + Com_DPrintf( "Could not open file (%s) for write!\n", filename ); + return 0; + } + + memset( header, 0, 18 ); + header[2] = rle ? 10 : 2; + + header[12] = width & 255; // width low + header[13] = width >> 8; // width high + + header[14] = height & 255; // height low + header[15] = height >> 8; // height high + + header[16] = bpp & 255; // pixel size + + if( upsideDown ) + { + header[17] |= 1 << 5; // Image Descriptor + } + + + fwrite( header, sizeof( W8 ), sizeof( header ), filestream ); + + + + scanline = (PW8) MM_MALLOC( width * BytesPerPixel ); + if( scanline == NULL ) + { + fclose( filestream ); + + return 0; + } + + for( y = 0; y < height; ++y ) + { + W32 k = 0; + + for( i = 0; i < (width * BytesPerPixel); ++i ) + { + scanline[ k++ ] = ptr[ (height - y - 1) * width * BytesPerPixel + i ]; + } + + + + if( bpp == 24 || bpp == 32 ) + { + // swap rgb to bgr + for( x = 0; x < (width * BytesPerPixel); x += BytesPerPixel ) + { + temp = scanline[ x ]; + scanline[ x ] = scanline[ x + 2 ]; + scanline[ x + 2 ] = temp; + } + } + + + if( rle ) + { + rle_write( filestream, scanline, width, BytesPerPixel ); + } + else + { + fwrite( scanline, sizeof( W8 ), width * BytesPerPixel, filestream ); + } + } + + MM_FREE( scanline ); + + fclose( filestream ); + + return 1; +} diff --git a/wolf3d/newCode/env/tga.h b/wolf3d/newCode/env/tga.h new file mode 100644 index 0000000..509c90b --- /dev/null +++ b/wolf3d/newCode/env/tga.h @@ -0,0 +1,49 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + Copyright (C) 1995 Spencer Kimball and Peter Mattis + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * tga.h: Handle Targa file format. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was + * originally written by id Software, Inc. + * + * Portion of this code was derived from The GIMP -- an image manipulation + * program, and was originally written by Spencer Kimball and Peter Mattis. + */ + +#ifndef __TGA_H__ +#define __TGA_H__ + +extern void LoadTGA( const char *filename, W8 **pic, W16 *width, W16 *height, W16 *bytes ); + + + +extern W8 WriteTGA( const char *filename, W16 bpp, W16 width, W16 height, + void *Data, W8 upsideDown, W8 rle ); + + +#endif /* __TGA_H__ */ + diff --git a/wolf3d/newCode/env/timer.h b/wolf3d/newCode/env/timer.h new file mode 100644 index 0000000..c9aca45 --- /dev/null +++ b/wolf3d/newCode/env/timer.h @@ -0,0 +1,44 @@ +/* + + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * timer.h: Timer. + * + * Author: Id Software, Inc. + * Date: 1997-2001 + * + */ + +/* + Notes: + This module is implemented by win_timer.c or unix_timer.c. + +*/ + +#ifndef __TIMER_H__ +#define __TIMER_H__ + +extern W32 curtime; // time returned by last Sys_Milliseconds() + +extern W32 Sys_Milliseconds( void ); + + +#endif /* __TIMER_H__ */ + diff --git a/wolf3d/newCode/env/unix_file.c b/wolf3d/newCode/env/unix_file.c new file mode 100644 index 0000000..adc34ba --- /dev/null +++ b/wolf3d/newCode/env/unix_file.c @@ -0,0 +1,286 @@ +/* + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * unix_file.c: Handles non-portable file services. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +PRIVATE char findbase[ MAX_OSPATH ]; +PRIVATE char findpath[ MAX_OSPATH ]; +PRIVATE char findpattern[ MAX_OSPATH ]; +PRIVATE DIR *fdir; + + +/* +----------------------------------------------------------------------------- + Function: FS_CreateDirectory() -Creates a new directory. + + Parameters: dirname -[in] Pointer to a NUL-terminated string that specifies + the path of the directory to be created. + + Returns: On success nonzero, otherwise zero. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W8 FS_CreateDirectory( const char *dirname ) +{ + int ret_val = mkdir( dirname, S_IRUSR | S_IWUSR | S_IXUSR ); + + if( ret_val == -1 && errno == EEXIST ) + { + return 1; + } + + return (W8)(! ret_val); +} + +/* +----------------------------------------------------------------------------- + Function: FS_ChangeCurrentDirectory() -Changes the current directory + + Parameters: path -[in] Pointer to a NUL-terminated string that specifies + the path to the new directory. + + Returns: On success nonzero, otherwise zero. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W8 FS_ChangeCurrentDirectory( const char *path ) +{ + return ! chdir( path ); +} + +/* +----------------------------------------------------------------------------- + Function: CompareAttributes() -Compare directory and file attributes. + + Parameters: path -[in] Specifies the path to compare file attributes. + musthave -[in] File or directory must have these attributes. + canthave- [in] File or directory can not have these attributes. + + Returns: On success true, otherwise false. + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean CompareAttributes( const char *path, W32 musthave, W32 canthave ) +{ + struct stat st; + + if( stat( path, &st ) == -1 ) + { + return false; + } + + if( ( st.st_mode & S_IFDIR ) && ( canthave & FA_DIR ) ) + { + return false; + } + + if( ( musthave & FA_DIR ) && !( st.st_mode & S_IFDIR ) ) + { + return false; + } + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: FS_FindFirstFile() -Searches a directory for a file. + + Parameters: path -[in] Pointer to a NUL-terminated string that specifies + a valid directory or path and file name. + musthave -[in] File or directory must have these attributes. + canthave- [in] File or directory can not have these attributes. + + Returns: On success string of file name or directory, otherwise NULL. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC char *FS_FindFirst( const char *path, W32 musthave, W32 canthave ) +{ + struct dirent *d; + char *p; + p; + + if( fdir ) + { + Com_Printf( "FS_FindFirst without close\n" ); + + return NULL; + } + + FS_FilePath( (char *)path, findbase ); + my_strlcpy( (char *)findpattern, FS_SkipPath( (char *)path ), sizeof( findpattern ) ); + + if( ! *findbase ) + { + if( (fdir = opendir( "." )) == NULL ) + { + return NULL; + } + } + else + { + if( (fdir = opendir( findbase )) == NULL ) + { + return NULL; + } + } + + while( (d = readdir( fdir )) != NULL ) + { + if( ! *findpattern || glob_match( findpattern, d->d_name ) ) + { + if( ! *findbase ) + { + my_strlcpy( findpath, d->d_name, sizeof( findpath ) ); + } + else + { + my_snprintf( findpath, sizeof( findpath ), "%s/%s", findbase, d->d_name ); + } + + if( CompareAttributes( findpath, musthave, canthave ) ) + { + return findpath; + } + } + } + + return NULL; + +} + +/* +----------------------------------------------------------------------------- + Function: FS_FindNext -Continues a file search from a previous call to + the FS_FindFirst function. + + Parameters: musthave -[in] File or directory must have these attributes. + canthave- [in] File or directory can not have these attributes. + + Returns: On success string of file name or directory, otherwise NULL. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC char *FS_FindNext( W32 musthave, W32 canthave ) +{ + struct dirent *d; + + if( fdir == NULL ) + { + return NULL; + } + + while( (d = readdir( fdir ) ) != NULL) + { + if( ! *findpattern || glob_match( findpattern, d->d_name ) ) + { + if( ! *findbase ) + { + my_strlcpy( findpath, d->d_name, sizeof( findpath ) ); + } + else + { + my_snprintf( findpath, sizeof( findpath ), "%s/%s", findbase, d->d_name ); + } + + if( CompareAttributes( findpath, musthave, canthave ) ) + { + return findpath; + } + } + } + + return NULL; +} + +/* +----------------------------------------------------------------------------- + Function: FS_FindClose() -Closes the search handle. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void FS_FindClose( void ) +{ + if( fdir ) + { + closedir( fdir ); + } + + fdir = NULL; +} + +/* +----------------------------------------------------------------------------- + Function: FS_DeleteFile() -Deletes an existing file. + + Parameters: filename -[in] Pointer to a NUL-terminated string that + specifies the file to be deleted. + + Returns: If successful the return value is nonzero, otherwise zero. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean FS_DeleteFile( const char *filename ) +{ + return( ! unlink( filename ) ); +} + +/* +----------------------------------------------------------------------------- + Function: FS_RemoveDirectory() -Deletes an existing empty directory. + + Parameters: pathname -[in] Pointer to a NUL-terminated string that + specifies the directory to be deleted. + + Returns: If successful the return value is nonzero, otherwise zero. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean FS_RemoveDirectory( const char *pathname ) +{ + return( ! rmdir( pathname ) ); +} + diff --git a/wolf3d/newCode/env/unix_timer.c b/wolf3d/newCode/env/unix_timer.c new file mode 100644 index 0000000..38b6f42 --- /dev/null +++ b/wolf3d/newCode/env/unix_timer.c @@ -0,0 +1,67 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * unix_timer.c: unix timer. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +PUBLIC W32 curtime; + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC W32 Sys_Milliseconds( void ) +{ + struct timeval tp; + struct timezone tzp; + static int secbase; + + gettimeofday( &tp, &tzp ); + + if( ! secbase ) + { + secbase = tp.tv_sec; + return tp.tv_usec / 1000; + } + + curtime = (tp.tv_sec - secbase) * 1000 + tp.tv_usec / 1000; + + return curtime; +} diff --git a/wolf3d/newCode/env/vector.c b/wolf3d/newCode/env/vector.c new file mode 100644 index 0000000..9d200b1 --- /dev/null +++ b/wolf3d/newCode/env/vector.c @@ -0,0 +1,650 @@ +/* + + Copyright (C) 2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * vector.h: 2D and 3D vector math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +vec3_t vec3_origin = { 0, 0, 0 }; + + +vec_t _VectorNormalize( vec3_t v ); + +vec_t (*pfVectorNormalize)( vec3_t v ) = _VectorNormalize; + + +/* +----------------------------------------------------------------------------- + Function: _VectorNormalize -Normalize a 3D vector. + + Parameters: v -[in] 3D vector to normalize. + + Returns: Unit vector value. + + Notes: + For a given vector, the process of finding a unit vector which is + parallel to it. This is done by dividing the given vector by its + magnitude. +----------------------------------------------------------------------------- +*/ +PUBLIC vec_t _VectorNormalize( vec3_t v ) +{ + float length, ilength; + + length = (float)pfSqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] ); + + if( length ) + { + ilength = 1 / length; + v[ 0 ] *= ilength; + v[ 1 ] *= ilength; + v[ 2 ] *= ilength; + } + + return length; +} + +/* +----------------------------------------------------------------------------- + Function: ProjectPointOnPlane -Project a point onto a plane. + + Parameters: dst -[out] Destination Point on Plane. + p -[in] Point to project onto the plane. + normal -[in] A vector to specify the orientation of the plane. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ) +{ + float d; + vec3_t n; + float inv_denom; + + inv_denom = 1.0f / DotProduct( normal, normal ); + + d = DotProduct( normal, p ) * inv_denom; + + n[ 0 ] = normal[ 0 ] * inv_denom; + n[ 1 ] = normal[ 1 ] * inv_denom; + n[ 2 ] = normal[ 2 ] * inv_denom; + + dst[ 0 ] = p[ 0 ] - d * n[ 0 ]; + dst[ 1 ] = p[ 1 ] - d * n[ 1 ]; + dst[ 2 ] = p[ 2 ] - d * n[ 2 ]; +} + +/* +----------------------------------------------------------------------------- + Function: PerpendicularVector - + + Parameters:dst -[out] Perpendicular Vector. + src -[in] Normalized vector. + + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PerpendicularVector( vec3_t dst, const vec3_t src ) +{ + int pos; + int i; + float minelem = 1.0F; + vec3_t tempvec; + + /* find the smallest magnitude axially aligned vector */ + for( pos = 0, i = 0 ; i < 3 ; ++i ) + { + if( fabs( src[ i ] ) < minelem ) + { + pos = i; + minelem = (float)fabs( src[ i ] ); + } + } + tempvec[ 0 ] = tempvec[ 1 ] = tempvec[ 2 ] = 0.0F; + tempvec[ pos ] = 1.0F; + + /* project the point onto the plane defined by src */ + ProjectPointOnPlane( dst, tempvec, src ); + + /* normalize the result */ + pfVectorNormalize( dst ); +} + +/* +----------------------------------------------------------------------------- + Function: RotatePointAroundVector -Rotate a point around a vector. + + Parameters: dst -[out] Point after rotation. + dir -[in] vector. + point -[in] Point. + degrees -[in] Degrees of rotation. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) +{ + mat3_t m; + mat3_t im; + mat3_t zrot; + mat3_t tmpmat; + mat3_t rot; + vec3_t vr, vup, vf; + float rad; + + vf[0] = dir[0]; + vf[1] = dir[1]; + vf[2] = dir[2]; + + PerpendicularVector( vr, dir ); + vectorCrossProduct( vr, vf, vup ); + + m[0] = vr[0]; + m[3] = vr[1]; + m[6] = vr[2]; + + m[1] = vup[0]; + m[4] = vup[1]; + m[7] = vup[2]; + + m[2] = vf[0]; + m[5] = vf[1]; + m[8] = vf[2]; + + memcpy( im, m, sizeof( im ) ); + + im[1] = m[3]; + im[2] = m[6]; + im[3] = m[1]; + im[5] = m[7]; + im[6] = m[2]; + im[7] = m[5]; + + memset( zrot, 0, sizeof( zrot ) ); + zrot[0] = zrot[4] = zrot[8] = 1.0F; + + rad = DEG2RAD( degrees ); + zrot[0] = (float)cos( rad ); + zrot[1] = (float)sin( rad ); + zrot[3] = (float)-sin( rad ); + zrot[4] = (float)cos( rad ); + + Matrix3x3Multiply( m, zrot, tmpmat ); + Matrix3x3Multiply( tmpmat, im, rot ); + + dst[0] = rot[0] * point[0] + rot[1] * point[1] + rot[2] * point[2]; + dst[1] = rot[3] * point[0] + rot[4] * point[1] + rot[5] * point[2]; + dst[2] = rot[6] * point[0] + rot[7] * point[1] + rot[8] * point[2]; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) +{ + int i; + vec3_t corner; + float a, b; + + for( i = 0; i < 3; ++i ) + { + a = (float)fabs( mins[i] ); + b = (float)fabs( maxs[i] ); + corner[i] = a > b ? a : b; + } + + return vectorLength( corner ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void AddPointToBounds( vec3_t v, vec3_t mins, vec3_t maxs ) +{ + if ( v[0] < mins[0] ) + { + mins[0] = v[0]; + } + if ( v[0] > maxs[0]) + { + maxs[0] = v[0]; + } + + if ( v[1] < mins[1] ) + { + mins[1] = v[1]; + } + if ( v[1] > maxs[1]) + { + maxs[1] = v[1]; + } + + if ( v[2] < mins[2] ) + { + mins[2] = v[2]; + } + if ( v[2] > maxs[2]) + { + maxs[2] = v[2]; + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up ) +{ + float angle; + static float sr, sp, sy, cr, cp, cy; + // static to help MS compiler fp bugs + + angle = angles[YAW] * ( M_PI*2 / 360 ); + sy = (float)sin( angle ); + cy = (float)cos( angle ); + angle = angles[PITCH] * ( M_PI*2 / 360 ); + sp = (float)sin( angle ); + cp = (float)cos( angle ); + angle = angles[ROLL] * ( M_PI*2 / 360 ); + sr = (float)sin( angle ); + cr = (float)cos( angle ); + + if( forward ) + { + forward[0] = cp*cy; + forward[1] = cp*sy; + forward[2] = -sp; + } + + if( right ) + { + right[0] = (-1*sr*sp*cy+-1*cr*-sy); + right[1] = (-1*sr*sp*sy+-1*cr*cy); + right[2] = -1*sr*cp; + } + + if( up ) + { + up[0] = (cr*sp*cy+-sr*-sy); + up[1] = (cr*sp*sy+-sr*cy); + up[2] = cr*cp; + } +} + +/* +----------------------------------------------------------------------------- + Function: vectorCompare -Compares two vectors for equality. + + Parameters: v1, v2 -[in] 3d vectors to compare. + + Returns: 1 if they are equal, otherwise 0. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL int vectorCompare( const vec3_t v1, const vec3_t v2 ) +{ + if( v1[ 0 ] != v2[ 0 ] || + v1[ 1 ] != v2[ 1 ] || + v1[ 2 ] != v2[ 2 ] ) + { + return 0; + } + + return 1; +} + +/* +----------------------------------------------------------------------------- + Function: vectorLength -Get the length of a vector. + + Parameters: v -[in] 3D vector to get the length of. + + Returns: The length of the vector. + + Notes: + Since the square of length is a sum of squares, and squares + (of real numbers) are always positive, length is always positive. + The only time the length of a 3D vector is zero is when the vector + is the zero vector. +----------------------------------------------------------------------------- +*/ +INLINECALL vec_t vectorLength( const vec3_t v ) +{ + return (vec_t)pfSqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] ); +} + +/* +----------------------------------------------------------------------------- + Function: CrossProduct -Calulates the cross product of two vectors. + + Parameters: v1, v2 -[in] 3D vectors. + cross -[out] The vector cross product. + + Returns: Nothing + + Notes: + The vector cross product takes two vector operands to produce a + vector result. The result, like all geometric vectors, has two + properties: length and orientation. + + To find a vector perpendicular to a particular plane, compute the + cross product of two vectors in that plane. But there are two + directions perpendicular to the plane. Which one does the cross + product give you? That is determined by the right hand rule. + + The cross product of two vectors is perpendicular to both; the right + hand rule picks the one out of two possible perpendicular directions. + + Computing Cross Product from Column Matrices: + u × v = ( uj vk - uk vj , uk vi - ui vk , ui vj - uj vi )T +----------------------------------------------------------------------------- +*/ +PUBLIC void vectorCrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) +{ + cross[ 0 ] = v1[ 1 ] * v2[ 2 ] - v1[ 2 ] * v2[ 1 ]; // X + cross[ 1 ] = v1[ 2 ] * v2[ 0 ] - v1[ 0 ] * v2[ 2 ]; // Y + cross[ 2 ] = v1[ 0 ] * v2[ 1 ] - v1[ 1 ] * v2[ 0 ]; // Z +} + + +#if defined(__i386__) && defined(_MSC_VER) + +// Taken from an article written by Michael Abrash that originally appeared in +// Dr. Dobb's Journal. +PUBLIC void vectorCrossProduct_asm( const vec3_t v1, const vec3_t v2, vec3_t cross ) +{ + __asm + { + mov eax, cross + mov ecx, v2 + mov edx, v1 + + ;optimized cross product; 22 cycles + fld dword ptr [ecx+4] ;starts & ends on cycle 0 + fmul dword ptr [edx+8] ;starts on cycle 1 + fld dword ptr [ecx+8] ;starts & ends on cycle 2 + fmul dword ptr [edx+0] ;starts on cycle 3 + fld dword ptr [ecx+0] ;starts & ends on cycle 4 + fmul dword ptr [edx+4] ;starts on cycle 5 + fld dword ptr [ecx+8] ;starts & ends on cycle 6 + fmul dword ptr [edx+4] ;starts on cycle 7 + fld dword ptr [ecx+0] ;starts & ends on cycle 8 + fmul dword ptr [edx+8] ;starts on cycle 9 + fld dword ptr [ecx+4] ;starts & ends on cycle 10 + fmul dword ptr [edx+0] ;starts on cycle 11 + fxch st(2) ;no cost + fsubrp st(5),st(0) ;starts on cycle 12 + fsubrp st(3),st(0) ;starts on cycle 13 + fsubrp st(1),st(0) ;starts on cycle 14 + fxch st(2) ;no cost, stalls for cycle 15 + fstp dword ptr [eax+0] ;starts on cycle 16, ends on cycle 17 + fstp dword ptr [eax+4] ;starts on cycle 18, ends on cycle 19 + fstp dword ptr [eax+8] ;starts on cycle 20, ends on cycle 21 + } +} + +#endif /* __i386__ */ + + + +/* +----------------------------------------------------------------------------- + Function: _DotProduct -Calculates the dot product. + + Parameters: v1, v2 -[in] 3D vectors to compute dot product. + + Returns: the dot product + + Notes: + Dot product, which takes two vectors as operands and produces a real + number as its output. Sometimes the dot product is called the inner + product or the scalar product. + The dot product is: + a · b = a1b1 + a2b2 + a3b3 +----------------------------------------------------------------------------- +*/ +PUBLIC vec_t _vectorDotProduct( const vec3_t v1, const vec3_t v2 ) +{ + return v1[ 0 ] * v2[ 0 ] + v1[ 1 ] * v2[ 1 ] + v1[ 2 ] * v2[ 2 ]; +} + + +#if defined(__i386__) && defined(_MSC_VER) + +// Taken from an article written by Michael Abrash that originally appeared in +// Dr. Dobb's Journal. +PUBLIC vec_t _vectorDotProduct_asm( const vec3_t v1, const vec3_t v2 ) +{ + float dotret; + + __asm + { + mov eax, v2 + mov ecx, v1 + + ;optimized dot product; 15 cycles + fld dword ptr [eax+0] ;starts & ends on cycle 0 + fmul dword ptr [ecx+0] ;starts on cycle 1 + fld dword ptr [eax+4] ;starts & ends on cycle 2 + fmul dword ptr [ecx+4] ;starts on cycle 3 + fld dword ptr [eax+8] ;starts & ends on cycle 4 + fmul dword ptr [ecx+8] ;starts on cycle 5 + fxch st(1) ;no cost + faddp st(2),st(0) ;starts on cycle 6, stalls for cycles 7-8 + faddp st(1),st(0) ;starts on cycle 9, stalls for cycles 10-12 + fstp dword ptr [dotret] ;starts on cycle 13, ends on cycle 14 + } + + return dotret; +} + +#endif /* __i386__ */ + + + +/* +----------------------------------------------------------------------------- + Function: _vectorSubtract -Vector Difference. + + Parameters: veca, vecb -[in] 3D vectors. + out -[out] The vector difference of vectors A and B. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL void _vectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ) +{ + out[ 0 ] = veca[ 0 ] - vecb[ 0 ]; + out[ 1 ] = veca[ 1 ] - vecb[ 1 ]; + out[ 2 ] = veca[ 2 ] - vecb[ 2 ]; +} + +/* +----------------------------------------------------------------------------- + Function: _vectorAdd -Vector addition. + + Parameters: veca, vecb -[in] 3D vectors. + out -[out] The vector sum of vectors A and B + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL void _vectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ) +{ + out[ 0 ] = veca[ 0 ] + vecb[ 0 ]; + out[ 1 ] = veca[ 1 ] + vecb[ 1 ]; + out[ 2 ] = veca[ 2 ] + vecb[ 2 ]; +} + +/* +----------------------------------------------------------------------------- + Function: _vectorCopy -Copy a vector. + + Parameters: in -[in] Source vector. + out -[out] Destination vector. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL void _vectorCopy( const vec3_t in, vec3_t out ) +{ + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = in[ 2 ]; +} + +/* +----------------------------------------------------------------------------- + Function: _vectorScale -Scale a vector. + + Parameters: in -[in] Source vector. + scale -[in] Scale vector. + out -[out] Destination vector. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL void _vectorScale( const vec3_t in, const vec_t scale, vec3_t out ) +{ + out[ 0 ] = in[ 0 ] * scale; + out[ 1 ] = in[ 1 ] * scale; + out[ 2 ] = in[ 2 ] * scale; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL void _vectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ) +{ + vecc[ 0 ] = veca[ 0 ] + scale * vecb[ 0 ]; + vecc[ 1 ] = veca[ 1 ] + scale * vecb[ 1 ]; + vecc[ 2 ] = veca[ 2 ] + scale * vecb[ 2 ]; +} + + + + + + +///////////////////////////////////////////////////////////////////// +// +// 2D Vector routines +// +///////////////////////////////////////////////////////////////////// + + +/* +----------------------------------------------------------------------------- + Function: vector2DCompare -Compares two vectors for equality. + + Parameters: v1, v2 -[in] 2d vectors to compare. + + Returns: 1 if they are equal, otherwise 0. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL W32 vector2DCompare( const vec2_t v1, const vec2_t v2 ) +{ + if( v1[ 0 ] != v2[ 0 ] || v1[ 1 ] != v2[ 1 ] ) + { + return 0; + } + + return 1; +} + +/* +----------------------------------------------------------------------------- + Function: vector2DLength -Get the length of a vector. + + Parameters: v -[in] 2D vector to get the length of. + + Returns: The length of the vector. + + Notes: +----------------------------------------------------------------------------- +*/ +INLINECALL vec_t vector2DLength( const vec2_t v ) +{ + return (vec_t)pfSqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] ); +} + + + diff --git a/wolf3d/newCode/env/vector.h b/wolf3d/newCode/env/vector.h new file mode 100644 index 0000000..c2ef60c --- /dev/null +++ b/wolf3d/newCode/env/vector.h @@ -0,0 +1,125 @@ +/* + + Copyright (C) 2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * vector.h: 2D and 3D vector math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __VECTOR_H__ +#define __VECTOR_H__ + +typedef float vec_t; +typedef vec_t vec2_t[ 2 ]; +typedef vec_t vec3_t[ 3 ]; +typedef vec_t vec4_t[ 4 ]; +typedef vec_t vec5_t[ 5 ]; + + + +extern vec3_t vec3_origin; + + +///////////////////////////////////////////////////////////////////// +// +// 3D Vector routines +// +///////////////////////////////////////////////////////////////////// + +#define vectorClear( a ) ( (a)[ 0 ] = (a)[ 1 ] = (a)[ 2 ] = 0 ) +#define vectorNegate( a, b ) ( (b)[ 0 ] = (-a)[ 0 ], (b)[ 1 ] = (-a)[ 1 ], (b)[ 2 ] = (-a)[ 2 ] ) +#define vectorSet( v, x, y, z ) ( (v)[ 0 ] = ( x ), (v)[ 1 ] = ( y ), (v)[ 2 ] = ( z ) ) +#define vectorInverse( a ) ( (a)[ 0 ] = (-a)[ 0 ], (a)[ 1 ] = (-a)[ 1 ], (a)[ 2 ] = (-a)[ 2 ] ) + +#if 1 + + #define DotProduct( x, y ) ( (x)[ 0 ] * (y)[ 0 ] + (x)[ 1 ] * (y)[ 1 ] + (x)[ 2 ] * (y)[ 2 ] ) + #define vectorSubtract( a, b, c ) ( (c)[ 0 ] = (a)[ 0 ] - (b)[ 0 ], (c)[ 1 ] = (a)[ 1 ] - (b)[ 1 ], (c)[ 2 ] = (a)[ 2 ] - (b)[ 2 ] ) + #define vectorAdd( a, b, c ) ( (c)[ 0 ] = (a)[ 0 ] + (b)[ 0 ], (c)[ 1 ] = (a)[ 1 ] + (b)[ 1 ], (c)[ 2 ] = (a)[ 2 ] + (b)[ 2 ] ) + #define vectorCopy( a, b ) ( (b)[ 0 ] = (a)[ 0 ], (b)[ 1 ] = (a)[ 1 ], (b)[ 2 ] = (a)[ 2 ] ) + #define vectorScale( v, s, o ) ( (o)[ 0 ] = (v)[ 0 ] * (s),(o)[ 1 ] = (v)[ 1 ] * (s), (o)[ 2 ] = (v)[ 2 ] * (s) ) + #define vectorMA( v, s, b, o ) ( (o)[ 0 ] = (v)[ 0 ] + (b)[ 0 ]*(s),(o)[ 1 ] = (v)[ 1 ] + (b)[ 1 ] * (s),(o)[ 2 ] = (v)[ 2 ] + (b)[ 2 ] * (s) ) + +#else + + /* just in case you don't want to use the macros */ + #define DotProduct( x, y ) _vectorDotProduct( x, y ) + #define vectorSubtract( a, b, c ) _vectorSubtract( a, b, c ) + #define vectorAdd( a, b, c ) _vectorAdd( a, b, c ) + #define vectorCopy( a, b ) _vectorCopy( a, b ) + #define vectorScale( v, s, o ) _vectorScale( v, s, o ) + #define vectorMA( v, s, b, o ) _vectorMA( v, s, b, o ) + +#endif + + +extern void vectorCrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ); + + +extern int vectorCompare( const vec3_t v1, const vec3_t v2 ); +extern vec_t vectorLength( const vec3_t v ); +extern vec_t (*pfVectorNormalize)( vec3_t vec ); + +extern void angleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up ); + + +extern void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); +extern void PerpendicularVector( vec3_t dst, const vec3_t src ); +extern void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); + + +extern void AddPointToBounds( vec3_t v, vec3_t mins, vec3_t maxs ); +extern float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); + + + +///////////////////////////////////////////////////////////////////// +// +// 2D Vector routines +// +///////////////////////////////////////////////////////////////////// + +#define vector2DClear( a ) ( (a)[ 0 ] = (a)[ 1 ] = 0 ) +#define vector2DNegate( a, b ) ( (b)[ 0 ] = (-a)[ 0 ], (b)[ 1 ] = (-a)[ 1 ] ) +#define vector2DSet( v, x, y ) ( (v)[ 0 ] = ( x ), (v)[ 1 ] = ( y ) ) +#define vector2DInverse( a ) ( (a)[ 0 ] = (-a)[ 0 ], (a)[ 1 ] = (-a)[ 1 ] ) + +#define vector2DPerpDot( a, b ) ( (a)[ 0 ] * (b)[ 1 ] - (a)[ 1 ] * (b)[ 0 ] ) +#define vector2DDotProduct( x, y ) ( (x)[ 0 ] * (y)[ 0 ] + (x)[ 1 ] * (y)[ 1 ] ) +#define vector2DSubtract( a, b, c ) ( (c)[ 0 ] = (a)[ 0 ] - (b)[ 0 ], (c)[ 1 ] = (a)[ 1 ] - (b)[ 1 ] ) +#define vector2DAdd( a, b, c ) ( (c)[ 0 ] = (a)[ 0 ] + (b)[ 0 ], (c)[ 1 ] = (a)[ 1 ] + (b)[ 1 ] ) +#define vector2DCopy( a, b ) ( (b)[ 0 ] = (a)[ 0 ], (b)[ 1 ] = (a)[ 1 ] ) +#define vector2DScale( v, s, o ) ( (o)[ 0 ] = (v)[ 0 ] * (s), (o)[ 1 ] = (v)[ 1 ] * (s) ) +#define vector2DMA( v, s, b, o ) ( (o)[ 0 ] = (v)[ 0 ] + (b)[ 0 ]*(s), (o)[ 1 ] = (v)[ 1 ] + (b)[ 1 ] * (s) ) + + +extern W32 vector2DCompare( const vec2_t v1, const vec2_t v2 ); +extern vec_t vector2DLength( const vec2_t v ); + + +#endif /* __VECTOR_H__ */ + diff --git a/wolf3d/newCode/env/video.h b/wolf3d/newCode/env/video.h new file mode 100644 index 0000000..8d12592 --- /dev/null +++ b/wolf3d/newCode/env/video.h @@ -0,0 +1,68 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * video.h -- video driver defs. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by vid_sys.c. + +*/ + + + +#ifndef __VIDEO_H__ +#define __VIDEO_H__ + +typedef struct vrect_s +{ + int x, y, width, height; + +} vrect_t; + +typedef struct +{ + unsigned width, height; // coordinates from main game +} viddef_t; + +extern viddef_t viddef; // global video state + +// Video module initialisation etc +extern void Video_Init( void ); +extern void Video_Shutdown( void ); +extern void Video_CheckChanges( void ); + + +extern void VID_NewWindow ( int width, int height ); +extern _boolean VID_GetModeInfo( int *width, int *height, int mode ); + + +#endif /* __VIDEO_H__ */ diff --git a/wolf3d/newCode/env/wavfile.c b/wolf3d/newCode/env/wavfile.c new file mode 100644 index 0000000..47e89ea --- /dev/null +++ b/wolf3d/newCode/env/wavfile.c @@ -0,0 +1,241 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wav.c: Wav file loader. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +PRIVATE W8 *iff_pdata; +PRIVATE W8 *iff_end; +PRIVATE W8 *iff_last_chunk; +PRIVATE W8 *iff_data; +PRIVATE int iff_chunk_len; + + + +PRIVATE short Wav_GetLittleShort( void ) +{ + short val = 0; + + val = *iff_pdata; + val += (*(iff_pdata + 1) << 8); + + iff_pdata += 2; + + return val; +} + + +PRIVATE int Wav_GetLittleLong( void ) +{ + int val = 0; + + val = *iff_pdata; + val += (*(iff_pdata + 1) << 8); + val += (*(iff_pdata + 2) << 16); + val += (*(iff_pdata + 3) << 24); + + iff_pdata += 4; + + return val; +} + + +PRIVATE void Wav_FindNextChunk( const char *name ) +{ + while( 1 ) + { + iff_pdata = iff_last_chunk; + + if( iff_pdata >= iff_end ) + { + // Didn't find the chunk + iff_pdata = NULL; + return; + } + + iff_pdata += 4; + iff_chunk_len = Wav_GetLittleLong(); + if( iff_chunk_len < 0 ) + { + iff_pdata = NULL; + return; + } + + iff_pdata -= 8; + iff_last_chunk = iff_pdata + 8 + ((iff_chunk_len + 1) & ~1); + if( ! my_strnicmp((const char *)iff_pdata, name, 4) ) + { + return; + } + } +} + + +PRIVATE void Wav_FindChunk( const char *name ) +{ + iff_last_chunk = iff_data; + + Wav_FindNextChunk( name ); +} + +PRIVATE void DumpChunks( void ) +{ + char str[ 5 ]; + + str[ 4 ] = 0; + iff_pdata = iff_data; + do + { + memcpy( str, iff_pdata, 4 ); + iff_pdata += 4; + iff_chunk_len = Wav_GetLittleLong(); + Com_Printf( "0x%x : %s (%d)\n", (int)(iff_pdata - 4), str, iff_chunk_len ); + iff_pdata += (iff_chunk_len + 1) & ~1; + + } while( iff_pdata < iff_end ); + +} + + +/* +----------------------------------------------------------------------------- + Function: LoadWavInfo -Load wav file. + + Parameters: filename -[in] Name of wav file to load. + wav -[out] wav data. + info -[out] wav sound info. + + Returns: True if file loaded, otherwise false. + + Notes: Caller is responsible for freeing wav data by calling Z_Free. + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean LoadWavInfo( const char *filename, W8 **wav, soundInfo_t *info ) +{ + filehandle_t *hFile; + W8 *data; + W32 wavlength; + + hFile = FS_OpenFile( filename, 0 ); + if( ! hFile ) + { + return false; + } + + data = (PW8)FS_GetLoadedFilePointer( hFile, SEEK_SET ); + wavlength = FS_GetFileSize( hFile ); + + iff_data = data; + iff_end = data + wavlength; + + // look for RIFF signature + Wav_FindChunk( "RIFF" ); + if( ! (iff_pdata && ! my_strnicmp( (const char *)iff_pdata + 8, "WAVE", 4 ) ) ) + { + Com_DPrintf( "[LoadWavInfo]: Missing RIFF/WAVE chunks (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + // Get "fmt " chunk + iff_data = iff_pdata + 12; + + Wav_FindChunk( "fmt " ); + if( ! iff_pdata ) + { + Com_DPrintf( "[LoadWavInfo]: Missing fmt chunk (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + iff_pdata += 8; + + if( Wav_GetLittleShort() != 1 ) + { + Com_DPrintf( "[LoadWavInfo]: Microsoft PCM format only (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + info->channels = Wav_GetLittleShort(); + info->sample_rate = Wav_GetLittleLong(); + + iff_pdata += 4; + + info->sample_size = Wav_GetLittleShort(); // Bytes Per Sample + + if (info->sample_size != 1 && info->sample_size != 2) + { + Com_DPrintf( "[LoadWavInfo]: only 8 and 16 bit WAV files supported (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + iff_pdata += 2; + + + // Find data chunk + Wav_FindChunk( "data" ); + if( ! iff_pdata ) + { + Com_DPrintf( "[LoadWavInfo]: missing 'data' chunk (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + iff_pdata += 4; + info->samples = Wav_GetLittleLong() / info->sample_size; + + if( info->samples <= 0 ) + { + Com_DPrintf( "[LoadWavInfo]: file with 0 samples (%s)\n", filename ); + FS_CloseFile( hFile ); + + return false; + } + + // Load the data + *wav = Z_Malloc( info->samples * info->sample_size ); + memcpy( *wav, data + (iff_pdata - data), info->samples * info->sample_size ); + + FS_CloseFile( hFile ); + + return true; +} + diff --git a/wolf3d/newCode/env/wavfile.h b/wolf3d/newCode/env/wavfile.h new file mode 100644 index 0000000..c06ec21 --- /dev/null +++ b/wolf3d/newCode/env/wavfile.h @@ -0,0 +1,54 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wav.h: Wav file loader. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#ifndef __WAV_H__ +#define __WAV_H__ + + +// Structure used to describe a sound. +typedef struct +{ + W32 sample_rate; // Sample rate in Hz + W32 channels; // Number of Channels (0x01 = Mono, 0x02 = Stereo) + W32 sample_size; // Bytes per sample + // 1 = 8 bit Mono + // 2 = 8 bit Stereo or 16 bit Mono + // 4 = 16 bit Stereo + W32 samples; + +} soundInfo_t; + + +extern _boolean LoadWavInfo( const char *filename, W8 **wav, soundInfo_t *info ); + +#endif /* __WAV_H__ */ diff --git a/wolf3d/newCode/env/zmem.c b/wolf3d/newCode/env/zmem.c new file mode 100644 index 0000000..872d594 --- /dev/null +++ b/wolf3d/newCode/env/zmem.c @@ -0,0 +1,191 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * zmem.c: Zone memory management. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + + Add the following line in your initization function: + z_chain.next = z_chain.prev = &z_chain; + +*/ + +#include "../wolfiphone.h" + + +// just cleared malloc with counters now... + + +#define Z_MAGIC 0x1d1d + + +PRIVATE int z_count, z_bytes; + +zhead_t z_chain; + + + +/* +----------------------------------------------------------------------------- + Function: Z_Free -Deallocates or frees a zone memory block. + + Parameters: memblock -[in] Previously allocated zone memory block to be freed. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Z_Free( void *memblock ) +{ + zhead_t *z; + + z = ( (zhead_t *)memblock ) - 1; + + if( z->magic != Z_MAGIC ) + { + Com_Error( ERR_FATAL, "Z_Free: bad magic" ); + } + + z->prev->next = z->next; + z->next->prev = z->prev; + + z_count--; + z_bytes -= z->size; + + MM_FREE( z ); +} + +/* +----------------------------------------------------------------------------- + Function: Z_Stats_f -Console function to list zone memory usage. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: Lists number of bytes and blocks of zone memory allocated. +----------------------------------------------------------------------------- +*/ +PUBLIC void Z_Stats_f( void ) +{ + Com_Printf( "%i bytes in %i blocks\n", z_bytes, z_count ); +} + + +/* +----------------------------------------------------------------------------- + Function: Z_FreeTags -Free allocated zone memory blocks based on tag. + + Parameters: tag -[in] Tag of zone memory blocks to free (see header for tag). + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Z_FreeTags( int tag ) +{ + zhead_t *z, *next; + + for( z = z_chain.next; z != &z_chain; z = next ) + { + next = z->next; + if( z->tag == tag ) + { + Z_Free( (void *)(z+1) ); + } + } +} + +/* +----------------------------------------------------------------------------- + Function: Z_TagMalloc -Allocates zone memory blocks. + + Parameters: + size -[in] Bytes to allocate. + tag -[in] Tag to associate with memory (see header for tag). + + Returns: + A void pointer to the allocated space, or will shutdown application + if there is insufficient memory available. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void *Z_TagMalloc( size_t size, int tag ) +{ + zhead_t *z; + + // Allocate memory + size += sizeof( zhead_t ); + z = MM_MALLOC( size ); + + + if( ! z ) + { + Com_Error( ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes", size ); + } + + // Set memory block to zero and fill in header. + memset( z, 0, size ); + z_count++; + z_bytes += size; + z->magic = Z_MAGIC; + z->tag = tag; + z->size = size; + + // Add new memory block to chain. + z->next = z_chain.next; + z->prev = &z_chain; + z_chain.next->prev = z; + z_chain.next = z; + + return (void *)(z+1); +} + +/* +----------------------------------------------------------------------------- + Function: Z_Malloc -Allocates zone memory blocks. + + Parameters: size -[in] Bytes to allocate. + + Returns: + A void pointer to the allocated space, or will shutdown application + if there is insufficient memory available. + + Notes: Calls Z_TagMalloc() with tag set to zero. +----------------------------------------------------------------------------- +*/ +PUBLIC void *Z_Malloc( size_t size ) +{ + return Z_TagMalloc( size, 0 ); +} diff --git a/wolf3d/newCode/env/zmem.h b/wolf3d/newCode/env/zmem.h new file mode 100644 index 0000000..855fc89 --- /dev/null +++ b/wolf3d/newCode/env/zmem.h @@ -0,0 +1,75 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * zmem.h: Zone memory management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by zmem.c + +*/ + +#ifndef __ZMEM_H__ +#define __ZMEM_H__ + +#include + +// memory tags to allow dynamic memory to be cleaned up +#define TAG_GAME 765 /* clear when unloading the dll */ +#define TAG_LEVEL 766 /* clear when loading a new level */ +#define TAG_LEVEL_SCP 767 /* clear when unloading level script */ + + + +typedef struct zhead_s +{ + struct zhead_s *prev, *next; + + short magic; + short tag; // for group free + int size; + +} zhead_t; + +extern zhead_t z_chain; + + +// Returns 0 filled memory block +extern void *Z_Malloc( size_t size ); + +extern void *Z_TagMalloc( size_t size, int tag ); +extern void Z_Free( void *memblock ); +extern void Z_FreeTags( int tag ); + +extern void Z_Stats_f( void ); + + +#endif /* __ZMEM_H__ */ diff --git a/wolf3d/newCode/iphone/.DS_Store b/wolf3d/newCode/iphone/.DS_Store new file mode 100644 index 0000000..219174a Binary files /dev/null and b/wolf3d/newCode/iphone/.DS_Store differ diff --git a/wolf3d/newCode/iphone/EAGLView.h b/wolf3d/newCode/iphone/EAGLView.h new file mode 100644 index 0000000..80e8881 --- /dev/null +++ b/wolf3d/newCode/iphone/EAGLView.h @@ -0,0 +1,58 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + + +#import +#import +#import +#import + +/* +This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. +The view content is basically an EAGL surface you render your OpenGL scene into. +Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. +*/ +@interface EAGLView : UIView { +@public + UITextField *textField; + +@private + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + + NSTimer *animationTimer; + NSTimeInterval animationInterval; + +} + +@property NSTimeInterval animationInterval; + +- (void)drawView; + +@end diff --git a/wolf3d/newCode/iphone/EAGLView.m b/wolf3d/newCode/iphone/EAGLView.m new file mode 100644 index 0000000..34a41f4 --- /dev/null +++ b/wolf3d/newCode/iphone/EAGLView.m @@ -0,0 +1,293 @@ +// +// EAGLView.m +// wolf3d +// +// Created by Cass Everitt on 2/20/09. +// Copyright Id Software 2009. All rights reserved. +// + + + +#import +#import + +#import "EAGLView.h" +#import "wolf3dAppDelegate.h" + +#include "wolfiphone.h" + +EAGLView *eaglview; + +// A class extension to declare private methods +@interface EAGLView () + +@property (nonatomic, retain) EAGLContext *context; +@property (nonatomic, assign) NSTimer *animationTimer; + +- (void) destroyFramebuffer; +- (void) swapBuffers; + +@end + + +@implementation EAGLView + +@synthesize context; +@synthesize animationTimer; +@synthesize animationInterval; + + +// You must implement this method ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + + +//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: +- (id)initWithCoder:(NSCoder*)coder { + self = [super initWithCoder:coder]; + + eaglview = self; + + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + + [NSNumber numberWithBool:NO], + kEAGLDrawablePropertyRetainedBacking, + + kEAGLColorFormatRGB565, + /* kEAGLColorFormatRGBA8, */ + kEAGLDrawablePropertyColorFormat, + + nil]; + + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + assert( context ); + + if ( ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; + } + self.multipleTouchEnabled = true; + + [EAGLContext setCurrentContext:context]; + + glGenFramebuffersOES(1, &viewFramebuffer); + glGenRenderbuffersOES(1, &viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + glGenRenderbuffersOES(1, &depthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + + if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + } + + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.032 + target:self + selector:@selector(drawView) + userInfo:nil repeats:YES]; + return self; +} + +- (void)drawView { + int start, end; + + [EAGLContext setCurrentContext:context]; + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + + [ (wolf3dAppDelegate *)[UIApplication sharedApplication].delegate restartAccelerometerIfNeeded]; + + start = Sys_Milliseconds(); + + extern void iphoneFrame(); + iphoneFrame(); + + end = Sys_Milliseconds(); +// Com_Printf( "msec: %i\n", end - start ); + + [self swapBuffers]; +} + +void GLimp_EndFrame() { + [eaglview swapBuffers]; +} + +- (void)swapBuffers { + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; +} + +- (void)layoutSubviews { + [self drawView]; +} + + + +- (void)destroyFramebuffer { + + glDeleteFramebuffersOES(1, &viewFramebuffer); + viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + viewRenderbuffer = 0; + glDeleteRenderbuffersOES(1, &depthRenderbuffer); + depthRenderbuffer = 0; +} + + +- (void)dealloc { + if ([EAGLContext currentContext] == context) { + [EAGLContext setCurrentContext:nil]; + } + + [context release]; + [super dealloc]; +} + +void WolfensteinTouches( int numTouches, int touches[16] ); + +- (void) handleTouches:(NSSet*)touches withEvent:(UIEvent*)event { + int touchCount = 0; + int points[16]; + static int previousTouchCount; + + NSSet *t = [event allTouches]; + for (UITouch *myTouch in t) + { + CGPoint touchLocation = [myTouch locationInView:nil]; + + points[ 2 * touchCount + 0 ] = touchLocation.x; + points[ 2 * touchCount + 1 ] = touchLocation.y; // ( h - 1 ) - touchLocation.y; + + touchCount++; + + if (myTouch.phase == UITouchPhaseBegan) { + // new touch handler + } + if (myTouch.phase == UITouchPhaseMoved) { + // touch moved handler + } + if (myTouch.phase == UITouchPhaseEnded) { + touchCount--; + } + } + + // toggle the console with four touches + if ( touchCount == 4 && previousTouchCount != 4 ) { + if ( textField == nil ) { + void iphoneActivateConsole(); + textField = [UITextField alloc]; + [textField initWithFrame:CGRectMake( 0, 0, 20, 20 ) ]; + [self addSubview:textField]; + [textField release]; + textField.hidden = true; + textField.delegate = self; + textField.autocapitalizationType = UITextAutocapitalizationTypeNone; + textField.autocorrectionType = UITextAutocorrectionTypeNo; + [textField becomeFirstResponder]; + + iphoneActivateConsole(); + } else { + void iphoneDeactivateConsole(); + [textField resignFirstResponder]; + [textField removeFromSuperview]; + textField = nil; + + iphoneDeactivateConsole(); + } + } + previousTouchCount = touchCount; + + WolfensteinTouches( touchCount, points ); +} + + +- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { + [self handleTouches:touches withEvent:event]; +} + +- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { + [self handleTouches:touches withEvent:event]; +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { + [self handleTouches:touches withEvent:event]; +} + + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + [self handleTouches:touches withEvent:event]; +} + + + +@end + + +@implementation EAGLView (UITextFieldDelegate) + +- (BOOL)textFieldShouldReturn:(UITextField *)_textField +{ + void iphoneExecuteCommandLine(); + iphoneExecuteCommandLine(); + return YES; +} + +@end + +const char * GetCurrentCommandLine() { + assert( eaglview->textField != nil ); + return [ eaglview->textField.text UTF8String ]; +} + +void SetCurrentCommandLine( const char * str) { + assert( eaglview->textField != nil ); + eaglview->textField.text = [ NSString stringWithUTF8String: str ]; +} + +void OpenURL( const char *url ) { + Com_Printf( "OpenURL char *: %s\n", url ); + + NSString *nss = [NSString stringWithCString: url encoding: NSASCIIStringEncoding]; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString: nss]]; +} + + +void iPhoneLoadJPG( W8* jpegData, int jpegBytes, W8 **pic, W16 *width, W16 *height, W16 *bytes ) { + CFDataRef data; + int dataBytes = 0; + UIImage *img = [ UIImage imageWithData: [NSData dataWithBytes: (const char *)jpegData length: (NSUInteger)jpegBytes ] ]; + int imgBytes; + *width = img.size.width; + *height = img.size.height; + imgBytes = (int)(*width) * (int)(*height) * 4; + data = CGDataProviderCopyData( CGImageGetDataProvider( img.CGImage ) ); + dataBytes = CFDataGetLength( data ); + *bytes = 4; + if ( dataBytes > imgBytes ) { + *pic = NULL; + return; + } + *pic = (W8 *)malloc( imgBytes ); + CFDataGetBytes( data, CFRangeMake(0, dataBytes), *pic ); + // convert BGRA to RGBA + for ( imgBytes = 0; imgBytes < dataBytes; imgBytes+= 4 ) { + W8 tmp = pic[0][ imgBytes + 0 ]; + pic[0][ imgBytes + 0 ] = pic[0][ imgBytes + 2 ]; + pic[0][ imgBytes + 2 ] = tmp; + } +} + diff --git a/wolf3d/newCode/iphone/Info.plist b/wolf3d/newCode/iphone/Info.plist new file mode 100644 index 0000000..75d10f1 --- /dev/null +++ b/wolf3d/newCode/iphone/Info.plist @@ -0,0 +1,36 @@ + + + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + ${PRODUCT_NAME}_icon.png + CFBundleIdentifier + com.idsoftware.${PRODUCT_NAME:identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UIInterfaceOrientation + UIInterfaceOrientationLandscapeLeft + UIStatusBarHidden + + + diff --git a/wolf3d/newCode/iphone/MainWindow.xib b/wolf3d/newCode/iphone/MainWindow.xib new file mode 100644 index 0000000..fc76dc5 --- /dev/null +++ b/wolf3d/newCode/iphone/MainWindow.xib @@ -0,0 +1,223 @@ + + + + 528 + 9E17 + 672 + 949.33 + 352.00 + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + IBFilesOwner + + + IBFirstResponder + + + + + 1316 + + YES + + + 1298 + {320, 480} + + + 3 + MQA + + 2 + + + NO + + + + {320, 480} + + + 1 + MSAxIDEAA + + NO + YES + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 5 + + + + glView + + + + 9 + + + + + YES + + 0 + + YES + + + + + + 2 + + + YES + + + + + + -1 + + + RmlsZSdzIE93bmVyA + + + 3 + + + + + 8 + + + + + -2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + 8.CustomClassName + 8.IBPluginDependency + + + YES + UIApplication + UIResponder + + YES + + YES + + + YES + + + {{500, 343}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + wolf3dAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + EAGLView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 9 + + + + YES + + EAGLView + UIView + + IBProjectSource + Classes/EAGLView.h + + + + wolf3dAppDelegate + NSObject + + YES + + YES + glView + window + + + YES + EAGLView + UIWindow + + + + IBProjectSource + Classes/wolf3dAppDelegate.h + + + + + 0 + wolf3d.xcodeproj + 3 + + diff --git a/wolf3d/newCode/iphone/default.png b/wolf3d/newCode/iphone/default.png new file mode 100644 index 0000000..ed576c0 Binary files /dev/null and b/wolf3d/newCode/iphone/default.png differ diff --git a/wolf3d/newCode/iphone/dist.plist b/wolf3d/newCode/iphone/dist.plist new file mode 100644 index 0000000..ce373e1 --- /dev/null +++ b/wolf3d/newCode/iphone/dist.plist @@ -0,0 +1,8 @@ + + + + + get-task-allow + + + diff --git a/wolf3d/newCode/iphone/gles_glue.c b/wolf3d/newCode/iphone/gles_glue.c new file mode 100644 index 0000000..08ac8f7 --- /dev/null +++ b/wolf3d/newCode/iphone/gles_glue.c @@ -0,0 +1,134 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + + +#include "wolfiphone.h" + +//int registration_sequence; + +#include "iphone_qgl.h" + + +#ifdef QGL_LOG_GL_CALLS +unsigned int QGLLogGLCalls = 1; +FILE *QGLDebugFile(void) { + return stdout; +} +#endif + +void QGLCheckError(const char *message) { + GLint err = qglGetError(); + if ( err != GL_NO_ERROR ) { + printf( "GL ERROR %d from %s\n", err, message ); + } +} + +unsigned int QGLBeginStarted = 0; + + + + +struct Vertex { + float xyz[3]; + float st[2]; + GLubyte c[4]; +}; + +#define MAX_VERTS 16384 + +typedef struct Vertex Vertex; +Vertex immediate[ MAX_VERTS ]; +Vertex vab; +short quad_indexes[MAX_VERTS * 3 / 2 ]; +int curr_vertex; +GLenum curr_prim; + +void InitImmediateModeGL() { + for ( int i = 0; i < MAX_VERTS * 3 / 2; i+=6 ) { + int q = i / 6 * 4; + quad_indexes[ i + 0 ] = q + 0; + quad_indexes[ i + 1 ] = q + 1; + quad_indexes[ i + 2 ] = q + 2; + + quad_indexes[ i + 3 ] = q + 0; + quad_indexes[ i + 4 ] = q + 2; + quad_indexes[ i + 5 ] = q + 3; + } + + qglVertexPointer( 3, GL_FLOAT, sizeof( Vertex ), immediate[ 0 ].xyz ); + qglTexCoordPointer( 2, GL_FLOAT, sizeof( Vertex ), immediate[ 0 ].st ); + qglColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( Vertex ), immediate[ 0 ].c ); + qglEnableClientState( GL_VERTEX_ARRAY ); + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + qglEnableClientState( GL_COLOR_ARRAY ); +} + +void pfglBegin( GLenum prim ) { + curr_vertex = 0; + curr_prim = prim; +} + +void pfglVertex3f( float x, float y, float z ) { + assert( curr_vertex < MAX_VERTS ); + vab.xyz[ 0 ] = x; + vab.xyz[ 1 ] = y; + vab.xyz[ 2 ] = z; + immediate[ curr_vertex ] = vab; + curr_vertex++; +} +void pfglVertex2i( GLint x, GLint y ) { + assert( curr_vertex < MAX_VERTS ); + vab.xyz[ 0 ] = (float)x; + vab.xyz[ 1 ] = (float)y; + vab.xyz[ 2 ] = 0.0f; + immediate[ curr_vertex ] = vab; + curr_vertex++; +} +void pfglColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) { + vab.c[ 0 ] = r; + vab.c[ 1 ] = g; + vab.c[ 2 ] = b; + vab.c[ 3 ] = a; +} +void pfglColor4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) { + vab.c[ 0 ] = (GLubyte) ( r * 255 ); + vab.c[ 1 ] = (GLubyte) ( g * 255 ); + vab.c[ 2 ] = (GLubyte) ( b * 255 ); + vab.c[ 3 ] = (GLubyte) ( a * 255 ); +} +void pfglTexCoord2i( GLint s, GLint t ) { + vab.st[ 0 ] = (float)s; + vab.st[ 1 ] = (float)t; +} +void pfglTexCoord2f( GLfloat s, GLfloat t ) { + vab.st[ 0 ] = s; + vab.st[ 1 ] = t; +} + +void pfglEnd() { + if ( curr_prim == GL_QUADS ) { + qglDrawElements( GL_TRIANGLES, curr_vertex / 4 * 6, GL_UNSIGNED_SHORT, quad_indexes ); + } else { + qglDrawArrays( curr_prim, 0, curr_vertex ); + } + curr_vertex = 0; + curr_prim = 0; +} + diff --git a/wolf3d/newCode/iphone/gles_glue.h b/wolf3d/newCode/iphone/gles_glue.h new file mode 100644 index 0000000..6eca2a8 --- /dev/null +++ b/wolf3d/newCode/iphone/gles_glue.h @@ -0,0 +1,77 @@ + + +#ifndef __GLES_GLUE_H__ +#define __GLES_GLUE_H__ + +#include "iphone_qgl.h" + +typedef GLfloat GLdouble; + +#define pfglEnable qglEnable +#define pfglDisable qglDisable +#define pfglActiveTextureARB qglActiveTexture +#define pfglGenTextures qglGenTextures +#define pfglDeleteTextures qglDeleteTextures +#define pfglDepthRange qglDepthRangef +#define pfglDepthFunc qglDepthFunc +#define pfglCullFace qglCullFace +#define pfglColor3f(r,g,b) pfglColor4f(r,g,b,1.0f) +#define pfglColor3ubv(c) pfglColor4ub( (c)[0], (c)[1], (c)[2], 255 ) +#define pfglColor4ubv(c) pfglColor4ub( (c)[0], (c)[1], (c)[2], (c)[3] ) +#define pfglBlendFunc qglBlendFunc +#define pfglClearColor qglClearColor +#define pfglClear qglClear +#define pfglDrawBuffer(buffer) +#define pfglLineWidth qglLineWidth +#define pfglBindTexture qglBindTexture +#define pfglTexParameteri qglTexParameteri +#define pfglTexParameterf qglTexParameterf +#define pfglTexImage2D qglTexImage2D +#define pfglFrustum qglFrustumf +#define pfglOrtho qglOrthof +#define pfglLoadIdentity qglLoadIdentity +#define pfglMatrixMode qglMatrixMode +#define pfglShadeModel qglShadeModel +#define pfglRotatef qglRotatef +#define pfglTranslatef qglTranslatef +#define pfglReadPixels qglReadPixels +#define pfglAlphaFunc qglAlphaFunc +#define pfglViewport qglViewport +#define pfglTexEnvi qglTexEnvi +#define pfglClientActiveTextureARB qglClientActiveTexture + +#define pfglGetIntegerv qglGetIntegerv +#define pfglGetString qglGetString +#define pfglGetError qglGetError + + +#define GL_QUADS 888 + +/* +void GLimp_BeginFrame(); +void GLimp_EndFrame( void ); +_boolean GLimp_Init( void *hinstance, void *hWnd ); +void GLimp_Shutdown( void ); +int GLimp_SetMode( int *pwidth, int *pheight, int mode, _boolean fullscreen ); +void GLimp_AppActivate( _boolean active ); +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +void pfglBegin( GLenum prim ); +void pfglVertex3f( float x, float y, float z ); +void pfglVertex2i( GLint x, GLint y ); +void pfglColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); +void pfglColor4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); +void pfglTexCoord2i( GLint s, GLint t ); +void pfglTexCoord2f( GLfloat s, GLfloat t ); + +void pfglEnd(); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/wolf3d/newCode/iphone/iphone_loop.c b/wolf3d/newCode/iphone/iphone_loop.c new file mode 100644 index 0000000..a64902a --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_loop.c @@ -0,0 +1,1025 @@ +/* + remove wolf_render.c + for the iphone build, we only need the following lsfx files: + + 001 + 003 + 008 + 009 + 012 + 023 + 028 + 030 + 031 + 033 + 034 + 035 + 036 + 037 + 038 + 040 + 044 + 045 + 061 + 062 + 064 + 069 + 076 + 078 + 080 + 085 + 086 + + */ + +#include "../wolfiphone.h" + +currentMap_t currentMap; + +vec3_t vnull = { 0, 0, 0 }; + +int iphoneFrameNum; +int intermissionTriggerFrame; +int slowAIFrame; + +// console mode +int consoleActive; + +// the native iPhone code should set the following each frame: +int numTouches; +int touches[5][2]; // [0] = x, [1] = y in landscape mode, raster order with y = 0 at top +float tilt; // -1.0 to 1.0 +float tiltPitch; + +#define MAX_TILT_HISTORY 64 +float tiltHistory[MAX_TILT_HISTORY][4]; +int tiltHistoryNum; + +// so we can detect button releases +int numPrevTouches; +int prevTouches[5][2]; + + +// the layout drawing code sets these, which are then used +// by the touch processing +int fireButtonX, fireButtonY, fireButtonSize; +int moveAxisX, moveAxisY, moveAxisSize; +int turnAxisX, turnAxisY, turnAxisSize; + +texture_t *numberPics[10]; + +int damageflash; +int bonusFrameNum; +int attackDirTime[2]; + +/* + ================== + iphoneActivateConsole + + ================== + */ +void iphoneActivateConsole() { + extern float scr_conlines; + scr_conlines = 0.5f; + consoleActive = 1; +} + +/* + ================== + iphoneDeactivateConsole + + ================== + */ +void iphoneDeactivateConsole() { + extern float scr_conlines; + scr_conlines = 0.0f; + consoleActive = 0; +} + +/* + ================== + iphoneExecuteCommandLine + + ================== + */ +void iphoneExecuteCommandLine() { + const char * GetCurrentCommandLine(); + void SetCurrentCommandLine(const char *); + char buf[256]; + strcpy( buf, GetCurrentCommandLine() ); + + Cmd_ExecuteString( buf ); + SetCurrentCommandLine( "" ); +} + + + +/* + ================== + iphoneSavePrevTouches + + ================== + */ +void iphoneSavePrevTouches() { + numPrevTouches = numTouches; + memcpy( prevTouches, touches, sizeof( prevTouches ) ); +#if 0 + // display the touch locations + for ( int i = 0 ; i < numTouches ; i++ ) { + int w = 32; + iphoneDrawPic( touches[i][0] - w/2, touches[i][1] - w/2, w, w, "iphone/diractional_02.tga" ); + } +#endif +} + +/* + ================== + iphoneCenterText + + Returns the width in pixels + ================== + */ +extern font_t *myfonts[ 1 ]; +int iphoneCenterText( int x, int y, const char *str ) { + int l = strlen( str ); + int i; + font_t *myfont = myfonts[0]; + int scale; + int step = 10; + + scale = 16; + + x -= l * step / 2; + + R_Bind( myfont->texfont->texnum ); + pfglBegin( GL_QUADS ); + + for ( i = 0 ; i < l ; i++, x += step ) { + int row, col; + float frow, fcol; + int num = str[i]; + + if ( num == ' ' ) { + continue; + } + + row = (num >> 4) - 2; + col = num & 15; + + frow = row * myfont->hFrac; + fcol = col * myfont->wFrac; + + pfglTexCoord2f( fcol, frow ); + pfglVertex2i( x, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow ); + pfglVertex2i( x+scale, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow+myfont->hFrac ); + pfglVertex2i( x+scale, y+scale ); + + pfglTexCoord2f( fcol, frow+myfont->hFrac ); + pfglVertex2i( x, y+scale ); + } + + pfglEnd(); + + return l * step; +} + + +/* + ================== + TouchDown + + Checks all touches against a square + ================== + */ +int TouchDown( int x, int y, int w, int h ) { + int i; + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + w && touches[i][1] < y + h ) { + return 1; + } + } + return 0; +} + +/* + ================== + TouchReleased + + Perform an action when released in the box. + If not down this frame, but down the previous frame, it is released + ================== + */ +int TouchReleased( int x, int y, int w, int h ) { + int i; + int downPrev = 0; + int downNow = 0; + + for ( i = 0 ; i < numPrevTouches ; i++ ) { + if ( prevTouches[i][0] >= x && prevTouches[i][1] >= y + && prevTouches[i][0] < x + w && prevTouches[i][1] < y + h ) { + downPrev = 1; + break; + } + } + + // see if not down this frame + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + w && touches[i][1] < y + h ) { + downNow = 1; + break; + } + } + + if ( !downPrev ) { + if ( downNow ) { + Sound_StartLocalSound( "iphone/bdown_01.wav" ); + } + // wasn't down the previous frame + return 0; + } + + if ( downNow ) { + // still down + return 0; + } + + if ( numTouches != 0 ) { + // finger dragged off + Sound_StartLocalSound( "iphone/baborted_01.wav" ); + return 0; + } + + // released + Sound_StartLocalSound( "iphone/baction_01.wav" ); + return 1; +} + +/* + ================== + iphoneSet2D + + ================== + */ +void iphoneSet2D( void ) { + pfglViewport( 0,0, 480, 320 ); + pfglMatrixMode( GL_MODELVIEW ); + pfglLoadIdentity(); + pfglDisable( GL_DEPTH_TEST ); + pfglDisable( GL_CULL_FACE ); + pfglEnable( GL_BLEND ); + pfglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + pfglDisable( GL_ALPHA_TEST ); + pfglColor4f( 1,1,1,1 ); + + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( 0, 480, 320, 0, -99999, 99999 ); +} + + +/* + ================== + DeadBandAdjust + + Compresses the 0.0 - 1.0 range into deadband - 1.0 + ================== + */ +float DeadBandAdjust( float f, float deadBand ) { + if ( f < 0 ) { + return -DeadBandAdjust( -f, deadBand ); + } + if ( f > 1.0 ) { + return 1.0; + } + if ( f < deadBand ) { + return 0; + } + return (f-deadBand) / (1.0 - deadBand); +} + +/* +================== +AxisHit + +Returns a -1 to 1 range + +If activeFraction is less than 1.0, the range will clamp +to the limits before the edge of the box is hit. +================== +*/ +float AxisHit( int x, int y, int size, int isXaxis, float activeFraction ) { + int i; + + // allow the touches to go outside the indicated bounds with clamping + x -= size/2; + y -= size/2; + size *= 2; + activeFraction *= 0.5f; + + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + size && touches[i][1] < y + size ) { + float f; + if ( isXaxis ) { + f = (float)( touches[i][0] - x ) / size * 2.0f - 1.0f; + } else { + f = (float)( touches[i][1] - y ) / size * 2.0f - 1.0f; + } + f /= activeFraction; + if ( f > 1.0f ) { + f = 1.0f; + } else if ( f < -1.0f ) { + f = -1.0f; + } + if ( f > -stickDeadBand->value && f < stickDeadBand->value ) { + f = 0; + } + return f; + } + } + return 0; +} + +void WolfensteinTouches( int _numTouches, int _touches[16] ) { + numTouches = _numTouches; + for ( int i = 0 ; i < numTouches ; i++ ) { + touches[i][0] = 480 - _touches[i*2+1]; + touches[i][1] = _touches[i*2+0]; + } +} + +void WolfensteinTilts( float *tilts ) { + int i; + int j; + int c; + float sum[3]; + static float prevTime; + + c = tiltAverages->value; + if ( c < 1 ) { + c = 1; + } else if ( c > MAX_TILT_HISTORY ) { + c = MAX_TILT_HISTORY; + } + + // acc[0] - [2] are accelerometer values, ax[3] is the timestamp + for ( i = 0 ; i < 3 ; i++ ) { + tiltHistory[tiltHistoryNum&(MAX_TILT_HISTORY-1)][i] = tilts[i]; + sum[i] = 0; + for ( j = 0 ; j < c ; j++ ) { + sum[i] += tiltHistory[(tiltHistoryNum-j)&(MAX_TILT_HISTORY-1)][i]; + } + sum[i] /= c; + } + // save the timestamp for analysis + tiltHistory[tiltHistoryNum&(MAX_TILT_HISTORY-1)][3] = tilts[3] - prevTime; + prevTime = tilts[3]; + tiltHistoryNum++; + + tilt = sum[1]; + tiltPitch = sum[0]; +// Com_Printf( "%4.2f %4.2f %4.2f\n", tilts[0], tilts[1], tilts[2] ); +} + +void ShowTilt() { + int i; + int axis = (int)showTilt->value; + colour4_t fillColor = { 255, 0, 0, 255 }; + colour4_t whiteColor = { 255, 255, 255, 255 }; + colour4_t nowColor = { 0, 255, 0, 255 }; + float x; + + if ( axis < 0 || axis > 2 ) { + return; + } + for ( i = 0 ; i < MAX_TILT_HISTORY ; i++ ) { + x = tiltHistory[(tiltHistoryNum-1-i)&(MAX_TILT_HISTORY-1)][axis] * ( 10 / 0.018168604 ); + if ( x < 0 ) { + R_Draw_Fill( 240 + x, i*4, -x, 4, fillColor ); + } else if ( x > 0 ) { + R_Draw_Fill( 240, i*4, x, 4, fillColor ); + } + } + x = tilt * ( 10 / 0.018168604 ); + if ( x < 0 ) { + R_Draw_Fill( 240 + x, i*4, -x, 4, nowColor ); + } else if ( x > 0 ) { + R_Draw_Fill( 240, i*4, x, 4, nowColor ); + } + R_Draw_Fill( 240, 0, 1, MAX_TILT_HISTORY*4, whiteColor ); +} + + +/* +================== +CreateIphoneUserCmd + +Build the movement, angles, and buttons for a frame of action: + +Player.position.angle +Player.cmd.buttons +Player.cmd.forwardMove +Player.cmd.sideMove +================== +*/ +PRIVATE void CreateIphoneUserCmd() +{ + float stickTurnValue; + float stickMoveValue; + + stickTurnValue = stickTurnBase->value + stickTurnScale->value * sensitivity->value; + stickMoveValue = stickMoveBase->value + stickMoveScale->value * sensitivity->value; + + usercmd_t *cmd = &Player.cmd; + memset( cmd, 0, sizeof( *cmd ) ); + + if ( TouchDown( fireButtonX, fireButtonY, fireButtonSize, fireButtonSize ) ) { + cmd->buttons |= BUTTON_ATTACK; + } + if ( tiltFire->value > 0 && tiltPitch < tiltFire->value ) { + cmd->buttons |= BUTTON_ATTACK; + } + + cmd->forwardmove = -stickMoveValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 0, 0.8f ); + + if( controlScheme->value == 0 || controlScheme->value == 1 ) { + Player.position.angle += -stickTurnValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 1, 0.8f ); + } else { + Player.position.angle += -stickTurnValue * AxisHit( turnAxisX, turnAxisY, turnAxisSize, 1, 0.8f ); + cmd->sidemove = stickMoveValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 1, 0.8f ); + } + + // accelerometer tilting + cmd->sidemove += tiltMove->value * DeadBandAdjust( tilt, tiltDeadBand->value ); + Player.position.angle -= tiltTurn->value * DeadBandAdjust( tilt, tiltDeadBand->value ); + + // always use + if ( iphoneFrameNum & 1 ) { + cmd->buttons |= BUTTON_USE; + } +} + + +/* +================== +iphoneHighlightPicWhenTouched + +Draw transparent except when touched +================= +*/ +void iphoneHighlightPicWhenTouched( int x, int y, int w, int h, const char *pic ) { + if ( TouchDown( x, y, w, h ) ) { + pfglColor4f(1,1,1,1); + } else { + pfglColor4f(1,1,1,0.5); + } + R_Draw_StretchPic( x, y, w, h, pic ); + pfglColor4f(1,1,1,1); +} +int iphoneActivatePicWhenTouched( int x, int y, int w, int h, const char *pic ) { + iphoneHighlightPicWhenTouched( x, y, w, h, pic ); + return TouchReleased( x, y, w, h ); +} + + +/* +================== +iphoneDrawControls + + scheme 0: turnstick on left + scheme 1: turnstick on right + scheme 2: dualstick, move on left + scheme 3: dualstick, move on right +================= +*/ +static const int BUTTON_SIZE = 100; +void iphoneDrawControls( void ) { + int ss = (int)stickSize->value; + + switch ( (int)controlScheme->value ) { + case 0: + moveAxisX = 0; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_02.tga" ); + + fireButtonX = 480 - BUTTON_SIZE; + fireButtonY = 320 - BUTTON_SIZE; + fireButtonSize = BUTTON_SIZE; + break; + + case 1: + moveAxisX = 480 - ss; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_02.tga" ); + + fireButtonX = 0; + fireButtonY = 320 - BUTTON_SIZE; + fireButtonSize = BUTTON_SIZE; + break; + + case 2: + moveAxisX = 0; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_01.tga" ); + + turnAxisX = 480 - ss; + turnAxisY = 320 - ss; + turnAxisSize = ss; + iphoneHighlightPicWhenTouched( turnAxisX, turnAxisY, turnAxisSize, turnAxisSize, "iphone/diractional_03.tga" ); + + fireButtonX = 480-BUTTON_SIZE; + fireButtonY = 0; + fireButtonSize = BUTTON_SIZE; + break; + case 3: + moveAxisX = 480 - ss; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_01.tga" ); + + turnAxisX = 0; + turnAxisY = 320 - ss; + turnAxisSize = ss; + iphoneHighlightPicWhenTouched( turnAxisX, turnAxisY, turnAxisSize, turnAxisSize, "iphone/diractional_03.tga" ); + + fireButtonX = 480-BUTTON_SIZE; + fireButtonY = 0; + fireButtonSize = BUTTON_SIZE; + break; + } + + iphoneHighlightPicWhenTouched( fireButtonX, fireButtonY, fireButtonSize, fireButtonSize, "iphone/shoot.tga" ); +} + +/* + ================== + iphoneDrawWeapon + + ================== + */ +void iphoneDrawWeapon( void ) { + char name[ 32 ]; + texture_t *tex; + static int w = 200; + static int h = 200; + int x = (viddef.width - w ) >> 1; + int y = viddef.height - 80 - h; + int frame; + + if ( gunFrame->value ) { + // screenshots look better with the muzzle flash + frame = Player.weapon * 5 + gunFrame->value + SPR_KNIFEREADY; + } else { + frame = Player.weapon * 5 + Player.weaponframe + SPR_KNIFEREADY; + } + + my_snprintf( name, sizeof( name ), "%s/%d.tga", spritelocation, frame); + tex = TM_FindTexture( name, TT_Pic ); + + R_Bind( tex->texnum ); + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0.01f, 0.01f ); pfglVertex2i( x, y ); + pfglTexCoord2f( 0.99f, 0.01f ); pfglVertex2i( x + w, y ); + pfglTexCoord2f( 0.99f, 0.99f ); pfglVertex2i( x + w, y + h ); + pfglTexCoord2f( 0.01f, 0.99f ); pfglVertex2i( x, y + h ); + + pfglEnd(); +} + +/* + ================== + iphoneDrawNumber + + ================== + */ +void iphoneDrawNumber( int x, int y, int number, int charWidth, int charHeight ) { + texture_t *tex; + int i; + char string[ 20 ]; + W32 length; + float charStep = charWidth * 0.8; // trim off extra width + + if ( number < 0 ) { + number = 0; + } + my_snprintf( string, sizeof( string ), "%d", number ); + length = strlen( string ); + + x -= length * charStep / 2; + + for( i = 0 ; i < length ; i++ ) { + int digit = string[i] - '0'; + tex = numberPics[digit]; + R_Bind( tex->texnum ); + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0, 0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1, 0 ); pfglVertex2i( x+charWidth, y ); + pfglTexCoord2f( 1, 1 ); pfglVertex2i( x+charWidth, y+charHeight ); + pfglTexCoord2f( 0, 1 ); pfglVertex2i( x, y+charHeight ); + + pfglEnd(); + x += charStep; + } +} + +/* + ================== + iphoneDrawHUD + + ================== + */ +void iphoneDrawHUD( void ) { + int y; + + if( Player.items & ITEM_KEY_1 ) { + R_Draw_Pic( 0, 100, "iphone/GOLDKEYPIC.tga" ); + } + + if( Player.items & ITEM_KEY_2 ) { + R_Draw_Pic( 0, 130, "iphone/SILVERKEYPIC.tga" ); + } + + iphoneDrawNumber( 240, 304, Player.health, 16, 16 ); + if ( fireButtonY < 160 ) { + y = fireButtonY + fireButtonSize + 8; + } else { + y = fireButtonY - 8 - 48; + } + iphoneDrawNumber( fireButtonX + fireButtonSize/2, y, Player.ammo[AMMO_BULLETS], 48, 48 ); +} + +/* + ================== + iphoneDrawFace + + ================== + */ +void iphoneDrawFace( void ) { + int i; + int w = 64; + int h = 80; + int x = (viddef.width - w ) >> 1; + int y = viddef.height - h; + const char *pic; + static const char *mugshotnames[ 24 ] = + { + "iphone/newhead/FACE1APIC.tga", + "iphone/newhead/FACE1BPIC.tga", + "iphone/newhead/FACE1CPIC.tga", + + "iphone/newhead/FACE2APIC.tga", + "iphone/newhead/FACE2BPIC.tga", + "iphone/newhead/FACE2CPIC.tga", + + "iphone/newhead/FACE3APIC.tga", + "iphone/newhead/FACE3BPIC.tga", + "iphone/newhead/FACE3CPIC.tga", + + "iphone/newhead/FACE4APIC.tga", + "iphone/newhead/FACE4BPIC.tga", + "iphone/newhead/FACE4CPIC.tga", + + "iphone/newhead/FACE5APIC.tga", + "iphone/newhead/FACE5BPIC.tga", + "iphone/newhead/FACE5CPIC.tga", + + "iphone/newhead/FACE6APIC.tga", + "iphone/newhead/FACE6BPIC.tga", + "iphone/newhead/FACE6CPIC.tga", + + "iphone/newhead/FACE7APIC.tga", + "iphone/newhead/FACE7BPIC.tga", + "iphone/newhead/FACE7CPIC.tga", + + "iphone/newhead/FACE8APIC.tga" + }; + + static const char *godmugshotnames[] = + { + "iphone/newhead/GODMODEFACE0PIC.tga", + "iphone/newhead/GODMODEFACE1PIC.tga", + "iphone/newhead/GODMODEFACE2PIC.tga" + }; + + iphoneDrawPic( 240 - 64, 320 - 80, 128, 80, "iphone/status_hud.tga" ); + + Player.facecount += tics; + if ( Player.face_gotgun && Player.facecount > 0 ) { + // gotgun will set facecount to a negative number initially, go back + // to normal face with random look after expired. + Player.face_gotgun = false; + } + if( Player.facecount > US_RndT() ) + { + Player.face_gotgun = Player.face_ouch = false; + Player.faceframe = US_RndT() >> 6; + if( Player.faceframe == 3 ) + { + Player.faceframe = 0; + } + + Player.facecount = 0; + } + + if( Player.health ) + { + if( g_version->value == SPEAROFDESTINY && Player.flags & FL_GODMODE ) + { + pic = godmugshotnames[ Player.faceframe ]; + } + else if( Player.face_gotgun ) + { + pic = "iphone/newhead/GOTGATLINGPIC.tga"; + } + else + { + int h = Player.health; + if ( h > 100 ) { + h = 100; + } + if ( h < 0 ) { + h = 0; + } + pic = mugshotnames[ 3*((100-h)/16)+Player.faceframe ]; + } + } + else + { +#if 0 // forgot to convert the mutant face pic... + if( Player.LastAttacker && Player.LastAttacker->type == en_needle ) + { + pic = "iphone/MUTANTBJPIC.tga"; + } + else +#endif + { + pic = "iphone/newhead/FACE8APIC.tga"; + } + } + + R_Draw_StretchPic( x, y, w, h, pic ); + + // blend the right / left damage indicators on the side + for ( i = 0 ; i < 2 ; i++ ) { + float f; + if ( attackDirTime[i] == 0 ) { + continue; + } + f = iphoneFrameNum - attackDirTime[i]; + if ( f > 30 ) { + attackDirTime[i] = 0; + continue; + } + if ( f < 20 ) { + f = 1.0; + } else { + f = ( 30 - f ) * 0.1; + } + pfglColor4f( 1, 1, 1, f ); + if ( i == 0 ) { + iphoneDrawPic( 240 - 64, 320 - 80, 40, 80, "iphone/L_damage.tga" ); + } else { + iphoneDrawPic( 240 + 64 - 40, 320 - 80, 40, 80, "iphone/R_damage.tga" ); + } + pfglColor4f( 1, 1, 1, 1 ); + } +} + +/* + ================== + iphoneSetNotifyText + + Notify text is a single centered line for "got a key", "found a secret", etc + ================== + */ +char notifyText[128]; +int notifyFrameNum; +void iphoneSetNotifyText( const char *str, ... ) { + va_list argptr; + + va_start( argptr, str ); + (void)vsnprintf( notifyText, sizeof( notifyText )-1, str, argptr ); + va_end( argptr ); + + notifyFrameNum = iphoneFrameNum; +} + +void iphoneDrawNotifyText() { + if ( notifyFrameNum == 0 ) { + return; + } + // display for three seconds, then fade over 0.3 + float f = iphoneFrameNum - notifyFrameNum - 80; + if ( f < 0 ) { + f = 1.0; + } else { + f = 1.0 - f * 0.1f; + if ( f < 0 ) { + notifyFrameNum = 0; + return; + } + } + + pfglColor4f( 1, 1, 1, f ); + iphoneCenterText( 240, 20, notifyText ); + pfglColor4f( 1, 1, 1, 1 ); +} + +void iphoneStartBonusFlash() { + bonusFrameNum = iphoneFrameNum; +} + +void iphoneStartDamageFlash( int damage ) { + damageflash += damage; + if ( damageflash > 64 ) { + damageflash = 64; + } + if ( damageflash < 10 ) { + damageflash = 10; + } +} + +/* + ================== + iphoneSetAttackDirection + + +1 = attacked from the left + -1 = attacked from the right + ================== + */ +void iphoneSetAttackDirection( int dir ) { + if ( dir > 0 ) { + attackDirTime[0] = iphoneFrameNum; + } + if ( dir < 0 ) { + attackDirTime[1] = iphoneFrameNum; + } +} + + +/* +================== +iphoneFrame + +================== +*/ +void iphoneFrame() { + unsigned char blendColor[4]; + + int msec = 14; // fixed time + + iphoneFrameNum++; + + // check for delayed intermission trigger after boss kill + if ( intermissionTriggerFrame > 0 && iphoneFrameNum >= intermissionTriggerFrame ) { + iphoneStartIntermission( 0 ); + } + + // toggle / scroll down the console + Client_Screen_RunConsole(); + + + // fixed frame timing, assume we go 30hz + tics = 2; // wolf's global rate counter + + Sound_Update( vnull, vnull, vnull, vnull ); + + if ( consoleActive ) { + iphoneSet2D(); + + Client_Screen_DrawConsole(); + + iphoneSavePrevTouches(); + GLimp_EndFrame(); + return; + } + if ( menuState != IPM_GAME ) { + iphoneSet2D(); + + iphoneDrawMenus(); + + iphoneSavePrevTouches(); + GLimp_EndFrame(); + return; + } + + //------------------ + // normal gameplay + //------------------ + + if( Player.playstate != ex_dead ) + { + CreateIphoneUserCmd(); + Player.position.angle = NormalizeAngle( Player.position.angle ); + + PL_Process( &Player, r_world ); // Player processing + if ( !slowAI->value || --slowAIFrame < 0 ) { + // slowAIframe is for slow-motion screenshot capture + slowAIFrame += slowAI->value; + ProcessGuards(); + } + PushWall_Process(); + Door_ProcessDoors_e( &r_world->Doors, tics, msec ); + + levelstate.time += tics; + } + + // fill the floor and ceiling + R_Draw_Fill( 0, 0, viddef.width, viddef.height >> 1, r_world->ceilingColour ); + R_Draw_Fill( 0, viddef.height >> 1, viddef.width, viddef.height, r_world->floorColour ); + + // draw 3D world + R_SetGL3D( Player.position ); + R_RayCast( Player.position, r_world ); + R_DrawSprites(); + + // draw 2D overlays + iphoneSet2D(); + + // do a full screen blend for damage, death, and bonus pickup + if( Player.playstate == ex_dead ) { + static int deathFadeIntensity; + blendColor[0] = 255; + blendColor[1] = 0; + blendColor[2] = 0; + blendColor[3] = deathFadeIntensity; + deathFadeIntensity += 2; + if( deathFadeIntensity >= 240 ) { + deathFadeIntensity = 0; + PL_NewGame( &Player ); + iphoneStartMap( currentMap.episode, currentMap.map, currentMap.skill ); + } + } else { + iphoneDrawWeapon(); + if( damageflash ) { + blendColor[0] = 255; + blendColor[1] = 0; + blendColor[2] = 0; + blendColor[3] = damageflash >= 64 ? 255 : damageflash * 4; + + if( (damageflash -= 1) < 0 ) { + damageflash = 0; + } + } else if ( bonusFrameNum ) { + float f = ( iphoneFrameNum - bonusFrameNum ) * 0.1; + if ( f > 1.0 ) { + bonusFrameNum = 0; + } else { + blendColor[0] = 255; + blendColor[1] = 255; + blendColor[2] = 128; + blendColor[3] = ( 1.0 - f ) * 64; + } + } + } + if ( blendColor[3] != 0 && blends->value != 0 ) { + R_DrawBox( 0, 0, viddef.width, viddef.height, *(int *)blendColor ); + } + + iphoneDrawNotifyText(); + + iphoneDrawFace(); + + iphoneDrawControls(); + + iphoneDrawHUD(); + + // draw menu and map buttons + if ( controlScheme->value < 2 ) { + if ( iphoneActivatePicWhenTouched( 480-50, 0, 50, 50, "iphone/menu.tga" ) ) { + menuState = IPM_MAIN; + } + if ( iphoneActivatePicWhenTouched( 0, 0, 50, 50, "iphone/map.tga" ) ) { + iphoneOpenAutomap(); + } + } else { + if ( iphoneActivatePicWhenTouched( 0, 50, 50, 50, "iphone/menu.tga" ) ) { + menuState = IPM_MAIN; + } + if ( iphoneActivatePicWhenTouched( 0, 0, 50, 50, "iphone/map.tga" ) ) { + iphoneOpenAutomap(); + } + } + + Client_Screen_DrawConsole(); + + ShowTilt(); + + iphoneSavePrevTouches(); + + // do the swapbuffers + GLimp_EndFrame(); +} diff --git a/wolf3d/newCode/iphone/iphone_main.c b/wolf3d/newCode/iphone/iphone_main.c new file mode 100644 index 0000000..bbcd626 --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_main.c @@ -0,0 +1,244 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * unix_main.c: UNIX interface to application. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +cvar_t *controlScheme; +cvar_t *sensitivity; +cvar_t *stickSize; +cvar_t *stickTurnBase; +cvar_t *stickTurnScale; +cvar_t *stickMoveBase; +cvar_t *stickMoveScale; +cvar_t *stickDeadBand; +cvar_t *tiltTurn; +cvar_t *tiltMove; +cvar_t *tiltDeadBand; +cvar_t *tiltAverages; +cvar_t *tiltFire; +cvar_t *music; +cvar_t *showTilt; +cvar_t *cropSprites; +cvar_t *blends; +cvar_t *gunFrame; +cvar_t *slowAI; + +W32 sys_frame_time; + +void Sys_Error( const char *format, ... ) +{ + va_list argptr; + char string[ 1024 ]; + + va_start( argptr, format ); + (void)vsnprintf( string, sizeof( string ), format, argptr ); + va_end( argptr ); + + fprintf( stderr, "Error: %s\n", string ); + + _exit( 1 ); + +} + +void Sys_Quit (void) +{ + _exit( 0 ); +} + +void Sys_SendKeyEvents (void) +{ +} + +char *Sys_GetClipboardData( void ) +{ + return NULL; +} + +void Reset_f() { + memset( ¤tMap, 0, sizeof( currentMap ) ); + currentMap.skill = 1; + cvar_vars = NULL; // don't write any cvars to the config file + iphoneShutdown(); +} + +/* + ================== + iphoneStartup + + ================== + */ +void iphoneStartup() { + int i; + char *s; + int start = Sys_Milliseconds(); + + z_chain.next = z_chain.prev = &z_chain; + + InitImmediateModeGL(); + + // Prepare enough of the subsystems to handle + // cvar and command buffer management. + COM_InitArgv( 0, NULL ); // FIXME: get args... + + Cmd_Init(); + Cvar_Init(); + Con_Init(); + FS_InitFilesystem(); + + // We need to add the early commands twice, because + // a basedir or cddir needs to be set before execing + // config files, but we want other parms to override + // the settings of the config files. + Cbuf_AddEarlyCommands( false ); + Cbuf_Execute(); + + R_Init(); + + Cmd_AddCommand( "reset", Reset_f ); + + developer = Cvar_Get( "developer", "0", CVAR_INIT ); + logfile_active = Cvar_Get( "logfile", "0", CVAR_INIT ); + + s = va( "%s %s %s %s %s %s", APP_VERSION, RELEASENAME, CPUSTRING, __DATE__, __TIME__, BUILDSTRING ); + Cvar_Get( "version", s, CVAR_SERVERINFO | CVAR_NOSET ); + + Con_Init(); + + Sound_Init(); + + Game_Init(); // game and player init + + Cbuf_AddText( "exec config.cfg\n" ); + Cbuf_AddEarlyCommands( true ); + Cbuf_Execute(); + + // add + commands from command line + Cbuf_AddLateCommands(); + Cbuf_Execute(); + + for ( i = 0 ; i < 10 ; i++ ) { + char name[64]; + sprintf( name, "iphone/font/%i.tga", i ); + numberPics[i] = TM_FindTexture( name, TT_Pic ); + } + + Com_Printf( "\n====== Application Initialized ======\n\n" ); + + Sound_Activate( true ); + consoleActive = 0; + + controlScheme = Cvar_Get( "controlScheme", "0", CVAR_ARCHIVE ); + sensitivity = Cvar_Get( "sensitivity", "0.3", CVAR_ARCHIVE ); + + stickSize = Cvar_Get( "stickSize", "120", CVAR_ARCHIVE ); + stickTurnBase = Cvar_Get( "stickTurnBase", "300", CVAR_ARCHIVE ); + stickTurnScale = Cvar_Get( "stickTurnScale", "500", CVAR_ARCHIVE ); + stickMoveBase = Cvar_Get( "stickMoveBase", "3000", CVAR_ARCHIVE ); + stickMoveScale = Cvar_Get( "stickMoveScale", "5000", CVAR_ARCHIVE ); + stickDeadBand = Cvar_Get( "stickDeadBand", "0.2", CVAR_ARCHIVE ); + tiltTurn = Cvar_Get( "tiltTurn", "0", CVAR_ARCHIVE ); + tiltMove = Cvar_Get( "tiltMove", "0", CVAR_ARCHIVE ); + tiltFire = Cvar_Get( "tiltFire", "0", CVAR_ARCHIVE ); + music = Cvar_Get( "music", "1", CVAR_ARCHIVE ); + tiltDeadBand = Cvar_Get( "tiltDeadBand", "0.08", CVAR_ARCHIVE ); + tiltAverages = Cvar_Get( "tiltAverages", "3", CVAR_ARCHIVE ); + cropSprites = Cvar_Get( "cropSprites", "1", 0 ); + showTilt = Cvar_Get( "showTilt", "-1", 0 ); + blends = Cvar_Get( "blends", "1", 0 ); + gunFrame = Cvar_Get( "gunFrame", "0", 0 ); + slowAI = Cvar_Get( "slowAI", "0", 0 ); + + // these should get overwritten by LoadTheGame + currentMap.skill = 1; + currentMap.episode = 0; + + if ( !LoadTheGame() ) { + memset( currentMap.mapFlags, 0,sizeof( currentMap.mapFlags ) ); + PL_NewGame( &Player ); + iphoneStartMap( 0, 0, 1 ); + } + + // always start at main menu + menuState = IPM_MAIN; + + Com_Printf( "startup time: %i msec\n", Sys_Milliseconds() - start ); +} + +/* + ================== + iphoneWriteConfig + + ================== + */ +void iphoneWriteConfig( void ) { + FILE *fp; + char path[ MAX_OSPATH]; + cvar_t *var; + char buffer[1024]; + + my_snprintf( path, sizeof( path ), "%s/config.cfg", iphoneDocDirectory ); + fp = fopen( path, "w" ); + if( ! fp ) { + Com_Printf( "Could not write config.cfg.\n" ); + return; + } + + // write out commands to set the archived cvars + for( var = cvar_vars ; var ; var = var->next ) { + if( var->flags & CVAR_ARCHIVE ) { + my_snprintf( buffer, sizeof( buffer ), "set %s \"%s\"\n", var->name, var->string ); + fprintf( fp, "%s", buffer ); + Com_Printf( "%s", buffer ); + } + } + + fclose( fp ); +} + + +/* + ================== + iphoneShutdown + + Save the game at this position + ================== + */ +void iphoneShutdown() { + Sound_StopAllSounds(); + Sound_StopBGTrack(); + iphoneWriteConfig(); + SaveTheGame(); + exit( 0 ); +} + diff --git a/wolf3d/newCode/iphone/iphone_menus.c b/wolf3d/newCode/iphone/iphone_menus.c new file mode 100644 index 0000000..91ba1d6 --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_menus.c @@ -0,0 +1,1061 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#include "../wolfiphone.h" + +int intermissionStartFrameNum; +int hasReleased; + +menuState_t menuState; +colour4_t highlightColor = { 128, 128, 128, 255 }; +colour4_t colorPressed = { 128, 128, 0, 255 }; + +/* + ================== + iphoneDrawPic + + ================== + */ +void iphoneDrawPic( int x, int y, int w, int h, const char *pic ) { + R_Draw_StretchPic( x, y, w, h, pic ); +} + +/* + ================== + iphoneDrawPicWithTouch + + ================== + */ +int iphoneDrawPicWithTouch( int x, int y, int w, int h, const char *pic ) { + int r = TouchReleased( x, y, w, h ); + + if ( r ) { + // make sure it is full intensity if it is touch-released, even if + // it wasn't active previously + pfglColor3f( 1, 1, 1 ); + } + R_Draw_StretchPic( x, y, w, h, pic ); + if ( TouchDown( x, y, w, h ) ) { + colour4_t color = { 255, 255, 255, 64 }; + R_Draw_Blend( x, y, w, h, color ); + } + return r; +} + + + +/* + ================== + iphoneSlider + + ================== + */ +void iphoneSlider( int x, int y, int w, int h, const char *title, cvar_t *cvar, + float min, float max ) { + float value = cvar->value; + char str[80]; + float f = ( value - min ) / ( max - min ); + colour4_t backColor = { 32, 32, 80, 255 }; + colour4_t highlightColor = { 64, 64, 160, 255 }; + + if ( f < 0 ) { + f = 0; + } + if ( f > 1 ) { + f = 1; + } + + // draw the background + R_Draw_Fill( x, y, w, h, backColor ); + + // draw the current range + R_Draw_Fill( x+2, y+2, f*(w-4), h-4, highlightColor ); + + // draw the title and fraction + sprintf( str, "%s : %i%%", title, (int)(f*100) ); + iphoneCenterText( x+ w/2, y+h/2-8, str ); + + // check for touches + if ( numTouches > 0 && touches[0][0] >= x && touches[0][0] < x + w + && touches[0][1] >= y && touches[0][1] < y+ h ) { + float newValue; + float delta; + + f = (float)( touches[0][0] - x ) / w; + // round to tenths + f = (int)( ( f + 0.05 ) * 10 ) * 0.1f; + if ( f < 0 ) { + f = 0; + } + if ( f > 1.0 ) { + f = 1.0; + } + + newValue = min + f * ( max - min ); + delta = fabs( newValue - cvar->value ); + if ( f == 0 && cvar->value == 0 ) { + // special case of disable-at-0 + } else if ( delta > 0.01 ) { + Cvar_SetValue( cvar->name, newValue ); + Sound_StartLocalSound( "iphone/slide_01.wav" ); + } + } + +} + +/* + ================== + BackButton + + ================== + */ +int BackButton() { + if ( iphoneDrawPicWithTouch( 0, 0, 64, 32, "iphone/button_back.tga" ) ) { + return 1; + } + return 0; +} + +void GetMoreLevels( int x, int y ) { + if ( iphoneDrawPicWithTouch( x, y, 128, 64, "iphone/button_levels.tga" ) ) { + // directly to the app store for more levels + OpenURL( "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=304694876" ); + } +} + + +/* + ================== + SaveTheGame + + ================== + */ +extern W8 areaconnect[ NUMAREAS ][ NUMAREAS ]; +extern _boolean areabyplayer[ NUMAREAS ]; + +void SaveTheGame() { + FILE *f; + char path[1024]; + int version = SAVEGAME_VERSION; + int i; + + my_snprintf( path, sizeof( path ), "%s/savegame.bin", iphoneDocDirectory ); + f = fopen( path, "wb" ); + if( ! f ) { + Com_Printf( "Could not open savegame.bin.\n" ); + return; + } + + // turn the r_world->Doors.doors from pointers to indexes + // ok to be destructive, because we are quiting + for ( i = 0 ; i < r_world->Doors.doornum ; i++ ) { + int index = r_world->Doors.Doors[i] - &r_world->Doors.DoorMap[0][0]; + assert( index >= 0 && index < 4096 ); + r_world->Doors.Doors[i] = (void *)index; + } + + // this is only used for the mutant death face, so just + // clear it instead of fixing it up + Player.LastAttacker = NULL; + + currentMap.version = SAVEGAME_VERSION; + fwrite( ¤tMap, 1,sizeof(currentMap), f ); + fwrite( r_world, 1,sizeof(*r_world), f ); + fwrite( &LevelRatios, 1,sizeof(LevelRatios), f ); + fwrite( &levelstate, 1,sizeof(levelstate), f ); + fwrite( Guards, 1,sizeof(Guards), f ); + fwrite( areaconnect, 1,sizeof(areaconnect), f ); + fwrite( areabyplayer, 1,sizeof(areabyplayer), f ); + fwrite( &PWall, 1,sizeof(PWall), f ); + fwrite( &Player, 1,sizeof(Player), f ); + fwrite( &version, 1,sizeof(version), f ); + + fclose( f ); +} + +/* + ================== + LoadTheGame + + ================== + */ +int LoadTheGame() { + FILE *f; + char path[1024]; + int version; + int i; + int oldCompleted; + + my_snprintf( path, sizeof( path ), "%s/savegame.bin", iphoneDocDirectory ); + f = fopen( path, "rb" ); + if( ! f ) { + Com_Printf( "Could not open savegame.bin.\n" ); + return 0; + } + + fread( ¤tMap, 1,sizeof(currentMap) , f); + + if ( currentMap.version != SAVEGAME_VERSION ) { + Com_Printf( "Savegame header version mismatch: %i != %i\n", currentMap.version, SAVEGAME_VERSION ); + fclose( f ); + return 0; + } + + // do a normal map start + Cvar_SetValue( skill->name, currentMap.skill ); + PL_NewGame( &Player ); + + oldCompleted = currentMap.levelCompleted; + iphoneStartMap( currentMap.episode, currentMap.map, currentMap.skill ); + currentMap.levelCompleted = oldCompleted; + + // load modifiactions on top + r_world = Z_Malloc( sizeof( *r_world ) ); + fread( r_world, 1,sizeof(*r_world), f); + fread( &LevelRatios, 1,sizeof(LRstruct), f ); + fread( &levelstate, 1,sizeof(levelstate), f ); + fread( Guards, 1,sizeof(Guards), f ); + fread( areaconnect, 1,sizeof(areaconnect), f ); + fread( areabyplayer, 1,sizeof(areabyplayer), f ); + fread( &PWall, 1,sizeof(PWall), f ); + fread( &Player, 1,sizeof(Player), f ); + fread( &version, 1,sizeof(version), f ); + + fclose( f ); + + if ( version != SAVEGAME_VERSION ) { + Com_Printf( "Savegame trailer version mismatch: %i != %i\n", version, SAVEGAME_VERSION ); + return 0; + } + + // turn the r_world->Doors.doors back to pointers + for ( i = 0 ; i < r_world->Doors.doornum ; i++ ) { + int index = (int)r_world->Doors.Doors[i]; + assert( index >= 0 && index < 4096 ); + r_world->Doors.Doors[i] = &r_world->Doors.DoorMap[0][0] + index; + } + return 1; +} + + +/* + ================== + iphoneStartMap + + This does not reset the player, so call PL_NewGame( &Player ) if it is a new start. + ================== + */ +void iphoneStartMap( int episodeNum, int mapNum, int skillLevel ) { + char command[128]; + int levelNum = episodeNum*10+mapNum; + + Com_Printf( "iphoneStartMap( %i, %i, %i )\n", episodeNum, mapNum, skillLevel ); + + // get the sound playing + Sound_Update( vnull, vnull, vnull, vnull ); + + // clean up game feedback + damageflash = 0; + bonusFrameNum = 0; + attackDirTime[0] = 0; + attackDirTime[1] = 0; + + // note that this has been tried now + currentMap.mapFlags[currentMap.skill][levelNum] |= MF_TRIED; + + // start the game + currentMap.episode = episodeNum; + currentMap.map = mapNum; + currentMap.skill = skillLevel; + currentMap.levelCompleted = 0; + + Cvar_SetValue( skill->name, skillLevel ); + Cvar_SetValue( episode->name, episodeNum ); + sprintf( command, "w%i%i", currentMap.episode, currentMap.map ); + Client_PrepRefresh( command ); + + menuState = IPM_GAME; +} + +/* + ================== + iphoneMainMenu + + ================== + */ +void iphoneMainMenu() { + char str[80]; + float scale = 40 / 32.0; + + iphoneDrawPic( 480-256, 0, 256, 128, "iphone/wolf_logo.tga" ); +#ifdef EPISODE1 + iphoneDrawPic( -20, 0, 256, 64, "iphone/ep_1.tga" ); + GetMoreLevels( 0, 96 ); +#else + iphoneDrawPic( -20, 0, 256, 64, "iphone/ep_1_6.tga" ); +#endif + iphoneDrawPic( 0, 320 - 128, 128, 128, "iphone/id_logo.tga" ); + + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 80, 128*scale, 64*scale, "iphone/button_resume.tga" ) ) { + // if the game was saved at the intermission screen, immediately + // bring it back up when it is loaded + if ( currentMap.levelCompleted ) { + iphoneStartIntermission( 0 ); + } else { + menuState = IPM_GAME; + } + } + sprintf( str, "E%iM%i", currentMap.episode+1, currentMap.map+1 ); + iphoneCenterText( 300, 80+34*scale, str ); + + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 170, 128*scale, 32*scale, "iphone/button_control.tga" ) ) { + menuState = IPM_CONTROLS; + } + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 220, 128*scale, 32*scale, "iphone/button_new.tga" ) ) { + menuState = IPM_SKILL; + } + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 270, 128*scale, 32*scale, "iphone/button_web.tga" ) ) { + OpenURL( "http://www.idsoftware.com/wolfenstein3dclassic/" ); + } + +} + + +/* + ================== + iphoneControlMenu + + ================== + */ +void iphoneControlMenu() { + int i; + + if ( BackButton() ) { + menuState = IPM_MAIN; + } + + for ( i = 0 ; i < 4 ; i++ ) { + char str[128]; + int remap[4] = { 3,4,1,2}; // artist named them differently than intended... + sprintf( str, "iphone/layout_%i.tga", remap[i] ); + if ( i != controlScheme->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 120 * i, 40, 120, 120, str ) ) { + Cvar_SetValue( controlScheme->name, i ); + } + pfglColor3f( 1, 1, 1 ); + } + + iphoneSlider( 20, 170, 440, 40, "sensitivity", sensitivity, 0, 1 ); + + iphoneSlider( 20, 220, 440, 40, "tilt move speed", tiltMove, 5000, 30000 ); + if ( tiltMove->value == 5000 ) { + Cvar_SetValue( tiltMove->name, 0 ); + } + if ( tiltMove->value ) { + Cvar_SetValue( tiltTurn->name, 0 ); + } + iphoneSlider( 20, 270, 440, 40, "tilt turn speed", tiltTurn, 500, 3000 ); + if ( tiltTurn->value == 500 ) { + Cvar_SetValue( tiltTurn->name, 0 ); + } + if ( tiltTurn->value ) { + Cvar_SetValue( tiltMove->name, 0 ); + } + + //iphoneSlider( 20, 280, 440, 40, "tilt fire", tiltFire, 0, 1 ); + +} + +/* + ================== + iphoneSkillMenu + + ================== + */ +void iphoneSkillMenu() { + int s; + char str[64]; + + if ( BackButton() ) { + menuState = IPM_MAIN; + } + + // highlight the current skill selection + s = (int)skill->value; +// R_Draw_Fill( 80, 40+64*s, 320, 64, highlightColor ); + + for ( s = 0 ; s < 4 ; s++ ) { + my_snprintf( str, sizeof( str ), "iphone/button_skill%i.tga", s+1 ); + + if ( s != (int)skill->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 112, 40+64*s, 256, 64, str ) ) { + Cvar_SetValue( skill->name, s ); + menuState = IPM_EPISODE; + } + pfglColor3f( 1, 1, 1 ); + } +} + +/* + ================== + iphoneEpisodeMenu + + ================== + */ +void iphoneEpisodeMenu() { + int e; + char str[64]; +#ifdef EPISODE1 + int numE = 1; +#else + int numE = 6; +#endif + + if ( BackButton() ) { + menuState = IPM_SKILL; + } + + // 96 x 48 images + for ( e = 0 ; e < numE ; e++ ) { + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", e+1 ); + + if ( e != (int)episode->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 48, 32+48*e, 384, 48, str ) ) { + Cvar_SetValue( episode->name, e ); + menuState = IPM_MAPS; + } + pfglColor3f( 1, 1, 1 ); + } + +#ifdef EPISODE1 + // buy more episodes button + GetMoreLevels( 240 - 64, 200 ); +#endif +} + +/* + ================== + iphoneMapMenu + + ================== + */ +void iphoneMapMenu() { + int e, m, s; + char str[64]; + + if ( BackButton() ) { + menuState = IPM_EPISODE; + } + + // draw the level selection + e = episode->value; + if ( e < 0 ) { + e = 0; + } + if ( e > 5 ) { + e = 5; + } + s = skill->value; + if ( s < 0 ) { + s = 0; + } + if ( s > 3 ) { + s = 3; + } + + // draw the episode selection + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", e+1 ); + iphoneDrawPicWithTouch( 96, 0, 384, 48, str ); + + // draw the individual maps + for ( m = 0 ; m < 10 ; m++ ) { + int x; + int y; + colour4_t colorSecret = { 32, 32, 32, 255 }; + colour4_t colorNoTry = { 0, 0, 0, 255 }; + colour4_t colorTried = { 80, 80, 0, 255 }; + colour4_t colorCompleted = { 0, 80, 0, 255 }; + + if ( m == 9 ) { + sprintf( str, "SECRET" ); + x = 120; + y = 90 + 160; + } else if ( m == 8 ) { + sprintf( str, "BOSS" ); + x = 360; + y = 90 + 160; + } else { + sprintf( str, "LEVEL %i", m+1 ); + x = 60 + 120 * ( m % 4 ); + y = 90 + 80 * ( m / 4 ); + } + + unsigned char *color = colorNoTry; + // decide on the background color + int levelNum = e*10+m; + int ch = currentMap.mapFlags[s][levelNum]; + // bit1 = attempted + // bit2 = completed + // bit3 = 100% kills + // bit4 = 100% secrets + // bit5 = 100% treasure + if ( m == 9 && !( ch & MF_TRIED ) ) { + color = colorSecret; + } if ( ch & MF_COMPLETED ) { + color = colorCompleted; + } else if ( ch & MF_TRIED ) { + color = colorTried; + } else { + color = colorNoTry; + } + + // blink the level you are currently on + if ( ( iphoneFrameNum & 8 ) && levelNum == currentMap.map && e == currentMap.episode ) { + color = colorNoTry; + } + + // draw the level text and check for button hit + if ( TouchDown( x-46, y-9, 88, 32 ) ) { + color = colorPressed; + } + R_Draw_Fill( x-46, y-9, 88, 32, color ); + iphoneCenterText( x, y, str ); + + // draw awards + if ( ch & MF_KILLS ) { + iphoneDrawPic( x-46,y+23, 22, 22, "iphone/kills.tga" ); + } + if ( ch & MF_SECRETS ) { + iphoneDrawPic( x-24,y+23, 22, 22, "iphone/secrets.tga" ); + } + if ( ch & MF_TREASURE ) { + iphoneDrawPic( x-2,y+23, 22, 22, "iphone/treasure.tga" ); + } + if ( ch & MF_TIME ) { + iphoneDrawPic( x+20,y+23, 22, 22, "iphone/partime.tga" ); + } + + // don't let them go to the secret level unless they earned it + if ( m == 9 && !( ch & MF_TRIED ) ) { + continue; + } + + if ( TouchReleased( x - 46, y - 9, 88, 32 ) ) { + PL_NewGame( &Player ); + iphoneStartMap( e, m, s ); + } + } +} + +/* + ================== + iphoneStartIntermission + + The framesFromNow value allow boss death animations to be triggered + ================== + */ +void iphoneStartIntermission( int framesFromNow ) { + // this goes in the savegame if they save at the intermission point, + // which will cause it to come back up there on return + currentMap.levelCompleted = 1; + + // mark this level as having been completed for the level selection menu + int mapNum = currentMap.episode * 10 + currentMap.map; + + // note that this has been tried now + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_COMPLETED; + + // mark the awards + if ( levelstate.time / 70.0f < levelstate.fpartime * 60 ) { // fpartime is in minutes, time is in tics + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_TIME; + } + if( levelstate.killed_monsters == levelstate.total_monsters ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_KILLS; + } + if( levelstate.found_secrets == levelstate.total_secrets ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_SECRETS; + } + if( levelstate.found_treasure == levelstate.total_treasure ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_TREASURE; + } + + intermissionStartFrameNum = iphoneFrameNum; + + if ( framesFromNow ) { + intermissionTriggerFrame = iphoneFrameNum + framesFromNow; + return; + } + + intermissionTriggerFrame = 0; + menuState = IPM_INTERMISSION; + hasReleased = 0; // ensure touch up before skipping intermission +} + +/* + ================== + DrawDigit + + ================== + */ +void DrawDigit( int x, int y, int digit ) { + R_Bind( numberPics[digit]->texnum ); + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0, 0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1, 0 ); pfglVertex2i( x+32, y ); + pfglTexCoord2f( 1, 1 ); pfglVertex2i( x+32, y+32 ); + pfglTexCoord2f( 0, 1 ); pfglVertex2i( x, y+32 ); + + pfglEnd(); +} + +void DrawDoubleDigit( int x, int y, int number ) { + int step = 32; + if ( number >= 100 ) { + // cram three digits into the same space + DrawDigit( x-8, y, number / 100 ); + number %= 100; + x += 16; + step = 24; + } + if ( number >= 10 ) { + DrawDigit( x, y, number / 10 ); + number %= 10; + } + DrawDigit( x+step, y, number ); +} + +void DrawTime( int x, int y, int seconds ) { + int min = seconds / 60; + int sec = seconds % 60; + + DrawDoubleDigit( x, y, min ); +// DrawDoubleDigit( x+76, y, sec ); + // always print both digits of seconds, so 2:00 prints correctly + DrawDigit( x+76, y, sec / 10 ); + DrawDigit( x+76+32, y, sec % 10 ); +} + +void DrawRatio( int y, int got, int total, const char *bonusPic ) { + DrawDoubleDigit( 285, y, got ); + DrawDoubleDigit( 361, y, total ); + + // draw the award icon + if ( got == total ) { + iphoneDrawPic( 480 - 40, y, 32, 32, bonusPic ); + } +} + +/* + ================== + iphoneIntermission + + ================== + */ +void iphoneIntermission() { + int nextLevel = 0; + char str[128]; + + iphoneDrawPic( 0, 0, 480, 320, "iphone/intermission.tga" ); + + // episode + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", currentMap.episode+1 ); + iphoneDrawPic( 0, 0, 384, 48, str ); + + // level + iphoneDrawNumber( 430, 0, currentMap.map + 1, 48, 48 ); + + // par / time + DrawTime( 51, 63, levelstate.fpartime * 60 ); // fpartime is in minutes + DrawTime( 285, 63, levelstate.time / 70 ); // levelstate.time is in tics + if ( levelstate.time/70 <= levelstate.fpartime * 60 ) { + iphoneDrawPic( 480 - 40, 63, 32, 32, "iphone/partime.tga" ); + } + + // ratios + DrawRatio( 124, levelstate.killed_monsters, levelstate.total_monsters, "iphone/kills.tga" ); + DrawRatio( 189, levelstate.found_secrets, levelstate.total_secrets, "iphone/secrets.tga" ); + DrawRatio( 255, levelstate.found_treasure, levelstate.total_treasure, "iphone/treasure.tga" ); + + // require all touches off before the intermission can exit + if ( numTouches == 0 && hasReleased == 0 ) { + hasReleased = 1; + return; // don't let the TouchReleased immediately fire + } + if ( !hasReleased ) { + return; + } + + //---------------------- + // tap for next level + //---------------------- + if ( !TouchReleased( 0, 0, 480, 320 ) ) { + return; + } + + menuState = IPM_GAME; + + PL_NextLevel( &Player ); + + if( g_version->value == SPEAROFDESTINY ) { + } + else + { + int currentLevel = currentMap.episode * 10 + currentMap.map; + + if( Player.playstate == ex_secretlevel ) { + switch( currentLevel ) { + case 0: nextLevel = 9; break; + case 10: nextLevel = 19; break; + case 26: nextLevel = 29; break; + case 32: nextLevel = 39; break; + case 44: nextLevel = 49; break; + case 52: nextLevel = 59; break; + } + } else { + switch ( currentLevel ) { + case 8: + case 18: + case 28: + case 38: + case 48: + case 58: + // go back to the episode select screen + menuState = IPM_VICTORY; + Sound_StartBGTrack( "music/URAHERO.ogg", "music/URAHERO.ogg" ); + return; + case 9: nextLevel = 1; break; + case 19: nextLevel = 11; break; + case 29: nextLevel = 27; break; + case 39: nextLevel = 33; break; + case 49: nextLevel = 44; break; + case 59: nextLevel = 53; break; + default: nextLevel = currentLevel + 1; break; + } + } + } + + iphoneStartMap( (nextLevel/10), (nextLevel%10), skill->value ); +} + +/* + ================== + iphoneVictory + + ================== + */ +void iphoneVictory() { + iphoneDrawPic( 0, 0, 480, 320, "iphone/victory.tga" ); + if ( !TouchReleased( 0, 0, 480, 320 ) ) { + return; + } + menuState = IPM_EPISODE; +} + +/* + ================== + iphoneAutomap + + ================== + */ +float mapOrigin[2]; +float mapCenterY; +float mapScale; + +typedef struct { + W8 x, y; + short texnum; +} mapTile_t; +#define MAPTILE_SPRITE_FLAG 1024 +#define MAX_MAP_TILES 5000 // 4096 tiles + sprites +mapTile_t mapTiles[MAX_MAP_TILES]; +int numMapTiles; + +int MapTileSort( const void *a, const void *b ) { + return ((mapTile_t *)a)->texnum - ((mapTile_t *)b)->texnum; +} + +void iphoneOpenAutomap() { + mapTile_t *mt = mapTiles; + numMapTiles = 0; + int x, y; + int xx, yy; + W32 tx, ty, n; + sprite_t* sprt; + + mapOrigin[0] = Player.position.origin[0] / (float)TILEGLOBAL; + mapOrigin[1] = Player.position.origin[1] / (float)TILEGLOBAL; + mapScale = 10; + menuState = IPM_AUTOMAP; + + // identify all the tiles to fill in + for( x = 0 ; x < 64; ++x ) { + for( y = 0 ; y < 64; ++y ) { + if ( r_world->tilemap[ x ][ y ] & ( WALL_TILE | PUSHWALL_TILE ) ) { + int visible = 0; + // check all 8 surrounding tiles for visibility + for ( xx = -1 ; xx <= 1 ; xx++ ) { + if ( x + xx < 0 ) { + continue; + } + if ( x + xx > 63 ) { + continue; + } + for ( yy = -1 ; yy <= 1 ; yy++ ) { + if ( y + yy < 0 ) { + continue; + } + if ( y + yy > 63 ) { + continue; + } + if ( r_world->tileEverVisible[x+xx][y+yy] ) { + visible = 1; + break; + } + } + } + if ( !visible ) { + continue; + } + int tex = r_world->wall_tex_y[ x ][ y ]; + // special hack for the elevator switch tile, which is always + // facing east west for the switch, and north south for the railing + if ( tex == 40 && ( ( x>0 && r_world->tileEverVisible[x+1][y] ) + || ( x < 63 && r_world->tileEverVisible[x-1][y] ) ) ) { + tex = r_world->wall_tex_x[ x ][ y ]; + } + if ( tex < 0x6a ) { // skip pushwall destinations + assert( tex >= 0 && tex < 1000 ); + mt->x = x; + mt->y = y; + mt->texnum = tex; + if ( !wallTextures[mt->texnum] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", mt->texnum ); + wallTextures[mt->texnum] = TM_FindTexture( name, TT_Wall ); + assert( wallTextures[mt->texnum] ); + } + mt++; + continue; + } + } + if ( !r_world->tileEverVisible[x][y] ) { + continue; + } + if( r_world->tilemap[ x ][ y ] & DOOR_TILE ) { + mt->x = x; + mt->y = y; + mt->texnum = r_world->Doors.DoorMap[ x ][ y ].texture; + if ( !wallTextures[ mt->texnum] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", mt->texnum ); + wallTextures[mt->texnum] = TM_FindTexture( name, TT_Wall ); + assert( wallTextures[mt->texnum] ); + } + mt++; + continue; + } + // solid floor + mt->x = x; + mt->y = y; + mt->texnum = -1; + mt++; + } + } + + // add solid sprite objects + for( n = 0, sprt = Spr_Sprites; n < n_of_sprt; ++n, ++sprt ) { + if( sprt->flags & SPRT_REMOVE ) { + continue; + } + if ( sprt->tex[0] >= SPR_GRD_S_1 ) { + // don't draw enemies, only static sprites + continue; + } + + tx = sprt->tilex; + ty = sprt->tiley; + + if( tx > 63 ) { + continue; + } + if( ty > 63 ) { + continue; + } + if ( !r_world->tileEverVisible[tx][ty] ) { + continue; + } + mt->x = tx; + mt->y = ty; + mt->texnum = MAPTILE_SPRITE_FLAG | sprt->tex[0]; + mt++; + + if ( !spriteTextures[ sprt->tex[0] ] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "sprites/%.3d.tga", sprt->tex[0] ); + spriteTextures[sprt->tex[0]] = TM_FindTexture( name, TT_Sprite ); + } + + if ( mt == &mapTiles[MAX_MAP_TILES] ) { + break; // list is full, some items won't show (shouldn't happen) + } + } + + // sort the tiles to be drawn by texture + numMapTiles = mt - mapTiles; + + qsort( mapTiles, numMapTiles, sizeof( mapTiles[0] ), MapTileSort ); +} + +void iphoneAutomap() { + mapTile_t *mt; + float px, py; + float angle, c, s; + int texnum; + + // do touch ops before drawing for minimum latency + + // drag for scrolling + if ( numTouches == 1 ) { + if ( numPrevTouches == 1 ) { + mapOrigin[0] -= ( touches[0][0] - prevTouches[0][0] ) / mapScale; + mapOrigin[1] += ( touches[0][1] - prevTouches[0][1] ) / mapScale; + } + } + + // pinch for scaling + if ( numTouches == 2 ) { + if ( numPrevTouches == 2 ) { + float curDist = sqrt( + ( touches[0][0] - touches[1][0] ) * ( touches[0][0] - touches[1][0] ) + + ( touches[0][1] - touches[1][1] ) * ( touches[0][1] - touches[1][1] ) ); + float prevDist = sqrt( + ( prevTouches[0][0] - prevTouches[1][0] ) * ( prevTouches[0][0] - prevTouches[1][0] ) + + ( prevTouches[0][1] - prevTouches[1][1] ) * ( prevTouches[0][1] - prevTouches[1][1] ) ); + if ( prevDist == 0 ) { + prevDist = curDist; + } + mapScale *= curDist / prevDist; + if ( mapScale < 4 ) { + mapScale = 4; + } + if ( mapScale > 64 ) { + mapScale = 64; + } + } + + } + + // todo -- double tap for center on player + + + // set up matrix for drawing in tile units + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( mapOrigin[0]-240.0 / mapScale, mapOrigin[0]+240.0 / mapScale, + mapOrigin[1]-160.0 / mapScale, mapOrigin[1]+160.0 / mapScale, -99999, 99999 ); + + mt = mapTiles; + texnum = 99999; + for ( int i = 0 ; i < numMapTiles ; i++, mt++ ) { + if ( texnum != mt->texnum ) { + texnum = mt->texnum; + if ( i != 0 ) { + pfglEnd(); + } + if ( mt->texnum == -1 ) { + qglDisable( GL_TEXTURE_2D ); + pfglColor3f( r_world->floorColour[0]/255.0, r_world->floorColour[1]/255.0, r_world->floorColour[2]/255.0 ); + } else if ( mt->texnum & MAPTILE_SPRITE_FLAG ) { + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + R_Bind( spriteTextures[mt->texnum&~MAPTILE_SPRITE_FLAG]->texnum ); + } else { + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + R_Bind( wallTextures[mt->texnum]->texnum ); + } + pfglBegin( GL_QUADS ); + } + pfglTexCoord2f( 0, 1 ); + pfglVertex2i( mt->x, mt->y ); + pfglTexCoord2f( 1, 1 ); + pfglVertex2i( mt->x+1, mt->y ); + pfglTexCoord2f( 1, 0 ); + pfglVertex2i( mt->x+1, mt->y+1 ); + pfglTexCoord2f( 0, 0 ); + pfglVertex2i( mt->x, mt->y+1 ); + } + pfglEnd(); + + // draw the yellow player triangle + qglDisable( GL_TEXTURE_2D ); + if ( iphoneFrameNum & 8 ) { // blink it + pfglColor3f( 1, 1, 0 ); + } else { + pfglColor3f( 0.5, 0.5, 0 ); + } + angle = M_PI * Player.position.angle / (float)ANG_180; + c = cos( angle ); + s = sin( angle ); + px = Player.position.origin[0] / (float)TILEGLOBAL; + py = Player.position.origin[1] / (float)TILEGLOBAL; + pfglBegin( GL_TRIANGLES ); + pfglVertex3f( px + c * 0.5, py + s * 0.5, 0 ); + pfglVertex3f( px - c * 0.5 - s * 0.3, py - s * 0.5 + c * 0.3, 0 ); + pfglVertex3f( px - c * 0.5 + s * 0.3, py - s * 0.5 - c * 0.3, 0 ); + pfglEnd(); + + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + + // back button for returning to game + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( 0, 480, 320, 0, -99999, 99999 ); + if ( BackButton() ) { + menuState = IPM_GAME; + } +} + +void iphoneDrawMenus() { + iphoneDrawPic( 0, 0, 480, 320, "iphone/background_1.tga" ); + + switch ( menuState ) { + case IPM_MAIN: iphoneMainMenu(); break; + case IPM_SKILL: iphoneSkillMenu(); break; + case IPM_EPISODE: iphoneEpisodeMenu(); break; + case IPM_MAPS: iphoneMapMenu(); break; + case IPM_CONTROLS: iphoneControlMenu(); break; + case IPM_INTERMISSION: iphoneIntermission(); break; + case IPM_VICTORY: iphoneVictory(); break; + case IPM_AUTOMAP: iphoneAutomap(); break; + } +} + + diff --git a/wolf3d/newCode/iphone/iphone_qgl.h b/wolf3d/newCode/iphone/iphone_qgl.h new file mode 100644 index 0000000..793ec74 --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_qgl.h @@ -0,0 +1,2392 @@ +/**** This file is autogenerated. Run GenerateQGL.pl to update it ****/ + +#ifndef _IPHONE_QGL_H_ +#define _IPHONE_QGL_H_ + +#ifdef QGL_LOG_GL_CALLS +extern unsigned int QGLLogGLCalls; +#ifdef __cplusplus +extern "C" { +#endif + FILE *QGLDebugFile(void); +#ifdef __cplusplus +} +#endif +#endif + +#include "iphone_qgl_enumerants.h" + + +#ifdef __cplusplus +extern "C" { +#endif + void QGLCheckError(const char *message); +#ifdef __cplusplus +} +#endif +extern unsigned int QGLBeginStarted; + +// This has to be done to avoid infinite recursion between our glGetError wrapper and QGLCheckError() +static inline GLenum _glGetError(void) { + return glGetError(); +} + +// void glAlphaFunc (GLenum func, GLclampf ref); +static inline void qglAlphaFunc(GLenum func, GLclampf ref) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glAlphaFunc(func=%s, ref=%f)\n", StringFromGLEnumerant( func ), ref); +#endif + glAlphaFunc(func, ref); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glAlphaFunc"); +#endif +} + +// void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +static inline void qglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearColor(red=%f, green=%f, blue=%f, alpha=%f)\n", red, green, blue, alpha); +#endif + glClearColor(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearColor"); +#endif +} + +// void glClearDepthf (GLclampf depth); +static inline void qglClearDepthf(GLclampf depth) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearDepthf(depth=%f)\n", depth); +#endif + glClearDepthf(depth); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearDepthf"); +#endif +} + +// void glClipPlanef (GLenum plane, const GLfloat *equation); +static inline void qglClipPlanef(GLenum plane, const GLfloat *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClipPlanef(plane=%s, equation=%p)\n", StringFromGLEnumerant( plane ), equation); +#endif + glClipPlanef(plane, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClipPlanef"); +#endif +} + +// void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +// void glDepthRangef (GLclampf zNear, GLclampf zFar); +static inline void qglDepthRangef(GLclampf zNear, GLclampf zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthRangef(zNear=%f, zFar=%f)\n", zNear, zFar); +#endif + glDepthRangef(zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthRangef"); +#endif +} + +// void glFogf (GLenum pname, GLfloat param); +static inline void qglFogf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glFogf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogf"); +#endif +} + +// void glFogfv (GLenum pname, const GLfloat *params); +static inline void qglFogfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glFogfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogfv"); +#endif +} + +// void glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +static inline void qglFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrustumf(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\n", left, right, bottom, top, zNear, zFar); +#endif + glFrustumf(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrustumf"); +#endif +} + +// void glGetClipPlanef (GLenum pname, GLfloat *equation); +static inline void qglGetClipPlanef(GLenum pname, GLfloat *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetClipPlanef(pname=%s, equation=%p)\n", StringFromGLEnumerant( pname ), equation); +#endif + glGetClipPlanef(pname, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetClipPlanef"); +#endif +} + +// void glGetFloatv (GLenum pname, GLfloat *params); +static inline void qglGetFloatv(GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetFloatv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetFloatv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetFloatv"); +#endif +} + +// void glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +static inline void qglGetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetLightfv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glGetLightfv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetLightfv"); +#endif +} + +// void glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +static inline void qglGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetMaterialfv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glGetMaterialfv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetMaterialfv"); +#endif +} + +// void glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params); +static inline void qglGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnvfv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnvfv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnvfv"); +#endif +} + +// void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +static inline void qglGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameterfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameterfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameterfv"); +#endif +} + +// void glLightModelf (GLenum pname, GLfloat param); +static inline void qglLightModelf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glLightModelf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelf"); +#endif +} + +// void glLightModelfv (GLenum pname, const GLfloat *params); +static inline void qglLightModelfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glLightModelfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelfv"); +#endif +} + +// void glLightf (GLenum light, GLenum pname, GLfloat param); +static inline void qglLightf(GLenum light, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightf(light=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), param); +#endif + glLightf(light, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightf"); +#endif +} + +// void glLightfv (GLenum light, GLenum pname, const GLfloat *params); +static inline void qglLightfv(GLenum light, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightfv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glLightfv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightfv"); +#endif +} + +// void glLineWidth (GLfloat width); +static inline void qglLineWidth(GLfloat width) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLineWidth(width=%f)\n", width); +#endif + glLineWidth(width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLineWidth"); +#endif +} + +// void glLoadMatrixf (const GLfloat *m); +static inline void qglLoadMatrixf(const GLfloat *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadMatrixf(m=%p)\n", m); +#endif + glLoadMatrixf(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadMatrixf"); +#endif +} + +// void glMaterialf (GLenum face, GLenum pname, GLfloat param); +static inline void qglMaterialf(GLenum face, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialf(face=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), param); +#endif + glMaterialf(face, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialf"); +#endif +} + +// void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +static inline void qglMaterialfv(GLenum face, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialfv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glMaterialfv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialfv"); +#endif +} + +// void glMultMatrixf (const GLfloat *m); +static inline void qglMultMatrixf(const GLfloat *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultMatrixf(m=%p)\n", m); +#endif + glMultMatrixf(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultMatrixf"); +#endif +} + +// void glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +static inline void qglMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultiTexCoord4f(target=%s, s=%f, t=%f, r=%f, q=%f)\n", StringFromGLEnumerant( target ), s, t, r, q); +#endif + glMultiTexCoord4f(target, s, t, r, q); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultiTexCoord4f"); +#endif +} + +// void glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +static inline void qglNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormal3f(nx=%f, ny=%f, nz=%f)\n", nx, ny, nz); +#endif + glNormal3f(nx, ny, nz); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormal3f"); +#endif +} + +// void glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +static inline void qglOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glOrthof(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\n", left, right, bottom, top, zNear, zFar); +#endif + glOrthof(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glOrthof"); +#endif +} + +// void glPointParameterf (GLenum pname, GLfloat param); +static inline void qglPointParameterf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glPointParameterf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterf"); +#endif +} + +// void glPointParameterfv (GLenum pname, const GLfloat *params); +static inline void qglPointParameterfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glPointParameterfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterfv"); +#endif +} + +// void glPointSize (GLfloat size); +static inline void qglPointSize(GLfloat size) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSize(size=%f)\n", size); +#endif + glPointSize(size); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSize"); +#endif +} + +// void glPolygonOffset (GLfloat factor, GLfloat units); +static inline void qglPolygonOffset(GLfloat factor, GLfloat units) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPolygonOffset(factor=%f, units=%f)\n", factor, units); +#endif + glPolygonOffset(factor, units); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPolygonOffset"); +#endif +} + +// void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +static inline void qglRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glRotatef(angle=%f, x=%f, y=%f, z=%f)\n", angle, x, y, z); +#endif + glRotatef(angle, x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glRotatef"); +#endif +} + +// void glScalef (GLfloat x, GLfloat y, GLfloat z); +static inline void qglScalef(GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScalef(x=%f, y=%f, z=%f)\n", x, y, z); +#endif + glScalef(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScalef"); +#endif +} + +// void glTexEnvf (GLenum target, GLenum pname, GLfloat param); +static inline void qglTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvf(target=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvf(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvf"); +#endif +} + +// void glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +static inline void qglTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnvfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvfv"); +#endif +} + +// void glTexParameterf (GLenum target, GLenum pname, GLfloat param); +static inline void qglTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterf(target=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameterf(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterf"); +#endif +} + +// void glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +static inline void qglTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameterfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterfv"); +#endif +} + +// void glTranslatef (GLfloat x, GLfloat y, GLfloat z); +static inline void qglTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTranslatef(x=%f, y=%f, z=%f)\n", x, y, z); +#endif + glTranslatef(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTranslatef"); +#endif +} + +// void glActiveTexture (GLenum texture); +static inline void qglActiveTexture(GLenum texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glActiveTexture(texture=%s)\n", StringFromGLEnumerant( texture )); +#endif + glActiveTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glActiveTexture"); +#endif +} + +// void glAlphaFuncx (GLenum func, GLclampx ref); +static inline void qglAlphaFuncx(GLenum func, GLclampx ref) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glAlphaFuncx(func=%s, ref=%ld)\n", StringFromGLEnumerant( func ), ref); +#endif + glAlphaFuncx(func, ref); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glAlphaFuncx"); +#endif +} + +// void glBindBuffer (GLenum target, GLuint buffer); +static inline void qglBindBuffer(GLenum target, GLuint buffer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBindBuffer(target=%s, buffer=%lu)\n", StringFromGLEnumerant( target ), buffer); +#endif + glBindBuffer(target, buffer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBindBuffer"); +#endif +} + +// void glBindTexture (GLenum target, GLuint texture); +static inline void qglBindTexture(GLenum target, GLuint texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBindTexture(target=%s, texture=%lu)\n", StringFromGLEnumerant( target ), texture); +#endif + glBindTexture(target, texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBindTexture"); +#endif +} + +// void glBlendFunc (GLenum sfactor, GLenum dfactor); +static inline void qglBlendFunc(GLenum sfactor, GLenum dfactor) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBlendFunc(sfactor=%s, dfactor=%s)\n", StringFromGLEnumerant( sfactor ), StringFromGLEnumerant( dfactor )); +#endif + glBlendFunc(sfactor, dfactor); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBlendFunc"); +#endif +} + +// void glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +static inline void qglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBufferData(target=%s, size=%ld, data=%p, usage=%s)\n", StringFromGLEnumerant( target ), size, data, StringFromGLEnumerant( usage )); +#endif + glBufferData(target, size, data, usage); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBufferData"); +#endif +} + +// void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +static inline void qglBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBufferSubData(target=%s, offset=%ld, size=%ld, data=%p)\n", StringFromGLEnumerant( target ), offset, size, data); +#endif + glBufferSubData(target, offset, size, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBufferSubData"); +#endif +} + +// void glClear (GLbitfield mask); +static inline void qglClear(GLbitfield mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClear(mask=%lu)\n", mask); +#endif + glClear(mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClear"); +#endif +} + +// void glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +static inline void qglClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearColorx(red=%ld, green=%ld, blue=%ld, alpha=%ld)\n", red, green, blue, alpha); +#endif + glClearColorx(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearColorx"); +#endif +} + +// void glClearDepthx (GLclampx depth); +static inline void qglClearDepthx(GLclampx depth) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearDepthx(depth=%ld)\n", depth); +#endif + glClearDepthx(depth); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearDepthx"); +#endif +} + +// void glClearStencil (GLint s); +static inline void qglClearStencil(GLint s) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearStencil(s=%ld)\n", s); +#endif + glClearStencil(s); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearStencil"); +#endif +} + +// void glClientActiveTexture (GLenum texture); +static inline void qglClientActiveTexture(GLenum texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClientActiveTexture(texture=%s)\n", StringFromGLEnumerant( texture )); +#endif + glClientActiveTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClientActiveTexture"); +#endif +} + +// void glClipPlanex (GLenum plane, const GLfixed *equation); +static inline void qglClipPlanex(GLenum plane, const GLfixed *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClipPlanex(plane=%s, equation=%p)\n", StringFromGLEnumerant( plane ), equation); +#endif + glClipPlanex(plane, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClipPlanex"); +#endif +} + +// void glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +static inline void qglColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColor4ub(red=%u, green=%u, blue=%u, alpha=%u)\n", red, green, blue, alpha); +#endif + glColor4ub(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColor4ub"); +#endif +} + +// void glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +static inline void qglColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColor4x(red=%ld, green=%ld, blue=%ld, alpha=%ld)\n", red, green, blue, alpha); +#endif + glColor4x(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColor4x"); +#endif +} + +// void glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +static inline void qglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColorMask(red=%u, green=%u, blue=%u, alpha=%u)\n", red, green, blue, alpha); +#endif + glColorMask(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColorMask"); +#endif +} + +// void glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColorPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glColorPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColorPointer"); +#endif +} + +// void glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +static inline void qglCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCompressedTexImage2D(target=%s, level=%ld, internalformat=%s, width=%ld, height=%ld, border=%ld, imageSize=%ld, data=%p)\n", StringFromGLEnumerant( target ), level, StringFromGLEnumerant( internalformat ), width, height, border, imageSize, data); +#endif + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCompressedTexImage2D"); +#endif +} + +// void glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +static inline void qglCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCompressedTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, width=%ld, height=%ld, format=%s, imageSize=%ld, data=%p)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, width, height, StringFromGLEnumerant( format ), imageSize, data); +#endif + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCompressedTexSubImage2D"); +#endif +} + +// void glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +static inline void qglCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCopyTexImage2D(target=%s, level=%ld, internalformat=%s, x=%ld, y=%ld, width=%ld, height=%ld, border=%ld)\n", StringFromGLEnumerant( target ), level, StringFromGLEnumerant( internalformat ), x, y, width, height, border); +#endif + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCopyTexImage2D"); +#endif +} + +// void glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCopyTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, x=%ld, y=%ld, width=%ld, height=%ld)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, x, y, width, height); +#endif + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCopyTexSubImage2D"); +#endif +} + +// void glCullFace (GLenum mode); +static inline void qglCullFace(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCullFace(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glCullFace(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCullFace"); +#endif +} + +// void glDeleteBuffers (GLsizei n, const GLuint *buffers); +static inline void qglDeleteBuffers(GLsizei n, const GLuint *buffers) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDeleteBuffers(n=%ld, buffers=%p)\n", n, buffers); +#endif + glDeleteBuffers(n, buffers); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDeleteBuffers"); +#endif +} + +// void glDeleteTextures (GLsizei n, const GLuint *textures); +static inline void qglDeleteTextures(GLsizei n, const GLuint *textures) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDeleteTextures(n=%ld, textures=%p)\n", n, textures); +#endif + glDeleteTextures(n, textures); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDeleteTextures"); +#endif +} + +// void glDepthFunc (GLenum func); +static inline void qglDepthFunc(GLenum func) +{ + func = GL_ALWAYS; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthFunc(func=%s)\n", StringFromGLEnumerant( func )); +#endif + glDepthFunc(func); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthFunc"); +#endif +} + +// void glDepthMask (GLboolean flag); +static inline void qglDepthMask(GLboolean flag) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthMask(flag=%u)\n", flag); +#endif + glDepthMask(flag); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthMask"); +#endif +} + +// void glDepthRangex (GLclampx zNear, GLclampx zFar); +static inline void qglDepthRangex(GLclampx zNear, GLclampx zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthRangex(zNear=%ld, zFar=%ld)\n", zNear, zFar); +#endif + glDepthRangex(zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthRangex"); +#endif +} + +// void glDisable (GLenum cap); +static inline void qglDisable(GLenum cap) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDisable(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + glDisable(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDisable"); +#endif +} + +// void glDisableClientState (GLenum array); +static inline void qglDisableClientState(GLenum array) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDisableClientState(array=%s)\n", StringFromGLEnumerant( array )); +#endif + glDisableClientState(array); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDisableClientState"); +#endif +} + +// void glDrawArrays (GLenum mode, GLint first, GLsizei count); +static inline void qglDrawArrays(GLenum mode, GLint first, GLsizei count) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawArrays(mode=%s, first=%ld, count=%ld)\n", StringFromGLEnumerant( mode ), first, count); +#endif + glDrawArrays(mode, first, count); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawArrays"); +#endif +} + +// void glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +static inline void qglDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawElements(mode=%s, count=%ld, type=%s, indices=%p)\n", StringFromGLEnumerant( mode ), count, StringFromGLEnumerant( type ), indices); +#endif + glDrawElements(mode, count, type, indices); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawElements"); +#endif +} + +// void glEnable (GLenum cap); +static inline void qglEnable(GLenum cap) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glEnable(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + glEnable(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glEnable"); +#endif +} + +// void glEnableClientState (GLenum array); +static inline void qglEnableClientState(GLenum array) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glEnableClientState(array=%s)\n", StringFromGLEnumerant( array )); +#endif + glEnableClientState(array); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glEnableClientState"); +#endif +} + +// void glFinish (void); +static inline void qglFinish(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFinish(void)\n"); +#endif + glFinish(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFinish"); +#endif +} + +// void glFlush (void); +static inline void qglFlush(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFlush(void)\n"); +#endif + glFlush(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFlush"); +#endif +} + +// void glFogx (GLenum pname, GLfixed param); +static inline void qglFogx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glFogx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogx"); +#endif +} + +// void glFogxv (GLenum pname, const GLfixed *params); +static inline void qglFogxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glFogxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogxv"); +#endif +} + +// void glFrontFace (GLenum mode); +static inline void qglFrontFace(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrontFace(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glFrontFace(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrontFace"); +#endif +} + +// void glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +static inline void qglFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrustumx(left=%ld, right=%ld, bottom=%ld, top=%ld, zNear=%ld, zFar=%ld)\n", left, right, bottom, top, zNear, zFar); +#endif + glFrustumx(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrustumx"); +#endif +} + +// void glGetBooleanv (GLenum pname, GLboolean *params); +static inline void qglGetBooleanv(GLenum pname, GLboolean *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetBooleanv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetBooleanv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetBooleanv"); +#endif +} + +// void glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +static inline void qglGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetBufferParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetBufferParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetBufferParameteriv"); +#endif +} + +// void glGetClipPlanex (GLenum pname, GLfixed eqn[4]); +static inline void qglGetClipPlanex(GLenum pname, GLfixed eqn[4]) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetClipPlanex(pname=%s, eqn=%ld)\n", StringFromGLEnumerant( pname ), eqn); +#endif + glGetClipPlanex(pname, eqn); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetClipPlanex"); +#endif +} + +// void glGenBuffers (GLsizei n, GLuint *buffers); +static inline void qglGenBuffers(GLsizei n, GLuint *buffers) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGenBuffers(n=%ld, buffers=%p)\n", n, buffers); +#endif + glGenBuffers(n, buffers); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGenBuffers"); +#endif +} + +// void glGenTextures (GLsizei n, GLuint *textures); +static inline void qglGenTextures(GLsizei n, GLuint *textures) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGenTextures(n=%ld, textures=%p)\n", n, textures); +#endif + glGenTextures(n, textures); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGenTextures"); +#endif +} + +// GLenum glGetError (void); +static inline GLenum qglGetError(void) +{ + GLenum returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetError(void)\n"); +#endif + returnValue = glGetError(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetError"); +#endif + return returnValue; +} + +// void glGetFixedv (GLenum pname, GLfixed *params); +static inline void qglGetFixedv(GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetFixedv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetFixedv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetFixedv"); +#endif +} + +// void glGetIntegerv (GLenum pname, GLint *params); +static inline void qglGetIntegerv(GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetIntegerv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetIntegerv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetIntegerv"); +#endif +} + +// void glGetLightxv (GLenum light, GLenum pname, GLfixed *params); +static inline void qglGetLightxv(GLenum light, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetLightxv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glGetLightxv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetLightxv"); +#endif +} + +// void glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params); +static inline void qglGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetMaterialxv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glGetMaterialxv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetMaterialxv"); +#endif +} + +// void glGetPointerv (GLenum pname, void **params); +static inline void qglGetPointerv(GLenum pname, void **params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetPointerv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetPointerv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetPointerv"); +#endif +} + +// const GLubyte * glGetString (GLenum name); +static inline const GLubyte * qglGetString(GLenum name) +{ + const GLubyte * returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetString(name=%s)\n", StringFromGLEnumerant( name )); +#endif + returnValue = glGetString(name); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetString"); +#endif + return returnValue; +} + +// void glGetTexEnviv (GLenum env, GLenum pname, GLint *params); +static inline void qglGetTexEnviv(GLenum env, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnviv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnviv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnviv"); +#endif +} + +// void glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params); +static inline void qglGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnvxv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnvxv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnvxv"); +#endif +} + +// void glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +static inline void qglGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameteriv"); +#endif +} + +// void glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params); +static inline void qglGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameterxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameterxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameterxv"); +#endif +} + +// void glHint (GLenum target, GLenum mode); +static inline void qglHint(GLenum target, GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glHint(target=%s, mode=%s)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( mode )); +#endif + glHint(target, mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glHint"); +#endif +} + +// GLboolean glIsBuffer (GLuint buffer); +static inline GLboolean qglIsBuffer(GLuint buffer) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsBuffer(buffer=%lu)\n", buffer); +#endif + returnValue = glIsBuffer(buffer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsBuffer"); +#endif + return returnValue; +} + +// GLboolean glIsEnabled (GLenum cap); +static inline GLboolean qglIsEnabled(GLenum cap) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsEnabled(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + returnValue = glIsEnabled(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsEnabled"); +#endif + return returnValue; +} + +// GLboolean glIsTexture (GLuint texture); +static inline GLboolean qglIsTexture(GLuint texture) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsTexture(texture=%lu)\n", texture); +#endif + returnValue = glIsTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsTexture"); +#endif + return returnValue; +} + +// void glLightModelx (GLenum pname, GLfixed param); +static inline void qglLightModelx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glLightModelx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelx"); +#endif +} + +// void glLightModelxv (GLenum pname, const GLfixed *params); +static inline void qglLightModelxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glLightModelxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelxv"); +#endif +} + +// void glLightx (GLenum light, GLenum pname, GLfixed param); +static inline void qglLightx(GLenum light, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightx(light=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), param); +#endif + glLightx(light, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightx"); +#endif +} + +// void glLightxv (GLenum light, GLenum pname, const GLfixed *params); +static inline void qglLightxv(GLenum light, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightxv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glLightxv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightxv"); +#endif +} + +// void glLineWidthx (GLfixed width); +static inline void qglLineWidthx(GLfixed width) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLineWidthx(width=%ld)\n", width); +#endif + glLineWidthx(width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLineWidthx"); +#endif +} + +// void glLoadIdentity (void); +static inline void qglLoadIdentity(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadIdentity(void)\n"); +#endif + glLoadIdentity(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadIdentity"); +#endif +} + +// void glLoadMatrixx (const GLfixed *m); +static inline void qglLoadMatrixx(const GLfixed *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadMatrixx(m=%p)\n", m); +#endif + glLoadMatrixx(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadMatrixx"); +#endif +} + +// void glLogicOp (GLenum opcode); +static inline void qglLogicOp(GLenum opcode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLogicOp(opcode=%s)\n", StringFromGLEnumerant( opcode )); +#endif + glLogicOp(opcode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLogicOp"); +#endif +} + +// void glMaterialx (GLenum face, GLenum pname, GLfixed param); +static inline void qglMaterialx(GLenum face, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialx(face=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), param); +#endif + glMaterialx(face, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialx"); +#endif +} + +// void glMaterialxv (GLenum face, GLenum pname, const GLfixed *params); +static inline void qglMaterialxv(GLenum face, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialxv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glMaterialxv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialxv"); +#endif +} + +// void glMatrixMode (GLenum mode); +static inline void qglMatrixMode(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMatrixMode(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glMatrixMode(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMatrixMode"); +#endif +} + +// void glMultMatrixx (const GLfixed *m); +static inline void qglMultMatrixx(const GLfixed *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultMatrixx(m=%p)\n", m); +#endif + glMultMatrixx(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultMatrixx"); +#endif +} + +// void glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +static inline void qglMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultiTexCoord4x(target=%s, s=%ld, t=%ld, r=%ld, q=%ld)\n", StringFromGLEnumerant( target ), s, t, r, q); +#endif + glMultiTexCoord4x(target, s, t, r, q); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultiTexCoord4x"); +#endif +} + +// void glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz); +static inline void qglNormal3x(GLfixed nx, GLfixed ny, GLfixed nz) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormal3x(nx=%ld, ny=%ld, nz=%ld)\n", nx, ny, nz); +#endif + glNormal3x(nx, ny, nz); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormal3x"); +#endif +} + +// void glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormalPointer(type=%s, stride=%ld, pointer=%p)\n", StringFromGLEnumerant( type ), stride, pointer); +#endif + glNormalPointer(type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormalPointer"); +#endif +} + +// void glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +static inline void qglOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glOrthox(left=%ld, right=%ld, bottom=%ld, top=%ld, zNear=%ld, zFar=%ld)\n", left, right, bottom, top, zNear, zFar); +#endif + glOrthox(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glOrthox"); +#endif +} + +// void glPixelStorei (GLenum pname, GLint param); +static inline void qglPixelStorei(GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPixelStorei(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glPixelStorei(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPixelStorei"); +#endif +} + +// void glPointParameterx (GLenum pname, GLfixed param); +static inline void qglPointParameterx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glPointParameterx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterx"); +#endif +} + +// void glPointParameterxv (GLenum pname, const GLfixed *params); +static inline void qglPointParameterxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glPointParameterxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterxv"); +#endif +} + +// void glPointSizex (GLfixed size); +static inline void qglPointSizex(GLfixed size) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSizex(size=%ld)\n", size); +#endif + glPointSizex(size); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSizex"); +#endif +} + +// void glPolygonOffsetx (GLfixed factor, GLfixed units); +static inline void qglPolygonOffsetx(GLfixed factor, GLfixed units) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPolygonOffsetx(factor=%ld, units=%ld)\n", factor, units); +#endif + glPolygonOffsetx(factor, units); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPolygonOffsetx"); +#endif +} + +// void glPopMatrix (void); +static inline void qglPopMatrix(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPopMatrix(void)\n"); +#endif + glPopMatrix(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPopMatrix"); +#endif +} + +// void glPushMatrix (void); +static inline void qglPushMatrix(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPushMatrix(void)\n"); +#endif + glPushMatrix(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPushMatrix"); +#endif +} + +// void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +static inline void qglReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glReadPixels(x=%ld, y=%ld, width=%ld, height=%ld, format=%s, type=%s, pixels=%p)\n", x, y, width, height, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glReadPixels(x, y, width, height, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glReadPixels"); +#endif +} + +// void glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +static inline void qglRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glRotatex(angle=%ld, x=%ld, y=%ld, z=%ld)\n", angle, x, y, z); +#endif + glRotatex(angle, x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glRotatex"); +#endif +} + +// void glSampleCoverage (GLclampf value, GLboolean invert); +static inline void qglSampleCoverage(GLclampf value, GLboolean invert) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glSampleCoverage(value=%f, invert=%u)\n", value, invert); +#endif + glSampleCoverage(value, invert); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glSampleCoverage"); +#endif +} + +// void glSampleCoveragex (GLclampx value, GLboolean invert); +static inline void qglSampleCoveragex(GLclampx value, GLboolean invert) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glSampleCoveragex(value=%ld, invert=%u)\n", value, invert); +#endif + glSampleCoveragex(value, invert); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glSampleCoveragex"); +#endif +} + +// void glScalex (GLfixed x, GLfixed y, GLfixed z); +static inline void qglScalex(GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScalex(x=%ld, y=%ld, z=%ld)\n", x, y, z); +#endif + glScalex(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScalex"); +#endif +} + +// void glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScissor(x=%ld, y=%ld, width=%ld, height=%ld)\n", x, y, width, height); +#endif + // fixme + int vidHeight = 320; +glScissor(vidHeight - y - height, x, height, width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScissor"); +#endif +} + +// void glShadeModel (GLenum mode); +static inline void qglShadeModel(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glShadeModel(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glShadeModel(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glShadeModel"); +#endif +} + +// void glStencilFunc (GLenum func, GLint ref, GLuint mask); +static inline void qglStencilFunc(GLenum func, GLint ref, GLuint mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilFunc(func=%s, ref=%ld, mask=%lu)\n", StringFromGLEnumerant( func ), ref, mask); +#endif + glStencilFunc(func, ref, mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilFunc"); +#endif +} + +// void glStencilMask (GLuint mask); +static inline void qglStencilMask(GLuint mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilMask(mask=%lu)\n", mask); +#endif + glStencilMask(mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilMask"); +#endif +} + +// void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +static inline void qglStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilOp(fail=%s, zfail=%s, zpass=%s)\n", StringFromGLEnumerant( fail ), StringFromGLEnumerant( zfail ), StringFromGLEnumerant( zpass )); +#endif + glStencilOp(fail, zfail, zpass); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilOp"); +#endif +} + +// void glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexCoordPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glTexCoordPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexCoordPointer"); +#endif +} + +// void glTexEnvi (GLenum target, GLenum pname, GLint param); +static inline void qglTexEnvi(GLenum target, GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvi(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvi(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvi"); +#endif +} + +// void glTexEnvx (GLenum target, GLenum pname, GLfixed param); +static inline void qglTexEnvx(GLenum target, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvx(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvx(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvx"); +#endif +} + +// void glTexEnviv (GLenum target, GLenum pname, const GLint *params); +static inline void qglTexEnviv(GLenum target, GLenum pname, const GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnviv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnviv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnviv"); +#endif +} + +// void glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params); +static inline void qglTexEnvxv(GLenum target, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnvxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvxv"); +#endif +} + +// void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +static inline void qglTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexImage2D(target=%s, level=%ld, internalformat=%ld, width=%ld, height=%ld, border=%ld, format=%s, type=%s, pixels=%p)\n", StringFromGLEnumerant( target ), level, internalformat, width, height, border, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexImage2D"); +#endif +} + +// void glTexParameteri (GLenum target, GLenum pname, GLint param); +static inline void qglTexParameteri(GLenum target, GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameteri(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameteri(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameteri"); +#endif +} + +// void glTexParameterx (GLenum target, GLenum pname, GLfixed param); +static inline void qglTexParameterx(GLenum target, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterx(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameterx(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterx"); +#endif +} + +// void glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +static inline void qglTexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameteriv"); +#endif +} + +// void glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params); +static inline void qglTexParameterxv(GLenum target, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameterxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterxv"); +#endif +} + +// void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +static inline void qglTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, width=%ld, height=%ld, format=%s, type=%s, pixels=%p)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, width, height, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexSubImage2D"); +#endif +} + +// void glTranslatex (GLfixed x, GLfixed y, GLfixed z); +static inline void qglTranslatex(GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTranslatex(x=%ld, y=%ld, z=%ld)\n", x, y, z); +#endif + glTranslatex(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTranslatex"); +#endif +} + +// void glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glVertexPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glVertexPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glVertexPointer"); +#endif +} + +// void glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glViewport(x=%ld, y=%ld, width=%ld, height=%ld)\n", x, y, width, height); +#endif +//extern glconfig_t glConfig; + int vidHeight = 320; + glViewport(vidHeight - y - height, x, height, width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glViewport"); +#endif +} + +// void glCurrentPaletteMatrixOES (GLuint matrixpaletteindex); +static inline void qglCurrentPaletteMatrixOES(GLuint matrixpaletteindex) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCurrentPaletteMatrixOES(matrixpaletteindex=%lu)\n", matrixpaletteindex); +#endif + glCurrentPaletteMatrixOES(matrixpaletteindex); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCurrentPaletteMatrixOES"); +#endif +} + +// void glLoadPaletteFromModelViewMatrixOES (void); +static inline void qglLoadPaletteFromModelViewMatrixOES(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadPaletteFromModelViewMatrixOES(void)\n"); +#endif + glLoadPaletteFromModelViewMatrixOES(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadPaletteFromModelViewMatrixOES"); +#endif +} + +// void glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMatrixIndexPointerOES(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glMatrixIndexPointerOES(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMatrixIndexPointerOES"); +#endif +} + +// void glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glWeightPointerOES(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glWeightPointerOES(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glWeightPointerOES"); +#endif +} + +// void glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSizePointerOES(type=%s, stride=%ld, pointer=%p)\n", StringFromGLEnumerant( type ), stride, pointer); +#endif + glPointSizePointerOES(type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSizePointerOES"); +#endif +} + +// void glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +static inline void qglDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexsOES(x=%d, y=%d, z=%d, width=%d, height=%d)\n", x, y, z, width, height); +#endif + glDrawTexsOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexsOES"); +#endif +} + +// void glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height); +static inline void qglDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexiOES(x=%ld, y=%ld, z=%ld, width=%ld, height=%ld)\n", x, y, z, width, height); +#endif + glDrawTexiOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexiOES"); +#endif +} + +// void glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +static inline void qglDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexxOES(x=%ld, y=%ld, z=%ld, width=%ld, height=%ld)\n", x, y, z, width, height); +#endif + glDrawTexxOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexxOES"); +#endif +} + +// void glDrawTexsvOES (const GLshort *coords); +static inline void qglDrawTexsvOES(const GLshort *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexsvOES(coords=%p)\n", coords); +#endif + glDrawTexsvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexsvOES"); +#endif +} + +// void glDrawTexivOES (const GLint *coords); +static inline void qglDrawTexivOES(const GLint *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexivOES(coords=%p)\n", coords); +#endif + glDrawTexivOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexivOES"); +#endif +} + +// void glDrawTexxvOES (const GLfixed *coords); +static inline void qglDrawTexxvOES(const GLfixed *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexxvOES(coords=%p)\n", coords); +#endif + glDrawTexxvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexxvOES"); +#endif +} + +// void glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +static inline void qglDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexfOES(x=%f, y=%f, z=%f, width=%f, height=%f)\n", x, y, z, width, height); +#endif + glDrawTexfOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexfOES"); +#endif +} + +// void glDrawTexfvOES (const GLfloat *coords); +static inline void qglDrawTexfvOES(const GLfloat *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexfvOES(coords=%p)\n", coords); +#endif + glDrawTexfvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexfvOES"); +#endif +} + +// Prevent calls to the 'normal' GL functions +#define glAlphaFunc CALL_THE_QGL_VERSION_OF_glAlphaFunc +#define glClearColor CALL_THE_QGL_VERSION_OF_glClearColor +#define glClearDepthf CALL_THE_QGL_VERSION_OF_glClearDepthf +#define glClipPlanef CALL_THE_QGL_VERSION_OF_glClipPlanef +#define glDepthRangef CALL_THE_QGL_VERSION_OF_glDepthRangef +#define glFogf CALL_THE_QGL_VERSION_OF_glFogf +#define glFogfv CALL_THE_QGL_VERSION_OF_glFogfv +#define glFrustumf CALL_THE_QGL_VERSION_OF_glFrustumf +#define glGetClipPlanef CALL_THE_QGL_VERSION_OF_glGetClipPlanef +#define glGetFloatv CALL_THE_QGL_VERSION_OF_glGetFloatv +#define glGetLightfv CALL_THE_QGL_VERSION_OF_glGetLightfv +#define glGetMaterialfv CALL_THE_QGL_VERSION_OF_glGetMaterialfv +#define glGetTexEnvfv CALL_THE_QGL_VERSION_OF_glGetTexEnvfv +#define glGetTexParameterfv CALL_THE_QGL_VERSION_OF_glGetTexParameterfv +#define glLightModelf CALL_THE_QGL_VERSION_OF_glLightModelf +#define glLightModelfv CALL_THE_QGL_VERSION_OF_glLightModelfv +#define glLightf CALL_THE_QGL_VERSION_OF_glLightf +#define glLightfv CALL_THE_QGL_VERSION_OF_glLightfv +#define glLineWidth CALL_THE_QGL_VERSION_OF_glLineWidth +#define glLoadMatrixf CALL_THE_QGL_VERSION_OF_glLoadMatrixf +#define glMaterialf CALL_THE_QGL_VERSION_OF_glMaterialf +#define glMaterialfv CALL_THE_QGL_VERSION_OF_glMaterialfv +#define glMultMatrixf CALL_THE_QGL_VERSION_OF_glMultMatrixf +#define glMultiTexCoord4f CALL_THE_QGL_VERSION_OF_glMultiTexCoord4f +#define glNormal3f CALL_THE_QGL_VERSION_OF_glNormal3f +#define glOrthof CALL_THE_QGL_VERSION_OF_glOrthof +#define glPointParameterf CALL_THE_QGL_VERSION_OF_glPointParameterf +#define glPointParameterfv CALL_THE_QGL_VERSION_OF_glPointParameterfv +#define glPointSize CALL_THE_QGL_VERSION_OF_glPointSize +#define glPolygonOffset CALL_THE_QGL_VERSION_OF_glPolygonOffset +#define glRotatef CALL_THE_QGL_VERSION_OF_glRotatef +#define glScalef CALL_THE_QGL_VERSION_OF_glScalef +#define glTexEnvf CALL_THE_QGL_VERSION_OF_glTexEnvf +#define glTexEnvfv CALL_THE_QGL_VERSION_OF_glTexEnvfv +#define glTexParameterf CALL_THE_QGL_VERSION_OF_glTexParameterf +#define glTexParameterfv CALL_THE_QGL_VERSION_OF_glTexParameterfv +#define glTranslatef CALL_THE_QGL_VERSION_OF_glTranslatef +#define glActiveTexture CALL_THE_QGL_VERSION_OF_glActiveTexture +#define glAlphaFuncx CALL_THE_QGL_VERSION_OF_glAlphaFuncx +#define glBindBuffer CALL_THE_QGL_VERSION_OF_glBindBuffer +#define glBindTexture CALL_THE_QGL_VERSION_OF_glBindTexture +#define glBlendFunc CALL_THE_QGL_VERSION_OF_glBlendFunc +#define glBufferData CALL_THE_QGL_VERSION_OF_glBufferData +#define glBufferSubData CALL_THE_QGL_VERSION_OF_glBufferSubData +#define glClear CALL_THE_QGL_VERSION_OF_glClear +#define glClearColorx CALL_THE_QGL_VERSION_OF_glClearColorx +#define glClearDepthx CALL_THE_QGL_VERSION_OF_glClearDepthx +#define glClearStencil CALL_THE_QGL_VERSION_OF_glClearStencil +#define glClientActiveTexture CALL_THE_QGL_VERSION_OF_glClientActiveTexture +#define glClipPlanex CALL_THE_QGL_VERSION_OF_glClipPlanex +#define glColor4ub CALL_THE_QGL_VERSION_OF_glColor4ub +#define glColor4x CALL_THE_QGL_VERSION_OF_glColor4x +#define glColorMask CALL_THE_QGL_VERSION_OF_glColorMask +#define glColorPointer CALL_THE_QGL_VERSION_OF_glColorPointer +#define glCompressedTexImage2D CALL_THE_QGL_VERSION_OF_glCompressedTexImage2D +#define glCompressedTexSubImage2D CALL_THE_QGL_VERSION_OF_glCompressedTexSubImage2D +#define glCopyTexImage2D CALL_THE_QGL_VERSION_OF_glCopyTexImage2D +#define glCopyTexSubImage2D CALL_THE_QGL_VERSION_OF_glCopyTexSubImage2D +#define glCullFace CALL_THE_QGL_VERSION_OF_glCullFace +#define glDeleteBuffers CALL_THE_QGL_VERSION_OF_glDeleteBuffers +#define glDeleteTextures CALL_THE_QGL_VERSION_OF_glDeleteTextures +#define glDepthFunc CALL_THE_QGL_VERSION_OF_glDepthFunc +#define glDepthMask CALL_THE_QGL_VERSION_OF_glDepthMask +#define glDepthRangex CALL_THE_QGL_VERSION_OF_glDepthRangex +#define glDisable CALL_THE_QGL_VERSION_OF_glDisable +#define glDisableClientState CALL_THE_QGL_VERSION_OF_glDisableClientState +#define glDrawArrays CALL_THE_QGL_VERSION_OF_glDrawArrays +#define glDrawElements CALL_THE_QGL_VERSION_OF_glDrawElements +#define glEnable CALL_THE_QGL_VERSION_OF_glEnable +#define glEnableClientState CALL_THE_QGL_VERSION_OF_glEnableClientState +#define glFinish CALL_THE_QGL_VERSION_OF_glFinish +#define glFlush CALL_THE_QGL_VERSION_OF_glFlush +#define glFogx CALL_THE_QGL_VERSION_OF_glFogx +#define glFogxv CALL_THE_QGL_VERSION_OF_glFogxv +#define glFrontFace CALL_THE_QGL_VERSION_OF_glFrontFace +#define glFrustumx CALL_THE_QGL_VERSION_OF_glFrustumx +#define glGetBooleanv CALL_THE_QGL_VERSION_OF_glGetBooleanv +#define glGetBufferParameteriv CALL_THE_QGL_VERSION_OF_glGetBufferParameteriv +#define glGetClipPlanex CALL_THE_QGL_VERSION_OF_glGetClipPlanex +#define glGenBuffers CALL_THE_QGL_VERSION_OF_glGenBuffers +#define glGenTextures CALL_THE_QGL_VERSION_OF_glGenTextures +#define glGetError CALL_THE_QGL_VERSION_OF_glGetError +#define glGetFixedv CALL_THE_QGL_VERSION_OF_glGetFixedv +#define glGetIntegerv CALL_THE_QGL_VERSION_OF_glGetIntegerv +#define glGetLightxv CALL_THE_QGL_VERSION_OF_glGetLightxv +#define glGetMaterialxv CALL_THE_QGL_VERSION_OF_glGetMaterialxv +#define glGetPointerv CALL_THE_QGL_VERSION_OF_glGetPointerv +#define glGetString CALL_THE_QGL_VERSION_OF_glGetString +#define glGetTexEnviv CALL_THE_QGL_VERSION_OF_glGetTexEnviv +#define glGetTexEnvxv CALL_THE_QGL_VERSION_OF_glGetTexEnvxv +#define glGetTexParameteriv CALL_THE_QGL_VERSION_OF_glGetTexParameteriv +#define glGetTexParameterxv CALL_THE_QGL_VERSION_OF_glGetTexParameterxv +#define glHint CALL_THE_QGL_VERSION_OF_glHint +#define glIsBuffer CALL_THE_QGL_VERSION_OF_glIsBuffer +#define glIsEnabled CALL_THE_QGL_VERSION_OF_glIsEnabled +#define glIsTexture CALL_THE_QGL_VERSION_OF_glIsTexture +#define glLightModelx CALL_THE_QGL_VERSION_OF_glLightModelx +#define glLightModelxv CALL_THE_QGL_VERSION_OF_glLightModelxv +#define glLightx CALL_THE_QGL_VERSION_OF_glLightx +#define glLightxv CALL_THE_QGL_VERSION_OF_glLightxv +#define glLineWidthx CALL_THE_QGL_VERSION_OF_glLineWidthx +#define glLoadIdentity CALL_THE_QGL_VERSION_OF_glLoadIdentity +#define glLoadMatrixx CALL_THE_QGL_VERSION_OF_glLoadMatrixx +#define glLogicOp CALL_THE_QGL_VERSION_OF_glLogicOp +#define glMaterialx CALL_THE_QGL_VERSION_OF_glMaterialx +#define glMaterialxv CALL_THE_QGL_VERSION_OF_glMaterialxv +#define glMatrixMode CALL_THE_QGL_VERSION_OF_glMatrixMode +#define glMultMatrixx CALL_THE_QGL_VERSION_OF_glMultMatrixx +#define glMultiTexCoord4x CALL_THE_QGL_VERSION_OF_glMultiTexCoord4x +#define glNormal3x CALL_THE_QGL_VERSION_OF_glNormal3x +#define glNormalPointer CALL_THE_QGL_VERSION_OF_glNormalPointer +#define glOrthox CALL_THE_QGL_VERSION_OF_glOrthox +#define glPixelStorei CALL_THE_QGL_VERSION_OF_glPixelStorei +#define glPointParameterx CALL_THE_QGL_VERSION_OF_glPointParameterx +#define glPointParameterxv CALL_THE_QGL_VERSION_OF_glPointParameterxv +#define glPointSizex CALL_THE_QGL_VERSION_OF_glPointSizex +#define glPolygonOffsetx CALL_THE_QGL_VERSION_OF_glPolygonOffsetx +#define glPopMatrix CALL_THE_QGL_VERSION_OF_glPopMatrix +#define glPushMatrix CALL_THE_QGL_VERSION_OF_glPushMatrix +#define glReadPixels CALL_THE_QGL_VERSION_OF_glReadPixels +#define glRotatex CALL_THE_QGL_VERSION_OF_glRotatex +#define glSampleCoverage CALL_THE_QGL_VERSION_OF_glSampleCoverage +#define glSampleCoveragex CALL_THE_QGL_VERSION_OF_glSampleCoveragex +#define glScalex CALL_THE_QGL_VERSION_OF_glScalex +#define glScissor CALL_THE_QGL_VERSION_OF_glScissor +#define glShadeModel CALL_THE_QGL_VERSION_OF_glShadeModel +#define glStencilFunc CALL_THE_QGL_VERSION_OF_glStencilFunc +#define glStencilMask CALL_THE_QGL_VERSION_OF_glStencilMask +#define glStencilOp CALL_THE_QGL_VERSION_OF_glStencilOp +#define glTexCoordPointer CALL_THE_QGL_VERSION_OF_glTexCoordPointer +#define glTexEnvi CALL_THE_QGL_VERSION_OF_glTexEnvi +#define glTexEnvx CALL_THE_QGL_VERSION_OF_glTexEnvx +#define glTexEnviv CALL_THE_QGL_VERSION_OF_glTexEnviv +#define glTexEnvxv CALL_THE_QGL_VERSION_OF_glTexEnvxv +#define glTexImage2D CALL_THE_QGL_VERSION_OF_glTexImage2D +#define glTexParameteri CALL_THE_QGL_VERSION_OF_glTexParameteri +#define glTexParameterx CALL_THE_QGL_VERSION_OF_glTexParameterx +#define glTexParameteriv CALL_THE_QGL_VERSION_OF_glTexParameteriv +#define glTexParameterxv CALL_THE_QGL_VERSION_OF_glTexParameterxv +#define glTexSubImage2D CALL_THE_QGL_VERSION_OF_glTexSubImage2D +#define glTranslatex CALL_THE_QGL_VERSION_OF_glTranslatex +#define glVertexPointer CALL_THE_QGL_VERSION_OF_glVertexPointer +#define glViewport CALL_THE_QGL_VERSION_OF_glViewport +#define glCurrentPaletteMatrixOES CALL_THE_QGL_VERSION_OF_glCurrentPaletteMatrixOES +#define glLoadPaletteFromModelViewMatrixOES CALL_THE_QGL_VERSION_OF_glLoadPaletteFromModelViewMatrixOES +#define glMatrixIndexPointerOES CALL_THE_QGL_VERSION_OF_glMatrixIndexPointerOES +#define glWeightPointerOES CALL_THE_QGL_VERSION_OF_glWeightPointerOES +#define glPointSizePointerOES CALL_THE_QGL_VERSION_OF_glPointSizePointerOES +#define glDrawTexsOES CALL_THE_QGL_VERSION_OF_glDrawTexsOES +#define glDrawTexiOES CALL_THE_QGL_VERSION_OF_glDrawTexiOES +#define glDrawTexxOES CALL_THE_QGL_VERSION_OF_glDrawTexxOES +#define glDrawTexsvOES CALL_THE_QGL_VERSION_OF_glDrawTexsvOES +#define glDrawTexivOES CALL_THE_QGL_VERSION_OF_glDrawTexivOES +#define glDrawTexxvOES CALL_THE_QGL_VERSION_OF_glDrawTexxvOES +#define glDrawTexfOES CALL_THE_QGL_VERSION_OF_glDrawTexfOES +#define glDrawTexfvOES CALL_THE_QGL_VERSION_OF_glDrawTexfvOES + +#endif // _IPHONE_QGL_H_ diff --git a/wolf3d/newCode/iphone/iphone_qgl_enumerants.h b/wolf3d/newCode/iphone/iphone_qgl_enumerants.h new file mode 100644 index 0000000..01892dd --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_qgl_enumerants.h @@ -0,0 +1,40 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#ifndef IPHONE_QGL_ENUMERANTS_H +#define IPHONE_QGL_ENUMERANTS_H + +#ifdef QGL_LOG_GL_CALLS + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + const char *StringFromGLEnumerant( GLenum enumerant ); + +#ifdef __cplusplus +} +#endif + +#endif // QGL_LOG_GL_CALLS + +#endif // IPHONE_QGL_ENUMERANTS_H \ No newline at end of file diff --git a/wolf3d/newCode/iphone/iphone_wolf.h b/wolf3d/newCode/iphone/iphone_wolf.h new file mode 100644 index 0000000..5314edf --- /dev/null +++ b/wolf3d/newCode/iphone/iphone_wolf.h @@ -0,0 +1,151 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +// define this to get only the first episode on selections, and the +// automatic sell screen at the end of episode 1 +//#define EPISODE_ONE_ONLY + +extern viddef_t viddef; + +typedef enum menuState { + IPM_GAME, + IPM_MAIN, + IPM_SKILL, + IPM_EPISODE, + IPM_MAPS, + IPM_CONTROLS, + IPM_INTERMISSION, + IPM_VICTORY, + IPM_AUTOMAP +} menuState_t; + +extern menuState_t menuState; + +void iphoneDrawMenus(); + +#define SAVEGAME_VERSION 106 + +#define MAX_SKILLS 4 +#define MAX_MAPS 60 + +#define MF_TRIED 1 +#define MF_COMPLETED 2 +#define MF_KILLS 4 +#define MF_SECRETS 8 +#define MF_TREASURE 16 +#define MF_TIME 32 + +typedef struct { + int episode; + int map; + int skill; + int levelCompleted; // already at intermission when saved + int version; + int mapFlags[MAX_SKILLS][MAX_MAPS]; +} currentMap_t; + +extern currentMap_t currentMap; + +void iphoneStartMap( int episodeNum, int mapNum, int skillLevel ); + +extern char iphoneDocDirectory[1024]; +extern char iphoneAppDirectory[1024]; + +extern texture_t *numberPics[10]; + +extern vec3_t vnull; + +void Client_PrepRefresh( const char *r_mapname ); + +extern int iphoneFrameNum; +extern int intermissionTriggerFrame; +extern int consoleActive; + +extern cvar_t *controlScheme; +extern cvar_t *sensitivity; +extern cvar_t *stickSize; +extern cvar_t *stickTurnBase; +extern cvar_t *stickTurnScale; +extern cvar_t *stickMoveBase; +extern cvar_t *stickMoveScale; +extern cvar_t *stickDeadBand; +extern cvar_t *tiltTurn; +extern cvar_t *tiltMove; +extern cvar_t *tiltDeadBand; +extern cvar_t *tiltAverages; +extern cvar_t *tiltFire; +extern cvar_t *music; +extern cvar_t *showTilt; +extern cvar_t *cropSprites; +extern cvar_t *blends; +extern cvar_t *gunFrame; +extern cvar_t *slowAI; + +// the native iPhone code should set the following each frame: +extern int numTouches; +extern int touches[5][2]; // [0] = x, [1] = y in landscape mode, raster order with y = 0 at top +extern float tilt; // -1.0 to 1.0 +extern float tiltPitch; + +// so we can detect button releases +extern int numPrevTouches; +extern int prevTouches[5][2]; + + +// the layout drawing code sets these, which are then used +// by the touch processing +extern int menuButtonX, menuButtonY, menuButtonSize; +extern int fireButtonX, fireButtonY, fireButtonSize; +extern int moveAxisX, moveAxisY, moveAxisSize; +extern int turnAxisX, turnAxisY, turnAxisSize; + +// incremented once each frame, regardless of framerate +extern int frameNum; + +int TouchDown( int x, int y, int w, int h ); +int TouchReleased( int x, int y, int w, int h ); +int iphoneCenterText( int x, int y, const char *str ); +void iphoneDrawNumber( int x, int y, int number, int charWidth, int charHeight ); +void iphoneDrawPic( int x, int y, int w, int h, const char *pic ); +void R_Draw_Blend( int x, int y, int w, int h, colour4_t c ); +void SaveTheGame(); +int LoadTheGame(); +void StartGame( void ); +void iphoneShutdown(); +void iphoneOpenAutomap(); + +void InitImmediateModeGL(); + +extern colour4_t colorPressed; + +extern int damageflash; +extern int bonusFrameNum; +extern int attackDirTime[2]; + +// interfaces from the game code +void iphoneStartBonusFlash(); +void iphoneStartDamageFlash( int points ); +void iphoneSetAttackDirection( int dir ); +void iphoneStartIntermission( int framesFromNow ); +void iphoneSetNotifyText( const char *str, ... ); + +// interfaces to hadware / system +void OpenURL( const char *url ); + diff --git a/wolf3d/newCode/iphone/main.m b/wolf3d/newCode/iphone/main.m new file mode 100644 index 0000000..189bf40 --- /dev/null +++ b/wolf3d/newCode/iphone/main.m @@ -0,0 +1,45 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#import +#include +#include + +int main(int argc, char *argv[]) { + + { + char cwd[256]; + strcpy( cwd, argv[0] ); + int len = strlen( cwd ); + for( int i = len-1; i >= 0; i-- ) { + if ( cwd[i] == '/' ) { + cwd[i] = 0; + break; + } + cwd[i] = 0; + } + setenv( "CWD", cwd, 1 ); + } + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} diff --git a/wolf3d/newCode/iphone/wolf3d.xcodeproj/project.pbxproj b/wolf3d/newCode/iphone/wolf3d.xcodeproj/project.pbxproj new file mode 100644 index 0000000..be678b7 --- /dev/null +++ b/wolf3d/newCode/iphone/wolf3d.xcodeproj/project.pbxproj @@ -0,0 +1,847 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; + 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; }; + 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; }; + 4333CCE80F5CC23E00AE2B6F /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4333CCE70F5CC23E00AE2B6F /* AudioToolbox.framework */; }; + 4364BF3F0F5CB25900F29317 /* dist.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4364BF3E0F5CB25900F29317 /* dist.plist */; }; + 43AE7CAB0F61FB0E00B2F562 /* wolf3dEpisode1_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 43AE7CAA0F61FB0E00B2F562 /* wolf3dEpisode1_icon.png */; }; + 43AE7E9F0F67387500B2F562 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43AE7E9E0F67387500B2F562 /* CoreGraphics.framework */; }; + 43CF02ED0F56955F00E4A23D /* wolf3d_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 43CF02EC0F56955F00E4A23D /* wolf3d_icon.png */; }; + 43CF02FF0F56974E00E4A23D /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 43CF02FE0F56974E00E4A23D /* Default.png */; }; + 43CF030A0F56D5C200E4A23D /* iphone_loop.c in Sources */ = {isa = PBXBuildFile; fileRef = 43CF03090F56D5C200E4A23D /* iphone_loop.c */; }; + 43E8D2E10F4FC61E003F09B2 /* iphone_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 43E8D2DF0F4FC61E003F09B2 /* iphone_main.c */; }; + 43E8D4E00F51B48B003F09B2 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43E8D4DF0F51B48B003F09B2 /* OpenAL.framework */; }; + 7229CC460F6B3222004123C5 /* wolf_actor_ai.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC250F6B3222004123C5 /* wolf_actor_ai.c */; }; + 7229CC470F6B3222004123C5 /* wolf_actors.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC270F6B3222004123C5 /* wolf_actors.c */; }; + 7229CC480F6B3222004123C5 /* wolf_ai_com.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC290F6B3222004123C5 /* wolf_ai_com.c */; }; + 7229CC490F6B3222004123C5 /* wolf_areas.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC2B0F6B3222004123C5 /* wolf_areas.c */; }; + 7229CC4A0F6B3222004123C5 /* wolf_bj.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC2C0F6B3222004123C5 /* wolf_bj.c */; }; + 7229CC4B0F6B3222004123C5 /* wolf_client_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC2E0F6B3222004123C5 /* wolf_client_main.c */; }; + 7229CC4D0F6B3222004123C5 /* wolf_doors.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC300F6B3222004123C5 /* wolf_doors.c */; }; + 7229CC4E0F6B3222004123C5 /* wolf_level.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC310F6B3222004123C5 /* wolf_level.c */; }; + 7229CC4F0F6B3222004123C5 /* wolf_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC340F6B3222004123C5 /* wolf_main.c */; }; + 7229CC500F6B3222004123C5 /* wolf_math.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC350F6B3222004123C5 /* wolf_math.c */; }; + 7229CC510F6B3222004123C5 /* wolf_opengl.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC370F6B3222004123C5 /* wolf_opengl.c */; }; + 7229CC520F6B3222004123C5 /* wolf_player.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC380F6B3222004123C5 /* wolf_player.c */; }; + 7229CC530F6B3222004123C5 /* wolf_powerups.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC3A0F6B3222004123C5 /* wolf_powerups.c */; }; + 7229CC540F6B3222004123C5 /* wolf_pushwalls.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC3C0F6B3222004123C5 /* wolf_pushwalls.c */; }; + 7229CC550F6B3222004123C5 /* wolf_raycast.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC3D0F6B3222004123C5 /* wolf_raycast.c */; }; + 7229CC560F6B3222004123C5 /* wolf_renderer.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC3F0F6B3222004123C5 /* wolf_renderer.c */; }; + 7229CC570F6B3222004123C5 /* wolf_sprites.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC410F6B3222004123C5 /* wolf_sprites.c */; }; + 7229CC580F6B3222004123C5 /* wolf_sv_ccmds.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC430F6B3222004123C5 /* wolf_sv_ccmds.c */; }; + 7229CC590F6B3222004123C5 /* wolf_weapon.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC440F6B3222004123C5 /* wolf_weapon.c */; }; + 7229CC7D0F6B3295004123C5 /* bitwise.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC5D0F6B3295004123C5 /* bitwise.c */; }; + 7229CC7E0F6B3295004123C5 /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC5E0F6B3295004123C5 /* block.c */; }; + 7229CC7F0F6B3295004123C5 /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC600F6B3295004123C5 /* codebook.c */; }; + 7229CC800F6B3295004123C5 /* floor0.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC640F6B3295004123C5 /* floor0.c */; }; + 7229CC810F6B3295004123C5 /* floor1.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC650F6B3295004123C5 /* floor1.c */; }; + 7229CC820F6B3295004123C5 /* framing.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC660F6B3295004123C5 /* framing.c */; }; + 7229CC830F6B3295004123C5 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC670F6B3295004123C5 /* info.c */; }; + 7229CC850F6B3295004123C5 /* mapping0.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC6C0F6B3295004123C5 /* mapping0.c */; }; + 7229CC860F6B3295004123C5 /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC6D0F6B3295004123C5 /* mdct.c */; }; + 7229CC870F6B3295004123C5 /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC740F6B3295004123C5 /* registry.c */; }; + 7229CC880F6B3295004123C5 /* res012.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC760F6B3295004123C5 /* res012.c */; }; + 7229CC890F6B3295004123C5 /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC770F6B3295004123C5 /* sharedbook.c */; }; + 7229CC8A0F6B3295004123C5 /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC780F6B3295004123C5 /* synthesis.c */; }; + 7229CC8B0F6B3295004123C5 /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC790F6B3295004123C5 /* vorbisfile.c */; }; + 7229CC8C0F6B3295004123C5 /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CC7A0F6B3295004123C5 /* window.c */; }; + 7229CE4A0F6C89F8004123C5 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7229CE460F6C89F8004123C5 /* EAGLView.m */; }; + 7229CE4C0F6C89F8004123C5 /* wolf3dAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7229CE490F6C89F8004123C5 /* wolf3dAppDelegate.m */; }; + 7229CE550F6C8CDE004123C5 /* gles_glue.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CE540F6C8CDE004123C5 /* gles_glue.c */; }; + 72935B740F6B2D9D0085DD28 /* angle.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B1A0F6B2D9D0085DD28 /* angle.c */; }; + 72935B750F6B2D9D0085DD28 /* arch.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B1D0F6B2D9D0085DD28 /* arch.c */; }; + 72935B790F6B2D9D0085DD28 /* cmd.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B230F6B2D9D0085DD28 /* cmd.c */; }; + 72935B7A0F6B2D9D0085DD28 /* com_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B250F6B2D9D0085DD28 /* com_string.c */; }; + 72935B7B0F6B2D9D0085DD28 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B270F6B2D9D0085DD28 /* common.c */; }; + 72935B7C0F6B2D9D0085DD28 /* console.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B2A0F6B2D9D0085DD28 /* console.c */; }; + 72935B7E0F6B2D9D0085DD28 /* cvar.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B2D0F6B2D9D0085DD28 /* cvar.c */; }; + 72935B7F0F6B2D9D0085DD28 /* fileio.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B2F0F6B2D9D0085DD28 /* fileio.c */; }; + 72935B800F6B2D9D0085DD28 /* files.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B310F6B2D9D0085DD28 /* files.c */; }; + 72935B810F6B2D9D0085DD28 /* filestring.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B320F6B2D9D0085DD28 /* filestring.c */; }; + 72935B820F6B2D9D0085DD28 /* font_manager.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B350F6B2D9D0085DD28 /* font_manager.c */; }; + 72935B830F6B2D9D0085DD28 /* glob.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B370F6B2D9D0085DD28 /* glob.c */; }; + 72935B870F6B2D9D0085DD28 /* math.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B3E0F6B2D9D0085DD28 /* math.c */; }; + 72935B880F6B2D9D0085DD28 /* matrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B3F0F6B2D9D0085DD28 /* matrix.c */; }; + 72935B890F6B2D9D0085DD28 /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B410F6B2D9D0085DD28 /* memory.c */; }; + 72935B8B0F6B2D9D0085DD28 /* oggfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B490F6B2D9D0085DD28 /* oggfile.c */; }; + 72935B8C0F6B2D9D0085DD28 /* openal_binding.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B4B0F6B2D9D0085DD28 /* openal_binding.c */; }; + 72935B8D0F6B2D9D0085DD28 /* openal_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B4D0F6B2D9D0085DD28 /* openal_main.c */; }; + 72935B8F0F6B2D9D0085DD28 /* opengl_draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B500F6B2D9D0085DD28 /* opengl_draw.c */; }; + 72935B910F6B2D9D0085DD28 /* opengl_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B530F6B2D9D0085DD28 /* opengl_main.c */; }; + 72935B920F6B2D9D0085DD28 /* opengl_texture.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B540F6B2D9D0085DD28 /* opengl_texture.c */; }; + 72935B930F6B2D9D0085DD28 /* random_number.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B560F6B2D9D0085DD28 /* random_number.c */; }; + 72935B940F6B2D9D0085DD28 /* share.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B590F6B2D9D0085DD28 /* share.c */; }; + 72935B950F6B2D9D0085DD28 /* sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B5A0F6B2D9D0085DD28 /* sound.c */; }; + 72935B960F6B2D9D0085DD28 /* sound_sfx_id.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B5D0F6B2D9D0085DD28 /* sound_sfx_id.c */; }; + 72935B970F6B2D9D0085DD28 /* sound_stream.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B5E0F6B2D9D0085DD28 /* sound_stream.c */; }; + 72935B990F6B2D9D0085DD28 /* texture_manager.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B610F6B2D9D0085DD28 /* texture_manager.c */; }; + 72935B9A0F6B2D9D0085DD28 /* tga.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B630F6B2D9D0085DD28 /* tga.c */; }; + 72935B9C0F6B2D9D0085DD28 /* unix_file.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B680F6B2D9D0085DD28 /* unix_file.c */; }; + 72935B9E0F6B2D9D0085DD28 /* unix_timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B6A0F6B2D9D0085DD28 /* unix_timer.c */; }; + 72935B9F0F6B2D9D0085DD28 /* vector.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B6B0F6B2D9D0085DD28 /* vector.c */; }; + 72935BA00F6B2D9D0085DD28 /* wavfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B6E0F6B2D9D0085DD28 /* wavfile.c */; }; + 72935BA20F6B2D9D0085DD28 /* zmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 72935B720F6B2D9D0085DD28 /* zmem.c */; }; + 72A7E8F70F5F2063005B83C0 /* iphone_menus.c in Sources */ = {isa = PBXBuildFile; fileRef = 72A7E8F60F5F2063005B83C0 /* iphone_menus.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1D6058910D05DD3D006BFB54 /* wolf3d.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = wolf3d.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + 28FD14FF0DC6FC520079059D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + 28FD15070DC6FC5B0079059D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 32CA4F630368D1EE00C91783 /* wolf3d_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wolf3d_Prefix.pch; sourceTree = ""; }; + 4333CCE70F5CC23E00AE2B6F /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; + 4364BF3E0F5CB25900F29317 /* dist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = dist.plist; sourceTree = ""; }; + 43AE7CAA0F61FB0E00B2F562 /* wolf3dEpisode1_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = wolf3dEpisode1_icon.png; sourceTree = ""; }; + 43AE7E9E0F67387500B2F562 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 43CF02EC0F56955F00E4A23D /* wolf3d_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = wolf3d_icon.png; sourceTree = ""; }; + 43CF02FE0F56974E00E4A23D /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 43CF03090F56D5C200E4A23D /* iphone_loop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iphone_loop.c; sourceTree = ""; }; + 43E8D2DF0F4FC61E003F09B2 /* iphone_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iphone_main.c; sourceTree = ""; }; + 43E8D4DF0F51B48B003F09B2 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /System/Library/Frameworks/OpenAL.framework; sourceTree = ""; }; + 7229CC240F6B3222004123C5 /* wolf_act_stat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_act_stat.h; path = ../wolf/wolf_act_stat.h; sourceTree = SOURCE_ROOT; }; + 7229CC250F6B3222004123C5 /* wolf_actor_ai.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_actor_ai.c; path = ../wolf/wolf_actor_ai.c; sourceTree = SOURCE_ROOT; }; + 7229CC260F6B3222004123C5 /* wolf_actor_ai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_actor_ai.h; path = ../wolf/wolf_actor_ai.h; sourceTree = SOURCE_ROOT; }; + 7229CC270F6B3222004123C5 /* wolf_actors.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_actors.c; path = ../wolf/wolf_actors.c; sourceTree = SOURCE_ROOT; }; + 7229CC280F6B3222004123C5 /* wolf_actors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_actors.h; path = ../wolf/wolf_actors.h; sourceTree = SOURCE_ROOT; }; + 7229CC290F6B3222004123C5 /* wolf_ai_com.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_ai_com.c; path = ../wolf/wolf_ai_com.c; sourceTree = SOURCE_ROOT; }; + 7229CC2A0F6B3222004123C5 /* wolf_ai_com.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_ai_com.h; path = ../wolf/wolf_ai_com.h; sourceTree = SOURCE_ROOT; }; + 7229CC2B0F6B3222004123C5 /* wolf_areas.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_areas.c; path = ../wolf/wolf_areas.c; sourceTree = SOURCE_ROOT; }; + 7229CC2C0F6B3222004123C5 /* wolf_bj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_bj.c; path = ../wolf/wolf_bj.c; sourceTree = SOURCE_ROOT; }; + 7229CC2D0F6B3222004123C5 /* wolf_bj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_bj.h; path = ../wolf/wolf_bj.h; sourceTree = SOURCE_ROOT; }; + 7229CC2E0F6B3222004123C5 /* wolf_client_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_client_main.c; path = ../wolf/wolf_client_main.c; sourceTree = SOURCE_ROOT; }; + 7229CC300F6B3222004123C5 /* wolf_doors.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_doors.c; path = ../wolf/wolf_doors.c; sourceTree = SOURCE_ROOT; }; + 7229CC310F6B3222004123C5 /* wolf_level.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_level.c; path = ../wolf/wolf_level.c; sourceTree = SOURCE_ROOT; }; + 7229CC320F6B3222004123C5 /* wolf_level.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_level.h; path = ../wolf/wolf_level.h; sourceTree = SOURCE_ROOT; }; + 7229CC330F6B3222004123C5 /* wolf_local.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_local.h; path = ../wolf/wolf_local.h; sourceTree = SOURCE_ROOT; }; + 7229CC340F6B3222004123C5 /* wolf_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_main.c; path = ../wolf/wolf_main.c; sourceTree = SOURCE_ROOT; }; + 7229CC350F6B3222004123C5 /* wolf_math.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_math.c; path = ../wolf/wolf_math.c; sourceTree = SOURCE_ROOT; }; + 7229CC360F6B3222004123C5 /* wolf_math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_math.h; path = ../wolf/wolf_math.h; sourceTree = SOURCE_ROOT; }; + 7229CC370F6B3222004123C5 /* wolf_opengl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_opengl.c; path = ../wolf/wolf_opengl.c; sourceTree = SOURCE_ROOT; }; + 7229CC380F6B3222004123C5 /* wolf_player.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_player.c; path = ../wolf/wolf_player.c; sourceTree = SOURCE_ROOT; }; + 7229CC390F6B3222004123C5 /* wolf_player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_player.h; path = ../wolf/wolf_player.h; sourceTree = SOURCE_ROOT; }; + 7229CC3A0F6B3222004123C5 /* wolf_powerups.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_powerups.c; path = ../wolf/wolf_powerups.c; sourceTree = SOURCE_ROOT; }; + 7229CC3B0F6B3222004123C5 /* wolf_powerups.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_powerups.h; path = ../wolf/wolf_powerups.h; sourceTree = SOURCE_ROOT; }; + 7229CC3C0F6B3222004123C5 /* wolf_pushwalls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_pushwalls.c; path = ../wolf/wolf_pushwalls.c; sourceTree = SOURCE_ROOT; }; + 7229CC3D0F6B3222004123C5 /* wolf_raycast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_raycast.c; path = ../wolf/wolf_raycast.c; sourceTree = SOURCE_ROOT; }; + 7229CC3E0F6B3222004123C5 /* wolf_raycast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_raycast.h; path = ../wolf/wolf_raycast.h; sourceTree = SOURCE_ROOT; }; + 7229CC3F0F6B3222004123C5 /* wolf_renderer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_renderer.c; path = ../wolf/wolf_renderer.c; sourceTree = SOURCE_ROOT; }; + 7229CC400F6B3222004123C5 /* wolf_renderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_renderer.h; path = ../wolf/wolf_renderer.h; sourceTree = SOURCE_ROOT; }; + 7229CC410F6B3222004123C5 /* wolf_sprites.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_sprites.c; path = ../wolf/wolf_sprites.c; sourceTree = SOURCE_ROOT; }; + 7229CC420F6B3222004123C5 /* wolf_sprites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolf_sprites.h; path = ../wolf/wolf_sprites.h; sourceTree = SOURCE_ROOT; }; + 7229CC430F6B3222004123C5 /* wolf_sv_ccmds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_sv_ccmds.c; path = ../wolf/wolf_sv_ccmds.c; sourceTree = SOURCE_ROOT; }; + 7229CC440F6B3222004123C5 /* wolf_weapon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wolf_weapon.c; path = ../wolf/wolf_weapon.c; sourceTree = SOURCE_ROOT; }; + 7229CC5B0F6B3295004123C5 /* asm_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asm_arm.h; path = ../Tremor/asm_arm.h; sourceTree = SOURCE_ROOT; }; + 7229CC5C0F6B3295004123C5 /* backends.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = backends.h; path = ../Tremor/backends.h; sourceTree = SOURCE_ROOT; }; + 7229CC5D0F6B3295004123C5 /* bitwise.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bitwise.c; path = ../Tremor/bitwise.c; sourceTree = SOURCE_ROOT; }; + 7229CC5E0F6B3295004123C5 /* block.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = block.c; path = ../Tremor/block.c; sourceTree = SOURCE_ROOT; }; + 7229CC5F0F6B3295004123C5 /* block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = block.h; path = ../Tremor/block.h; sourceTree = SOURCE_ROOT; }; + 7229CC600F6B3295004123C5 /* codebook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = codebook.c; path = ../Tremor/codebook.c; sourceTree = SOURCE_ROOT; }; + 7229CC610F6B3295004123C5 /* codebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codebook.h; path = ../Tremor/codebook.h; sourceTree = SOURCE_ROOT; }; + 7229CC620F6B3295004123C5 /* codec_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codec_internal.h; path = ../Tremor/codec_internal.h; sourceTree = SOURCE_ROOT; }; + 7229CC630F6B3295004123C5 /* config_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config_types.h; path = ../Tremor/config_types.h; sourceTree = SOURCE_ROOT; }; + 7229CC640F6B3295004123C5 /* floor0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor0.c; path = ../Tremor/floor0.c; sourceTree = SOURCE_ROOT; }; + 7229CC650F6B3295004123C5 /* floor1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor1.c; path = ../Tremor/floor1.c; sourceTree = SOURCE_ROOT; }; + 7229CC660F6B3295004123C5 /* framing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = framing.c; path = ../Tremor/framing.c; sourceTree = SOURCE_ROOT; }; + 7229CC670F6B3295004123C5 /* info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = info.c; path = ../Tremor/info.c; sourceTree = SOURCE_ROOT; }; + 7229CC680F6B3295004123C5 /* ivorbiscodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbiscodec.h; path = ../Tremor/ivorbiscodec.h; sourceTree = SOURCE_ROOT; }; + 7229CC690F6B3295004123C5 /* ivorbisfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbisfile.h; path = ../Tremor/ivorbisfile.h; sourceTree = SOURCE_ROOT; }; + 7229CC6B0F6B3295004123C5 /* lsp_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lsp_lookup.h; path = ../Tremor/lsp_lookup.h; sourceTree = SOURCE_ROOT; }; + 7229CC6C0F6B3295004123C5 /* mapping0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mapping0.c; path = ../Tremor/mapping0.c; sourceTree = SOURCE_ROOT; }; + 7229CC6D0F6B3295004123C5 /* mdct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mdct.c; path = ../Tremor/mdct.c; sourceTree = SOURCE_ROOT; }; + 7229CC6E0F6B3295004123C5 /* mdct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct.h; path = ../Tremor/mdct.h; sourceTree = SOURCE_ROOT; }; + 7229CC6F0F6B3295004123C5 /* mdct_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct_lookup.h; path = ../Tremor/mdct_lookup.h; sourceTree = SOURCE_ROOT; }; + 7229CC700F6B3295004123C5 /* misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = misc.h; path = ../Tremor/misc.h; sourceTree = SOURCE_ROOT; }; + 7229CC710F6B3295004123C5 /* ogg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ogg.h; path = ../Tremor/ogg.h; sourceTree = SOURCE_ROOT; }; + 7229CC720F6B3295004123C5 /* os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os.h; path = ../Tremor/os.h; sourceTree = SOURCE_ROOT; }; + 7229CC730F6B3295004123C5 /* os_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os_types.h; path = ../Tremor/os_types.h; sourceTree = SOURCE_ROOT; }; + 7229CC740F6B3295004123C5 /* registry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = registry.c; path = ../Tremor/registry.c; sourceTree = SOURCE_ROOT; }; + 7229CC750F6B3295004123C5 /* registry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = registry.h; path = ../Tremor/registry.h; sourceTree = SOURCE_ROOT; }; + 7229CC760F6B3295004123C5 /* res012.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = res012.c; path = ../Tremor/res012.c; sourceTree = SOURCE_ROOT; }; + 7229CC770F6B3295004123C5 /* sharedbook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sharedbook.c; path = ../Tremor/sharedbook.c; sourceTree = SOURCE_ROOT; }; + 7229CC780F6B3295004123C5 /* synthesis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = synthesis.c; path = ../Tremor/synthesis.c; sourceTree = SOURCE_ROOT; }; + 7229CC790F6B3295004123C5 /* vorbisfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vorbisfile.c; path = ../Tremor/vorbisfile.c; sourceTree = SOURCE_ROOT; }; + 7229CC7A0F6B3295004123C5 /* window.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = window.c; path = ../Tremor/window.c; sourceTree = SOURCE_ROOT; }; + 7229CC7B0F6B3295004123C5 /* window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window.h; path = ../Tremor/window.h; sourceTree = SOURCE_ROOT; }; + 7229CC7C0F6B3295004123C5 /* window_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window_lookup.h; path = ../Tremor/window_lookup.h; sourceTree = SOURCE_ROOT; }; + 7229CC8E0F6B3363004123C5 /* wolfiphone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wolfiphone.h; path = ../wolfiphone.h; sourceTree = SOURCE_ROOT; }; + 7229CE450F6C89F8004123C5 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; + 7229CE460F6C89F8004123C5 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; }; + 7229CE480F6C89F8004123C5 /* wolf3dAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wolf3dAppDelegate.h; sourceTree = ""; }; + 7229CE490F6C89F8004123C5 /* wolf3dAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = wolf3dAppDelegate.m; sourceTree = ""; }; + 7229CE540F6C8CDE004123C5 /* gles_glue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gles_glue.c; sourceTree = ""; }; + 72935B1A0F6B2D9D0085DD28 /* angle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = angle.c; path = ../env/angle.c; sourceTree = SOURCE_ROOT; }; + 72935B1B0F6B2D9D0085DD28 /* angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = angle.h; path = ../env/angle.h; sourceTree = SOURCE_ROOT; }; + 72935B1C0F6B2D9D0085DD28 /* app_def.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = app_def.h; path = ../env/app_def.h; sourceTree = SOURCE_ROOT; }; + 72935B1D0F6B2D9D0085DD28 /* arch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = arch.c; path = ../env/arch.c; sourceTree = SOURCE_ROOT; }; + 72935B1E0F6B2D9D0085DD28 /* arch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = arch.h; path = ../env/arch.h; sourceTree = SOURCE_ROOT; }; + 72935B230F6B2D9D0085DD28 /* cmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cmd.c; path = ../env/cmd.c; sourceTree = SOURCE_ROOT; }; + 72935B240F6B2D9D0085DD28 /* cmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cmd.h; path = ../env/cmd.h; sourceTree = SOURCE_ROOT; }; + 72935B250F6B2D9D0085DD28 /* com_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = com_string.c; path = ../env/com_string.c; sourceTree = SOURCE_ROOT; }; + 72935B260F6B2D9D0085DD28 /* com_string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = com_string.h; path = ../env/com_string.h; sourceTree = SOURCE_ROOT; }; + 72935B270F6B2D9D0085DD28 /* common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../env/common.c; sourceTree = SOURCE_ROOT; }; + 72935B280F6B2D9D0085DD28 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = common.h; path = ../env/common.h; sourceTree = SOURCE_ROOT; }; + 72935B290F6B2D9D0085DD28 /* common_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = common_utils.h; path = ../env/common_utils.h; sourceTree = SOURCE_ROOT; }; + 72935B2A0F6B2D9D0085DD28 /* console.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = console.c; path = ../env/console.c; sourceTree = SOURCE_ROOT; }; + 72935B2B0F6B2D9D0085DD28 /* console.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = console.h; path = ../env/console.h; sourceTree = SOURCE_ROOT; }; + 72935B2D0F6B2D9D0085DD28 /* cvar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cvar.c; path = ../env/cvar.c; sourceTree = SOURCE_ROOT; }; + 72935B2E0F6B2D9D0085DD28 /* cvar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cvar.h; path = ../env/cvar.h; sourceTree = SOURCE_ROOT; }; + 72935B2F0F6B2D9D0085DD28 /* fileio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fileio.c; path = ../env/fileio.c; sourceTree = SOURCE_ROOT; }; + 72935B310F6B2D9D0085DD28 /* files.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = files.c; path = ../env/files.c; sourceTree = SOURCE_ROOT; }; + 72935B320F6B2D9D0085DD28 /* filestring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = filestring.c; path = ../env/filestring.c; sourceTree = SOURCE_ROOT; }; + 72935B330F6B2D9D0085DD28 /* filestring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = filestring.h; path = ../env/filestring.h; sourceTree = SOURCE_ROOT; }; + 72935B340F6B2D9D0085DD28 /* filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = filesystem.h; path = ../env/filesystem.h; sourceTree = SOURCE_ROOT; }; + 72935B350F6B2D9D0085DD28 /* font_manager.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = font_manager.c; path = ../env/font_manager.c; sourceTree = SOURCE_ROOT; }; + 72935B360F6B2D9D0085DD28 /* font_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = font_manager.h; path = ../env/font_manager.h; sourceTree = SOURCE_ROOT; }; + 72935B370F6B2D9D0085DD28 /* glob.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = glob.c; path = ../env/glob.c; sourceTree = SOURCE_ROOT; }; + 72935B380F6B2D9D0085DD28 /* glob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glob.h; path = ../env/glob.h; sourceTree = SOURCE_ROOT; }; + 72935B3E0F6B2D9D0085DD28 /* math.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = math.c; path = ../env/math.c; sourceTree = SOURCE_ROOT; }; + 72935B3F0F6B2D9D0085DD28 /* matrix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = matrix.c; path = ../env/matrix.c; sourceTree = SOURCE_ROOT; }; + 72935B400F6B2D9D0085DD28 /* matrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = matrix.h; path = ../env/matrix.h; sourceTree = SOURCE_ROOT; }; + 72935B410F6B2D9D0085DD28 /* memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = memory.c; path = ../env/memory.c; sourceTree = SOURCE_ROOT; }; + 72935B420F6B2D9D0085DD28 /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = memory.h; path = ../env/memory.h; sourceTree = SOURCE_ROOT; }; + 72935B450F6B2D9D0085DD28 /* mymath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mymath.h; path = ../env/mymath.h; sourceTree = SOURCE_ROOT; }; + 72935B460F6B2D9D0085DD28 /* myopengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myopengl.h; path = ../env/myopengl.h; sourceTree = SOURCE_ROOT; }; + 72935B470F6B2D9D0085DD28 /* myopengl_extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myopengl_extension.h; path = ../env/myopengl_extension.h; sourceTree = SOURCE_ROOT; }; + 72935B480F6B2D9D0085DD28 /* num_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = num_type.h; path = ../env/num_type.h; sourceTree = SOURCE_ROOT; }; + 72935B490F6B2D9D0085DD28 /* oggfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = oggfile.c; path = ../env/oggfile.c; sourceTree = SOURCE_ROOT; }; + 72935B4A0F6B2D9D0085DD28 /* oggfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = oggfile.h; path = ../env/oggfile.h; sourceTree = SOURCE_ROOT; }; + 72935B4B0F6B2D9D0085DD28 /* openal_binding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = openal_binding.c; path = ../env/openal_binding.c; sourceTree = SOURCE_ROOT; }; + 72935B4C0F6B2D9D0085DD28 /* openal_binding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = openal_binding.h; path = ../env/openal_binding.h; sourceTree = SOURCE_ROOT; }; + 72935B4D0F6B2D9D0085DD28 /* openal_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = openal_main.c; path = ../env/openal_main.c; sourceTree = SOURCE_ROOT; }; + 72935B500F6B2D9D0085DD28 /* opengl_draw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = opengl_draw.c; path = ../env/opengl_draw.c; sourceTree = SOURCE_ROOT; }; + 72935B520F6B2D9D0085DD28 /* opengl_local.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = opengl_local.h; path = ../env/opengl_local.h; sourceTree = SOURCE_ROOT; }; + 72935B530F6B2D9D0085DD28 /* opengl_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = opengl_main.c; path = ../env/opengl_main.c; sourceTree = SOURCE_ROOT; }; + 72935B540F6B2D9D0085DD28 /* opengl_texture.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = opengl_texture.c; path = ../env/opengl_texture.c; sourceTree = SOURCE_ROOT; }; + 72935B560F6B2D9D0085DD28 /* random_number.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = random_number.c; path = ../env/random_number.c; sourceTree = SOURCE_ROOT; }; + 72935B570F6B2D9D0085DD28 /* random_number.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = random_number.h; path = ../env/random_number.h; sourceTree = SOURCE_ROOT; }; + 72935B580F6B2D9D0085DD28 /* renderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = renderer.h; path = ../env/renderer.h; sourceTree = SOURCE_ROOT; }; + 72935B590F6B2D9D0085DD28 /* share.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = share.c; path = ../env/share.c; sourceTree = SOURCE_ROOT; }; + 72935B5A0F6B2D9D0085DD28 /* sound.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sound.c; path = ../env/sound.c; sourceTree = SOURCE_ROOT; }; + 72935B5B0F6B2D9D0085DD28 /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sound.h; path = ../env/sound.h; sourceTree = SOURCE_ROOT; }; + 72935B5C0F6B2D9D0085DD28 /* sound_local.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sound_local.h; path = ../env/sound_local.h; sourceTree = SOURCE_ROOT; }; + 72935B5D0F6B2D9D0085DD28 /* sound_sfx_id.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sound_sfx_id.c; path = ../env/sound_sfx_id.c; sourceTree = SOURCE_ROOT; }; + 72935B5E0F6B2D9D0085DD28 /* sound_stream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sound_stream.c; path = ../env/sound_stream.c; sourceTree = SOURCE_ROOT; }; + 72935B610F6B2D9D0085DD28 /* texture_manager.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = texture_manager.c; path = ../env/texture_manager.c; sourceTree = SOURCE_ROOT; }; + 72935B620F6B2D9D0085DD28 /* texture_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = texture_manager.h; path = ../env/texture_manager.h; sourceTree = SOURCE_ROOT; }; + 72935B630F6B2D9D0085DD28 /* tga.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tga.c; path = ../env/tga.c; sourceTree = SOURCE_ROOT; }; + 72935B640F6B2D9D0085DD28 /* tga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tga.h; path = ../env/tga.h; sourceTree = SOURCE_ROOT; }; + 72935B650F6B2D9D0085DD28 /* timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = timer.h; path = ../env/timer.h; sourceTree = SOURCE_ROOT; }; + 72935B680F6B2D9D0085DD28 /* unix_file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = unix_file.c; path = ../env/unix_file.c; sourceTree = SOURCE_ROOT; }; + 72935B6A0F6B2D9D0085DD28 /* unix_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = unix_timer.c; path = ../env/unix_timer.c; sourceTree = SOURCE_ROOT; }; + 72935B6B0F6B2D9D0085DD28 /* vector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vector.c; path = ../env/vector.c; sourceTree = SOURCE_ROOT; }; + 72935B6C0F6B2D9D0085DD28 /* vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vector.h; path = ../env/vector.h; sourceTree = SOURCE_ROOT; }; + 72935B6D0F6B2D9D0085DD28 /* video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = video.h; path = ../env/video.h; sourceTree = SOURCE_ROOT; }; + 72935B6E0F6B2D9D0085DD28 /* wavfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = wavfile.c; path = ../env/wavfile.c; sourceTree = SOURCE_ROOT; }; + 72935B6F0F6B2D9D0085DD28 /* wavfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wavfile.h; path = ../env/wavfile.h; sourceTree = SOURCE_ROOT; }; + 72935B720F6B2D9D0085DD28 /* zmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = zmem.c; path = ../env/zmem.c; sourceTree = SOURCE_ROOT; }; + 72935B730F6B2D9D0085DD28 /* zmem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zmem.h; path = ../env/zmem.h; sourceTree = SOURCE_ROOT; }; + 72A7E8F30F5F2001005B83C0 /* iphone_wolf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iphone_wolf.h; sourceTree = ""; }; + 72A7E8F60F5F2063005B83C0 /* iphone_menus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iphone_menus.c; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, + 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */, + 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */, + 43E8D4E00F51B48B003F09B2 /* OpenAL.framework in Frameworks */, + 4333CCE80F5CC23E00AE2B6F /* AudioToolbox.framework in Frameworks */, + 43AE7E9F0F67387500B2F562 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* wolf3d.app */, + 4364BF3E0F5CB25900F29317 /* dist.plist */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + 43AE7E9E0F67387500B2F562 /* CoreGraphics.framework */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 72935B180F6B2D630085DD28 /* env */, + 7229CC5A0F6B324A004123C5 /* tremor */, + 72935B190F6B2D720085DD28 /* wolf */, + 32CA4F630368D1EE00C91783 /* wolf3d_Prefix.pch */, + 29B97316FDCFA39411CA2CEA /* main.m */, + 7229CE540F6C8CDE004123C5 /* gles_glue.c */, + 7229CE450F6C89F8004123C5 /* EAGLView.h */, + 7229CE460F6C89F8004123C5 /* EAGLView.m */, + 7229CE480F6C89F8004123C5 /* wolf3dAppDelegate.h */, + 7229CE490F6C89F8004123C5 /* wolf3dAppDelegate.m */, + 7229CC8E0F6B3363004123C5 /* wolfiphone.h */, + 72A7E8F30F5F2001005B83C0 /* iphone_wolf.h */, + 72A7E8F60F5F2063005B83C0 /* iphone_menus.c */, + 43CF03090F56D5C200E4A23D /* iphone_loop.c */, + 43E8D2DF0F4FC61E003F09B2 /* iphone_main.c */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + 43AE7CAA0F61FB0E00B2F562 /* wolf3dEpisode1_icon.png */, + 43CF02FE0F56974E00E4A23D /* Default.png */, + 43CF02EC0F56955F00E4A23D /* wolf3d_icon.png */, + 28AD733E0D9D9553002E5188 /* MainWindow.xib */, + 8D1107310486CEB800E47090 /* Info.plist */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4333CCE70F5CC23E00AE2B6F /* AudioToolbox.framework */, + 43E8D4DF0F51B48B003F09B2 /* OpenAL.framework */, + 28FD15070DC6FC5B0079059D /* QuartzCore.framework */, + 28FD14FF0DC6FC520079059D /* OpenGLES.framework */, + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, + 1D30AB110D05D00D00671497 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7229CC5A0F6B324A004123C5 /* tremor */ = { + isa = PBXGroup; + children = ( + 7229CC5B0F6B3295004123C5 /* asm_arm.h */, + 7229CC5C0F6B3295004123C5 /* backends.h */, + 7229CC5D0F6B3295004123C5 /* bitwise.c */, + 7229CC5E0F6B3295004123C5 /* block.c */, + 7229CC5F0F6B3295004123C5 /* block.h */, + 7229CC600F6B3295004123C5 /* codebook.c */, + 7229CC610F6B3295004123C5 /* codebook.h */, + 7229CC620F6B3295004123C5 /* codec_internal.h */, + 7229CC630F6B3295004123C5 /* config_types.h */, + 7229CC640F6B3295004123C5 /* floor0.c */, + 7229CC650F6B3295004123C5 /* floor1.c */, + 7229CC660F6B3295004123C5 /* framing.c */, + 7229CC670F6B3295004123C5 /* info.c */, + 7229CC680F6B3295004123C5 /* ivorbiscodec.h */, + 7229CC690F6B3295004123C5 /* ivorbisfile.h */, + 7229CC6B0F6B3295004123C5 /* lsp_lookup.h */, + 7229CC6C0F6B3295004123C5 /* mapping0.c */, + 7229CC6D0F6B3295004123C5 /* mdct.c */, + 7229CC6E0F6B3295004123C5 /* mdct.h */, + 7229CC6F0F6B3295004123C5 /* mdct_lookup.h */, + 7229CC700F6B3295004123C5 /* misc.h */, + 7229CC710F6B3295004123C5 /* ogg.h */, + 7229CC720F6B3295004123C5 /* os.h */, + 7229CC730F6B3295004123C5 /* os_types.h */, + 7229CC740F6B3295004123C5 /* registry.c */, + 7229CC750F6B3295004123C5 /* registry.h */, + 7229CC760F6B3295004123C5 /* res012.c */, + 7229CC770F6B3295004123C5 /* sharedbook.c */, + 7229CC780F6B3295004123C5 /* synthesis.c */, + 7229CC790F6B3295004123C5 /* vorbisfile.c */, + 7229CC7A0F6B3295004123C5 /* window.c */, + 7229CC7B0F6B3295004123C5 /* window.h */, + 7229CC7C0F6B3295004123C5 /* window_lookup.h */, + ); + name = tremor; + sourceTree = ""; + }; + 72935B180F6B2D630085DD28 /* env */ = { + isa = PBXGroup; + children = ( + 72935B1A0F6B2D9D0085DD28 /* angle.c */, + 72935B1B0F6B2D9D0085DD28 /* angle.h */, + 72935B1C0F6B2D9D0085DD28 /* app_def.h */, + 72935B1D0F6B2D9D0085DD28 /* arch.c */, + 72935B1E0F6B2D9D0085DD28 /* arch.h */, + 72935B230F6B2D9D0085DD28 /* cmd.c */, + 72935B240F6B2D9D0085DD28 /* cmd.h */, + 72935B250F6B2D9D0085DD28 /* com_string.c */, + 72935B260F6B2D9D0085DD28 /* com_string.h */, + 72935B270F6B2D9D0085DD28 /* common.c */, + 72935B280F6B2D9D0085DD28 /* common.h */, + 72935B290F6B2D9D0085DD28 /* common_utils.h */, + 72935B2A0F6B2D9D0085DD28 /* console.c */, + 72935B2B0F6B2D9D0085DD28 /* console.h */, + 72935B2D0F6B2D9D0085DD28 /* cvar.c */, + 72935B2E0F6B2D9D0085DD28 /* cvar.h */, + 72935B2F0F6B2D9D0085DD28 /* fileio.c */, + 72935B310F6B2D9D0085DD28 /* files.c */, + 72935B320F6B2D9D0085DD28 /* filestring.c */, + 72935B330F6B2D9D0085DD28 /* filestring.h */, + 72935B340F6B2D9D0085DD28 /* filesystem.h */, + 72935B350F6B2D9D0085DD28 /* font_manager.c */, + 72935B360F6B2D9D0085DD28 /* font_manager.h */, + 72935B370F6B2D9D0085DD28 /* glob.c */, + 72935B380F6B2D9D0085DD28 /* glob.h */, + 72935B3E0F6B2D9D0085DD28 /* math.c */, + 72935B3F0F6B2D9D0085DD28 /* matrix.c */, + 72935B400F6B2D9D0085DD28 /* matrix.h */, + 72935B410F6B2D9D0085DD28 /* memory.c */, + 72935B420F6B2D9D0085DD28 /* memory.h */, + 72935B450F6B2D9D0085DD28 /* mymath.h */, + 72935B460F6B2D9D0085DD28 /* myopengl.h */, + 72935B470F6B2D9D0085DD28 /* myopengl_extension.h */, + 72935B480F6B2D9D0085DD28 /* num_type.h */, + 72935B490F6B2D9D0085DD28 /* oggfile.c */, + 72935B4A0F6B2D9D0085DD28 /* oggfile.h */, + 72935B4B0F6B2D9D0085DD28 /* openal_binding.c */, + 72935B4C0F6B2D9D0085DD28 /* openal_binding.h */, + 72935B4D0F6B2D9D0085DD28 /* openal_main.c */, + 72935B500F6B2D9D0085DD28 /* opengl_draw.c */, + 72935B520F6B2D9D0085DD28 /* opengl_local.h */, + 72935B530F6B2D9D0085DD28 /* opengl_main.c */, + 72935B540F6B2D9D0085DD28 /* opengl_texture.c */, + 72935B560F6B2D9D0085DD28 /* random_number.c */, + 72935B570F6B2D9D0085DD28 /* random_number.h */, + 72935B580F6B2D9D0085DD28 /* renderer.h */, + 72935B590F6B2D9D0085DD28 /* share.c */, + 72935B5A0F6B2D9D0085DD28 /* sound.c */, + 72935B5B0F6B2D9D0085DD28 /* sound.h */, + 72935B5C0F6B2D9D0085DD28 /* sound_local.h */, + 72935B5D0F6B2D9D0085DD28 /* sound_sfx_id.c */, + 72935B5E0F6B2D9D0085DD28 /* sound_stream.c */, + 72935B610F6B2D9D0085DD28 /* texture_manager.c */, + 72935B620F6B2D9D0085DD28 /* texture_manager.h */, + 72935B630F6B2D9D0085DD28 /* tga.c */, + 72935B640F6B2D9D0085DD28 /* tga.h */, + 72935B650F6B2D9D0085DD28 /* timer.h */, + 72935B680F6B2D9D0085DD28 /* unix_file.c */, + 72935B6A0F6B2D9D0085DD28 /* unix_timer.c */, + 72935B6B0F6B2D9D0085DD28 /* vector.c */, + 72935B6C0F6B2D9D0085DD28 /* vector.h */, + 72935B6D0F6B2D9D0085DD28 /* video.h */, + 72935B6E0F6B2D9D0085DD28 /* wavfile.c */, + 72935B6F0F6B2D9D0085DD28 /* wavfile.h */, + 72935B720F6B2D9D0085DD28 /* zmem.c */, + 72935B730F6B2D9D0085DD28 /* zmem.h */, + ); + name = env; + sourceTree = ""; + }; + 72935B190F6B2D720085DD28 /* wolf */ = { + isa = PBXGroup; + children = ( + 7229CC240F6B3222004123C5 /* wolf_act_stat.h */, + 7229CC250F6B3222004123C5 /* wolf_actor_ai.c */, + 7229CC260F6B3222004123C5 /* wolf_actor_ai.h */, + 7229CC270F6B3222004123C5 /* wolf_actors.c */, + 7229CC280F6B3222004123C5 /* wolf_actors.h */, + 7229CC290F6B3222004123C5 /* wolf_ai_com.c */, + 7229CC2A0F6B3222004123C5 /* wolf_ai_com.h */, + 7229CC2B0F6B3222004123C5 /* wolf_areas.c */, + 7229CC2C0F6B3222004123C5 /* wolf_bj.c */, + 7229CC2D0F6B3222004123C5 /* wolf_bj.h */, + 7229CC2E0F6B3222004123C5 /* wolf_client_main.c */, + 7229CC300F6B3222004123C5 /* wolf_doors.c */, + 7229CC310F6B3222004123C5 /* wolf_level.c */, + 7229CC320F6B3222004123C5 /* wolf_level.h */, + 7229CC330F6B3222004123C5 /* wolf_local.h */, + 7229CC340F6B3222004123C5 /* wolf_main.c */, + 7229CC350F6B3222004123C5 /* wolf_math.c */, + 7229CC360F6B3222004123C5 /* wolf_math.h */, + 7229CC370F6B3222004123C5 /* wolf_opengl.c */, + 7229CC380F6B3222004123C5 /* wolf_player.c */, + 7229CC390F6B3222004123C5 /* wolf_player.h */, + 7229CC3A0F6B3222004123C5 /* wolf_powerups.c */, + 7229CC3B0F6B3222004123C5 /* wolf_powerups.h */, + 7229CC3C0F6B3222004123C5 /* wolf_pushwalls.c */, + 7229CC3D0F6B3222004123C5 /* wolf_raycast.c */, + 7229CC3E0F6B3222004123C5 /* wolf_raycast.h */, + 7229CC3F0F6B3222004123C5 /* wolf_renderer.c */, + 7229CC400F6B3222004123C5 /* wolf_renderer.h */, + 7229CC410F6B3222004123C5 /* wolf_sprites.c */, + 7229CC420F6B3222004123C5 /* wolf_sprites.h */, + 7229CC430F6B3222004123C5 /* wolf_sv_ccmds.c */, + 7229CC440F6B3222004123C5 /* wolf_weapon.c */, + ); + name = wolf; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* wolf3d */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "wolf3d" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + 435F41A90F532CA300887552 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = wolf3d; + productName = wolf3d; + productReference = 1D6058910D05DD3D006BFB54 /* wolf3d.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "wolf3d" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* wolf3d */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, + 43CF02ED0F56955F00E4A23D /* wolf3d_icon.png in Resources */, + 43CF02FF0F56974E00E4A23D /* Default.png in Resources */, + 4364BF3F0F5CB25900F29317 /* dist.plist in Resources */, + 43AE7CAB0F61FB0E00B2F562 /* wolf3dEpisode1_icon.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 435F41A90F532CA300887552 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = "/bin/sh -x"; + shellScript = "PBXCP=${DEVELOPER_DIR}/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp\n${PBXCP} -exclude .svn \"${PROJECT_DIR}/../../base\" \"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589B0D05DD56006BFB54 /* main.m in Sources */, + 43E8D2E10F4FC61E003F09B2 /* iphone_main.c in Sources */, + 43CF030A0F56D5C200E4A23D /* iphone_loop.c in Sources */, + 72A7E8F70F5F2063005B83C0 /* iphone_menus.c in Sources */, + 72935B740F6B2D9D0085DD28 /* angle.c in Sources */, + 72935B750F6B2D9D0085DD28 /* arch.c in Sources */, + 72935B790F6B2D9D0085DD28 /* cmd.c in Sources */, + 72935B7A0F6B2D9D0085DD28 /* com_string.c in Sources */, + 72935B7B0F6B2D9D0085DD28 /* common.c in Sources */, + 72935B7C0F6B2D9D0085DD28 /* console.c in Sources */, + 72935B7E0F6B2D9D0085DD28 /* cvar.c in Sources */, + 72935B7F0F6B2D9D0085DD28 /* fileio.c in Sources */, + 72935B800F6B2D9D0085DD28 /* files.c in Sources */, + 72935B810F6B2D9D0085DD28 /* filestring.c in Sources */, + 72935B820F6B2D9D0085DD28 /* font_manager.c in Sources */, + 72935B830F6B2D9D0085DD28 /* glob.c in Sources */, + 72935B870F6B2D9D0085DD28 /* math.c in Sources */, + 72935B880F6B2D9D0085DD28 /* matrix.c in Sources */, + 72935B890F6B2D9D0085DD28 /* memory.c in Sources */, + 72935B8B0F6B2D9D0085DD28 /* oggfile.c in Sources */, + 72935B8C0F6B2D9D0085DD28 /* openal_binding.c in Sources */, + 72935B8D0F6B2D9D0085DD28 /* openal_main.c in Sources */, + 72935B8F0F6B2D9D0085DD28 /* opengl_draw.c in Sources */, + 72935B910F6B2D9D0085DD28 /* opengl_main.c in Sources */, + 72935B920F6B2D9D0085DD28 /* opengl_texture.c in Sources */, + 72935B930F6B2D9D0085DD28 /* random_number.c in Sources */, + 72935B940F6B2D9D0085DD28 /* share.c in Sources */, + 72935B950F6B2D9D0085DD28 /* sound.c in Sources */, + 72935B960F6B2D9D0085DD28 /* sound_sfx_id.c in Sources */, + 72935B970F6B2D9D0085DD28 /* sound_stream.c in Sources */, + 72935B990F6B2D9D0085DD28 /* texture_manager.c in Sources */, + 72935B9A0F6B2D9D0085DD28 /* tga.c in Sources */, + 72935B9C0F6B2D9D0085DD28 /* unix_file.c in Sources */, + 72935B9E0F6B2D9D0085DD28 /* unix_timer.c in Sources */, + 72935B9F0F6B2D9D0085DD28 /* vector.c in Sources */, + 72935BA00F6B2D9D0085DD28 /* wavfile.c in Sources */, + 72935BA20F6B2D9D0085DD28 /* zmem.c in Sources */, + 7229CC460F6B3222004123C5 /* wolf_actor_ai.c in Sources */, + 7229CC470F6B3222004123C5 /* wolf_actors.c in Sources */, + 7229CC480F6B3222004123C5 /* wolf_ai_com.c in Sources */, + 7229CC490F6B3222004123C5 /* wolf_areas.c in Sources */, + 7229CC4A0F6B3222004123C5 /* wolf_bj.c in Sources */, + 7229CC4B0F6B3222004123C5 /* wolf_client_main.c in Sources */, + 7229CC4D0F6B3222004123C5 /* wolf_doors.c in Sources */, + 7229CC4E0F6B3222004123C5 /* wolf_level.c in Sources */, + 7229CC4F0F6B3222004123C5 /* wolf_main.c in Sources */, + 7229CC500F6B3222004123C5 /* wolf_math.c in Sources */, + 7229CC510F6B3222004123C5 /* wolf_opengl.c in Sources */, + 7229CC520F6B3222004123C5 /* wolf_player.c in Sources */, + 7229CC530F6B3222004123C5 /* wolf_powerups.c in Sources */, + 7229CC540F6B3222004123C5 /* wolf_pushwalls.c in Sources */, + 7229CC550F6B3222004123C5 /* wolf_raycast.c in Sources */, + 7229CC560F6B3222004123C5 /* wolf_renderer.c in Sources */, + 7229CC570F6B3222004123C5 /* wolf_sprites.c in Sources */, + 7229CC580F6B3222004123C5 /* wolf_sv_ccmds.c in Sources */, + 7229CC590F6B3222004123C5 /* wolf_weapon.c in Sources */, + 7229CC7D0F6B3295004123C5 /* bitwise.c in Sources */, + 7229CC7E0F6B3295004123C5 /* block.c in Sources */, + 7229CC7F0F6B3295004123C5 /* codebook.c in Sources */, + 7229CC800F6B3295004123C5 /* floor0.c in Sources */, + 7229CC810F6B3295004123C5 /* floor1.c in Sources */, + 7229CC820F6B3295004123C5 /* framing.c in Sources */, + 7229CC830F6B3295004123C5 /* info.c in Sources */, + 7229CC850F6B3295004123C5 /* mapping0.c in Sources */, + 7229CC860F6B3295004123C5 /* mdct.c in Sources */, + 7229CC870F6B3295004123C5 /* registry.c in Sources */, + 7229CC880F6B3295004123C5 /* res012.c in Sources */, + 7229CC890F6B3295004123C5 /* sharedbook.c in Sources */, + 7229CC8A0F6B3295004123C5 /* synthesis.c in Sources */, + 7229CC8B0F6B3295004123C5 /* vorbisfile.c in Sources */, + 7229CC8C0F6B3295004123C5 /* window.c in Sources */, + 7229CE4A0F6C89F8004123C5 /* EAGLView.m in Sources */, + 7229CE4C0F6C89F8004123C5 /* wolf3dAppDelegate.m in Sources */, + 7229CE550F6C8CDE004123C5 /* gles_glue.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Cass Everitt"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = wolf3d_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = IPHONE; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + PRODUCT_NAME = wolf3d; + PROFILE_PREFIX = com.idsoftware; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "242E7162-329E-4733-B361-E893AB528543"; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: John Carmack"; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = wolf3d_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = IPHONE; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + PRODUCT_NAME = wolf3d; + PROFILE_PREFIX = com.idsoftware; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "329BF7D2-0B30-4F7B-9204-EB2CBD012BA8"; + }; + name = Release; + }; + 4364BF480F5CB27300F29317 /* AdHocDist */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = dist.plist; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Cass Everitt"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_THUMB_SUPPORT = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "E2E91433-8CD1-46DB-9DC5-B7E4C84FD1C2"; + SDKROOT = iphoneos2.0; + }; + name = AdHocDist; + }; + 4364BF490F5CB27300F29317 /* AdHocDist */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: id Software"; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = wolf3d_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = IPHONE; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + PRODUCT_NAME = wolf3d; + PROFILE_PREFIX = nu.r3; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "31C73095-0DD9-4ABA-BB25-8D23F661F10F"; + }; + name = AdHocDist; + }; + 43AE7CA40F61EC4E00B2F562 /* ReleaseEpisode1 */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_THUMB_SUPPORT = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = iphoneos2.0; + }; + name = ReleaseEpisode1; + }; + 43AE7CA50F61EC4E00B2F562 /* ReleaseEpisode1 */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: John Carmack"; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = wolf3d_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + EPISODE1, + IPHONE, + ); + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + PRODUCT_NAME = wolf3dEpisode1; + PROFILE_PREFIX = com.idsoftware; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "329BF7D2-0B30-4F7B-9204-EB2CBD012BA8"; + }; + name = ReleaseEpisode1; + }; + 43AE7CAE0F61FC9200B2F562 /* DebugEpisode1 */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = iphoneos2.0; + }; + name = DebugEpisode1; + }; + 43AE7CAF0F61FC9200B2F562 /* DebugEpisode1 */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: John Carmack"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = wolf3d_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + EPISODE1, + IPHONE, + ); + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = Info.plist; + PRODUCT_NAME = wolf3dEpisode1; + PROFILE_PREFIX = com.idsoftware; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "329BF7D2-0B30-4F7B-9204-EB2CBD012BA8"; + }; + name = DebugEpisode1; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = iphoneos2.0; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_THUMB_SUPPORT = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = iphoneos2.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "wolf3d" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + 43AE7CAF0F61FC9200B2F562 /* DebugEpisode1 */, + 1D6058950D05DD3E006BFB54 /* Release */, + 43AE7CA50F61EC4E00B2F562 /* ReleaseEpisode1 */, + 4364BF490F5CB27300F29317 /* AdHocDist */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "wolf3d" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + 43AE7CAE0F61FC9200B2F562 /* DebugEpisode1 */, + C01FCF5008A954540054247B /* Release */, + 43AE7CA40F61EC4E00B2F562 /* ReleaseEpisode1 */, + 4364BF480F5CB27300F29317 /* AdHocDist */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/wolf3d/newCode/iphone/wolf3dAppDelegate.h b/wolf3d/newCode/iphone/wolf3dAppDelegate.h new file mode 100644 index 0000000..6875a75 --- /dev/null +++ b/wolf3d/newCode/iphone/wolf3dAppDelegate.h @@ -0,0 +1,46 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#import +#import + +#ifdef _cplusplus +extern "C" { +#endif +void vibrateDevice(); +#ifdef _cplusplus +} +#endif + +@class EAGLView; + +@interface wolf3dAppDelegate : NSObject { + UIWindow *window; + EAGLView *glView; + int lastAccelUpdateMsec; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet EAGLView *glView; + +- (void)restartAccelerometerIfNeeded; + +@end + diff --git a/wolf3d/newCode/iphone/wolf3dAppDelegate.m b/wolf3d/newCode/iphone/wolf3dAppDelegate.m new file mode 100644 index 0000000..9c0e6f6 --- /dev/null +++ b/wolf3d/newCode/iphone/wolf3dAppDelegate.m @@ -0,0 +1,120 @@ +/* + + Copyright (C) 2009 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#import "wolf3dAppDelegate.h" +#import "EAGLView.h" +#import + +extern int iphoneStartup(); +extern int iphoneShutdown(); + +char iphoneDocDirectory[1024]; +char iphoneAppDirectory[1024]; + + +void vibrateDevice() { + printf( "vibrate\n" ); + AudioServicesPlaySystemSound( kSystemSoundID_Vibrate ); +} + +@implementation wolf3dAppDelegate + +@synthesize window; +@synthesize glView; + +- (void)applicationDidFinishLaunching:(UIApplication *)application { + application.statusBarHidden = YES; + application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft; + + // get the documents directory, where we will write configs and save games + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + [documentsDirectory getCString: iphoneDocDirectory + maxLength: sizeof( iphoneDocDirectory ) - 1 + encoding: NSASCIIStringEncoding ]; + + // get the app directory, where our data files live + paths = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES); + NSString *appDirectory = documentsDirectory = [paths objectAtIndex:0]; + [appDirectory getCString: iphoneAppDirectory + maxLength: sizeof( iphoneAppDirectory ) - 1 + encoding: NSASCIIStringEncoding ]; + + // start the flow of accelerometer events + UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; + accelerometer.delegate = self; + accelerometer.updateInterval = 0.01; + + // do all the game startup work + iphoneStartup(); +} + + +- (void)applicationWillResignActive:(UIApplication *)application { +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { +} + +- (void)applicationWillTerminate:(UIApplication *)application { + iphoneShutdown(); +} + + + +- (void)dealloc { + [window release]; + [glView release]; + [super dealloc]; +} + +- (void)restartAccelerometerIfNeeded { + int Sys_Milliseconds(); + + // I have no idea why this seems to happen sometimes... + if ( Sys_Milliseconds() - lastAccelUpdateMsec > 1000 ) { + static int count; + if ( ++count < 100 ) { + printf( "Restarting accelerometer updates.\n" ); + } + UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; + accelerometer.delegate = self; + accelerometer.updateInterval = 0.01; + } +} + +- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration +{ + int Sys_Milliseconds(); + void WolfensteinTilts( float *tilts ); + float acc[4]; + acc[0] = acceleration.x; + acc[1] = acceleration.y; + acc[2] = acceleration.z; + acc[3] = acceleration.timestamp; + WolfensteinTilts( acc ); + lastAccelUpdateMsec = Sys_Milliseconds(); +} + +@end + + + diff --git a/wolf3d/newCode/iphone/wolf3dEpisode1_icon.png b/wolf3d/newCode/iphone/wolf3dEpisode1_icon.png new file mode 100644 index 0000000..2e2d986 Binary files /dev/null and b/wolf3d/newCode/iphone/wolf3dEpisode1_icon.png differ diff --git a/wolf3d/newCode/iphone/wolf3d_Prefix.pch b/wolf3d/newCode/iphone/wolf3d_Prefix.pch new file mode 100644 index 0000000..58ef796 --- /dev/null +++ b/wolf3d/newCode/iphone/wolf3d_Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'wolf3d' target in the 'wolf3d' project +// + +#ifdef __OBJC__ +#import +#import +#endif diff --git a/wolf3d/newCode/iphone/wolf3d_icon.png b/wolf3d/newCode/iphone/wolf3d_icon.png new file mode 100644 index 0000000..956a45a Binary files /dev/null and b/wolf3d/newCode/iphone/wolf3d_icon.png differ diff --git a/wolf3d/newCode/wolf/wolf_act_stat.h b/wolf3d/newCode/wolf/wolf_act_stat.h new file mode 100644 index 0000000..a3b6022 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_act_stat.h @@ -0,0 +1,1619 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_act_stat.h: Wolfenstein3-D entity management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + + +*/ + +#ifndef __WOLF_ACT_STAT_H__ +#define __WOLF_ACT_STAT_H__ + +#include "wolf_bj.h" +#include "wolf_actor_ai.h" +#include "wolf_ai_com.h" +#include "wolf_sprites.h" + +#define ST_INFO_NULL { 0, SPR_DEMO, 0, NULL, NULL, st_dead } + +/* + 1-if object can be rotated, 0 if one sprite for every direction + base object's state texture if rotation is on facing player + after how man frames change state to .next_state + what to do every frame + what to do once per state + next state +*/ + +stateinfo objstate[ NUMENEMIES ][ NUMSTATES ] = +{ + // en_guard, + { + { 1, SPR_GRD_S_1, 0, T_Stand, NULL, st_stand }, // st_stand, + + { 1, SPR_GRD_W1_1, 20, T_Path, NULL, st_path1s }, // st_path1, + { 1, SPR_GRD_W1_1, 5, NULL, NULL, st_path2 }, // st_path1s, + { 1, SPR_GRD_W2_1, 15, T_Path, NULL, st_path3 }, // st_path2, + { 1, SPR_GRD_W3_1, 20, T_Path, NULL, st_path3s }, // st_path3, + { 1, SPR_GRD_W3_1, 5, NULL, NULL, st_path4 }, // st_path3s, + { 1, SPR_GRD_W4_1, 15, T_Path, NULL, st_path1 }, // st_path4, + + { 0, SPR_GRD_PAIN_1, 10, NULL, NULL, st_chase1},// st_pain, + { 0, SPR_GRD_PAIN_2, 10, NULL, NULL, st_chase1},// st_pain1, + + { 0, SPR_GRD_SHOOT1, 20, NULL, NULL, st_shoot2},// st_shoot1, + { 0, SPR_GRD_SHOOT2, 20, NULL, T_Shoot,st_shoot3},// st_shoot2, + { 0, SPR_GRD_SHOOT3, 20, NULL, NULL, st_chase1},// st_shoot3, + + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot4, + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot5, + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot6, + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot7, + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot8, + { 0, SPR_DEMO, 0, NULL, NULL, st_chase1 }, // st_shoot9, + + { 1, SPR_GRD_W1_1, 10, T_Chase, NULL, st_chase1s }, // st_chase1, + { 1, SPR_GRD_W1_1, 3, NULL, NULL, st_chase2 }, // st_chase1s, + { 1, SPR_GRD_W2_1, 8, T_Chase, NULL, st_chase3 }, // st_chase2, + { 1, SPR_GRD_W3_1, 10, T_Chase, NULL, st_chase3s }, // st_chase3, + { 1, SPR_GRD_W3_1, 3, NULL, NULL, st_chase4 }, // st_chase3s, + { 1, SPR_GRD_W4_1, 8, T_Chase, NULL, st_chase1 }, // st_chase4, + + { 0, SPR_GRD_DIE_1, 15, NULL, A_DeathScream,st_die2 }, // st_die1, + { 0, SPR_GRD_DIE_2, 15, NULL, NULL, st_die3 }, // st_die2, + { 0, SPR_GRD_DIE_3, 15, NULL, NULL, st_dead }, // st_die3, + + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die4, + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die5, + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die6, + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die7, + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die8, + { 0, SPR_DEMO, 0, NULL, NULL, st_dead }, // st_die9, + + { 0, SPR_GRD_DEAD, 0, NULL, NULL, st_dead } // st_dead + }, + // en_officer, + { + {1, SPR_OFC_S_1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {1, SPR_OFC_W1_1, 20, T_Path, NULL, st_path1s},// st_path1, + {1, SPR_OFC_W1_1, 5, NULL , NULL, st_path2}, // st_path1s, + {1, SPR_OFC_W2_1, 15, T_Path, NULL, st_path3}, // st_path2, + {1, SPR_OFC_W3_1, 20, T_Path, NULL, st_path3s},// st_path3, + {1, SPR_OFC_W3_1, 5, NULL , NULL, st_path4}, // st_path3s, + {1, SPR_OFC_W4_1, 15, T_Path, NULL, st_path1}, // st_path4, + + {0, SPR_OFC_PAIN_1, 10, NULL, NULL, st_chase1},// st_pain, + {0, SPR_OFC_PAIN_2, 10, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_OFC_SHOOT1, 6, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_OFC_SHOOT2, 20, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_OFC_SHOOT3, 10, NULL, NULL, st_chase1},// st_shoot3, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {1, SPR_OFC_W1_1, 10, T_Chase, NULL, st_chase1s},// st_chase1, + {1, SPR_OFC_W1_1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {1, SPR_OFC_W2_1, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {1, SPR_OFC_W3_1, 10, T_Chase, NULL, st_chase3s},// st_chase3, + {1, SPR_OFC_W3_1, 3, NULL , NULL, st_chase4}, // st_chase3s, + {1, SPR_OFC_W4_1, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_OFC_DIE_1, 11, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_OFC_DIE_2, 11, NULL, NULL, st_die3},// st_die2, + {0, SPR_OFC_DIE_3, 11, NULL, NULL, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_OFC_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_ss, + { + {1, SPR_SS_S_1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {1, SPR_SS_W1_1, 20, T_Path, NULL, st_path1s},// st_path1, + {1, SPR_SS_W1_1, 5, NULL , NULL, st_path2}, // st_path1s, + {1, SPR_SS_W2_1, 15, T_Path, NULL, st_path3}, // st_path2, + {1, SPR_SS_W3_1, 20, T_Path, NULL, st_path3s},// st_path3, + {1, SPR_SS_W3_1, 5, NULL , NULL, st_path4}, // st_path3s, + {1, SPR_SS_W4_1, 15, T_Path, NULL, st_path1}, // st_path4, + + {0, SPR_SS_PAIN_1, 10, NULL, NULL, st_chase1},// st_pain, + {0, SPR_SS_PAIN_2, 10, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_SS_SHOOT1, 20, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_SS_SHOOT2, 20, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_SS_SHOOT3, 10, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_SS_SHOOT2, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_SS_SHOOT3, 10, NULL, NULL, st_shoot6},// st_shoot5, + {0, SPR_SS_SHOOT2, 10, NULL, T_Shoot, st_shoot7},// st_shoot6, + {0, SPR_SS_SHOOT3, 10, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_SS_SHOOT2, 10, NULL, T_Shoot, st_shoot9},// st_shoot8, + {0, SPR_SS_SHOOT3, 10, NULL, NULL, st_chase1},// st_shoot9, + + {1, SPR_SS_W1_1, 10, T_Chase, NULL, st_chase1s},// st_chase1, + {1, SPR_SS_W1_1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {1, SPR_SS_W2_1, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {1, SPR_SS_W3_1, 10, T_Chase, NULL, st_chase3s},// st_chase3, + {1, SPR_SS_W3_1, 3, NULL , NULL, st_chase4}, // st_chase3s, + {1, SPR_SS_W4_1, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_SS_DIE_1, 15, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_SS_DIE_2, 15, NULL, NULL, st_die3},// st_die2, + {0, SPR_SS_DIE_3, 15, NULL, NULL, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_SS_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_dog, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {1, SPR_DOG_W1_1, 20, T_Path, NULL, st_path1s},// st_path1, + {1, SPR_DOG_W1_1, 5, NULL , NULL, st_path2}, // st_path1s, + {1, SPR_DOG_W2_1, 15, T_Path, NULL, st_path3}, // st_path2, + {1, SPR_DOG_W3_1, 20, T_Path, NULL, st_path3s},// st_path3, + {1, SPR_DOG_W3_1, 5, NULL , NULL, st_path4}, // st_path3s, + {1, SPR_DOG_W4_1, 15, T_Path, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_DOG_JUMP1, 10, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_DOG_JUMP2, 10, NULL, T_Bite, st_shoot3},// st_shoot2, + {0, SPR_DOG_JUMP3, 10, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_DOG_JUMP1, 10, NULL, NULL, st_shoot5},// st_shoot4, + {0, SPR_DOG_W1_1, 10, NULL, NULL, st_chase1},// st_shoot5, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {1, SPR_DOG_W1_1, 10, T_DogChase, NULL, st_chase1s},// st_chase1, + {1, SPR_DOG_W1_1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {1, SPR_DOG_W2_1, 8, T_DogChase, NULL, st_chase3}, // st_chase2, + {1, SPR_DOG_W3_1, 10, T_DogChase, NULL, st_chase3s},// st_chase3, + {1, SPR_DOG_W3_1, 3, NULL , NULL, st_chase4}, // st_chase3s, + {1, SPR_DOG_W4_1, 8, T_DogChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_DOG_DIE_1, 15, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_DOG_DIE_2, 15, NULL, NULL, st_die3},// st_die2, + {0, SPR_DOG_DIE_3, 15, NULL, NULL, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_DOG_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_boss, + { + {0, SPR_BOSS_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_BOSS_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_BOSS_SHOOT2, 10, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_BOSS_SHOOT3, 10, NULL, T_Shoot, st_shoot4},// st_shoot3, + {0, SPR_BOSS_SHOOT2, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_BOSS_SHOOT3, 10, NULL, T_Shoot, st_shoot6},// st_shoot5, + {0, SPR_BOSS_SHOOT2, 10, NULL, T_Shoot, st_shoot7},// st_shoot6, + {0, SPR_BOSS_SHOOT3, 10, NULL, T_Shoot, st_shoot8},// st_shoot7, + {0, SPR_BOSS_SHOOT1, 10, NULL, NULL, st_chase1},// st_shoot8, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_BOSS_W1, 10, T_Chase, NULL, st_chase1s},// st_chase1, + {0, SPR_BOSS_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_BOSS_W2, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_BOSS_W3, 10, T_Chase, NULL, st_chase3s},// st_chase3, + {0, SPR_BOSS_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_BOSS_W4, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_BOSS_DIE1, 15, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_BOSS_DIE2, 15, NULL, NULL, st_die3},// st_die2, + {0, SPR_BOSS_DIE3, 15, NULL, NULL, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_BOSS_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_schabbs, + { + {0, SPR_SCHABB_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_SCHABB_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_SCHABB_SHOOT2, 10, NULL, T_Launch, st_chase1},// st_shoot2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_SCHABB_W1, 10, T_BossChase, NULL, st_chase1s},// st_chase1, + {0, SPR_SCHABB_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_SCHABB_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_SCHABB_W3, 10, T_BossChase, NULL, st_chase3s},// st_chase3, + {0, SPR_SCHABB_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_SCHABB_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_SCHABB_W1, 10, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_SCHABB_W1, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_SCHABB_DIE1, 10, NULL, NULL, st_die4},// st_die3, + {0, SPR_SCHABB_DIE2, 10, NULL, NULL, st_die5},// st_die4, + {0, SPR_SCHABB_DIE3, 10, NULL, NULL, st_dead},// st_die5, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_SCHABB_DEAD, 0, NULL, A_StartDeathCam, st_dead} // st_dead + }, + // en_fake, + { + {0, SPR_FAKE_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot2},// st_shoot1, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot3},// st_shoot2, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot4},// st_shoot3, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot5},// st_shoot4, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot6},// st_shoot4, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot7},// st_shoot4, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot8},// st_shoot4, + {0, SPR_FAKE_SHOOT, 8, NULL, T_Launch, st_shoot9},// st_shoot4, + {0, SPR_FAKE_SHOOT, 8, NULL, NULL, st_chase1},// st_shoot4, + + {0, SPR_FAKE_W1, 10, T_Fake, NULL, st_chase1s},// st_chase1, + {0, SPR_FAKE_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_FAKE_W2, 8, T_Fake, NULL, st_chase3}, // st_chase2, + {0, SPR_FAKE_W3, 10, T_Fake, NULL, st_chase3s},// st_chase3, + {0, SPR_FAKE_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_FAKE_W4, 8, T_Fake, NULL, st_chase1}, // st_chase4, + + {0, SPR_FAKE_DIE1, 10, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_FAKE_DIE2, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_FAKE_DIE3, 10, NULL, NULL, st_die4},// st_die3, + {0, SPR_FAKE_DIE4, 10, NULL, NULL, st_die5},// st_die4, + {0, SPR_FAKE_DIE5, 10, NULL, NULL, st_dead},// st_die5, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_FAKE_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_hitler, (mecha) + { + {0, SPR_MECHA_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_MECHA_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_MECHA_SHOOT2, 10, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_MECHA_SHOOT3, 10, NULL, T_Shoot, st_shoot4},// st_shoot3, + {0, SPR_MECHA_SHOOT2, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_MECHA_SHOOT3, 10, NULL, T_Shoot, st_shoot6},// st_shoot5, + {0, SPR_MECHA_SHOOT2, 10, NULL, T_Shoot, st_chase1},// st_shoot6, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_MECHA_W1, 10, T_Chase, A_MechaSound, st_chase1s},// st_chase1, + {0, SPR_MECHA_W1, 6, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_MECHA_W2, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_MECHA_W3, 10, T_Chase, A_MechaSound, st_chase3s},// st_chase3, + {0, SPR_MECHA_W3, 6, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_MECHA_W4, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_MECHA_DIE1, 10, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_MECHA_DIE2, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_MECHA_DIE3, 10, NULL, A_HitlerMorph, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_MECHA_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_hitler, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_HITLER_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_HITLER_SHOOT2, 10, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_HITLER_SHOOT3, 10, NULL, T_Shoot, st_shoot4},// st_shoot3, + {0, SPR_HITLER_SHOOT2, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_HITLER_SHOOT3, 10, NULL, T_Shoot, st_shoot6},// st_shoot5, + {0, SPR_HITLER_SHOOT2, 10, NULL, T_Shoot, st_chase1},// st_shoot6, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_HITLER_W1, 6, T_Chase, NULL, st_chase1s}, // st_chase1, + {0, SPR_HITLER_W1, 4, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_HITLER_W2, 2, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_HITLER_W3, 6, T_Chase, NULL, st_chase3s}, // st_chase3, + {0, SPR_HITLER_W3, 4, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_HITLER_W4, 2, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_HITLER_W1, 1, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_HITLER_W1, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_HITLER_DIE1, 10, NULL, NULL, st_dead},// st_die3, + {0, SPR_HITLER_DIE2, 10, NULL, NULL, st_dead},// st_die4, + {0, SPR_HITLER_DIE3, 10, NULL, NULL, st_dead},// st_die5, + {0, SPR_HITLER_DIE4, 10, NULL, NULL, st_dead},// st_die6, + {0, SPR_HITLER_DIE5, 10, NULL, NULL, st_dead},// st_die7, + {0, SPR_HITLER_DIE6, 10, NULL, NULL, st_dead},// st_die8, + {0, SPR_HITLER_DIE7, 10, NULL, NULL, st_dead},// st_die9, + + {0, SPR_HITLER_DEAD, 0, NULL, A_StartDeathCam, st_dead} // st_dead + }, + // en_mutant, + { + {1, SPR_MUT_S_1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {1, SPR_MUT_W1_1, 20, T_Path, NULL, st_path1s},// st_path1, + {1, SPR_MUT_W1_1, 5, NULL , NULL, st_path2}, // st_path1s, + {1, SPR_MUT_W2_1, 15, T_Path, NULL, st_path3}, // st_path2, + {1, SPR_MUT_W3_1, 20, T_Path, NULL, st_path3s},// st_path3, + {1, SPR_MUT_W3_1, 5, NULL , NULL, st_path4}, // st_path3s, + {1, SPR_MUT_W4_1, 15, T_Path, NULL, st_path1}, // st_path4, + + {0, SPR_MUT_PAIN_1, 10, NULL, NULL, st_chase1},// st_pain, + {0, SPR_MUT_PAIN_2, 10, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_MUT_SHOOT1, 6, NULL, T_Shoot, st_shoot2}, // st_shoot1, + {0, SPR_MUT_SHOOT2, 20, NULL, NULL, st_shoot3}, // st_shoot2, + {0, SPR_MUT_SHOOT3, 10, NULL, T_Shoot, st_shoot4}, // st_shoot3, + {0, SPR_MUT_SHOOT4, 20, NULL, NULL, st_chase1}, // st_shoot4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {1, SPR_MUT_W1_1, 10, T_Chase, NULL, st_chase1s},// st_chase1, + {1, SPR_MUT_W1_1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {1, SPR_MUT_W2_1, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {1, SPR_MUT_W3_1, 10, T_Chase, NULL, st_chase3s},// st_chase3, + {1, SPR_MUT_W3_1, 3, NULL , NULL, st_chase4}, // st_chase3s, + {1, SPR_MUT_W4_1, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_MUT_DIE_1, 7, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_MUT_DIE_2, 7, NULL, NULL, st_die3},// st_die2, + {0, SPR_MUT_DIE_3, 7, NULL, NULL, st_die4},// st_die3, + {0, SPR_MUT_DIE_4, 7, NULL, NULL, st_dead},// st_die4, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_MUT_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_blinky, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot3},// st_shoot2, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot5},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot6},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_BLINKY_W1, 10, T_Ghosts, NULL, st_chase2},// st_chase1, + {0, SPR_DEMO, 0, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_BLINKY_W2, 10, T_Ghosts, NULL, st_chase1},// st_chase2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase3s},// st_chase3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1}, // st_chase4, + + {0, SPR_DEMO, 10, NULL, NULL, st_die2},// st_die1, + {0, SPR_DEMO, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_DEMO, 10, NULL, NULL, st_dead},// st_die3, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead} // st_dead + }, + // en_clyde, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot3},// st_shoot2, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot5},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot6},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_CLYDE_W1, 10, T_Ghosts, NULL, st_chase2},// st_chase1, + {0, SPR_DEMO, 0, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_CLYDE_W2, 10, T_Ghosts, NULL, st_chase1},// st_chase2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase3s},// st_chase3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1}, // st_chase4, + + {0, SPR_DEMO, 10, NULL, NULL, st_die2},// st_die1, + {0, SPR_DEMO, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_DEMO, 10, NULL, NULL, st_dead},// st_die3, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead} // st_dead + }, + // en_pinky, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot3},// st_shoot2, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot5},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot6},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_PINKY_W1, 10, T_Ghosts, NULL, st_chase2},// st_chase1, + {0, SPR_DEMO, 0, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_PINKY_W2, 10, T_Ghosts, NULL, st_chase1},// st_chase2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase3s},// st_chase3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1}, // st_chase4, + + {0, SPR_DEMO, 10, NULL, NULL, st_die2},// st_die1, + {0, SPR_DEMO, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_DEMO, 10, NULL, NULL, st_dead},// st_die3, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead} // st_dead + }, + // en_inky, + { + {0, SPR_DEMO, 0, NULL, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_DEMO, 0, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot3},// st_shoot2, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot4},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot5},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot6},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot8},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_shoot9},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_INKY_W1, 10, T_Ghosts, NULL, st_chase2},// st_chase1, + {0, SPR_DEMO, 0, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_INKY_W2, 10, T_Ghosts, NULL, st_chase1},// st_chase2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase3s},// st_chase3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1}, // st_chase4, + + {0, SPR_DEMO, 10, NULL, NULL, st_die2},// st_die1, + {0, SPR_DEMO, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_DEMO, 10, NULL, NULL, st_dead},// st_die3, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead} // st_dead + }, + // en_gretel, + { + {0, SPR_GRETEL_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_GRETEL_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_GRETEL_SHOOT2, 10, NULL, T_Shoot, st_shoot3},// st_shoot2, + {0, SPR_GRETEL_SHOOT3, 10, NULL, T_Shoot, st_shoot4},// st_shoot3, + {0, SPR_GRETEL_SHOOT2, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_GRETEL_SHOOT3, 10, NULL, T_Shoot, st_shoot6},// st_shoot5, + {0, SPR_GRETEL_SHOOT2, 10, NULL, T_Shoot, st_shoot7},// st_shoot6, + {0, SPR_GRETEL_SHOOT3, 10, NULL, T_Shoot, st_shoot8},// st_shoot7, + {0, SPR_GRETEL_SHOOT1, 10, NULL, NULL, st_chase1},// st_shoot8, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_GRETEL_W1, 10, T_Chase, NULL, st_chase1s},// st_chase1, + {0, SPR_GRETEL_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_GRETEL_W2, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_GRETEL_W3, 10, T_Chase, NULL, st_chase3s},// st_chase3, + {0, SPR_GRETEL_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_GRETEL_W4, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_GRETEL_DIE1, 15, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_GRETEL_DIE2, 15, NULL, NULL, st_die3},// st_die2, + {0, SPR_GRETEL_DIE3, 15, NULL, NULL, st_dead},// st_die3, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die4, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die5, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_GRETEL_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_gift, + { + {0, SPR_GIFT_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_GIFT_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_GIFT_SHOOT2, 10, NULL, T_Launch, st_chase1},// st_shoot2, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot3, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot4, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot5, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot6, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_GIFT_W1, 10, T_BossChase, NULL, st_chase1s},// st_chase1, + {0, SPR_GIFT_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_GIFT_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_GIFT_W3, 10, T_BossChase, NULL, st_chase3s},// st_chase3, + {0, SPR_GIFT_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_GIFT_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_GIFT_W1, 10, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_GIFT_W1, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_GIFT_DIE1, 10, NULL, NULL, st_die4},// st_die3, + {0, SPR_GIFT_DIE2, 10, NULL, NULL, st_die5},// st_die4, + {0, SPR_GIFT_DIE3, 10, NULL, NULL, st_dead},// st_die5, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_GIFT_DEAD, 0, NULL, A_StartDeathCam, st_dead} // st_dead + }, + // en_fat, + { + {0, SPR_FAT_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + {0, SPR_DEMO, 0, NULL, NULL, st_path1s},// st_path1, + {0, SPR_DEMO, 0, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_DEMO, 0, NULL, NULL, st_path3}, // st_path2, + {0, SPR_DEMO, 0, NULL, NULL, st_path3s},// st_path3, + {0, SPR_DEMO, 0, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_DEMO, 0, NULL, NULL, st_path1}, // st_path4, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_pain1, + + {0, SPR_FAT_SHOOT1, 30, NULL, NULL, st_shoot2},// st_shoot1, + {0, SPR_FAT_SHOOT2, 10, NULL, T_Launch, st_shoot3},// st_shoot2, + {0, SPR_FAT_SHOOT3, 10, NULL, T_Shoot, st_shoot4},// st_shoot3, + {0, SPR_FAT_SHOOT4, 10, NULL, T_Shoot, st_shoot5},// st_shoot4, + {0, SPR_FAT_SHOOT3, 10, NULL, T_Shoot, st_shoot6},// st_shoot5, + {0, SPR_FAT_SHOOT4, 10, NULL, T_Shoot, st_chase1},// st_shoot6, + + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot7, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot8, + {0, SPR_DEMO, 0, NULL, NULL, st_chase1},// st_shoot9, + + {0, SPR_FAT_W1, 10, T_BossChase, NULL, st_chase1s},// st_chase1, + {0, SPR_FAT_W1, 3, NULL , NULL, st_chase2}, // st_chase1s, + {0, SPR_FAT_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_FAT_W3, 10, T_BossChase, NULL, st_chase3s},// st_chase3, + {0, SPR_FAT_W3, 3, NULL , NULL, st_chase4}, // st_chase3s, + {0, SPR_FAT_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_FAT_W1, 10, NULL, A_DeathScream, st_die2},// st_die1, + {0, SPR_FAT_W1, 10, NULL, NULL, st_die3},// st_die2, + {0, SPR_FAT_DIE1, 10, NULL, NULL, st_die4},// st_die3, + {0, SPR_FAT_DIE2, 10, NULL, NULL, st_die5},// st_die4, + {0, SPR_FAT_DIE3, 10, NULL, NULL, st_dead},// st_die5, + + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die6, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die7, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die8, + {0, SPR_DEMO, 0, NULL, NULL, st_dead},// st_die9, + + {0, SPR_FAT_DEAD, 0, NULL, A_StartDeathCam, st_dead} // st_dead + }, +// --- Projectiles + // en_needle, + { + ST_INFO_NULL, // st_stand, + + {0, SPR_HYPO1, 6, T_Projectile, NULL, st_path2}, // st_path1, + ST_INFO_NULL, // st_path1s, + {0, SPR_HYPO2, 6, T_Projectile, NULL, st_path3}, // st_path2, + {0, SPR_HYPO3, 6, T_Projectile, NULL, st_path4}, // st_path3, + ST_INFO_NULL, // st_path3s, + {0, SPR_HYPO4, 6, T_Projectile, NULL, st_path1}, // st_path4, + + ST_INFO_NULL,// st_pain, + ST_INFO_NULL,// st_pain1, + + ST_INFO_NULL,// st_shoot1, + ST_INFO_NULL,// st_shoot2, + ST_INFO_NULL,// st_shoot3, + ST_INFO_NULL,// st_shoot4, + ST_INFO_NULL,// st_shoot5, + ST_INFO_NULL,// st_shoot6, + + ST_INFO_NULL,// st_shoot7, + ST_INFO_NULL,// st_shoot8, + ST_INFO_NULL,// st_shoot9, + + ST_INFO_NULL,// st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL,// st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + ST_INFO_NULL, // st_die1, + ST_INFO_NULL, // st_die2, + ST_INFO_NULL, // st_die3, + ST_INFO_NULL,// st_die4, + ST_INFO_NULL,// st_die5, + + ST_INFO_NULL,// st_die6, + ST_INFO_NULL,// st_die7, + ST_INFO_NULL,// st_die8, + ST_INFO_NULL,// st_die9, + + ST_INFO_NULL // st_dead + }, + // en_fire, + { + ST_INFO_NULL, // st_stand, + + {0, SPR_FIRE1, 6, NULL, T_Projectile, st_path2}, // st_path1, + ST_INFO_NULL, // st_path1s, + {0, SPR_FIRE2, 6, NULL, T_Projectile, st_path1}, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL,// st_pain, + ST_INFO_NULL,// st_pain1, + + ST_INFO_NULL,// st_shoot1, + ST_INFO_NULL,// st_shoot2, + ST_INFO_NULL,// st_shoot3, + ST_INFO_NULL,// st_shoot4, + ST_INFO_NULL,// st_shoot5, + ST_INFO_NULL,// st_shoot6, + + ST_INFO_NULL,// st_shoot7, + ST_INFO_NULL,// st_shoot8, + ST_INFO_NULL,// st_shoot9, + + ST_INFO_NULL,// st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL,// st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + ST_INFO_NULL, // st_die1, + ST_INFO_NULL, // st_die2, + ST_INFO_NULL, // st_die3, + ST_INFO_NULL,// st_die4, + ST_INFO_NULL,// st_die5, + + ST_INFO_NULL,// st_die6, + ST_INFO_NULL,// st_die7, + ST_INFO_NULL,// st_die8, + ST_INFO_NULL,// st_die9, + + ST_INFO_NULL // st_dead + }, + // en_rocket, + { + {1, SPR_ROCKET_1, 3, T_Projectile, A_Smoke, st_stand}, // st_stand, + + ST_INFO_NULL,// st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL,// st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL,// st_pain, + ST_INFO_NULL,// st_pain1, + + ST_INFO_NULL,// st_shoot1, + ST_INFO_NULL,// st_shoot2, + ST_INFO_NULL,// st_shoot3, + ST_INFO_NULL,// st_shoot4, + ST_INFO_NULL,// st_shoot5, + ST_INFO_NULL,// st_shoot6, + + ST_INFO_NULL,// st_shoot7, + ST_INFO_NULL,// st_shoot8, + ST_INFO_NULL,// st_shoot9, + + ST_INFO_NULL,// st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL,// st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + {0, SPR_BOOM_1, 6, NULL, NULL, st_die2}, // st_die1, + {0, SPR_BOOM_2, 6, NULL, NULL, st_die3}, // st_die2, + {0, SPR_BOOM_3, 6, NULL, NULL, st_remove}, // st_die3, + ST_INFO_NULL,// st_die4, + ST_INFO_NULL,// st_die5, + + ST_INFO_NULL,// st_die6, + ST_INFO_NULL,// st_die7, + ST_INFO_NULL,// st_die8, + ST_INFO_NULL,// st_die9, + + ST_INFO_NULL // st_dead + }, + // en_smoke, + { + ST_INFO_NULL, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + ST_INFO_NULL, // st_shoot1, + ST_INFO_NULL, // st_shoot2, + ST_INFO_NULL, // st_shoot3, + ST_INFO_NULL, // st_shoot4, + ST_INFO_NULL, // st_shoot5, + ST_INFO_NULL, // st_shoot6, + + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + ST_INFO_NULL, // st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL, // st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + {0, SPR_SMOKE_1, 3, NULL, NULL, st_die2}, // st_die1, + {0, SPR_SMOKE_2, 3, NULL, NULL, st_die3}, // st_die2, + {0, SPR_SMOKE_3, 3, NULL, NULL, st_die4}, // st_die3, + {0, SPR_SMOKE_4, 3, NULL, NULL, st_remove}, // st_die4, + ST_INFO_NULL, // st_die5, + + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + ST_INFO_NULL // st_dead + }, + // en_bj, + { + ST_INFO_NULL, // st_stand, + + {0, SPR_BJ_W1, 12, T_BJRun, NULL, st_path1s}, // st_path1, + {0, SPR_BJ_W1, 3, NULL, NULL, st_path2}, // st_path1s, + {0, SPR_BJ_W2, 8, T_BJRun, NULL, st_path3}, // st_path2, + {0, SPR_BJ_W3, 12, T_BJRun, NULL, st_path3s}, // st_path3, + {0, SPR_BJ_W3, 3, NULL, NULL, st_path4}, // st_path3s, + {0, SPR_BJ_W4, 8, T_BJRun, NULL, st_path1}, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + {0, SPR_BJ_JUMP1, 14, T_BJJump, NULL, st_shoot2}, // st_shoot1, + {0, SPR_BJ_JUMP2, 14, T_BJJump, T_BJYell, st_shoot3}, // st_shoot2, + {0, SPR_BJ_JUMP3, 14, T_BJJump, NULL, st_shoot4}, // st_shoot3, + {0, SPR_BJ_JUMP4,300, NULL, T_BJDone, st_shoot4}, // st_shoot4, + ST_INFO_NULL, // st_shoot5, + ST_INFO_NULL, // st_shoot6, + + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + ST_INFO_NULL, // st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL, // st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + ST_INFO_NULL, // st_die1, + ST_INFO_NULL, // st_die2, + ST_INFO_NULL, // st_die3, + ST_INFO_NULL, // st_die4, + ST_INFO_NULL, // st_die5, + + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + ST_INFO_NULL // st_dead + }, + +// --- Spear of destiny! + // en_spark, + { + ST_INFO_NULL, // st_stand, + + {0, SPR_SPARK1, 6, T_Projectile, NULL, st_path2}, // st_path1, + ST_INFO_NULL, // st_path1s, + {0, SPR_SPARK2, 6, T_Projectile, NULL, st_path3}, // st_path2, + {0, SPR_SPARK3, 6, T_Projectile, NULL, st_path4}, // st_path3, + ST_INFO_NULL, // st_path3s, + {0, SPR_SPARK4, 6, T_Projectile, NULL, st_path1}, // st_path4, + + ST_INFO_NULL,// st_pain, + ST_INFO_NULL,// st_pain1, + + ST_INFO_NULL,// st_shoot1, + ST_INFO_NULL,// st_shoot2, + ST_INFO_NULL,// st_shoot3, + ST_INFO_NULL,// st_shoot4, + ST_INFO_NULL,// st_shoot5, + ST_INFO_NULL,// st_shoot6, + + ST_INFO_NULL,// st_shoot7, + ST_INFO_NULL,// st_shoot8, + ST_INFO_NULL,// st_shoot9, + + ST_INFO_NULL,// st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL,// st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + ST_INFO_NULL, // st_die1, + ST_INFO_NULL, // st_die2, + ST_INFO_NULL, // st_die3, + ST_INFO_NULL,// st_die4, + ST_INFO_NULL,// st_die5, + + ST_INFO_NULL,// st_die6, + ST_INFO_NULL,// st_die7, + ST_INFO_NULL,// st_die8, + ST_INFO_NULL,// st_die9, + + ST_INFO_NULL // st_dead + }, + // en_hrocket, + { + {1, SPR_HROCKET_1, 3, T_Projectile, A_Smoke, st_stand}, // st_stand, + + ST_INFO_NULL,// st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL,// st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL,// st_pain, + ST_INFO_NULL,// st_pain1, + + ST_INFO_NULL,// st_shoot1, + ST_INFO_NULL,// st_shoot2, + ST_INFO_NULL,// st_shoot3, + ST_INFO_NULL,// st_shoot4, + ST_INFO_NULL,// st_shoot5, + ST_INFO_NULL,// st_shoot6, + + ST_INFO_NULL,// st_shoot7, + ST_INFO_NULL,// st_shoot8, + ST_INFO_NULL,// st_shoot9, + + ST_INFO_NULL,// st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL,// st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + {0, SPR_HBOOM_1, 6, NULL, NULL, st_die2}, // st_die1, + {0, SPR_HBOOM_2, 6, NULL, NULL, st_die3}, // st_die2, + {0, SPR_HBOOM_3, 6, NULL, NULL, st_remove}, // st_die3, + ST_INFO_NULL,// st_die4, + ST_INFO_NULL,// st_die5, + + ST_INFO_NULL,// st_die6, + ST_INFO_NULL,// st_die7, + ST_INFO_NULL,// st_die8, + ST_INFO_NULL,// st_die9, + + ST_INFO_NULL // st_dead + }, + // en_hsmoke, + { + ST_INFO_NULL, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + ST_INFO_NULL, // st_shoot1, + ST_INFO_NULL, // st_shoot2, + ST_INFO_NULL, // st_shoot3, + ST_INFO_NULL, // st_shoot4, + ST_INFO_NULL, // st_shoot5, + ST_INFO_NULL, // st_shoot6, + + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + ST_INFO_NULL, // st_chase1, + ST_INFO_NULL, // st_chase1s, + ST_INFO_NULL, // st_chase2, + ST_INFO_NULL, // st_chase3, + ST_INFO_NULL, // st_chase3s, + ST_INFO_NULL, // st_chase4, + + {0, SPR_HSMOKE_1, 3, NULL, NULL, st_die2}, // st_die1, + {0, SPR_HSMOKE_2, 3, NULL, NULL, st_die3}, // st_die2, + {0, SPR_HSMOKE_3, 3, NULL, NULL, st_die4}, // st_die3, + {0, SPR_HSMOKE_4, 3, NULL, NULL, st_remove}, // st_die4, + ST_INFO_NULL, // st_die5, + + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + ST_INFO_NULL // st_dead + }, + // en_spectre, + { + ST_INFO_NULL, // st_stand, + + {0, SPR_SPECTRE_W1, 10, T_Stand, NULL, st_path2}, // st_path1, + ST_INFO_NULL, // st_path1s, + {0, SPR_SPECTRE_W2, 10, T_Stand, NULL, st_path3}, // st_path2, + {0, SPR_SPECTRE_W3, 10, T_Stand, NULL, st_path4}, // st_path3, + ST_INFO_NULL, // st_path3s, + {0, SPR_SPECTRE_W4, 10, T_Stand, NULL, st_path1}, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + ST_INFO_NULL, // st_shoot1, + ST_INFO_NULL, // st_shoot2, + ST_INFO_NULL, // st_shoot3, + ST_INFO_NULL, // st_shoot4, + ST_INFO_NULL, // st_shoot5, + ST_INFO_NULL, // st_shoot6, + + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_SPECTRE_W1, 10, T_Ghosts, NULL, st_chase2}, // st_chase1, + ST_INFO_NULL, // st_chase1s, + {0, SPR_SPECTRE_W2, 10, T_Ghosts, NULL, st_chase3}, // st_chase2, + {0, SPR_SPECTRE_W3, 10, T_Ghosts, NULL, st_chase4}, // st_chase3, + ST_INFO_NULL, // st_chase3s, + {0, SPR_SPECTRE_W4, 10, T_Ghosts, NULL, st_chase1}, // st_chase4, + + {0, SPR_SPECTRE_F1, 10, NULL, NULL, st_die2}, // st_die1, + {0, SPR_SPECTRE_F2, 10, NULL, NULL, st_die3}, // st_die2, + {0, SPR_SPECTRE_F3, 10, NULL, NULL, st_die4}, // st_die3, + {0, SPR_SPECTRE_F4, 300, NULL, NULL, st_die5}, // st_die4, + {0, SPR_SPECTRE_F4, 10, NULL, A_Dormant, st_die5}, // st_die5, + + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + ST_INFO_NULL // st_dead + }, + // en_angel, + { + {0, SPR_ANGEL_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + {0, SPR_ANGEL_TIRED1, 40, NULL, A_Breathing, st_pain1}, // st_pain, + {0, SPR_ANGEL_TIRED2, 40, NULL, NULL, st_shoot4}, // st_pain1, + + {0, SPR_ANGEL_SHOOT1, 10, NULL, A_StartAttack, st_shoot2}, // st_shoot1, + {0, SPR_ANGEL_SHOOT2, 20, NULL, T_Launch, st_shoot3}, // st_shoot2, + {0, SPR_ANGEL_SHOOT1, 10, NULL, A_Relaunch, st_shoot2}, // st_shoot3, + + {0, SPR_ANGEL_TIRED1, 40, NULL, A_Breathing, st_shoot5}, // st_shoot4, + {0, SPR_ANGEL_TIRED2, 40, NULL, NULL, st_shoot6}, // st_shoot5, + {0, SPR_ANGEL_TIRED1, 40, NULL, A_Breathing, st_shoot7}, // st_shoot6, + {0, SPR_ANGEL_TIRED2, 40, NULL, NULL, st_shoot8}, // st_shoot7, + {0, SPR_ANGEL_TIRED1, 40, NULL, A_Breathing, st_chase1}, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_ANGEL_W1, 10, T_BossChase, NULL, st_chase1s}, // st_chase1, + {0, SPR_ANGEL_W1, 3, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_ANGEL_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_ANGEL_W3, 10, T_BossChase, NULL, st_chase3s}, // st_chase3, + {0, SPR_ANGEL_W3, 3, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_ANGEL_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_ANGEL_W1, 1, NULL, A_DeathScream, st_die2}, // st_die1, + {0, SPR_ANGEL_W1, 1, NULL, NULL, st_die3}, // st_die2, + {0, SPR_ANGEL_DIE1, 10, NULL, A_Slurpie, st_die4}, // st_die3, + {0, SPR_ANGEL_DIE2, 10, NULL, NULL, st_die5}, // st_die4, + {0, SPR_ANGEL_DIE3, 10, NULL, NULL, st_die6}, // st_die5, + {0, SPR_ANGEL_DIE4, 10, NULL, NULL, st_die7}, // st_die6, + {0, SPR_ANGEL_DIE5, 10, NULL, NULL, st_die8}, // st_die7, + {0, SPR_ANGEL_DIE6, 10, NULL, NULL, st_die9}, // st_die8, + {0, SPR_ANGEL_DIE7, 10, NULL, NULL, st_dead}, // st_die9, + + {0, SPR_ANGEL_DEAD, 130, NULL, A_Victory, st_dead} // st_dead + }, + // en_trans, + { + {0, SPR_TRANS_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + {0, SPR_TRANS_SHOOT1, 30, NULL, NULL, st_shoot2}, // st_shoot1, + {0, SPR_TRANS_SHOOT2, 10, NULL, T_Shoot, st_shoot3}, // st_shoot2, + {0, SPR_TRANS_SHOOT3, 10, NULL, T_Shoot, st_shoot4}, // st_shoot3, + {0, SPR_TRANS_SHOOT2, 10, NULL, T_Shoot, st_shoot5}, // st_shoot4, + {0, SPR_TRANS_SHOOT3, 10, NULL, T_Shoot, st_shoot6}, // st_shoot5, + {0, SPR_TRANS_SHOOT2, 10, NULL, T_Shoot, st_shoot7}, // st_shoot6, + {0, SPR_TRANS_SHOOT3, 10, NULL, T_Shoot, st_shoot8}, // st_shoot7, + {0, SPR_TRANS_SHOOT1, 10, NULL, NULL, st_chase1}, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_TRANS_W1, 10, T_Chase, NULL, st_chase1s}, // st_chase1, + {0, SPR_TRANS_W1, 3, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_TRANS_W2, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_TRANS_W3, 10, T_Chase, NULL, st_chase3s}, // st_chase3, + {0, SPR_TRANS_W3, 3, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_TRANS_W4, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_TRANS_W1, 1, NULL, A_DeathScream, st_die2}, // st_die1, + {0, SPR_TRANS_W1, 1, NULL, NULL, st_die3}, // st_die2, + {0, SPR_TRANS_DIE1, 15, NULL, NULL, st_die4}, // st_die3, + {0, SPR_TRANS_DIE2, 15, NULL, NULL, st_die5}, // st_die4, + {0, SPR_TRANS_DIE3, 15, NULL, NULL, st_dead}, // st_die5, + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + {0, SPR_TRANS_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_uber, + { + {0, SPR_UBER_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + {0, SPR_UBER_SHOOT1, 30, NULL, NULL, st_shoot2}, // st_shoot1, + {0, SPR_UBER_SHOOT2, 12, NULL, T_UShoot, st_shoot3}, // st_shoot2, + {0, SPR_UBER_SHOOT3, 12, NULL, T_UShoot, st_shoot4}, // st_shoot3, + {0, SPR_UBER_SHOOT4, 12, NULL, T_UShoot, st_shoot5}, // st_shoot4, + {0, SPR_UBER_SHOOT3, 12, NULL, T_UShoot, st_shoot6}, // st_shoot5, + {0, SPR_UBER_SHOOT2, 12, NULL, T_UShoot, st_shoot7}, // st_shoot6, + {0, SPR_UBER_SHOOT1, 12, NULL, NULL, st_chase1}, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_UBER_W1, 10, T_Chase, NULL, st_chase1s}, // st_chase1, + {0, SPR_UBER_W1, 3, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_UBER_W2, 8, T_Chase, NULL, st_chase3}, // st_chase2, + {0, SPR_UBER_W3, 10, T_Chase, NULL, st_chase3s}, // st_chase3, + {0, SPR_UBER_W3, 3, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_UBER_W4, 8, T_Chase, NULL, st_chase1}, // st_chase4, + + {0, SPR_UBER_W1, 1, NULL, A_DeathScream, st_die2}, // st_die1, + {0, SPR_UBER_W1, 1, NULL, NULL, st_die3}, // st_die2, + {0, SPR_UBER_DIE1, 15, NULL, NULL, st_die4}, // st_die3, + {0, SPR_UBER_DIE2, 15, NULL, NULL, st_die5}, // st_die4, + {0, SPR_UBER_DIE3, 15, NULL, NULL, st_die6}, // st_die5, + {0, SPR_UBER_DIE4, 15, NULL, NULL, st_dead}, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + {0, SPR_UBER_DEAD, 0, NULL, NULL, st_dead} // st_dead + }, + // en_will, + { + {0, SPR_WILL_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + {0, SPR_WILL_SHOOT1, 30, NULL, NULL, st_shoot2}, // st_shoot1, + {0, SPR_WILL_SHOOT2, 10, NULL, T_Launch, st_shoot3}, // st_shoot2, + {0, SPR_WILL_SHOOT3, 10, NULL, T_Shoot, st_shoot4}, // st_shoot3, + {0, SPR_WILL_SHOOT4, 10, NULL, T_Shoot, st_shoot5}, // st_shoot4, + {0, SPR_WILL_SHOOT3, 10, NULL, T_Shoot, st_shoot6}, // st_shoot5, + {0, SPR_WILL_SHOOT4, 10, NULL, T_Shoot, st_chase1}, // st_shoot6, + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_WILL_W1, 10, T_BossChase, NULL, st_chase1s}, // st_chase1, + {0, SPR_WILL_W1, 3, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_WILL_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_WILL_W3, 10, T_BossChase, NULL, st_chase3s}, // st_chase3, + {0, SPR_WILL_W3, 3, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_WILL_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_WILL_W1, 1, NULL, A_DeathScream, st_die2}, // st_die1, + {0, SPR_WILL_W1, 10, NULL, NULL, st_die3}, // st_die2, + {0, SPR_WILL_DIE1, 10, NULL, NULL, st_die4}, // st_die3, + {0, SPR_WILL_DIE2, 10, NULL, NULL, st_die5}, // st_die4, + {0, SPR_WILL_DIE3, 10, NULL, NULL, st_dead}, // st_die5, + ST_INFO_NULL, // st_die6, + ST_INFO_NULL, // st_die7, + ST_INFO_NULL, // st_die8, + ST_INFO_NULL, // st_die9, + + {0, SPR_WILL_DEAD, 20, NULL, NULL, st_dead} // st_dead + }, + // en_death + { + {0, SPR_DEATH_W1, 0, T_Stand, NULL, st_stand}, // st_stand, + + ST_INFO_NULL, // st_path1, + ST_INFO_NULL, // st_path1s, + ST_INFO_NULL, // st_path2, + ST_INFO_NULL, // st_path3, + ST_INFO_NULL, // st_path3s, + ST_INFO_NULL, // st_path4, + + ST_INFO_NULL, // st_pain, + ST_INFO_NULL, // st_pain1, + + {0, SPR_DEATH_SHOOT1, 30, NULL, NULL, st_shoot2}, // st_shoot1, + {0, SPR_DEATH_SHOOT2, 10, NULL, T_Launch, st_shoot3}, // st_shoot2, + {0, SPR_DEATH_SHOOT4, 10, NULL, T_Shoot, st_shoot4}, // st_shoot3, + {0, SPR_DEATH_SHOOT3, 10, NULL, T_Launch, st_shoot5}, // st_shoot4, + {0, SPR_DEATH_SHOOT4, 10, NULL, T_Shoot, st_chase1}, // st_shoot5, + ST_INFO_NULL, // st_shoot6, + ST_INFO_NULL, // st_shoot7, + ST_INFO_NULL, // st_shoot8, + ST_INFO_NULL, // st_shoot9, + + {0, SPR_DEATH_W1, 10, T_BossChase, NULL, st_chase1s}, // st_chase1, + {0, SPR_DEATH_W1, 3, NULL, NULL, st_chase2}, // st_chase1s, + {0, SPR_DEATH_W2, 8, T_BossChase, NULL, st_chase3}, // st_chase2, + {0, SPR_DEATH_W3, 10, T_BossChase, NULL, st_chase3s}, // st_chase3, + {0, SPR_DEATH_W3, 3, NULL, NULL, st_chase4}, // st_chase3s, + {0, SPR_DEATH_W4, 8, T_BossChase, NULL, st_chase1}, // st_chase4, + + {0, SPR_DEATH_W1, 1, NULL, A_DeathScream, st_die2}, // st_die1, + {0, SPR_DEATH_W1, 10, NULL, NULL, st_die3}, // st_die2, + {0, SPR_DEATH_DIE1, 10, NULL, NULL, st_die4}, // st_die3, + {0, SPR_DEATH_DIE2, 10, NULL, NULL, st_die5}, // st_die4, + {0, SPR_DEATH_DIE3, 10, NULL, NULL, st_die6}, // st_die5, + {0, SPR_DEATH_DIE4, 10, NULL, NULL, st_die7}, // st_die6, + {0, SPR_DEATH_DIE5, 10, NULL, NULL, st_die7}, // st_die7, + {0, SPR_DEATH_DIE6, 10, NULL, NULL, st_die7}, // st_die8, + ST_INFO_NULL, // st_die9, + + {0, SPR_DEATH_DEAD, 0, NULL, NULL, st_dead} // st_dead + } + +}; + +int starthitpoints[ 4 ][ NUMENEMIES ] = +// +// BABY MODE +// +{ + {25, // guards + 50, // officer + 100, // SS + 1, // dogs + 850, // Hans + 850, // Schabbs + 200, // fake hitler + 800, // mecha hitler + 500, // hitler + 45, // mutants + 25, // ghosts + 25, // ghosts + 25, // ghosts + 25, // ghosts + + 850, // Gretel + 850, // Gift + 850, // Fat + +// --- Projectiles + 0, // en_needle, + 0, // en_fire, + 0, // en_rocket, + 0, // en_smoke, + 100, // en_bj, +// --- Spear of destiny! + 0, // en_spark, + 0, // en_hrocket, + 0, // en_hsmoke, + + 5, // en_spectre, + 1450, // en_angel, + 850, // en_trans, + 1050, // en_uber, + 950, // en_will, + 1250 // en_death + }, + // + // DON'T HURT ME MODE + // + {25, // guards + 50, // officer + 100, // SS + 1, // dogs + 950, // Hans + 950, // Schabbs + 300, // fake hitler + 950, // mecha hitler + 700, // hitler + 55, // mutants + 25, // ghosts + 25, // ghosts + 25, // ghosts + 25, // ghosts + + 950, // Gretel + 950, // Gift + 950, // Fat + +// --- Projectiles + 0, // en_needle, + 0, // en_fire, + 0, // en_rocket, + 0, // en_smoke, + 100, // en_bj, +// --- Spear of destiny! + 0, // en_spark, + 0, // en_hrocket, + 0, // en_hsmoke, + + 10, // en_spectre, + 1550, // en_angel, + 950, // en_trans, + 1150, // en_uber, + 1050, // en_will, + 1350 // en_death + }, + // + // BRING 'EM ON MODE + // + {25, // guards + 50, // officer + 100, // SS + 1, // dogs + + 1050, // Hans + 1550, // Schabbs + 400, // fake hitler + 1050, // mecha hitler + 800, // hitler + + 55, // mutants + 25, // ghosts + 25, // ghosts + 25, // ghosts + 25, // ghosts + + 1050, // Gretel + 1050, // Gift + 1050, // Fat + +// --- Projectiles + 0, // en_needle, + 0, // en_fire, + 0, // en_rocket, + 0, // en_smoke, + 100, // en_bj, +// --- Spear of destiny! + 0, // en_spark, + 0, // en_hrocket, + 0, // en_hsmoke, + + 15, // en_spectre, + 1650, // en_angel, + 1050, // en_trans, + 1250, // en_uber, + 1150, // en_will, + 1450 // en_death + }, + // + // DEATH INCARNATE MODE + // + {25, // guards + 50, // officer + 100, // SS + 1, // dogs + + 1200, // Hans + 2400, // Schabbs + 500, // fake hitler + 1200, // mecha hitler + 900, // hitler + + 65, // mutants + 25, // ghosts + 25, // ghosts + 25, // ghosts + 25, // ghosts + + 1200, // Gretel + 1200, // Gift + 1200, // Fat + +// --- Projectiles + 0, // en_needle, + 0, // en_fire, + 0, // en_rocket, + 0, // en_smoke, + 100, // en_bj, +// --- Spear of destiny! + 0, // en_spark, + 0, // en_hrocket, + 0, // en_hsmoke, + + 25, // en_spectre, + 2000, // en_angel, + 1200, // en_trans, + 1400, // en_uber, + 1300, // en_will, + 1600 // en_death + } +}; + + +#endif /* __WOLF_ACT_STAT_H__ */ + diff --git a/wolf3d/newCode/wolf/wolf_actor_ai.c b/wolf3d/newCode/wolf/wolf_actor_ai.c new file mode 100644 index 0000000..05718df --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_actor_ai.c @@ -0,0 +1,968 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2001 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_actor_ai.c: Wolfenstein3-D artificial intelligence. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + +const char dsounds[ 7 ][ 32 ] = +{ + "sfx/025.wav", + "sfx/026.wav", + "sfx/086.wav", + "sfx/088.wav", + "sfx/105.wav", + "sfx/107.wav", + "sfx/109.wav" +}; + +const char dsodsounds[ 7 ][ 32 ] = +{ + "sfx/021.wav", + "sfx/022.wav", + "sfx/052.wav", + "sfx/054.wav", + "sfx/057.wav", + "sfx/059.wav", + "sfx/061.wav" +}; + +/* +----------------------------------------------------------------------------- + Function: A_DeathScream() -Do a death scream sound depending on actor type. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void A_DeathScream( entity_t *self ) +{ + switch( self->type ) + { + case en_mutant: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/033.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/037.wav" ), 1, ATTN_NORM, 0 ); + } + break; + + case en_guard: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( dsodsounds[ US_RndT() % 6 ] ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( dsounds[ US_RndT() % 6 ] ), 1, ATTN_NORM, 0 ); + } + break; + + case en_officer: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/046.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/074.wav" ), 1, ATTN_NORM, 0 ); + } + break; + + case en_ss: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/035.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/046.wav" ), 1, ATTN_NORM, 0 ); + } + break; + + case en_dog: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/031.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/035.wav" ), 1, ATTN_NORM, 0 ); + } + break; + + case en_boss: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/019.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_schabbs: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/061.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_fake: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/069.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_mecha: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/084.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_hitler: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/044.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_gretel: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/115.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_gift: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/091.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_fat: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/119.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_spectre: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "lsfx/062.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_angel: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/098.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_trans: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/070.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_uber: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/082.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_will: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/072.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_death: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/090.wav" ), 1, ATTN_NORM, 0 ); + break; + } +} + +/* +----------------------------------------------------------------------------- + Function: A_FirstSighting() -Puts an actor into attack mode and possibly + reverses the direction if the player is + behind it. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void A_FirstSighting( entity_t *self ) +{ + switch( self->type ) + { + case en_guard: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/001.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_officer: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/043.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/071.wav" ), 1, ATTN_NORM, 0 ); + } + self->speed *= 5; // go faster when chasing player + break; + + case en_mutant: + self->speed *= 3; // go faster when chasing player + break; + + case en_ss: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/015.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 4; // go faster when chasing player + break; + + case en_dog: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/002.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 2; // go faster when chasing player + break; + + case en_boss: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/017.wav" ), 1, ATTN_NORM, 0 ); + self->speed = SPDPATROL * 3; // go faster when chasing player + break; + + case en_gretel: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/112.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_gift: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/096.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_fat: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/102.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_schabbs: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/065.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_fake: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/054.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_mecha: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/040.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 3; // go faster when chasing player + break; + + case en_hitler: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/040.wav" ), 1, ATTN_NORM, 0 ); + self->speed *= 5; // go faster when chasing player + break; + + case en_blinky: + case en_clyde: + case en_pinky: + case en_inky: + self->speed *= 2; // go faster when chasing player + break; + +// +// Spear of Destiny +// + case en_spectre: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "lsfx/003.wav" ), 1, ATTN_NORM, 0 ); + self->speed = 800; // go faster when chasing player + break; + + case en_angel: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/095.wav" ), 1, ATTN_NORM, 0 ); + self->speed = 1536; // go faster when chasing player + break; + + case en_trans: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/066.wav" ), 1, ATTN_NORM, 0 ); + self->speed = 1536; // go faster when chasing player + break; + + case en_uber: + self->speed = 3000; // go faster when chasing player + break; + + case en_will: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/073.wav" ), 1, ATTN_NORM, 0 ); + self->speed = 2048; // go faster when chasing player + break; + + case en_death: + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/085.wav" ), 1, ATTN_NORM, 0 ); + self->speed = 2048; // go faster when chasing player + break; + + default: + return; + } + + A_StateChange( self, st_chase1 ); + if( self->waitfordoorx ) + { + self->waitfordoorx = self->waitfordoory = 0; // ignore the door opening command + } + + self->dir = dir8_nodir; + self->flags |= FL_ATTACKMODE | FL_FIRSTATTACK; +} + + +/* +----------------------------------------------------------------------------- + Function: A_KillActor() -Actor has been killed, so give points and spawn + powerups. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void A_KillActor( entity_t *self ) +{ + int tilex, tiley; + + tilex = self->tilex = self->x >> TILESHIFT; // drop item on center + tiley = self->tiley = self->y >> TILESHIFT; + + switch( self->type ) + { + case en_guard: + PL_GivePoints( &Player, 100 ); + Powerup_Spawn( tilex, tiley, pow_clip2, r_world ); + break; + + case en_officer: + PL_GivePoints( &Player, 400 ); + Powerup_Spawn( tilex, tiley, pow_clip2, r_world ); + break; + + case en_mutant: + PL_GivePoints( &Player, 700 ); + Powerup_Spawn( tilex, tiley, pow_clip2, r_world ); + break; + + case en_ss: + PL_GivePoints( &Player, 500 ); + if( Player.items & ITEM_WEAPON_3 ) // have a schmeiser? + { + Powerup_Spawn( tilex, tiley, pow_clip2, r_world ); + } + else + { + Powerup_Spawn( tilex, tiley, pow_machinegun, r_world ); + } + break; + + case en_dog: + PL_GivePoints( &Player, 200 ); + break; + + case en_boss: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + + case en_gretel: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + + case en_gift: + PL_GivePoints( &Player, 5000 ); + A_StartDeathCam( self ); + break; + + case en_fat: + PL_GivePoints( &Player, 5000 ); + A_StartDeathCam( self ); + break; + + case en_schabbs: + PL_GivePoints( &Player, 5000 ); + A_DeathScream( self ); + A_StartDeathCam( self ); + break; + + case en_fake: + PL_GivePoints( &Player, 2000 ); + break; + + case en_mecha: + PL_GivePoints( &Player, 5000 ); + break; + + case en_hitler: + PL_GivePoints( &Player, 5000 ); + A_DeathScream( self ); + A_StartDeathCam( self ); + break; + + case en_spectre: + PL_GivePoints( &Player, 200 ); + break; + + case en_angel: + PL_GivePoints( &Player, 5000 ); + break; + + case en_trans: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + + case en_uber: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + + case en_will: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + + case en_death: + PL_GivePoints( &Player, 5000 ); + Powerup_Spawn( tilex, tiley, pow_key1, r_world ); + break; + } + + A_StateChange( self, st_die1 ); + + if ( ++levelstate.killed_monsters == levelstate.total_monsters ) { + iphoneSetNotifyText( "You killed the last enemy!" ); + } + + self->flags &= ~FL_SHOOTABLE; + self->flags |= FL_NONMARK; + +} + +/* +----------------------------------------------------------------------------- + Function: A_DamageActor() -Called when the player succesfully hits an enemy. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + Does damage points to enemy ob, either putting it into a stun frame or + killing it. +----------------------------------------------------------------------------- +*/ +PUBLIC void A_DamageActor( entity_t *self, int damage ) +{ + Player.madenoise = 1; + +// do double damage if shooting a non attack mode actor + if( ! (self->flags & FL_ATTACKMODE) ) + { + damage <<= 1; + } + + self->health -= damage; + + if( self->health <= 0 ) + { + A_KillActor( self ); + } + else + { + if( ! (self->flags & FL_ATTACKMODE) ) + { + A_FirstSighting( self ); // put into combat mode + } + + switch( self->type ) // dogs only have one hit point + { + case en_guard: + case en_officer: + case en_mutant: + case en_ss: + if( self->health & 1 ) + { + A_StateChange( self, st_pain ); + } + else + { + A_StateChange( self, st_pain1 ); + } + break; + } + } +} + +/////////////////////////// +// +// Hitler +// +/////////////////////////// + + +/* +----------------------------------------------------------------------------- + Function: A_MechaSound -Play Mecha sound. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_MechaSound( entity_t *self ) +{ + if( areabyplayer[ self->areanumber ] ) + { + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "sfx/080.wav" ), 1, ATTN_NORM, 0 ); + } +} + +/* +----------------------------------------------------------------------------- + Function: A_Slurpie -Play Slurpie sound. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Slurpie( entity_t *self ) +{ + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "lsfx/061.wav" ), 1, ATTN_NORM, 0 ); +} + + +/* +----------------------------------------------------------------------------- + Function: A_HitlerMorph() -Spawn new actor, when Mecha Hitler is dead. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void A_HitlerMorph( entity_t *self ) +{ + int hitpoints[ 4 ] = { 500, 700, 800, 900 }; + entity_t *hitler; + + hitler = GetNewActor(); + if( ! hitler ) + { + return; + } + + hitler->x = self->x;// + hitler->y = self->y;// + hitler->distance = self->distance; + hitler->tilex = self->tilex;// + hitler->tiley = self->tiley;// + hitler->angle = self->angle;// + hitler->dir = self->dir;// + hitler->health = hitpoints[ (int)skill->value ]; + hitler->areanumber = self->areanumber; + hitler->state = st_chase1;// + hitler->type = en_hitler; // + hitler->speed = SPDPATROL * 5;// + hitler->ticcount = 0;// + hitler->flags=self->flags | FL_SHOOTABLE; // + hitler->sprite = Sprite_GetNewSprite(); + + if ( ++levelstate.killed_monsters == levelstate.total_monsters ) { + iphoneSetNotifyText( "You killed the last enemy!" ); + } +} + +/////////////////////////// +// +// Angel of Death +// +/////////////////////////// + +/* + Angel can't shoot more then 3 sparks in a row. + It will get tired! +*/ + +PRIVATE int angel_temp = 0; + +// + +/* +----------------------------------------------------------------------------- + Function: A_Breathing -Play Angel of Death Breathing sound. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Breathing( entity_t *self ) +{ + Sound_StartSound( NULL, 0, CHAN_VOICE, Sound_RegisterSound( "lsfx/080.wav" ), 1, ATTN_NORM, 0 ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_StartAttack( entity_t *self ) +{ + angel_temp = 0; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Relaunch( entity_t *self ) +{ + if( ++angel_temp == 3 ) + { + A_StateChange( self, st_pain ); + return; + } + + if( US_RndT() & 1 ) + { + A_StateChange( self, st_chase1 ); + return; + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Victory( entity_t *self ) +{ + iphoneStartIntermission( 0 ); +} + + +/* +----------------------------------------------------------------------------- + Function: A_Dormant() -Entity is dormant state. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Dormant( entity_t *self ) +{ + int deltax, deltay; + int xl, xh, yl, yh, x, y, n; + + deltax = self->x - Player.position.origin[ 0 ]; + + if( deltax < -MINACTORDIST || deltax > MINACTORDIST ) + { + goto moveok; + } + + deltay = self->y - Player.position.origin[ 1 ]; + if( deltay < -MINACTORDIST || deltay > MINACTORDIST ) + { + goto moveok; + } + + return; + +moveok: + xl = (self->x - MINDIST) >> TILESHIFT; + xh = (self->x + MINDIST) >> TILESHIFT; + yl = (self->y - MINDIST) >> TILESHIFT; + yh = (self->y + MINDIST) >> TILESHIFT; + + for( y = yl ; y <= yh ; ++y ) + for( x = xl ; x <= xh ; ++x ) + { + if( r_world->tilemap[ x ][ y ] & SOLID_TILE ) + { + return; + } + + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].state >= st_die1 ) + { + continue; + } + + if( Guards[ n ].tilex == x && Guards[ n ].tiley == y ) + { + return; // another guard in path + } + } + } + + self->flags |= FL_AMBUSH | FL_SHOOTABLE; + self->flags &= ~FL_ATTACKMODE; + self->dir = dir8_nodir; + A_StateChange( self, st_path1 ); +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_StartDeathCam( entity_t *self ) +{ + // the DeathCam feature isn't implimented, but we want to give the animation time + // to play before declaring victory. + iphoneStartIntermission( 50 ); +} + + +/* +----------------------------------------------------------------------------- + Function: A_Smoke() -Rockets emmit smoke. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void A_Smoke( entity_t *self ) +{ + entity_t *smoke; + + smoke = GetNewActor(); + if( ! smoke ) + { + return; + } + + smoke->x = self->x; + smoke->y = self->y; + smoke->tilex = self->tilex; + smoke->tiley = self->tiley; + smoke->state = st_die1; + smoke->type = (self->type==en_hrocket) ? en_hsmoke : en_smoke; + smoke->ticcount = 6; + smoke->flags = FL_NEVERMARK; + smoke->sprite = Sprite_GetNewSprite(); +} + + +/* +----------------------------------------------------------------------------- + Function: ProjectileTryMove() -Called when projectile is airborne. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + lvl -[in] Valid Pointer to LevelData_t structure. + + Returns: true if move ok, otherwise false. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean ProjectileTryMove( entity_t *self, LevelData_t *lvl ) +{ + #define PROJSIZE 0x2000 + + + int xl, yl, xh, yh, x, y; + + xl = (self->x - PROJSIZE) >> TILESHIFT; + yl = (self->y - PROJSIZE) >> TILESHIFT; + + xh = (self->x + PROJSIZE) >> TILESHIFT; + yh = (self->y + PROJSIZE) >> TILESHIFT; + + // Checking for solid walls: + for( y = yl ; y <= yh ; ++y ) + { + for( x = xl ; x <= xh ; ++x ) + { +// FIXME: decide what to do with statics & Doors! + if( lvl->tilemap[ x ][ y ] & (WALL_TILE | BLOCK_TILE) ) + { + return false; + } + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE ) + { + if( Door_Opened( &lvl->Doors, x, y ) != DOOR_FULLOPEN ) + { + return false; + } + } + } + } +// FIXME: Projectile will fly through objects (even guards & columns) - must fix to create rocket launcher! + return true; +} + + +/* +----------------------------------------------------------------------------- + Function: T_Projectile() -Called when projectile is airborne. + + Parameters: self -[in] Valid Pointer to an entity_t structure. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Projectile( entity_t *self ) +{ + #define PROJECTILESIZE 0xC000 + + + int deltax, deltay, speed, damage; + + speed = self->speed * tics; + + deltax = (int)(speed * CosTable[ self->angle ]); + deltay = (int)(speed * SinTable[ self->angle ]); + + if( deltax > TILEGLOBAL ) + { + deltax = TILEGLOBAL; + } + + if( deltax < -TILEGLOBAL ) + { + deltax = -TILEGLOBAL; // my + } + + if( deltay > TILEGLOBAL) + { + deltay = TILEGLOBAL; + } + + if( deltay < -TILEGLOBAL) + { + deltay = -TILEGLOBAL; // my + } + + self->x += deltax; + self->y += deltay; + + deltax = ABS( self->x-Player.position.origin[ 0 ] ); + deltay = ABS( self->y-Player.position.origin[ 1 ] ); + + if( ! ProjectileTryMove( self, r_world ) ) + { + if( self->type == en_rocket || self->type == en_hrocket ) + { // rocket ran into obstacle, draw explosion! + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/001.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/086.wav" ), 1, ATTN_NORM, 0 ); + } + A_StateChange( self, st_die1 ); + } + else + { + A_StateChange( self, st_remove ); // mark for removal + } + return; + } + + if( deltax < PROJECTILESIZE && deltay < PROJECTILESIZE ) + { // hit the player + switch( self->type ) + { + case en_needle: + damage = (US_RndT() >> 3) + 20; + break; + + case en_rocket: + case en_hrocket: + case en_spark: + damage = (US_RndT()>>3) + 30; + break; + + case en_fire: + damage = (US_RndT() >> 3); + break; + + default: + damage = 0; + break; + } + + PL_Damage( &Player, self, damage ); + A_StateChange( self, st_remove ); // mark for removal + return; + } + + self->tilex = self->x >> TILESHIFT; + self->tiley = self->y >> TILESHIFT; +} diff --git a/wolf3d/newCode/wolf/wolf_actor_ai.h b/wolf3d/newCode/wolf/wolf_actor_ai.h new file mode 100644 index 0000000..f428cb6 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_actor_ai.h @@ -0,0 +1,73 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_actor_ai.h: Wolfenstein3-D entity management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_actor_ai.c. + +*/ + +#ifndef __WOLF_ACTOR_AI_H__ +#define __WOLF_ACTOR_AI_H__ + +#include "wolf_actors.h" + +extern void A_DeathScream( entity_t *self ); +extern void A_FirstSighting( entity_t *self ); +extern void A_DamageActor( entity_t *self, int damage ); + +// hitler +extern void A_MechaSound( entity_t *self ); +extern void A_Slurpie( entity_t *self ); +extern void A_HitlerMorph( entity_t *self ); + +// angel +extern void A_Breathing( entity_t *self ); +extern void A_StartAttack( entity_t *self ); +extern void A_Relaunch( entity_t *self ); +extern void A_Victory( entity_t *self ); + +// ghost +extern void A_Dormant( entity_t *self ); + +extern void A_StartDeathCam( entity_t *self ); + +// missiles +extern void T_Projectile( entity_t *self ); +extern void A_Smoke( entity_t *self ); + + +#endif /* __WOLF_ACTOR_AI_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_actors.c b/wolf3d/newCode/wolf/wolf_actors.c new file mode 100644 index 0000000..51f97e0 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_actors.c @@ -0,0 +1,471 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2001 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_actors.c: Wolfenstein3-D actor manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + +#include "wolf_act_stat.h" + +entity_t Guards[ MAX_GUARDS + 1 ], *New; +W16 NumGuards = 0; +W8 add8dir[ 9 ] = { 4, 5, 6, 7, 0, 1, 2, 3, 0 }; +W8 r_add8dir[ 9 ]= { 4, 7, 6, 5, 0, 1, 2, 3, 0 }; + + + +/* +----------------------------------------------------------------------------- + Function: A_StateChange -Changes guard's state to that defined in NewState. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void A_StateChange( entity_t *ent, en_state NewState ) +{ + ent->state = NewState; + assert( ent->type >= 0 && ent->type < NUMENEMIES ); + if ( NewState == st_remove ) { + ent->ticcount = 0; + } else { + assert( ent->state >= 0 && ent->state < NUMSTATES ); + ent->ticcount = objstate[ ent->type ][ ent->state ].timeout; //0; + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE int DoGuard( entity_t *ent ) // FIXME: revise! +{ // returns 0 if we must remove this Guard from Guards list, otherwise 1; + think_t think; + + assert( ent->tilex >= 0 && ent->tilex < 64 ); + assert( ent->tiley >= 0 && ent->tiley < 64 ); + assert( ent->dir >= 0 && ent->dir <= 8 ); + + // ticcounts fire discrete actions separate from think functions + if ( ent->ticcount ) { + ent->ticcount -= tics; + while( ent->ticcount <= 0 ) + { + assert( ent->type >= 0 && ent->type < NUMENEMIES ); + assert( ent->state >= 0 && ent->state < NUMSTATES ); + think = objstate[ ent->type ][ ent->state ].action; // end of state action + if( think ) + { + think( ent ); + if( ent->state == st_remove ) + { + return 0; + } + } + + ent->state = objstate[ ent->type ][ ent->state ].next_state; + if( ent->state == st_remove ) + { + return 0; + } + + if( ! objstate[ ent->type ][ ent->state ].timeout ) + { + ent->ticcount = 0; + break; + } + + ent->ticcount += objstate[ ent->type ][ ent->state ].timeout; + } + } + +// +// think +// + assert( ent->type >= 0 && ent->type < NUMENEMIES ); + assert( ent->state >= 0 && ent->state < NUMSTATES ); + think = objstate[ ent->type ][ ent->state ].think; + if( think ) + { + think( ent ); + if( ent->state == st_remove ) + { + return 0; + } + } + + return 1; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE void RemoveActor( entity_t *actor ) +{ + Sprite_RemoveSprite( actor->sprite ); + memmove( actor, actor+1, (int)(&Guards[ NumGuards ]) - (int)(actor+1) ); + NumGuards--; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void ProcessGuards( void ) +{ + int n, tex; + assert( NumGuards < MAX_GUARDS ); + for( n = 0 ; n < NumGuards ; ++n ) + { + if( ! DoGuard( &Guards[ n ] ) ) + { // remove guard from the game forever! + RemoveActor( &Guards[ n-- ] ); + continue; + } + + Sprite_SetPos( Guards[ n ].sprite, Guards[ n ].x, Guards[ n ].y, Guards[ n ].angle ); + tex = objstate[ Guards[ n ].type ][ Guards[ n ].state ].texture; + + if( objstate[ Guards[ n ].type ][ Guards[ n ].state ].rotate ) + { + if( Guards[ n ].type == en_rocket || Guards[ n ].type == en_hrocket ) + { + tex += r_add8dir[ Get8dir( angle_wise( FINE2RAD(Player.position.angle), FINE2RAD(Guards[ n ].angle) ) ) ]; + } + else + { + tex += add8dir[ Get8dir( angle_wise( FINE2RAD(Player.position.angle), FINE2RAD(Guards[ n ].angle) ) ) ]; + } + } + + Sprite_SetTex( Guards[ n ].sprite, 0, tex ); + } +} + + +/* +----------------------------------------------------------------------------- + Function: ResetGuards -Reset actors status + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void ResetGuards( void ) +{ + memset( Guards, 0, sizeof( Guards ) ); + NumGuards = 0; + New = NULL; +} + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC entity_t *GetNewActor( void ) +{ + if( NumGuards > MAX_GUARDS ) + { + return NULL; + } + + memset( &Guards[ NumGuards ], 0, sizeof( Guards[ 0 ] ) ); + + return &Guards[ NumGuards++ ]; +} + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC entity_t *SpawnActor( enemy_t which, int x, int y, dir4type dir, LevelData_t *lvl ) +{ + entity_t *new_actor; + + new_actor = GetNewActor(); + if( ! new_actor ) + { + return NULL; + } + + new_actor->x = TILE2POS( x ); + new_actor->y = TILE2POS( y ); + + new_actor->tilex = x; + new_actor->tiley = y; + + assert( dir >= 0 && dir <= 4 ); + new_actor->angle = dir4angle[ dir ]; + new_actor->dir = dir4to8[ dir ]; + + new_actor->areanumber = lvl->areas[ x ][ y ]; +// Com_Printf( "Actor at %i,%i had areaNum: %i\n", x, y, new_actor->areanumber ); + if ( new_actor->areanumber < 0 ) { + // ambush marker tiles are listed as -3 area + new_actor->areanumber = 0; + } + + assert( new_actor->areanumber >= 0 && new_actor->areanumber < NUMAREAS ); + new_actor->type = which; + + new_actor->health = starthitpoints[ (int)skill->value ][ which ]; + new_actor->sprite = Sprite_GetNewSprite(); + + return new_actor; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void SpawnStand( enemy_t which, int x, int y, int dir, LevelData_t *lvl ) +{ + entity_t *self; + + self = SpawnActor( which, x, y, dir, r_world ); + if( ! self ) + { + return; + } + + self->state = st_stand; + self->speed = SPDPATROL; + self->ticcount = objstate[ which ][ st_stand ].timeout ? US_RndT() % objstate[ which ][ st_stand ].timeout + 1 : 0; + self->flags |= FL_SHOOTABLE; + if( lvl->tilemap[ x ][ y ] & AMBUSH_TILE ) + { + self->flags |= FL_AMBUSH; + } + + levelstate.total_monsters++; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void SpawnPatrol( enemy_t which, int x, int y, int dir ) +{ + entity_t *self; + + self = SpawnActor( which, x, y, dir, r_world ); + if( ! self ) + { + return; + } + + self->state = st_path1; + self->speed = (which == en_dog) ? SPDDOG : SPDPATROL; + self->distance = TILEGLOBAL; + self->ticcount = objstate[ which ][ st_path1 ].timeout ? US_RndT() % objstate[ which ][ st_path1 ].timeout + 1 : 0; + self->flags |= FL_SHOOTABLE; + + levelstate.total_monsters++; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void SpawnDeadGuard( enemy_t which, int x, int y ) +{ + entity_t *self; + + self = SpawnActor( which, x, y, dir4_nodir, r_world ); + if( ! self ) + { + return; + } + + self->state = st_dead; + self->speed = 0; + self->health = 0; + self->ticcount = objstate[ which ][ st_dead ].timeout ? US_RndT() % objstate[ which ][ st_dead ].timeout + 1 : 0; + +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void SpawnBoss( enemy_t which, int x, int y ) +{ + entity_t *self; + dir4type face; + + switch( which ) + { + case en_boss: + case en_schabbs: + case en_fat: + case en_hitler: + face = dir4_south; + break; + + case en_fake: + case en_gretel: + case en_gift: + face = dir4_north; + break; + + case en_trans: + case en_uber: + case en_will: + case en_death: + case en_angel: + case en_spectre: + face = dir4_nodir; + break; + + default: + face = dir4_nodir; + break; + } + + self = SpawnActor( which, x, y, face, r_world ); + if( ! self ) + { + return; + } + + self->state = which == en_spectre ? st_path1 : st_stand; + self->speed = SPDPATROL; + self->health = starthitpoints[ (int)skill->value ][ which ]; + self->ticcount = objstate[ which ][ st_stand ].timeout ? US_RndT() % objstate[ which ][ st_stand ].timeout + 1 : 0; + self->flags |= FL_SHOOTABLE | FL_AMBUSH; + + levelstate.total_monsters++; + +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void SpawnGhosts( enemy_t which, int x, int y ) +{ + entity_t *self; + + self = SpawnActor( which, x, y, dir4_nodir, r_world ); + if( ! self ) + { + return; + } + + self->state = st_chase1; + self->speed = SPDPATROL * 3; + self->health = starthitpoints[ (int)skill->value ][ which ]; + self->ticcount = objstate[ which ][ st_chase1 ].timeout ? US_RndT() % objstate[ which ][ st_chase1 ].timeout + 1: 0; + self->flags |= FL_AMBUSH; + + levelstate.total_monsters++; +} diff --git a/wolf3d/newCode/wolf/wolf_actors.h b/wolf3d/newCode/wolf/wolf_actors.h new file mode 100644 index 0000000..d7439b8 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_actors.h @@ -0,0 +1,172 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_actors.h: Wolfenstein3-D entity management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_actors.c + +*/ + +#ifndef __WOLF_ACTORS_H__ +#define __WOLF_ACTORS_H__ + +#define SPDPATROL 512 +#define SPDDOG 1500 + +#define FL_SHOOTABLE 1 +#define FL_BONUS 2 +#define FL_NEVERMARK 4 +#define FL_VISABLE 8 +#define FL_ATTACKMODE 16 +#define FL_FIRSTATTACK 32 +#define FL_AMBUSH 64 +#define FL_NONMARK 128 + +#define MAX_GUARDS 255 +#define NUMENEMIES 31 +#define NUMSTATES 34 + +#define MINACTORDIST 0x10000 // minimum dist from player center to any actor center + +typedef enum +{ + en_guard, + en_officer, + en_ss, + en_dog, + en_boss, + en_schabbs, + en_fake, + en_mecha, + en_hitler, + en_mutant, + en_blinky, + en_clyde, + en_pinky, + en_inky, + en_gretel, + en_gift, + en_fat, +// --- Projectiles + en_needle, + en_fire, + en_rocket, + en_smoke, + en_bj, +// --- Spear of destiny! + en_spark, + en_hrocket, + en_hsmoke, + + en_spectre, + en_angel, + en_trans, + en_uber, + en_will, + en_death + +} enemy_t; + +typedef enum +{ + st_stand, + st_path1, st_path1s, st_path2, st_path3, st_path3s, st_path4, + st_pain, st_pain1, + st_shoot1, st_shoot2, st_shoot3, st_shoot4, st_shoot5, st_shoot6, st_shoot7, st_shoot8, st_shoot9, + st_chase1, st_chase1s, st_chase2, st_chase3, st_chase3s, st_chase4, + st_die1, st_die2, st_die3, st_die4, st_die5, st_die6, st_die7, st_die8, st_die9, + st_dead, + st_remove + +} en_state; + +typedef struct entity_s +{ + int x, y, angle; + int type; + int health; + int max_health; + int speed; + int ticcount; + int temp2; + int distance; + char tilex, tiley; + char areanumber; + int waitfordoorx, waitfordoory; // waiting on this door if non 0 + W8 flags; // FL_SHOOTABLE, etc + en_state state; + dir8type dir; + int sprite; + +} entity_t; + +typedef void (*think_t)( entity_t *self ); + +typedef struct +{ + char rotate; // 1-if object can be rotated, 0 if one sprite for every direction + int texture; // base object's state texture if rotation is on facing player + int timeout; // after how man ticks change state to .next_state + think_t think; // what to do every frame + think_t action; // what to do once per state + en_state next_state; // next state + +} stateinfo; + + + +extern entity_t Guards[ MAX_GUARDS + 1 ]; +extern entity_t *New; +extern W16 NumGuards; +extern stateinfo objstate[ NUMENEMIES ][ NUMSTATES ]; + +extern void ResetGuards(void); + + +extern entity_t *GetNewActor( void ); +extern entity_t *SpawnActor( enemy_t which, int x, int y, dir4type dir, LevelData_t *lvl ); +extern void A_StateChange( entity_t *Guard, en_state NewState ); + + +extern void SpawnStand( enemy_t which, int tilex, int tiley, int dir, LevelData_t *lvl ); +extern void SpawnPatrol( enemy_t which, int tilex, int tiley, int dir ); +extern void SpawnDeadGuard( enemy_t which, int x, int y ); +extern void SpawnBoss( enemy_t which, int x, int y ); +extern void SpawnGhosts( enemy_t which, int x, int y ); + + +#endif /* __WOLF_ACTORS_H__ */ + diff --git a/wolf3d/newCode/wolf/wolf_ai_com.c b/wolf3d/newCode/wolf/wolf_ai_com.c new file mode 100644 index 0000000..dcdc6a4 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_ai_com.c @@ -0,0 +1,1315 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_ai_com.c: Wolfenstein3-D actor manager. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + + + +#define RUNSPEED 6000 + + +/* +----------------------------------------------------------------------------- + Function: AI_ChangeDir() -Entity is going to move in a new direction. + + Parameters: + + Returns: 1 if direction is OK, otherwise 0. + + Notes: + Called, when actor finished previous moving & located in the 'center' of + the tile. Entity will try walking in direction. + +----------------------------------------------------------------------------- +*/ +PRIVATE int AI_ChangeDir( entity_t *self, dir8type new_dir, LevelData_t *lvl ) +{ + int oldx, oldy, newx, newy; // all it tiles + int n; + + oldx = POS2TILE( self->x ); + oldy = POS2TILE( self->y ); + assert( new_dir >= 0 && new_dir <= 8 ); + newx = oldx + dx8dir[ new_dir ]; + newy = oldy + dy8dir[ new_dir ]; + + if( new_dir & 0x01 ) // same as %2 (diagonal dir) + { + if( lvl->tilemap[ newx ][ oldy ] & SOLID_TILE || + lvl->tilemap[ oldx ][ newy ] & SOLID_TILE || + lvl->tilemap[ newx ][ newy ] & SOLID_TILE ) + { + return 0; + } + + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].state >= st_die1 ) + continue; + + if( Guards[ n ].tilex == newx && Guards[ n ].tiley == newy ) + return 0; // another guard in path + + if( Guards[ n ].tilex == oldx && Guards[ n ].tiley == newy ) + return 0; // another guard in path + + if( Guards[ n ].tilex == newx && Guards[ n ].tiley == oldy ) + return 0; // another guard in path + } + } + else // linear dir (E, N, W, S) + { + if( lvl->tilemap[ newx ][ newy ] & SOLID_TILE ) + { + return 0; + } + + if( lvl->tilemap[ newx ][ newy ] & DOOR_TILE ) + { + if( self->type == en_fake || self->type == en_dog) // they can't open doors + { + if( lvl->Doors.DoorMap[ newx ][ newy ].action != dr_open ) // path is blocked by a closed opened door + { + return 0; + } + } + else + { + self->waitfordoorx = newx; + self->waitfordoory = newy; + goto moveok; + } + } + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].state >= st_die1 ) + { + continue; + } + + if( Guards[ n ].tilex == newx && Guards[ n ].tiley == newy ) + { + return 0; // another guard in path + } + } + } + +moveok: + self->tilex = newx; + self->tiley = newy; + + lvl->tilemap[ oldx ][ oldy ] &= ~ACTOR_TILE; // update map status + lvl->tilemap[ newx ][ newy ] |= ACTOR_TILE; + + if( lvl->areas[ newx ][ newy ] > 0 ) + { // ambush tiles don't have valid area numbers (-3), so don't change the area if walking over them + self->areanumber = lvl->areas[ newx ][ newy ]; + assert( self->areanumber >= 0 && self->areanumber < NUMAREAS ); + } + + self->distance = TILEGLOBAL; + self->dir = new_dir; + + return 1; +} + +/* +----------------------------------------------------------------------------- + Function: AI_Path() -Entity is going to turn on a way point. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void AI_Path( entity_t *self ) +{ + if( r_world->tilemap[ self->x >> TILESHIFT ][ self->y >> TILESHIFT ] & WAYPOINT_TILE ) + { + long tileinfo = r_world->tilemap[self->x>>TILESHIFT][self->y>>TILESHIFT]; + if(tileinfo&TILE_IS_E_TURN) + self->dir=dir8_east; + else if(tileinfo&TILE_IS_NE_TURN) + self->dir=dir8_northeast; + else if(tileinfo&TILE_IS_N_TURN) + self->dir=dir8_north; + else if(tileinfo&TILE_IS_NW_TURN) + self->dir=dir8_northwest; + else if(tileinfo&TILE_IS_W_TURN) + self->dir=dir8_west; + else if(tileinfo&TILE_IS_SW_TURN) + self->dir=dir8_southwest; + else if(tileinfo&TILE_IS_S_TURN) + self->dir=dir8_south; + else if(tileinfo&TILE_IS_SE_TURN) + self->dir=dir8_southeast; + } + + if( ! AI_ChangeDir( self, self->dir, r_world )) + { + self->dir=dir8_nodir; + } +} + +/* +----------------------------------------------------------------------------- + Function: AI_Dodge() -Attempts to choose and initiate a movement for entity + that sends it towards the player while dodging. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void AI_Dodge( entity_t *self ) +{ + int deltax, deltay, i; + dir8type dirtry[ 5 ], turnaround, tdir; + + if( self->flags & FL_FIRSTATTACK ) + { +// turning around is only ok the very first time after noticing the player + turnaround = dir8_nodir; + self->flags &= ~FL_FIRSTATTACK; + } + else + { + turnaround = opposite8[ self->dir ]; + } + + deltax = POS2TILE( Player.position.origin[ 0 ] ) - POS2TILE( self->x ); + deltay = POS2TILE( Player.position.origin[ 1 ] ) - POS2TILE( self->y ); + +// +// arange 5 direction choices in order of preference +// the four cardinal directions plus the diagonal straight towards +// the player +// + + if( deltax > 0 ) + { + dirtry[ 1 ] = dir8_east; + dirtry[ 3 ] = dir8_west; + } + else + { + dirtry[ 1 ] = dir8_west; + dirtry[ 3 ] = dir8_east; + } + + if( deltay > 0 ) + { + dirtry[ 2 ] = dir8_north; + dirtry[ 4 ] = dir8_south; + } + else + { + dirtry[ 2 ] = dir8_south; + dirtry[ 4 ] = dir8_north; + } + +// randomize a bit for dodging + if( ABS( deltax ) > ABS( deltay ) ) + { + tdir = dirtry[1]; dirtry[1]=dirtry[2]; dirtry[2]=tdir; // => swap dirtry[1] & dirtry[2] + tdir = dirtry[3]; dirtry[3]=dirtry[4]; dirtry[4]=tdir; // => swap dirtry[3] & dirtry[4] + } + + if( US_RndT() < 128 ) + { + tdir=dirtry[1]; dirtry[1]=dirtry[2]; dirtry[2]=tdir; + tdir=dirtry[3]; dirtry[3]=dirtry[4]; dirtry[4]=tdir; + } + + dirtry[ 0 ] = diagonal[ dirtry[ 1 ] ][ dirtry[ 2 ] ]; + +// try the directions util one works + for( i = 0 ; i < 5 ; ++i ) + { + if( dirtry[ i ] == dir8_nodir || dirtry[ i ] == turnaround ) + { + continue; + } + + if( AI_ChangeDir( self, dirtry[ i ], r_world ) ) + { + return; + } + } + +// turn around only as a last resort + if( turnaround != dir8_nodir ) + { + if( AI_ChangeDir( self, turnaround, r_world ) ) + { + return; + } + } + + self->dir = dir8_nodir; +} + +/* +----------------------------------------------------------------------------- + Function: AI_Chase() -As AI_Dodge, but doesn't try to dodge. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void AI_Chase( entity_t *self ) +{ + int deltax, deltay; + dir8type d[2]; + dir8type tdir, olddir, turnaround; + + olddir = self->dir; + turnaround = opposite8[ olddir ]; + d[ 0 ] = d[ 1 ] = dir8_nodir; + + deltax = POS2TILE( Player.position.origin[ 0 ] ) - POS2TILE( self->x ); + deltay = POS2TILE( Player.position.origin[ 1 ] ) - POS2TILE( self->y ); + + if( deltax > 0 ) + { + d[ 0 ] = dir8_east; + } + else if( deltax < 0 ) + { + d[ 0 ] = dir8_west; + } + + if( deltay > 0 ) + { + d[ 1 ] = dir8_north; + } + else if( deltay < 0 ) + { + d[ 1 ] = dir8_south; + } + + if( ABS( deltay ) > ABS( deltax ) ) + { + tdir = d[ 0 ]; + d[ 0 ] = d[ 1 ]; + d[ 1 ] = tdir; + } // swap d[0] & d[1] + + if( d[ 0 ] == turnaround ) + { + d[ 0 ] = dir8_nodir; + } + + if( d[ 1 ] == turnaround ) + { + d[ 1 ] = dir8_nodir; + } + + if( d[ 0 ] != dir8_nodir ) + { + if( AI_ChangeDir( self, d[ 0 ], r_world ) ) + { + return; + } + } + + if( d[ 1 ] != dir8_nodir ) + { + if( AI_ChangeDir( self, d[ 1 ], r_world ) ) + { + return; + } + } + + // there is no direct path to the player, so pick another direction + if( olddir != dir8_nodir ) + { + if( AI_ChangeDir( self, olddir, r_world ) ) + { + return; + } + } + + if(US_RndT()>128) // randomly determine direction of search + { + for( tdir = dir8_east; tdir <= dir8_south; tdir += 2 ) // * Revision + { + if( tdir != turnaround ) + { + if( AI_ChangeDir(self, tdir, r_world) ) + { + return; + } + } + } + } + else + { + for( tdir = dir8_south; (int)tdir >= dir8_east; tdir -= 2 ) // * Revision (JDC fix for unsigned enums) + { + if( tdir != turnaround ) + { + if( AI_ChangeDir( self, tdir, r_world ) ) + { + return; + } + } + + } + } + + if( turnaround != dir8_nodir ) + { + if( AI_ChangeDir( self, turnaround, r_world ) ) + { + return; + } + } + + self->dir = dir8_nodir; // can't move +} + + +/* +----------------------------------------------------------------------------- + Function: AI_Retreat() -Run Away from player. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void AI_Retreat( entity_t *self ) +{ + int deltax, deltay; + dir8type d[2], tdir; + + deltax = POS2TILE( Player.position.origin[ 0 ] ) - POS2TILE( self->x ); + deltay = POS2TILE( Player.position.origin[ 1 ] ) - POS2TILE( self->y ); + + d[ 0 ] = deltax < 0 ? dir8_east : dir8_west; + d[ 1 ] = deltay < 0 ? dir8_north : dir8_south; + + if( ABS( deltay ) > ABS( deltax ) ) + { + tdir = d[ 0 ]; + d[ 0 ] = d[ 1 ]; + d[ 1 ] = tdir; + } // swap d[0] & d[1] + + if( AI_ChangeDir( self, d[ 0 ], r_world) ) + { + return; + } + + if( AI_ChangeDir( self, d[ 1 ], r_world) ) + { + return; + } + +// there is no direct path to the player, so pick another direction + + if( US_RndT() > 128 ) // randomly determine direction of search + { + for(tdir = dir8_east; tdir <= dir8_south; tdir += 2 ) // * Revision + { + if( AI_ChangeDir(self, tdir, r_world) ) + { + return; + } + } + } + else + { + for( tdir = dir8_south; (int)tdir >= dir8_east; tdir -= 2 ) // * Revision (JDC fix for unsigned enums) + { + if( AI_ChangeDir(self, tdir, r_world) ) + { + return; + } + } + } + + self->dir=dir8_nodir; // can't move +} + + +/* +----------------------------------------------------------------------------- + Function: AI_CheckSight() -Checks a straight line between player and + current object. + + Parameters: buf -[out] Storage location for data. + offset -[in] Number of bytes from beginning of file. + length -[in] Maximum number of items to be read. + + Returns: true if the player has been spoted, otherwise false. + + Notes: + If the sight is ok, check alertness and angle to see if they notice. +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean AI_CheckSight( entity_t *self ) +{ + #define MINSIGHT 0x18000 + + + int deltax, deltay; + + +// don't bother tracing a line if the area isn't connected to the player's + if( ! (self->flags & FL_AMBUSH) ) + { + if( ! areabyplayer[ self->areanumber ] ) + { + return false; + } + } + +// if the player is real close, sight is automatic + deltax = Player.position.origin[ 0 ] - self->x; + deltay = Player.position.origin[ 1 ] - self->y; + + if( ABS( deltax ) < MINSIGHT && ABS( deltay ) < MINSIGHT ) + { + return true; + } + +// see if they are looking in the right direction + switch( self->dir ) + { + case dir8_north: + if( deltay < 0 ) + return false; + break; + + case dir8_east: + if( deltax < 0 ) + return false; + break; + + case dir8_south: + if( deltay > 0 ) + return false; + break; + + case dir8_west: + if( deltax > 0 ) + return false; + break; + } + +// trace a line to check for blocking tiles (corners) + return Level_CheckLine( self->x, self->y, Player.position.origin[0], Player.position.origin[1], r_world ); +} + + +/* +----------------------------------------------------------------------------- + Function: AI_FindTarget() -Called by entities that ARE NOT chasing the player. + + Parameters: + + Returns: + If the player is detected (by sight, noise, or proximity), the entity + is put into its combat frame and true is returned. + + Notes: + Incorporates a random reaction delay. +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean AI_FindTarget( entity_t *self ) +{ + if( self->temp2 ) // count down reaction time + { + self->temp2 -= tics; + if( self->temp2 > 0 ) + { + return false; + } + self->temp2 = 0; // time to react + } + else + { + // check if we can/want to see/hear player + if( Player.flags & FL_NOTARGET ) + { + return false; // notarget cheat + } + assert( self->areanumber >= 0 && self->areanumber < NUMAREAS ); + if( ! (self->flags & FL_AMBUSH) && ! areabyplayer[ self->areanumber ] ) + { + return false; + } + + + if( ! AI_CheckSight( self ) ) // Player is visible - normal behavior + { + if( self->flags & FL_AMBUSH || ! Player.madenoise ) + { + return false; + } + } + self->flags &= ~FL_AMBUSH; + +// if we are here we see/hear player!!! + switch( self->type ) + { + case en_guard: + self->temp2 = 1 + US_RndT() / 4; + break; + + case en_officer: + self->temp2 = 2; + break; + + case en_mutant: + self->temp2 = 1 + US_RndT() / 6; + break; + + case en_ss: + self->temp2 = 1 + US_RndT() / 6; + break; + + case en_dog: + self->temp2 = 1 + US_RndT() / 8; + break; + + case en_boss: + case en_schabbs: + case en_fake: + case en_mecha: + case en_hitler: + case en_gretel: + case en_gift: + case en_fat: + case en_spectre: + case en_angel: + case en_trans: + case en_uber: + case en_will: + case en_death: + self->temp2 = 1; + break; + } + + return false; // we are amazed & waiting to understand what to do! + } + + A_FirstSighting( self ); + + return true; +} + + +/* +----------------------------------------------------------------------------- + Function: T_Move() -Moves object for distance in global units, + in ob->dir direction. + + Parameters: + + Returns: + If the player is detected (by sight, noise, or proximity), the entity + is put into its combat frame and true is returned. + + Notes: + ob->x = adjusted for new position + ob->y + + Actors are not allowed to move inside the player. + Does NOT check to see if the move is tile map valid. +----------------------------------------------------------------------------- +*/ +PRIVATE void T_Move( entity_t *self, long dist ) +{ + + if( self->dir == dir8_nodir || ! dist ) + { + return; + } + + self->x += dist * dx8dir[ self->dir ]; + self->y += dist * dy8dir[ self->dir ]; + +// check to make sure it's not on top of player + if( ABS( self->x - Player.position.origin[ 0 ] ) <= MINACTORDIST ) + if( ABS( self->y - Player.position.origin[ 1 ] ) <= MINACTORDIST ) + { + if(self->type==en_blinky|| + self->type==en_clyde || + self->type==en_pinky || + self->type==en_inky || + self->type==en_spectre) PL_Damage(&Player, self, 2); // ghosts hurt player! +// +// back up +// + self->x -= dist * dx8dir[ self->dir ]; + self->y -= dist * dy8dir[ self->dir ]; + return; + } + + self->distance -= dist; + if( self->distance < 0 ) + { + self->distance = 0; + } +} + + +/* +----------------------------------------------------------------------------- + Function: T_Advance() -Move object forward. + + Parameters: + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void T_Advance( entity_t *self, think_t think ) +{ + long move; + + if( ! think ) + { + Com_DPrintf( "Warning: Advance without proc\n" ); + return; + } + + move = self->speed * tics; + while( move > 0) + { + +// waiting for a door to open + if( self->waitfordoorx ) + { + doors_t *door = &r_world->Doors.DoorMap[ self->waitfordoorx ][ self->waitfordoory ]; + + Door_OpenDoor( door ); + if( door->action != dr_open ) + { + return; // not opened yet... + } + self->waitfordoorx = self->waitfordoory = 0; // go ahead, the door is now open + } + + if( move < self->distance ) + { + T_Move( self, move ); + break; + } + +// fix position to account for round off during moving + self->x = TILE2POS( self->tilex ); + self->y = TILE2POS( self->tiley ); + + move -= self->distance; + +// think: Where to go now? + think( self ); + self->angle = dir8angle[ self->dir ]; + if( self->dir == dir8_nodir ) + { + return; // all movement is blocked + } + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Stand( entity_t *self ) +{ + AI_FindTarget( self ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Path( entity_t *self ) +{ + + if( AI_FindTarget( self ) ) + { + return; + } + + if( ! self->speed ) + { + return; // if patroling with a speed of 0 + } + + if( self->dir == dir8_nodir ) + { + AI_Path( self ); + if( self->dir == dir8_nodir ) + { + return; // all movement is blocked + } + } + + T_Advance(self, AI_Path); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Ghosts( entity_t *self ) +{ + if( self->dir == dir8_nodir ) + { + AI_Chase( self ); + if( self->dir == dir8_nodir ) + { + return; // object is blocked in + } + + self->angle = dir8angle[ self->dir ]; + } + + T_Advance( self, AI_Chase ); +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Chase( entity_t *self ) +{ + int dx,dy,dist,chance; + char dodge; + + // if (gamestate.victoryflag) return; + + dodge = 0; + if( Level_CheckLine( self->x, self->y, Player.position.origin[0], Player.position.origin[1], r_world ) ) // got a shot at player? + { + dx = ABS( POS2TILE( self->x ) - POS2TILE( Player.position.origin[ 0 ] ) ); + dy = ABS( POS2TILE( self->y ) - POS2TILE( Player.position.origin[ 1 ] ) ); + dist = max_of_2(dx, dy); + if( ! dist || (dist == 1 && self->distance < 16) ) + { + chance = 300; + } + else + { + chance = (tics << 4) / dist;//100/dist; + } + + if( US_RndT() < chance ) + { // go into attack frame + A_StateChange(self, st_shoot1); + return; + } + dodge = 1; + } + + if( self->dir == dir8_nodir ) + { + if( dodge ) + { + AI_Dodge( self ); + } + else + { + AI_Chase( self ); + } + + if( self->dir == dir8_nodir ) + { + return; // object is blocked in + } + self->angle = dir8angle[ self->dir ]; + } + + T_Advance( self, dodge ? AI_Dodge : AI_Chase ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Bite( entity_t *self ) +{ + long dx, dy; + + Sound_StartSound( NULL, 1, CHAN_VOICE, Sound_RegisterSound( "lsfx/076.wav" ), 1, ATTN_NORM, 0 ); + + dx = ABS( Player.position.origin[ 0 ] - self->x ) - TILEGLOBAL; + if( dx <= MINACTORDIST ) + { + dy = ABS( Player.position.origin[ 1 ] - self->y ) - TILEGLOBAL; + if( dy <= MINACTORDIST ) + { + if(US_RndT()<180) + { + PL_Damage(&Player, self, US_RndT()>>4); + return; + } + } + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_DogChase( entity_t *self ) +{ + long dx, dy; + + if( self->dir == dir8_nodir ) + { + AI_Dodge( self ); + self->angle = dir8angle[ self->dir ]; + if( self->dir == dir8_nodir ) + { + return; // object is blocked in + } + } + +// +// check for bite range +// + dx = ABS( Player.position.origin[ 0 ] - self->x ) - TILEGLOBAL / 2; + if(dx <= MINACTORDIST) + { + dy = ABS( Player.position.origin[ 1 ] - self->y ) - TILEGLOBAL / 2; + if( dy <= MINACTORDIST ) + { + A_StateChange( self, st_shoot1 ); + return; // bite player! + } + } + + T_Advance( self, AI_Dodge ); +} + + +/* +----------------------------------------------------------------------------- + Function: T_BossChase + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + They retreat if too close to player. +----------------------------------------------------------------------------- +*/ +PUBLIC void T_BossChase( entity_t *self ) +{ + int dx, dy, dist; + W8 dodge; + + dodge = 0; + dx = ABS( self->tilex - POS2TILE( Player.position.origin[ 0 ] ) ); + dy = ABS( self->tiley - POS2TILE( Player.position.origin[ 1 ] ) ); + dist = max_of_2( dx, dy ); + + if( Level_CheckLine( self->x, self->y, Player.position.origin[0], Player.position.origin[1], r_world ) ) // got a shot at player? + { + if( US_RndT() < tics << 3 ) + { // go into attack frame + A_StateChange( self, st_shoot1 ); + return; + } + dodge = 1; + } + + if( self->dir == dir8_nodir ) + { + if(dodge) + { + AI_Dodge(self); + } + else + { + AI_Chase(self); + } + + if( self->dir == dir8_nodir ) + { + return; // object is blocked in + } + } + + T_Advance( self, dist < 4 ? AI_Retreat : (dodge ? AI_Dodge : AI_Chase)); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Fake( entity_t *self ) +{ + + if( Level_CheckLine( self->x, self->y, Player.position.origin[0], Player.position.origin[1], r_world ) ) // got a shot at player? + { + if( US_RndT() < tics << 1 ) + { // go into attack frame + A_StateChange( self, st_shoot1 ); + return; + } + } + + if( self->dir == dir8_nodir ) + { + AI_Dodge( self ); + if( self->dir == dir8_nodir ) + { + return; // object is blocked in + } + } + + T_Advance( self, AI_Dodge ); +} + + + +/* +----------------------------------------------------------------------------- + Function: T_Shoot -Try to damage the player. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Shoot( entity_t *self ) +{ + int dx, dy, dist; + int hitchance, damage; + + if( ! areabyplayer[ self->areanumber ] ) + { + return; + } + + if( ! Level_CheckLine( self->x, self->y, Player.position.origin[0], Player.position.origin[1], r_world ) ) + { + return; // player is behind a wall + } + + dx = ABS( POS2TILE( self->x ) - POS2TILE( Player.position.origin[ 0 ] ) ); + dy = ABS( POS2TILE( self->y ) - POS2TILE( Player.position.origin[ 1 ] ) ); + dist = max_of_2( dx, dy ); + + if( self->type == en_ss || self->type == en_boss ) + { + dist = dist * 2 / 3; // ss are better shots + } + + if( Player.speed >= RUNSPEED ) + { + hitchance = 160; + } + else + { + hitchance = 256; + } + +// if guard is visible by player +// player can see to dodge +// (if CheckLine both player & enemy see each other) +// So left only check if guard is in player's fov: FIXME: not fixed fov! + if( angle_diff( TransformPoint( self->x, self->y, Player.position.origin[0], Player.position.origin[1] ), FINE2DEG( Player.position.angle ) ) < (M_PI/3) ) + { + hitchance -= dist * 16; + } + else + { + hitchance -= dist * 8; + } + +// see if the shot was a hit + if( US_RndT() < hitchance ) + { + if( dist < 2 ) + { + damage = US_RndT() >> 2; + } + else if( dist < 4 ) + { + damage = US_RndT() >> 3; + } + else + { + damage = US_RndT() >> 4; + } + + PL_Damage( &Player, self, damage ); + } + + switch( self->type ) + { + case en_ss: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "sfx/020.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "sfx/024.wav" ), 1, ATTN_NORM, 0 ); + } + break; + + case en_gift: + case en_fat: + case en_mecha: + case en_hitler: + case en_boss: + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "sfx/022.wav" ), 1, ATTN_NORM, 0 ); + break; + + default: + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "sfx/038.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "sfx/049.wav" ), 1, ATTN_NORM, 0 ); + } + break; + } +} + +/* +----------------------------------------------------------------------------- + Function: T_UShoot -[UberMutant] + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_UShoot( entity_t *self ) +{ + int dx, dy, dist; + + T_Shoot( self ); + + dx = ABS( self->tilex - POS2TILE( Player.position.origin[ 0 ] ) ); + dy = ABS( self->tiley - POS2TILE( Player.position.origin[ 1 ] ) ); + dist = max_of_2( dx, dy ); + + if( dist <= 1 ) + { + PL_Damage( &Player, self, 10 ); + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void T_Launch( entity_t *self ) +{ + entity_t *proj; + float iangle; + + iangle = TransformPoint( self->x, self->y, Player.position.origin[ 0 ], Player.position.origin[ 1 ] ) + M_PI; + if( iangle > 2 * M_PI ) + { + iangle -= 2 * M_PI; + } + + if( self->type == en_death ) + {// death knight launches 2 rockets with 4 degree shift each. + T_Shoot( self ); + if( self->state == st_shoot2 ) + { + iangle = normalize_angle( iangle - DEG2RAD( 4 ) ); + } + else + { + iangle = normalize_angle( iangle + DEG2RAD( 4 ) ); + } + } + + proj = GetNewActor(); + if( proj == NULL ) + { + return; + } + + proj->x = self->x; + proj->y = self->y; + + proj->tilex = self->tilex; + proj->tiley = self->tiley; + + proj->state = st_stand; + proj->ticcount = 1; + proj->dir = dir8_nodir; + + proj->angle = RAD2FINE( iangle ); + proj->speed = 0x2000; + proj->flags = FL_NONMARK; // FL_NEVERMARK; + proj->sprite = Sprite_GetNewSprite(); + + switch( self->type ) + { + case en_death: + proj->type = en_hrocket; + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/078.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_angel: + proj->type = en_spark; + proj->state = st_path1; + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/069.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_fake: + proj->type = en_fire; + proj->state = st_path1; + proj->flags = FL_NEVERMARK; + proj->speed = 0x1200; + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/069.wav" ), 1, ATTN_NORM, 0 ); + break; + + case en_schabbs: + proj->type = en_needle; + proj->state = st_path1; + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/008.wav" ), 1, ATTN_NORM, 0 ); + break; + + default: + proj->type = en_rocket; + + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/008.wav" ), 1, ATTN_NORM, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_WEAPON, Sound_RegisterSound( "lsfx/085.wav" ), 1, ATTN_NORM, 0 ); + } + } + +} diff --git a/wolf3d/newCode/wolf/wolf_ai_com.h b/wolf3d/newCode/wolf/wolf_ai_com.h new file mode 100644 index 0000000..9fb8a1a --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_ai_com.h @@ -0,0 +1,65 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_ai_com.h: Wolfenstein3-D entity management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_ai_com.c + +*/ + +#ifndef __WOLF_AI_COM_H__ +#define __WOLF_AI_COM_H__ + +#include "wolf_actors.h" + +// common AI functions + +extern void T_Stand( entity_t *self ); +extern void T_Path( entity_t *self ); +extern void T_Ghosts( entity_t *self ); +extern void T_Chase( entity_t *self ); +extern void T_Bite( entity_t *self ); +extern void T_DogChase( entity_t *self ); +extern void T_BossChase( entity_t *self ); +extern void T_Fake( entity_t *self ); + +extern void T_Shoot( entity_t *self ); +extern void T_UShoot( entity_t *self ); +extern void T_Launch( entity_t *self ); + + +#endif /* __WOLF_AI_COM_H__ */ + diff --git a/wolf3d/newCode/wolf/wolf_areas.c b/wolf3d/newCode/wolf/wolf_areas.c new file mode 100644 index 0000000..960a502 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_areas.c @@ -0,0 +1,170 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_areas.c: Wolfenstein3-D area management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Acknowledgement: + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + + +/* + Notes: + + Open doors connect two areas, so sounds will travel between them and sight + will be checked when the player is in a connected area. + + Areaconnect is incremented/decremented by each door. If >0 they connect. + + Every time a door opens or closes the areabyplayer matrix gets recalculated. + An area is true if it connects with the player's current spor. + +*/ + +#include "../wolfiphone.h" + + + + +W8 areaconnect[ NUMAREAS ][ NUMAREAS ]; +_boolean areabyplayer[ NUMAREAS ]; + + + +/* +----------------------------------------------------------------------------- + Function: Areas_RecursiveConnect() -Scans outward from playerarea, + marking all connected areas. + + Parameters: areanumber -[in] area. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Areas_RecursiveConnect( int areanumber ) +{ + int i; + + for( i = 0 ; i < NUMAREAS ; ++i ) + { + if( areaconnect[ areanumber ][ i ] && ! areabyplayer[ i ] ) + { + areabyplayer[ i ] = true; + Areas_RecursiveConnect( i ); + } + } +} + +/* +----------------------------------------------------------------------------- + Function: Areas_ConnectAreas() -Connect area. + + Parameters: areanumber -[in] area. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Areas_ConnectAreas( int areanumber ) +{ + int c = 0; + int i; + + assert( areanumber < NUMAREAS ); + memset( areabyplayer, 0, sizeof( areabyplayer ) ); + areabyplayer[ areanumber ] = true; + Areas_RecursiveConnect( areanumber ); + for ( i = 0 ; i < NUMAREAS ; i++ ) { + if ( areabyplayer[i] ) { + c++; + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Areas_InitAreas( int areanumber ) +{ + memset( areaconnect, 0, sizeof( areaconnect ) ); + memset( areabyplayer, 0, sizeof( areabyplayer ) ); + areabyplayer[ areanumber ] = true; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Areas_JoinAreas( int area1, int area2 ) +{// FIXME: check for overflow! + areaconnect[ area1 ][ area2 ]++; + areaconnect[ area2 ][ area1 ]++; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Areas_DisconnectAreas( int area1, int area2 ) +{// FIXME: check for underflow! + areaconnect[ area1 ][ area2 ]--; + areaconnect[ area2 ][ area1 ]--; +} diff --git a/wolf3d/newCode/wolf/wolf_bj.c b/wolf3d/newCode/wolf/wolf_bj.c new file mode 100644 index 0000000..0f59ae2 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_bj.c @@ -0,0 +1,136 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + + + +#define BJRUNSPEED 2048 +#define BJJUMPSPEED 680 + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +void SpawnBJVictory( void ) +{ + entity_t *bj; + + bj = SpawnActor( en_bj, POS2TILE(Player.position.origin[0]), POS2TILE(Player.position.origin[1]), dir4_north, r_world ); + if( ! bj ) + { + return; + } + + bj->x = Player.position.origin[ 0 ]; + bj->y = Player.position.origin[ 1 ]; + bj->state = st_path1; + bj->speed = BJRUNSPEED; + bj->flags = FL_NONMARK; // FL_NEVERMARK; + bj->temp2 = 6; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +void T_BJRun( entity_t *Guard ) +{ +// MoveObj(Guard, Guard->speed); + + if( ! Guard->distance ) + { + Guard->distance = TILEGLOBAL; + if ( !(--Guard->temp2) ) + { + A_StateChange( Guard, st_shoot1 ); + Guard->speed = BJJUMPSPEED; + return; + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +void T_BJJump( entity_t *Guard ) +{ +// MoveObj(Guard, Guard->speed); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +void T_BJYell( entity_t *Guard ) +{ + Sound_StartSound( NULL, 0, CHAN_VOICE, Sound_RegisterSound( "sfx/082.wav" ), 1, ATTN_NORM, 0 ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +void T_BJDone( entity_t *Guard ) +{ + Player.playstate = ex_victory; // exit castle tile +} diff --git a/wolf3d/newCode/wolf/wolf_bj.h b/wolf3d/newCode/wolf/wolf_bj.h new file mode 100644 index 0000000..d2adcef --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_bj.h @@ -0,0 +1,59 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_bj.h: Wolfenstein3-D bj code . + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_bj.c + +*/ + +#ifndef __WOLF_BJ_H__ +#define __WOLF_BJ_H__ + + + +extern void SpawnBJVictory( void ); +extern void T_BJRun( entity_t *Guard ); +extern void T_BJJump( entity_t *Guard ); +extern void T_BJYell( entity_t *Guard ); +extern void T_BJDone( entity_t *Guard ); + + + + + +#endif /* __WOLF_BJ_H__ */ + diff --git a/wolf3d/newCode/wolf/wolf_client_main.c b/wolf3d/newCode/wolf/wolf_client_main.c new file mode 100644 index 0000000..f5507f1 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_client_main.c @@ -0,0 +1,94 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Client_PrepRefresh( const char *r_mapname ) +{ + char mapname[ 32 ]; + + if( ! r_mapname || ! *r_mapname ) + { + return; + } + + if( g_version->value == SPEAROFDESTINY ) + { + spritelocation = SODSPRITESDIRNAME; + } + else + { + spritelocation = WL6SPRITESDIRNAME; + } + + my_strlcpy( mapname, r_mapname, sizeof( mapname ) ); // skip "maps/" + + // !@# fix crash bug if you type something short... + if ( strlen( mapname ) > 4 && !strcmp( mapname + strlen( mapname ) - 4, ".map" ) ) { + mapname[ strlen( mapname ) - 4 ] = '\0'; // cut off ".map" + } + + // register models, pics, and skins + R_BeginRegistration( mapname ); + + if( r_world == NULL ) + { + return; + } + + + Com_Printf( "Map: %s\n", r_world->mapName ); + + Level_ScanInfoPlane( r_world ); // Spawn items/guards + + Com_Printf( "Spawning Entities\n" ); + PL_Spawn( r_world->pSpawn, r_world ); // Spawn Player + + Com_Printf( "Caching Textures and Sounds\n" ); + Level_PrecacheTextures_Sound( r_world ); + + // clear any lines of console text + Con_ClearNotify(); + + if( r_world->musicName ) + { + Sound_StartBGTrack( r_world->musicName, r_world->musicName ); + } + + Player.playstate = ex_playing; +} + +int tics; + + + + diff --git a/wolf3d/newCode/wolf/wolf_doors.c b/wolf3d/newCode/wolf/wolf_doors.c new file mode 100644 index 0000000..f1c4d55 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_doors.c @@ -0,0 +1,506 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_doors.c: Wolfenstein 3-D door management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Acknowledgement: + * Portion of this code was derived from Wolfenstein 3-D, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +#define CLOSEWALL MINDIST // Space between wall & player +#define MAXDOORS 64 // max number of sliding doors + + + + +/* +----------------------------------------------------------------------------- + Function: Door_ResetDoors -Resets doors status + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Door_ResetDoors( LevelDoors_t *lvldoors ) +{ + lvldoors->doornum = 0; + + memset( lvldoors->Doors, 0, sizeof( lvldoors->Doors ) ); + memset( lvldoors->DoorMap, 0, sizeof( lvldoors->DoorMap ) ); +} + + + + +/* +----------------------------------------------------------------------------- + Function: Door_SpawnDoor -Spawns door at x, y, position. + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC int Door_SpawnDoor( LevelDoors_t *lvldoors, int x, int y, int type ) +{ + if( lvldoors->doornum >= MAXDOORS ) + { + Com_DPrintf( "[%s]: Too many Doors on level! (%d)\n", "wolf_doors.c", lvldoors->doornum ); + return 0; + } + + switch( type ) + { + case 0x5A: + lvldoors->DoorMap[ x ][ y ].type = DOOR_VERT; + lvldoors->DoorMap[ x ][ y ].vertical= true; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DDOOR + 1; + break; + + case 0x5B: + lvldoors->DoorMap[ x ][ y ].type = DOOR_HORIZ; + lvldoors->DoorMap[ x ][ y ].vertical = false; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DDOOR; + break; + + case 0x5C: + lvldoors->DoorMap[ x ][ y ].type = DOOR_G_VERT; + lvldoors->DoorMap[ x ][ y ].vertical = true; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DLOCK + 1; + break; + + case 0x5D: + lvldoors->DoorMap[ x ][ y ].type = DOOR_G_HORIZ; + lvldoors->DoorMap[ x ][ y ].vertical = false; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DLOCK; + break; + + case 0x5E: + lvldoors->DoorMap[ x ][ y ].type = DOOR_S_VERT; + lvldoors->DoorMap[ x ][ y ].vertical = true; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DLOCK + 1; + break; + + case 0x5F: + lvldoors->DoorMap[ x ][ y ].type = DOOR_S_HORIZ; + lvldoors->DoorMap[ x ][ y ].vertical = false; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DLOCK; + break; + + case 0x64: + lvldoors->DoorMap[ x ][ y ].type = DOOR_E_VERT; + lvldoors->DoorMap[ x ][ y ].vertical = true; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DELEV + 1; + break; + + case 0x65: + lvldoors->DoorMap[ x ][ y ].type = DOOR_E_HORIZ; + lvldoors->DoorMap[ x ][ y ].vertical = false; + lvldoors->DoorMap[ x ][ y ].texture = TEX_DELEV; + break; + + default: + Com_DPrintf( "Door_SpawnDoor: Unknown door type: %d\n", type ); + return 0; + } + + lvldoors->DoorMap[ x ][ y ].tilex = x; + lvldoors->DoorMap[ x ][ y ].tiley = y; + lvldoors->DoorMap[ x ][ y ].action = dr_closed; + + lvldoors->Doors[ lvldoors->doornum ] = &lvldoors->DoorMap[ x ][ y ]; + lvldoors->doornum++; + + return lvldoors->doornum - 1; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Door_SetAreas( LevelDoors_t *lvldoors, int (*areas)[64] ) +{ + int n, x, y; + + for( n = 0 ; n < lvldoors->doornum ; ++n ) + { + x = lvldoors->Doors[ n ]->tilex; + y = lvldoors->Doors[ n ]->tiley; + + if( lvldoors->Doors[ n ]->vertical ) + { + lvldoors->Doors[ n ]->area1 = areas[ x + 1 ][ y ] >= 0 ? areas[ x + 1 ][ y ] : 0; + lvldoors->Doors[ n ]->area2 = areas[ x - 1 ][ y ] >= 0 ? areas[ x - 1 ][ y ] : 0; + } + else + { + lvldoors->Doors[ n ]->area1 = areas[ x ][ y + 1 ] >= 0 ? areas[ x ][ y + 1 ] : 0; + lvldoors->Doors[ n ]->area2 = areas[ x ][ y - 1 ] >= 0 ? areas[ x ][ y - 1 ] : 0; + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE W8 CanCloseDoor( int x, int y, char vert ) +{ + int n; + + if( POS2TILE( Player.position.origin[ 0 ] ) == x && + POS2TILE( Player.position.origin[ 1 ] ) == y ) + { + return 0; + } + + if( vert ) + { + if( POS2TILE( Player.position.origin[ 1 ] ) == y ) + { + if( POS2TILE( Player.position.origin[ 0 ] + CLOSEWALL ) == x ) + { + return 0; + } + + if( POS2TILE( Player.position.origin[ 0 ] - CLOSEWALL ) == x ) + { + return 0; + } + } + + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].tilex == x && Guards[ n ].tiley == y ) + { + return 0; // guard in door + } + + if( Guards[ n ].tilex == x - 1 && + Guards[ n ].tiley == y && + POS2TILE( Guards[ n ].x + CLOSEWALL ) == x ) + { + return 0; // guard in door + } + + if( Guards[ n ].tilex == x + 1 && + Guards[ n ].tiley == y && + POS2TILE( Guards[ n ].x - CLOSEWALL ) == x ) + { + return 0; // guard in door + } + } + } + else + { + if( POS2TILE( Player.position.origin[ 0 ] ) == x ) + { + if( POS2TILE( Player.position.origin[ 1 ] + CLOSEWALL ) == y ) + { + return 0; + } + + if( POS2TILE( Player.position.origin[ 1 ] - CLOSEWALL ) == y ) + { + return 0; + } + } + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].tilex == x && Guards[ n ].tiley == y ) + { + return 0; // guard in door + } + + if( Guards[ n ].tilex == x && + Guards[ n ].tiley == y - 1 && + POS2TILE( Guards[ n ].y + CLOSEWALL ) == y ) + { + return 0; // guard in door + } + + if( Guards[ n ].tilex == x && + Guards[ n ].tiley == y + 1 && + POS2TILE( Guards[ n ].y - CLOSEWALL ) == y ) + { + return 0; // guard in door + } + } + } + + return 1; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Door_OpenDoor( doors_t *Door ) +{ + if( Door->action == dr_open ) + { + Door->ticcount = 0; // reset opened time + } + else + { + Door->action = dr_opening; // start opening it + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Door_ChangeDoorState( doors_t *Door ) +{ + if( Door->action < dr_opening ) + { + Door_OpenDoor( Door ); + } + else if( Door->action == dr_open && CanCloseDoor( Door->tilex, Door->tiley, Door->vertical ) ) + { + // !@# for the iphone with automatic using, don't allow any door close actions + // Door->action = dr_closing; + // Door->ticcount = DOOR_FULLOPEN; + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Door_ProcessDoors_e( LevelDoors_t *lvldoors, int t_tk, int t_ms ) +{ + int n; + + for( n = 0 ; n < lvldoors->doornum ; ++n ) + { + switch( lvldoors->Doors[ n ]->action ) + { + case dr_closed: // this door is closed! + continue; + + case dr_opening: + if( lvldoors->Doors[ n ]->ticcount >= DOOR_FULLOPEN ) // door fully opened! + { + lvldoors->Doors[ n ]->action = dr_open; + lvldoors->Doors[ n ]->ticcount = 0; + } + else // opening! + { + if( lvldoors->Doors[ n ]->ticcount == 0 ) + { // door is just starting to open, so connect the areas + Areas_JoinAreas( lvldoors->Doors[ n ]->area1, lvldoors->Doors[ n ]->area2 ); + Areas_ConnectAreas( Player.areanumber ); + if( areabyplayer[ lvldoors->Doors[ n ]->area1 ] ) // Door Opening sound! + { + Sound_StartSound( NULL, 1, CHAN_AUTO, Sound_RegisterSound( "sfx/010.wav" ), 1, ATTN_STATIC, 0 ); + } + } + + lvldoors->Doors[n]->ticcount += t_tk; + + if( lvldoors->Doors[ n ]->ticcount > DOOR_FULLOPEN ) + { + lvldoors->Doors[ n ]->ticcount = DOOR_FULLOPEN; + } + } + break; + + case dr_closing: + if( lvldoors->Doors[ n ]->ticcount <= 0 ) // door fully closed! disconnect areas! + { + Areas_DisconnectAreas( lvldoors->Doors[ n ]->area1, lvldoors->Doors[ n ]->area2 ); + Areas_ConnectAreas( Player.areanumber ); + lvldoors->Doors[ n ]->ticcount = 0; + lvldoors->Doors[ n ]->action = dr_closed; + } + else // closing! + { + if( lvldoors->Doors[ n ]->ticcount == DOOR_FULLOPEN ) + { + if( areabyplayer[ lvldoors->Doors[ n ]->area1 ] ) // Door Closing sound! + { + Sound_StartSound( NULL, 1, CHAN_AUTO, Sound_RegisterSound( "sfx/007.wav" ), 1, ATTN_STATIC, 0 ); + } + } + lvldoors->Doors[ n ]->ticcount -= t_tk; + if( lvldoors->Doors[ n ]->ticcount < 0 ) + { + lvldoors->Doors[ n ]->ticcount = 0; + } + } + break; + + case dr_open: + if( lvldoors->Doors[ n ]->ticcount > DOOR_MINOPEN ) + { // If player or something is in door do not close it! + if( ! CanCloseDoor( lvldoors->Doors[ n ]->tilex, lvldoors->Doors[ n ]->tiley, lvldoors->Doors[ n ]->vertical ) ) + { + lvldoors->Doors[ n ]->ticcount = DOOR_MINOPEN; // do not close door immediately! + } + } + if( lvldoors->Doors[ n ]->ticcount >= DOOR_TIMEOUT ) + { // Door timeout, time to close it! + lvldoors->Doors[ n ]->action = dr_closing; + lvldoors->Doors[ n ]->ticcount = DOOR_FULLOPEN; + } + else + { // Increase timeout! + lvldoors->Doors[ n ]->ticcount += t_tk; + } + break; + + } // End switch lvldoors->Doors[ n ].action + + } // End for n = 0 ; n < lvldoors->doornum ; ++n + +} + +/* +----------------------------------------------------------------------------- + Function: Door_Opened -Check to see if a door is open. + + Parameters: + + Returns: DOOR_FULLOPEN Door is opened + 0 Door is closed + >0 DoorMap[ x ][ y ].action == dr_open ? DOOR_FULLOPEN : lvldoors->DoorMap[ x ][ y ].ticcount; +} + +/* +----------------------------------------------------------------------------- + Function: Door_TryUse -Try to use a door with keys that the player has. + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Door_TryUse( doors_t *Door, int keys ) +{ + switch( Door->type ) + { + case DOOR_VERT: + case DOOR_HORIZ: + case DOOR_E_VERT: + case DOOR_E_HORIZ: + Door_ChangeDoorState( Door ); // does not require key! + break; + + case DOOR_G_VERT: + case DOOR_G_HORIZ: + if( keys & ITEM_KEY_1 ) + { + Door_ChangeDoorState( Door ); + } + else + { + iphoneSetNotifyText( "You need a gold key" ); + } + break; + + case DOOR_S_VERT: + case DOOR_S_HORIZ: + if( keys & ITEM_KEY_2 ) + { + Door_ChangeDoorState( Door ); + } + else + { + iphoneSetNotifyText( "You need a silver key" ); + } + break; + } + + return true; // FIXME + +} diff --git a/wolf3d/newCode/wolf/wolf_level.c b/wolf3d/newCode/wolf/wolf_level.c new file mode 100644 index 0000000..15bbbca --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_level.c @@ -0,0 +1,1389 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_level.c: Wolfenstein3-D Level management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Acknowledgement: + * Portion of this code was derived from Wolfenstein 3-D, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + + +statinfo_t static_wl6[]= +{ + {false, -1}, // puddle spr1v + { true, -1}, // Green Barrel " + { true, -1}, // Table/chairs " + { true, -1}, // Floor lamp " + {false, -1}, // Chandelier " + { true, -1}, // Hanged man " + {false, pow_alpo}, // Bad food " + { true, -1}, // Red pillar " + { true, -1}, // Tree spr2v + {false, -1}, // Skeleton flat " + { true, -1}, // Sink " (SOD:gibs) + { true, -1}, // Potted plant " + { true, -1}, // Urn " + { true, -1}, // Bare table " + {false, -1}, // Ceiling light " + {false, -1}, // Kitchen stuff " + { true, -1}, // suit of armor spr3v + { true, -1}, // Hanging cage " + { true, -1}, // SkeletoninCage " + {false, -1}, // Skeleton relax " + {false, pow_key1}, // Key 1 " + {false, pow_key2}, // Key 2 " + { true, -1}, // stuff (SOD:gibs) + {false, -1}, // stuff + {false, pow_food}, // Good food spr4v + {false, pow_firstaid}, // First aid " + {false, pow_clip}, // Clip " + {false, pow_machinegun},// Machine gun " + {false, pow_chaingun}, // Gatling gun " + {false, pow_cross}, // Cross " + {false, pow_chalice}, // Chalice " + {false, pow_bible}, // Bible " + {false, pow_crown}, // crown spr5v + {false, pow_fullheal}, // one up " + {false, pow_gibs}, // gibs " + { true, -1}, // barrel " + { true, -1}, // well " + { true, -1}, // Empty well " + {false, pow_gibs}, // Gibs 2 " + { true, -1}, // flag " + { true, -1}, // Call Apogee spr7v + {false, -1}, // junk " + {false, -1}, // junk " + {false, -1}, // junk " + {false, -1}, // pots " + { true, -1}, // stove " (SOD:gibs) + { true, -1}, // spears " (SOD:gibs) + {false, -1}, // vines " +}; + + +statinfo_t static_sod[] = +{ + {false, -1}, // puddle spr1v + { true, -1}, // Green Barrel " + { true, -1}, // Table/chairs " + { true, -1}, // Floor lamp " + {false, -1}, // Chandelier " + { true, -1}, // Hanged man " + {false, pow_alpo}, // Bad food " + { true, -1}, // Red pillar " + { true, -1}, // Tree spr2v + {false, -1}, // Skeleton flat " + { true, -1}, // Sink " (SOD:gibs) + { true, -1}, // Potted plant " + { true, -1}, // Urn " + { true, -1}, // Bare table " + {false, -1}, // Ceiling light " + { true, -1}, // Gibs! + { true, -1}, // suit of armor spr3v + { true, -1}, // Hanging cage " + { true, -1}, // SkeletoninCage " + {false, -1}, // Skeleton relax " + {false, pow_key1}, // Key 1 " + {false, pow_key2}, // Key 2 " + { true, -1}, // stuff (SOD:gibs) + {false, -1}, // stuff + {false, pow_food}, // Good food spr4v + {false, pow_firstaid}, // First aid " + {false, pow_clip}, // Clip " + {false, pow_machinegun},// Machine gun " + {false, pow_chaingun}, // Gatling gun " + {false, pow_cross}, // Cross " + {false, pow_chalice}, // Chalice " + {false, pow_bible}, // Bible " + {false, pow_crown}, // crown spr5v + {false, pow_fullheal}, // one up " + {false, pow_gibs}, // gibs " + { true, -1}, // barrel " + { true, -1}, // well " + { true, -1}, // Empty well " + {false, pow_gibs}, // Gibs 2 " + { true, -1}, // flag " + {false, -1}, // Red light + {false, -1}, // junk " + {false, -1}, // junk " + {false, -1}, // junk " + { true, -1}, // Gibs! + { true, -1}, // stove " (SOD:gibs) + { true, -1}, // spears " (SOD:gibs) + {false, -1}, // vines " + { true, -1}, // marble pillar + {false, pow_25clip}, // bonus 25 clip + { true, -1}, // truck + {false, pow_spear}, // SPEAR OF DESTINY! +}; + +statinfo_t *statinfo = static_wl6; +int num_statics = sizeof( static_wl6 ) / sizeof( static_wl6[ 0 ] ); + +texture_t *wallTextures[1000]; +texture_t *spriteTextures[1000]; + +PRIVATE W16 cachedGuard = 0; +PRIVATE W16 cachedOfficer = 0; +PRIVATE W16 cachedSS = 0; +PRIVATE W16 cachedDog = 0; +PRIVATE W16 cachedMutant = 0; + +PRIVATE int progress_bar = 0; + +extern void R_EndFrame( void ); + +LevelData_t levelData; + + +PRIVATE void CacheTextures( W16 start, W16 end ) +{ + W16 i; + static char texname[ 64 ]; + + + if( end < start ) + { + return; + } + + for( i = start ; i <= end ; ++i ) + { + my_snprintf( texname, sizeof( texname ), "%s/%.3d.tga", spritelocation, i ); + spriteTextures[i] = TM_FindTexture( texname, TT_Wall ); + } + +// R_DrawPsyched( ++progress_bar + 30 ); +// R_EndFrame(); +} + +/* +----------------------------------------------------------------------------- + Function: Level_ScanInfoPlane -Spawn all actors and mark down special places. + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Level_ScanInfoPlane( LevelData_t *lvl ) +{ + int x, y; + W16 tile; + + cachedGuard = 0; + cachedOfficer = 0; + cachedSS = 0; + cachedDog = 0; + cachedMutant = 0; + progress_bar = 0; + + for( y = 0 ; y < 64; ++y ) + { + for( x = 0 ; x < 64 ; ++x ) + { + tile = lvl->Plane2[ (63 - y) * 64 + x ]; + if( ! tile ) + { + continue; + } + + switch( tile ) + { +// +// guard +// + case 180: + case 181: + case 182: + case 183: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 144: + case 145: + case 146: + case 147: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 108: + case 109: + case 110: + case 111: + if( ! cachedGuard ) + { + CacheTextures( SPR_GRD_S_1, SPR_GRD_SHOOT3 ); + cachedGuard = 1; + } + SpawnStand( en_guard, x, y, tile - 108, lvl ); + break; + + case 184: + case 185: + case 186: + case 187: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 148: + case 149: + case 150: + case 151: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 112: + case 113: + case 114: + case 115: + if( ! cachedGuard ) + { + CacheTextures( SPR_GRD_S_1, SPR_GRD_SHOOT3 ); + cachedGuard = 1; + } + SpawnPatrol( en_guard, x, y,tile - 112 ); + break; + + case 124: + SpawnDeadGuard( en_guard, x, y ); + break; +// +// officer +// + case 188: + case 189: + case 190: + case 191: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 152: + case 153: + case 154: + case 155: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 116: + case 117: + case 118: + case 119: + if( ! cachedOfficer ) + { + CacheTextures( SPR_OFC_S_1, SPR_OFC_SHOOT3 ); + cachedOfficer = 1; + } + SpawnStand( en_officer, x, y, tile - 116, lvl ); + break; + + + case 192: + case 193: + case 194: + case 195: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 156: + case 157: + case 158: + case 159: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 120: + case 121: + case 122: + case 123: + if( ! cachedOfficer ) + { + CacheTextures( SPR_OFC_S_1, SPR_OFC_SHOOT3 ); + cachedOfficer = 1; + } + SpawnPatrol( en_officer, x, y, tile - 120 ); + break; +// +// SS +// + case 198: + case 199: + case 200: + case 201: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 162: + case 163: + case 164: + case 165: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 126: + case 127: + case 128: + case 129: + if( ! cachedSS ) + { + CacheTextures( SPR_SS_S_1, SPR_SS_SHOOT3 ); + cachedSS = 1; + } + SpawnStand( en_ss, x, y, tile - 126, lvl ); + break; + + case 202: + case 203: + case 204: + case 205: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 166: + case 167: + case 168: + case 169: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 130: + case 131: + case 132: + case 133: + if( ! cachedSS ) + { + CacheTextures( SPR_SS_S_1, SPR_SS_SHOOT3 ); + cachedSS = 1; + } + SpawnPatrol( en_ss, x, y, tile - 130 ); + break; +// +// dogs +// + case 206: + case 207: + case 208: + case 209: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 170: + case 171: + case 172: + case 173: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 134: + case 135: + case 136: + case 137: + if( ! cachedDog ) + { + CacheTextures( SPR_DOG_W1_1, SPR_DOG_JUMP3 ); + cachedDog = 1; + } + SpawnStand( en_dog, x, y, tile - 134, lvl ); + break; + + case 210: + case 211: + case 212: + case 213: + if( skill->value < gd_hard ) + break; + tile -= 36; + case 174: + case 175: + case 176: + case 177: + if( skill->value < gd_medium ) + break; + tile -= 36; + case 138: + case 139: + case 140: + case 141: + if( ! cachedDog ) + { + CacheTextures( SPR_DOG_W1_1, SPR_DOG_JUMP3 ); + cachedDog = 1; + } + SpawnPatrol( en_dog, x, y, tile - 138 ); + break; +// bosses + case 214: + CacheTextures( SPR_BOSS_W1, SPR_BOSS_DIE3 ); + SpawnBoss( en_boss, x, y ); + break; + + case 197: + CacheTextures( SPR_GRETEL_W1, SPR_GRETEL_DIE3 ); + SpawnBoss( en_gretel, x, y ); + break; + + case 215: + CacheTextures( SPR_GIFT_W1, SPR_GIFT_DEAD ); + SpawnBoss( en_gift, x, y ); + break; + + case 179: + CacheTextures( SPR_FAT_W1, SPR_FAT_DEAD ); + SpawnBoss( en_fat, x, y ); + break; + + case 196: + CacheTextures( SPR_SCHABB_W1, SPR_HYPO4 ); + SpawnBoss( en_schabbs, x, y ); + break; + + case 160: + CacheTextures( SPR_FAKE_W1, SPR_FAKE_DEAD ); + SpawnBoss( en_fake, x, y ); + break; + + case 178: + CacheTextures( SPR_MECHA_W1, SPR_HITLER_DIE7 ); + SpawnBoss( en_mecha, x, y ); + break; +// +// Spear +// + case 106: + CacheTextures( SPR_SPECTRE_W1, SPR_SPECTRE_F4 ); + SpawnBoss( en_spectre, x, y ); + break; + + case 107: + CacheTextures( SPR_ANGEL_W1, SPR_ANGEL_DEAD ); + SpawnBoss( en_angel, x, y ); + break; + + case 125: + CacheTextures( SPR_TRANS_W1, SPR_TRANS_DIE3 ); + SpawnBoss( en_trans, x, y ); + break; + + case 142: + CacheTextures( SPR_UBER_W1, SPR_UBER_DEAD ); + SpawnBoss( en_uber, x, y ); + break; + + case 143: + CacheTextures( SPR_WILL_W1, SPR_WILL_DEAD ); + SpawnBoss( en_will, x, y ); + break; + + case 161: + CacheTextures( SPR_DEATH_W1, SPR_DEATH_DEAD ); + SpawnBoss( en_death, x, y ); + break; +// +// mutants +// + case 252: + case 253: + case 254: + case 255: + if( skill->value < gd_hard ) + break; + tile -= 18; + case 234: + case 235: + case 236: + case 237: + if( skill->value < gd_medium ) + break; + tile -= 18; + case 216: + case 217: + case 218: + case 219: + if( ! cachedMutant ) + { + CacheTextures( SPR_MUT_S_1, SPR_MUT_SHOOT4 ); + cachedMutant = 1; + } + SpawnStand( en_mutant, x, y, tile - 216, lvl ); + break; + + case 256: + case 257: + case 258: + case 259: + if (skill->valuevalue < gd_medium ) + break; + tile -= 18; + case 220: + case 221: + case 222: + case 223: + if( ! cachedMutant ) + { + CacheTextures( SPR_MUT_S_1, SPR_MUT_SHOOT4 ); + cachedMutant = 1; + } + SpawnPatrol( en_mutant, x, y, tile - 220 ); + break; + +// +// ghosts +// + case 224: + CacheTextures( SPR_BLINKY_W1, SPR_BLINKY_W2 ); + SpawnGhosts( en_blinky, x, y ); + break; + + case 225: + CacheTextures( SPR_PINKY_W1, SPR_PINKY_W2 ); + SpawnGhosts( en_clyde, x, y ); + break; + + case 226: + CacheTextures( SPR_CLYDE_W1, SPR_CLYDE_W2 ); + SpawnGhosts( en_pinky, x, y ); + break; + + case 227: + CacheTextures( SPR_INKY_W1, SPR_INKY_W2 ); + SpawnGhosts( en_inky, x, y ); + break; + } + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Lvl_SpawnStatic( LevelData_t *lvl, int type, int x, int y ) +{ + int spr_id; + + if( statinfo[ type ].powerup == -1 ) + { + if( statinfo[ type ].block ) // blocking static + { + lvl->tilemap[ x ][ y ] |= BLOCK_TILE; + } + else // dressing static + { + lvl->tilemap[ x ][ y ] |= DRESS_TILE; + } + + spr_id = Sprite_GetNewSprite(); + if( spr_id == -1 ) + { + return; + } + + Sprite_SetPos( spr_id, TILE2POS( x ), TILE2POS( y ), 0 ); + Sprite_SetTex( spr_id, 0, SPR_STAT_0 + type ); + } + else + { + Powerup_Spawn( x, y, statinfo[ type ].powerup, lvl ); + if( statinfo[ type ].powerup == pow_cross || + statinfo[ type ].powerup == pow_chalice || + statinfo[ type ].powerup == pow_bible || + statinfo[ type ].powerup == pow_crown || + statinfo[ type ].powerup == pow_fullheal ) + { + levelstate.total_treasure++; // FIXME: move this to Powerup_Spawn Function! + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Lvl_SpawnObj( LevelData_t *lvl, int type, int x, int y ) +{ + if( type >= 23 && type < 23 + num_statics ) + {// static object + Lvl_SpawnStatic( lvl, type - 23, x, y); + return; + } + + switch( type ) + { + case 0x13: // start N + lvl->pSpawn.origin[ 0 ] = TILE2POS( x ); + lvl->pSpawn.origin[ 1 ] = TILE2POS( y ); + lvl->pSpawn.angle = ANG_90; + break; + + case 0x14: // start E + lvl->pSpawn.origin[ 0 ] = TILE2POS( x ); + lvl->pSpawn.origin[ 1 ] = TILE2POS( y ); + lvl->pSpawn.angle = ANG_0; + break; + + case 0x15: // start S + lvl->pSpawn.origin[ 0 ] = TILE2POS( x ); + lvl->pSpawn.origin[ 1 ] = TILE2POS( y ); + lvl->pSpawn.angle = ANG_270; + break; + + case 0x16: // start W + lvl->pSpawn.origin[ 0 ] = TILE2POS( x ); + lvl->pSpawn.origin[ 1 ] = TILE2POS( y ); + lvl->pSpawn.angle = ANG_180; + break; + + case 0x5a: // turn E + lvl->tilemap[ x ][ y ] |= TILE_IS_E_TURN;//FIXME! + break; + + case 0x5b: // turn NE + lvl->tilemap[ x ][ y ] |= TILE_IS_NE_TURN;//FIXME! + break; + + case 0x5c: // turn N + lvl->tilemap[ x ][ y ] |= TILE_IS_N_TURN;//FIXME! + break; + + case 0x5d: // turn NW + lvl->tilemap[ x ][ y ] |= TILE_IS_NW_TURN;//FIXME! + break; + + case 0x5e: // turn W + lvl->tilemap[ x ][ y ] |= TILE_IS_W_TURN;//FIXME! + break; + + case 0x5f: // turn SW + lvl->tilemap[ x ][ y ] |= TILE_IS_SW_TURN;//FIXME! + break; + + case 0x60: // turn S + lvl->tilemap[ x ][ y ] |= TILE_IS_S_TURN;//FIXME! + break; + + case 0x61: // turn SE + lvl->tilemap[ x ][ y ] |= TILE_IS_SE_TURN;//FIXME! + break; + + case 0x62: // pushwall modifier + lvl->tilemap[ x ][ y ] |= SECRET_TILE; + levelstate.total_secrets++; + break; + + case 0x63: // Victory trigger + lvl->tilemap[ x ][ y ] |= EXIT_TILE; + break; + // spawn guards + + } // end of switch( type ) + +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + length -[in] The length of the EXPANDED data. + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Lvl_CarmackExpand( W16 *source, W16 *dest, W16 length ) +{ + #define NEARTAG 0xA7 + #define FARTAG 0xA8 + + + W32 chhigh, offset; + W16 *copyptr, *outptr; + W8 *inptr; + W16 ch, count; + + length /= 2; + + inptr = (W8 *)source; + outptr = dest; + + while( length ) + { + ch = *(W16 *)inptr; + inptr += 2; + chhigh = ch >> 8; + if( chhigh == NEARTAG ) + { + count = ch & 0xff; + if( ! count ) + { // have to insert a word containing the tag byte + ch |= *inptr++; + *outptr++ = (W16)ch; + length--; + } + else + { + offset = *inptr++; + copyptr = outptr - offset; + length -= count; + while( count-- ) + { + *outptr++ = *copyptr++; + } + } + } + else if( chhigh == FARTAG ) + { + count = ch & 0xff; + if( ! count ) + { // have to insert a word containing the tag byte + ch |= *inptr++; + *outptr++ = ch; + length--; + } + else + { + offset = *(W16 *)inptr; + inptr += 2; + copyptr = dest + offset; + length -= count; + while( count-- ) + { + *outptr++ = *copyptr++; + } + } + } + else + { + *outptr++ = ch; + length--; + } + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + length -[in] Is EXPANDED length + + Returns: + + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Lvl_RLEWexpand( W16 *source, W16 *dest, + long length, unsigned rlewtag ) +{ + unsigned value,count,i; + W16 *end; + + + +// +// expand it +// + end = dest + (length >> 1); + + do + { + value = *source++; + if( value != rlewtag ) + { + // + // uncompressed + // + *dest++ = value; + } + else + { + // + // compressed string + // + count = *source++; + value = *source++; + + for( i = 1 ; i <= count ; ++i ) + { + *dest++ = value; + } + } + + } while( dest < end ); + +} + + +#define MAPHEADER_SIZE 49 +#define MAP_SIGNATURE 0x21444921 + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC LevelData_t *Level_LoadMap( const char *levelname ) +{ + W16 rle; + W32 offset[ 3 ]; + W16 length[ 3 ]; + W16 w, h; + W32 signature; + W16 *buffer, expanded; + W8 *data; + W32 ceiling, floor; + LevelData_t *newMap; + filehandle_t *fhandle; + W16 mapNameLength; + char *mapName; + W16 musicNameLength; + char *musicName; + SW32 filesize; + + int x, y0, y, layer1, layer2, layer3; + + + + if( g_version->value == SPEAROFDESTINY ) + { + statinfo = static_sod; + num_statics = sizeof( static_sod ) / sizeof( static_sod[ 0 ] ); + } + else + { + statinfo = static_wl6; + num_statics = sizeof( static_wl6 ) / sizeof( static_wl6[ 0 ] ); + } + + + + newMap = &levelData; + memset( newMap, 0, sizeof( LevelData_t ) ); + + + fhandle = FS_OpenFile( levelname, 0 ); + if( ! fhandle ) + { + Com_Printf( "Could not load map (%s)\n", levelname ); + + return NULL; + } + + filesize = FS_GetFileSize( fhandle ); + if( filesize < MAPHEADER_SIZE ) + { + return NULL; + } + + +// +// Process map header +// + FS_ReadFile( &signature, 1, 4, fhandle ); + if( signature != MAP_SIGNATURE ) + { + return NULL; + } + + + + FS_ReadFile( &rle, 2, 1, fhandle ); + + FS_ReadFile( &w, 2, 1, fhandle ); + FS_ReadFile( &h, 2, 1, fhandle ); + + FS_ReadFile( &ceiling, 4, 1, fhandle ); + FS_ReadFile( &floor, 4, 1, fhandle ); + + + FS_ReadFile( &length, 2, 3, fhandle ); + FS_ReadFile( &offset, 4, 3, fhandle ); + + + FS_ReadFile( &mapNameLength, 1, 2, fhandle ); + FS_ReadFile( &musicNameLength, 1, 2, fhandle ); + + FS_ReadFile( &levelstate.fpartime, sizeof( float ), 1, fhandle ); + + FS_ReadFile( levelstate.spartime, sizeof( W8 ), 5, fhandle ); + levelstate.spartime[ 5 ] = '\0'; + + + if( filesize < (MAPHEADER_SIZE + mapNameLength + musicNameLength + + length[ 0 ] + length[ 1 ] + length[ 2 ]) ) + { + return NULL; + } + + mapName = Z_Malloc( mapNameLength + 1 ); + musicName = Z_Malloc( musicNameLength + 1 ); + + + FS_ReadFile( mapName, 1, mapNameLength, fhandle ); + mapName[ mapNameLength ] = '\0'; + + + FS_ReadFile( musicName, 1, musicNameLength, fhandle ); + musicName[ musicNameLength ] = '\0'; + + + if( filesize < (MAPHEADER_SIZE + mapNameLength + musicNameLength) ) + { + return NULL; + } + +// +// Plane1 -Walls +// + data = MM_MALLOC( length[ 0 ] ); + + FS_FileSeek( fhandle, offset[ 0 ], SEEK_SET ); + FS_ReadFile( data, 1, length[ 0 ], fhandle ); + + + expanded = *((unsigned short *)data); + buffer = MM_MALLOC( expanded ); + + Lvl_CarmackExpand( (unsigned short *)data+1, buffer, expanded ); + Lvl_RLEWexpand( buffer+1, newMap->Plane1, 64*64*2, rle ); + + MM_FREE( buffer ); + MM_FREE( data ); + +// +// Plane2 -Objects +// + data = MM_MALLOC( length[ 1 ] ); + + FS_FileSeek( fhandle, offset[ 1 ], SEEK_SET ); + FS_ReadFile( data, 1, length[ 1 ], fhandle ); + + + expanded = *((PW16)data); + buffer = MM_MALLOC( expanded ); + + Lvl_CarmackExpand( (PW16)data+1, buffer, expanded ); + Lvl_RLEWexpand( buffer+1, newMap->Plane2, 64*64*2, rle ); + + MM_FREE( buffer ); + MM_FREE( data ); + +// +// Plane3 -Other +// + data = MM_MALLOC( length[ 2 ] ); + + FS_FileSeek( fhandle, offset[ 2 ], SEEK_SET ); + FS_ReadFile( data, 1, length[ 2 ], fhandle ); + + + expanded = *((PW16)data); + buffer = MM_MALLOC( expanded ); + + Lvl_CarmackExpand( (PW16)data+1, buffer, expanded ); + Lvl_RLEWexpand( buffer+1, newMap->Plane3, 64*64*2, rle ); + + MM_FREE( buffer ); + MM_FREE( data ); + + + FS_CloseFile( fhandle ); + + + for( y0 = 0 ; y0 < 64 ; ++y0 ) + for( x = 0 ; x < 64 ; ++x ) + { + y = 63 - y0; + layer1 = newMap->Plane1[ y0 * 64 + x ]; + layer2 = newMap->Plane2[ y0 * 64 + x ]; + layer3 = newMap->Plane3[ y0 * 64 + x ]; + +// if server, process obj layer! + if( layer2 ) + { + Lvl_SpawnObj( newMap, layer2, x, y ); + } + +// Map data layer + if( layer1 == 0 ) + { + newMap->areas[ x ][ y ] = -3; // unknown area + } + else if( layer1 < 0x6a ) // solid map object + { + if( (layer1 >= 0x5A && layer1 <= 0x5F) || + layer1 == 0x64 || layer1 == 0x65 ) // door + { + newMap->tilemap[ x ][ y ] |= DOOR_TILE; + Door_SpawnDoor( &newMap->Doors, x, y, layer1 ); + newMap->areas[ x ][ y ] = -2; // door area + } + else + { + newMap->tilemap[ x ][ y ] |= WALL_TILE; + + newMap->wall_tex_x[ x ][ y ] = (layer1-1) * 2 + 1; + newMap->wall_tex_y[ x ][ y ] = (layer1-1) * 2; + newMap->areas[ x ][ y ] = -1; // wall area + + if( layer1 == 0x15 ) // elevator + { + newMap->tilemap[ x ][ y ] |= ELEVATOR_TILE; + } + } + } + else if( layer1 == 0x6a ) // Ambush floor tile + { + newMap->tilemap[ x ][ y ] |= AMBUSH_TILE; + newMap->areas[ x ][ y ] = -3; // unknown area + } + else if( layer1 >= FIRSTAREA && + layer1 < (FIRSTAREA + NUMAREAS) ) // area + { + if( layer1 == FIRSTAREA ) // secret level + { + newMap->tilemap[ x ][ y ] |= SECRETLEVEL_TILE; + } + + newMap->areas[ x ][ y ] = layer1 - FIRSTAREA;// spawn area + } + else + { + newMap->areas[ x ][ y ] = -3; // unknown area + } +// End of the map data layer + } + + // JDC: try to replace all the unknown areas with an adjacent area, to + // avoid the silent attack / no damage problem when you get an ambush + // guard stuck on their original tile + for ( x = 1 ; x < 63 ; x++ ) { + for ( y = 1 ; y < 63 ; y++ ) { + if ( newMap->areas[x][y] != -3 ) { + continue; + } + if ( newMap->areas[x-1][y] >= 0 ) { + newMap->areas[x][y] = newMap->areas[x-1][y]; + } else if ( newMap->areas[x+1][y] >= 0 ) { + newMap->areas[x][y] = newMap->areas[x+1][y]; + } else if ( newMap->areas[x][y-1] >= 0 ) { + newMap->areas[x][y] = newMap->areas[x][y-1]; + } else if ( newMap->areas[x+1][y+1] >= 0 ) { + newMap->areas[x][y] = newMap->areas[x][y+1]; + } + } + } + + Door_SetAreas( &newMap->Doors, newMap->areas ); + + my_strlcpy( levelstate.level_name, mapName, sizeof( levelstate.level_name ) ); + + strcpy( newMap->mapName, mapName ); + strcpy( newMap->musicName, musicName ); + + newMap->ceilingColour[ 0 ] = (W8)((ceiling >> 16) & 0xFF); + newMap->ceilingColour[ 1 ] = (W8)((ceiling >> 8) & 0xFF); + newMap->ceilingColour[ 2 ] = (W8)((ceiling ) & 0xFF); + newMap->floorColour[ 0 ] = (W8)((floor >> 16) & 0xFF); + newMap->floorColour[ 1 ] = (W8)((floor >> 8) & 0xFF); + newMap->floorColour[ 2 ] = (W8)((floor ) & 0xFF); + + return newMap; +} + + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Level_PrecacheTextures_Sound( LevelData_t *lvl ) +{ + int x, y; + char texname[ 32 ]; + + + + for( x = 0 ; x < 64 ; ++x ) + for( y = 0 ; y < 64 ; ++y ) + { + if( lvl->tilemap[ x ][ y ] & WALL_TILE ) + { + my_snprintf( texname, sizeof( texname ), "walls/%.3d.tga", lvl->wall_tex_x[ x ][ y ] ); + wallTextures[lvl->wall_tex_x[ x ][ y ] ] = TM_FindTexture( texname, TT_Wall ); + + my_snprintf( texname, sizeof( texname ), "walls/%.3d.tga", lvl->wall_tex_y[ x ][ y ] ); + wallTextures[lvl->wall_tex_y[ x ][ y ]] = TM_FindTexture( texname, TT_Wall ); + } + + if( lvl->tilemap[ x ][ y ] & POWERUP_TILE ) + { + int tex = lvl->tilemap[ x ][ y ] & POWERUP_TILE; + my_snprintf( texname, sizeof( texname ), "%s/%.3d.tga", spritelocation, tex ); + spriteTextures[tex] = TM_FindTexture( texname, TT_Wall ); + } + } + + // Doors + for( x = TEX_DOOR; x < TEX_DLOCK+1 ; ++x ) + { + my_snprintf( texname, sizeof( texname ), "walls/%.3d.tga", x ); + wallTextures[x] = TM_FindTexture( texname, TT_Wall ); + } + + + // Items + CacheTextures( 26, 36 ); + + // Weapon frames + CacheTextures( SPR_KNIFEREADY, SPR_CHAINATK4 ); +#if 0 + for( x = 1; x < 8 ; ++x ) + { + my_snprintf( texname, sizeof( texname ), "pics/FACE%dAPIC.tga", x ); + (void)TM_FindTexture( texname, TT_Pic ); + + my_snprintf( texname, sizeof( texname ), "pics/FACE%dBPIC.tga", x ); + (void)TM_FindTexture( texname, TT_Pic ); + + my_snprintf( texname, sizeof( texname ), "pics/FACE%dCPIC.tga", x ); + (void)TM_FindTexture( texname, TT_Pic ); + } + + my_snprintf( texname, sizeof( texname ), "pics/FACE8APIC.tga" ); + (void)TM_FindTexture( texname, TT_Pic ); +#endif +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: true if a straight line between 2 points is unobstructed, + otherwise false. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean Level_CheckLine( SW32 x1, SW32 y1, SW32 x2, SW32 y2, LevelData_t *lvl ) +{ + SW32 xt1, yt1, xt2, yt2; /* tile positions */ + SW32 x, y; /* current point in !tiles! */ + SW32 xdist, ydist; + SW32 xstep, ystep; /* Step value for each whole xy */ + + SW32 deltafrac; /* current point in !1/256 of tile! */ + + SW32 Frac; /* Fractional xy stepper */ + + SW32 partial; /* how much to move in our direction to border */ + SW32 intercept; /* Temp for door code */ + + + + #define FRACBITS 8 /* Number of bits of fraction */ + + +// get start & end tiles + xt1 = x1 >> TILESHIFT; + yt1 = y1 >> TILESHIFT; + + xt2 = x2 >> TILESHIFT; + yt2 = y2 >> TILESHIFT; + + xdist = ABS( xt2 - xt1 ); // X distance in tiles + ydist = ABS( yt2 - yt1 ); // Y distance in tiles + +// 1/256 tile precision (TILESHIFT is 16) + x1 >>= FRACBITS; y1 >>= FRACBITS; + x2 >>= FRACBITS; y2 >>= FRACBITS; + + + if( xdist ) // always positive check only for 0 + { + if( xt2 > xt1 ) + { + partial = 256 - (x1 & 0xff); + xstep = 1; + } + else + { + partial = x1 & 0xff; + xstep = -1; + } + + deltafrac = ABS( x2 - x1 ); + ystep = ((y2 - y1) << FRACBITS) / deltafrac; + Frac = y1 + ((ystep * partial) >> FRACBITS); + + x = xt1 + xstep; + xt2 += xstep; + do + { + y = Frac >> FRACBITS; + Frac += ystep; + + + assert( x >= 0 && x < 64 && y >= 0 && y < 64 ); + if( lvl->tilemap[ x ][ y ] & WALL_TILE ) + { + return false; // Wall is in path quitting! + } + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE ) + {// door, see if the door is open enough + if( lvl->Doors.DoorMap[ x ][ y ].action != dr_open ) + { + if( lvl->Doors.DoorMap[ x ][ y ].action == dr_closed ) + { + return false; + } + // checking vertical doors in action: ->_I_ + intercept = ((Frac - ystep / 2) & 0xFF) >> 4; // 1/64 of tile + if( intercept < (63 - lvl->Doors.DoorMap[ x ][ y ].ticcount) ) + { + return false; + } + } + } + x += xstep; + + } while( x != xt2 ); + } + + if( ydist ) // always positive check only for 0 + { + if( yt2 > yt1 ) + { + partial = 256 - (y1 & 0xff); + ystep = 1; + } + else + { + partial = y1 & 0xff; + ystep = -1; + } + + deltafrac = ABS( y2 - y1 ); + xstep = ((x2 - x1) << FRACBITS) / deltafrac; + Frac = x1 + ((xstep * partial) >> FRACBITS); + + y = yt1 + ystep; + yt2 += ystep; + do + { + x = Frac >> FRACBITS; + Frac += xstep; + + assert( x >= 0 && x < 64 && y >= 0 && y < 64 ); + if( lvl->tilemap[ x ][ y ] & WALL_TILE ) + { + return false; // Wall is in path quitting! + } + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE ) + {// door, see if the door is open enough + if( lvl->Doors.DoorMap[ x ][ y ].action != dr_open ) + { + if( lvl->Doors.DoorMap[ x ][ y ].action == dr_closed ) + { + return false; + } + // checking vertical doors in action: ->_I_ + intercept = ((Frac - xstep / 2) & 0xFF) >> 4; // 1/64 of tile + if( intercept < lvl->Doors.DoorMap[ x ][ y ].ticcount ) + { + return false; + } + } + } + y += ystep; + + } while( y != yt2 ); + } + + return true; +} diff --git a/wolf3d/newCode/wolf/wolf_level.h b/wolf3d/newCode/wolf/wolf_level.h new file mode 100644 index 0000000..52d8386 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_level.h @@ -0,0 +1,285 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_level.h: Wolfenstein3-D level management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Acknowledgement: + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_areas.c, wolf_doors.c, wolf_level.c and + wolf_pushwalls.c + + +*/ + +#ifndef __WOLF_LEVEL_H__ +#define __WOLF_LEVEL_H__ + + +/////////////////// +// +// Areas +// +/////////////////// + +#define NUMAREAS 37 // number of areas +#define FIRSTAREA 0x6B // first area in map data (it is by the way a way to the secret floor!) +#define AMBUSHTILE 0x6A // def guard +#define AMBUSH -2 + +/////////////////// +// +// Doors +// +/////////////////// +#define MAX_DOORS 256 +#define DOOR_TIMEOUT 300 +#define DOOR_MINOPEN 50 + +#define DOOR_FULLOPEN 63 + + +#define DOOR_VERT 255 +#define DOOR_HORIZ 254 +#define DOOR_E_VERT 253 +#define DOOR_E_HORIZ 252 + +#define DOOR_G_VERT 251 +#define DOOR_G_HORIZ 250 +#define DOOR_S_VERT 249 +#define DOOR_S_HORIZ 248 + +#define FIRST_DOOR 248 +#define LAST_LOCK 251 + + + + +#define TEX_DOOR 126 + +// texture IDs used by cache routines +#define TEX_DDOOR (0 + TEX_DOOR) // Simple Door +#define TEX_PLATE (2 + TEX_DOOR) // Door Plate +#define TEX_DELEV (4 + TEX_DOOR) // Elevator Door +#define TEX_DLOCK (6 + TEX_DOOR) // Locked Door + + + +/////////////////// +// +// Level +// +/////////////////// +#define WALL_TILE 1 +#define PUSHWALL_TILE (1 << 20) +#define DOOR_TILE 2 +#define SECRET_TILE 4 +#define DRESS_TILE 8 +#define BLOCK_TILE 16 +#define ACTOR_TILE 32 +#define DEADACTOR_TILE 64 +#define POWERUP_TILE 128 +#define AMBUSH_TILE 256 +#define EXIT_TILE 512 +#define SECRETLEVEL_TILE 1024 +#define ELEVATOR_TILE (1 << 11) +#define TILE_IS_E_TURN (1 << 12) +#define TILE_IS_NE_TURN (1 << 13) +#define TILE_IS_N_TURN (1 << 14) +#define TILE_IS_NW_TURN (1 << 15) +#define TILE_IS_W_TURN (1 << 16) +#define TILE_IS_SW_TURN (1 << 17) +#define TILE_IS_S_TURN (1 << 18) +#define TILE_IS_SE_TURN (1 << 19) + +#define SOLID_TILE (WALL_TILE | BLOCK_TILE | PUSHWALL_TILE) +#define BLOCKS_MOVE_TILE (WALL_TILE | BLOCK_TILE | PUSHWALL_TILE | ACTOR_TILE) +#define WAYPOINT_TILE (TILE_IS_E_TURN | TILE_IS_NE_TURN | TILE_IS_N_TURN | TILE_IS_NW_TURN | TILE_IS_W_TURN | TILE_IS_SW_TURN | TILE_IS_S_TURN | TILE_IS_SE_TURN ) + +/////////////////// +// +// Doors +// +/////////////////// +typedef enum +{ + dr_closing = -1, + dr_closed, + dr_opening, + dr_open + +} dr_state; + +typedef struct +{ + int tilex, tiley; + _boolean vertical; + int ticcount; + + dr_state action; + + int area1, area2; +/*DOOR_VERT 255 + DOOR_HORIZ 254 + DOOR_E_VERT 253 + DOOR_E_HORIZ 252 + DOOR_G_VERT 251 + DOOR_G_HORIZ 250 + DOOR_S_VERT 249 + DOOR_S_HORIZ 248*/ + int type; + + int texture; + +} doors_t; + +typedef struct +{ + int doornum; + doors_t *Doors[ 256 ]; + doors_t DoorMap[ 64 ][ 64 ]; + +} LevelDoors_t; + +/////////////////// +// +// Level +// +/////////////////// +typedef struct +{ + char fname[ 32 ]; /* Map filename */ + + W16 Plane1[ 64 * 64 ]; /* walls */ + W16 Plane2[ 64 * 64 ]; /* objects */ + W16 Plane3[ 64 * 64 ]; /* other */ + + + long tilemap[ 64 ][ 64 ]; // wall values only + W8 spotvis[ 64 ][ 64 ]; +// objtype *actorat[ 64 ][ 64 ]; + + // this is an array of references to texture descriptions +// the renderer must know what to draw by this number + int wall_tex_x[ 64 ][ 64 ]; // x_wall + int wall_tex_y[ 64 ][ 64 ]; // y_wall + +// this is a (0-based) array of area numbers! +// must be all filled by level loading sub +// if -1 it is a wall, if -2 it is a door, if -3 it is unknown + int areas[ 64 ][ 64 ]; + + LevelDoors_t Doors; + + placeonplane_t pSpawn; // player spawn place + + + char mapName[128]; /* Map name */ + char musicName[128]; /* Music file name */ + + colour3_t ceilingColour, floorColour; + + W8 tileEverVisible[ 64 ][ 64 ]; // for automap +} LevelData_t; + + +typedef struct statinfo_t +{ + _boolean block; + int powerup; + +} statinfo_t; + + +extern LevelData_t *r_world; + + +extern LevelData_t *Level_LoadMap( const char *levelname ); +extern void Level_PrecacheTextures_Sound( LevelData_t *lvl ); +extern _boolean Level_CheckLine( SW32 x1, SW32 y1, SW32 x2, SW32 y2, LevelData_t *lvl ); +extern void Level_ScanInfoPlane( LevelData_t *lvl ); + +/////////////////// +// +// Doors +// +/////////////////// +extern void Door_ResetDoors( LevelDoors_t *lvl ); +extern int Door_SpawnDoor( LevelDoors_t *lvl, int x, int y, int type ); +extern void Door_SetAreas( LevelDoors_t *lvl, int (*areas)[64] ); +extern void Door_OpenDoor( doors_t *Door ); +extern void Door_ProcessDoors_e( LevelDoors_t *lvl, int t_tk, int t_ms ); +extern int Door_Opened( LevelDoors_t *lvl, int x, int y ); +extern _boolean Door_TryUse( doors_t *Door, int keys ); + +/////////////////// +// +// Areas +// +/////////////////// +extern _boolean areabyplayer[ NUMAREAS ]; + +extern void Areas_ConnectAreas( int areanumber ); +extern void Areas_InitAreas( int areanumber ); +extern void Areas_JoinAreas( int area1, int area2 ); +extern void Areas_DisconnectAreas( int area1, int area2 ); + + +/////////////////// +// +// Push Walls +// +/////////////////// +typedef struct +{ + _boolean active; + int PWtilesmoved; + int PWpointsmoved; + dir4type dir; + int x, y; + int dx, dy; + int tex_x, tex_y; + +} Pwall_t; + + +extern Pwall_t PWall; + + +extern void PushWall_Reset( void ); +extern _boolean PushWall_Push( int x, int y, dir4type dir ); +extern void PushWall_Process( void ); + + +#endif /* __WOLF_LEVEL_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_local.h b/wolf3d/newCode/wolf/wolf_local.h new file mode 100644 index 0000000..0c84640 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_local.h @@ -0,0 +1,150 @@ +/* + + Copyright (C) 2004 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_local.h: Wolfenstein3-D init. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_main.c + +*/ + +#ifndef __WOLF_LOCAL_H__ +#define __WOLF_LOCAL_H__ + + +// Game Version +#define WOLFENSTEINWL6 0x00 +#define SPEAROFDESTINY 0x01 + + + +#define TILEGLOBAL 0x10000 +#define HALFTILE 0x8000 +#define TILESHIFT 16 + +#define MINDIST (0x5800) + + + + + +typedef enum difficulty_e +{ + gd_baby, + gd_easy, + gd_medium, + gd_hard + +} difficulty_t; + +// +// this structure is cleared as each map is entered +// +typedef struct +{ + int framenum; + float time; + + char level_name[ MAX_OSPATH ]; // the descriptive name (Outer Base, etc) + char mapname[ MAX_OSPATH ]; // the server name (base1, etc) + char nextmap[ MAX_OSPATH ]; // go here when fraglimit is hit + + // intermission state + W32 levelCompleted; // in case the game was saved at the intermission + + W32 floornum; + float fpartime; + char spartime[6]; + + W32 total_secrets; + W32 found_secrets; + + W32 total_treasure; + W32 found_treasure; + + W32 total_monsters; + W32 killed_monsters; + + +} level_locals_t; + + + +extern level_locals_t levelstate; + + + +typedef struct +{ + W32 total_secrets; + W32 found_secrets; + + W32 total_treasure; + W32 found_treasure; + + W32 total_monsters; + W32 killed_monsters; + W32 time; + +} LRstruct; + + +extern LRstruct LevelRatios; + + + +extern cvar_t *g_version; +extern cvar_t *episode; +extern cvar_t *skill; + +extern int tics; + + +W32 floornumber; + + +extern void Game_Init( void ); +extern void Game_Reset( void ); + + + +extern void ProcessGuards( void ); + + +#define WL6SPRITESDIRNAME "sprites" +#define SODSPRITESDIRNAME "sodsprites" + + +extern char *spritelocation; + + + +#endif /* __WOLF_LOCAL_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_main.c b/wolf3d/newCode/wolf/wolf_main.c new file mode 100644 index 0000000..eea88ca --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_main.c @@ -0,0 +1,87 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + +level_locals_t levelstate; + +LRstruct LevelRatios; + +cvar_t *g_version; // Wolfenstein or Spear of Destiny +cvar_t *episode; +cvar_t *skill; + + +char *spritelocation = WL6SPRITESDIRNAME; + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Game_Reset( void ) +{ + memset( &levelstate, 0, sizeof( levelstate ) ); +} + +extern void Map_f( void ); + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Game_Init( void ) +{ + Com_Printf( "\n------ Game Init ------\n" ); + + episode = Cvar_Get( "episode", "0", CVAR_ARCHIVE ); + skill = Cvar_Get( "skill", "1", CVAR_ARCHIVE ); + g_version = Cvar_Get( "g_version", "0", CVAR_ARCHIVE ); + +#ifndef EPISODE1 + Cmd_AddCommand( "map", Map_f ); +#endif + + G_Build_Tables(); + Powerup_Reset(); + Sprite_Reset(); + Game_Reset(); + PL_Init(); + + Com_Printf( "\n-----------------------\n" ); + +} diff --git a/wolf3d/newCode/wolf/wolf_math.c b/wolf3d/newCode/wolf/wolf_math.c new file mode 100644 index 0000000..ef14f07 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_math.c @@ -0,0 +1,341 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_math.c: Wolfenstein 3-D math routines. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * + */ + +#include "../wolfiphone.h" + +#define XRES 640 +#define YRES 480 + +// ------------------------- * LUTs * ------------------------- +double SinTable[ ANG_360 + ANG_90 + 1 ], + *CosTable = SinTable + ANG_90, + TanTable[ ANG_360 + 1 ]; + +int XnextTable[ ANG_360 + 1 ], + YnextTable[ ANG_360 + 1 ]; + +int ColumnAngle[ 640 ]; // ViewAngle=PlayerAngle+ColumnAngle[curcolumn]; /in fines/ + +char dx4dir[5]={1, 0, -1, 0, 0}; // dx & dy based on direction +char dy4dir[5]={0, 1, 0, -1, 0}; +char dx8dir[9]={1, 1, 0, -1, -1, -1, 0, 1, 0}; // dx & dy based on direction +char dy8dir[9]={0, 1, 1, 1, 0, -1, -1, -1, 0}; +dir4type opposite4[5]={2, 3, 0, 1, 4}; +dir8type opposite8[9]={4, 5, 6, 7, 0, 1, 2, 3, 8}; +dir8type dir4to8[5]={0, 2, 4, 6, 8}; +dir8type diagonal[9][9]= +{ +/* east */ {dir8_nodir, dir8_nodir, dir8_northeast, dir8_nodir, dir8_nodir, dir8_nodir, dir8_southeast, dir8_nodir, dir8_nodir}, + {dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, +/* north */ {dir8_northeast, dir8_nodir, dir8_nodir, dir8_nodir, dir8_northwest, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, + {dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, +/* west */ {dir8_nodir, dir8_nodir, dir8_northwest, dir8_nodir, dir8_nodir, dir8_nodir, dir8_southwest, dir8_nodir, dir8_nodir}, + {dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, +/* south */ {dir8_southeast, dir8_nodir, dir8_nodir, dir8_nodir, dir8_southwest, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, + {dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir}, + {dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir, dir8_nodir} +}; +// dir of delta tooks dx{-1|0|1}+1 & dy{-1|0|1}+1 and give direction +dir4type dir4d[3][3]={{dir4_nodir, dir4_west , dir4_nodir}, + {dir4_south, dir4_nodir, dir4_north}, + {dir4_nodir, dir4_east , dir4_nodir}}; +int dir8angle[9]={ANG_0, ANG_45, ANG_90, ANG_135, ANG_180, ANG_225, ANG_270, ANG_315, ANG_0}; +int dir4angle[5]={ANG_0, ANG_90, ANG_180, ANG_270, ANG_0}; + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC int G_Build_Tables( void ) +{ + double angle, tanfov2, tanval, value; + int n; + + for( n = 0 ; n <= ANG_90 ; ++n ) + { + angle = FINE2RAD( n ); + + value = sin( angle ); + SinTable[ n ] = SinTable[ ANG_180 - n ] = SinTable[ n + ANG_360 ] = value; + SinTable[ ANG_180 + n ] = SinTable[ ANG_360 - n ] = -value; + } + + for( n = 0 ; n <= ANG_360 ; ++n ) + { + angle = FINE2RAD( n ); //angle is in radians, n is in FINEs + + if( n == ANG_90 || n == ANG_270 ) + { + TanTable[ n ] = tan( FINE2RAD( n - 0.5 ) ); // infinity + YnextTable[ n ] = (int)(FLOATTILE * tan( FINE2RAD( n - 0.5 ) )); // infinity + } + else + { + TanTable[ n ] = tan( angle ); + YnextTable[ n ] = (int)(FLOATTILE * tan( angle )); + } + + if( n == ANG_0 || n == ANG_360 ) + XnextTable[ n ] = (int)(FLOATTILE / tan( FINE2RAD( n + 0.5 ) )); // infinity + else if( n == ANG_180 ) + XnextTable[ n ] = (int)(FLOATTILE / tan(FINE2RAD( n - 0.5 ) )); // -infinity + else if( n == ANG_90 || n == ANG_270 ) + XnextTable[ n ] = 0; + else + XnextTable[ n ] = (int)(FLOATTILE / tan( angle )); + } + + tanfov2 = TanDgr( CalcFov( 75, XRES, YRES) / 2.0 ) * ((float)XRES / (float)YRES ); + for( n = 0 ; n < XRES ; ++n ) + { + tanval = tanfov2 * (-1.0 + 2.0 * (double)n / (double)(XRES-1) ); + ColumnAngle[ n ] = (int)RAD2FINE( atan( tanval ) ); + } + + US_InitRndT( 1 ); // random number generators + + + return 1; +} + + + +/* +----------------------------------------------------------------------------- + Function: NormalizeAngle -clips angle to [0..360] bounds. + + Parameters: + + Returns: + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC int NormalizeAngle( int alpha ) +{ + if( alpha > ANG_360 ) + alpha %= ANG_360; + + if(alpha x + point1 = {x, y} +----------------------------------------------------------------------------- +*/ +PUBLIC float TransformPoint( double Point1X, double Point1Y, double Point2X, double Point2Y ) +{ + float angle; + + angle = atan2( Point1Y - Point2Y, Point1X - Point2X ); + + return normalize_angle( angle ); +} + diff --git a/wolf3d/newCode/wolf/wolf_math.h b/wolf3d/newCode/wolf/wolf_math.h new file mode 100644 index 0000000..39f6925 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_math.h @@ -0,0 +1,147 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_math.h: Wolfenstein 3-D math routines. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * + */ + +/* + Notes: + This module is implemented by wolf_math.c + +*/ +#ifndef __WOLF_MATH_H__ +#define __WOLF_MATH_H__ + + +#define FLOATTILE 65536.0f + + +// Angle Direction Types & LUTs (Hard Coded! Please do not mess them) +typedef enum {q_first, q_second, q_third, q_fourth} quadrant; +typedef enum {dir4_east, dir4_north, dir4_west, dir4_south, dir4_nodir} dir4type; +typedef enum { dir8_east, dir8_northeast, dir8_north, dir8_northwest, dir8_west, + dir8_southwest, dir8_south, dir8_southeast, dir8_nodir} dir8type; + +extern char dx4dir[5], dy4dir[5], dx8dir[9], dy8dir[9]; +extern dir4type opposite4[5], dir4d[3][3]; +extern dir8type opposite8[9], dir4to8[5], diagonal[9][9]; +extern int dir8angle[9], dir4angle[5]; +// ------------------------- * Vectors * ------------------------- +// Vectors & angles for 3D-Space + + + +typedef struct +{ + long origin[2]; + long angle; + +} placeonplane_t; + + +// ------------------------- * Some Macroses * ------------------------- + + +#define max_of_2(a, b) ((a)>(b)?(a):(b)) + + + +#define LABS(x) ((long)(x)>0?(x):-(x)) + + +#define TILE2POS(a) (((a)<>TILESHIFT) +#define POS2TILEf(a) ((a)/FLOATTILE) +// ------------------------- * vvv FINE angles vvv * ------------------------- +#define ASTEP 0.0078125f // 1 FINE=x DEGREES +#define ASTEPRAD 0.000136354f // 1 FINE=x RADIANS +#define ANG_1RAD 7333.8598 // 1 RADIAN=x FINES +#define ANG_0 0 //(int)((float)0/ASTEP) +#define ANG_1 128 //(int)((float)1/ASTEP) +#define ANG_6 768 //(int)((float)6/ASTEP) +#define ANG_15 1920 //(int)((float)15/ASTEP) +#define ANG_22_5 2880 //(int)((float)22.5/ASTEP) +#define ANG_30 3840 //(int)((float)30/ASTEP) +#define ANG_45 5760 //(int)((float)45/ASTEP) +#define ANG_67_5 8640 //(int)((float)67.5/ASTEP) +#define ANG_90 11520 //(int)((float)90/ASTEP) +#define ANG_112_5 14400 //(int)((float)112.5/ASTEP) +#define ANG_135 17280 //(int)((float)135/ASTEP) +#define ANG_157_5 20160 //(int)((float)157.5/ASTEP) +#define ANG_180 23040 //(int)((float)180/ASTEP) +#define ANG_202_5 25920 //(int)((float)202.5/ASTEP) +#define ANG_225 28800 //(int)((float)225/ASTEP) +#define ANG_247_5 31680 //(int)((float)247.5/ASTEP) +#define ANG_270 34560 //(int)((float)270/ASTEP) +#define ANG_292_5 37440 //(int)((float)292.5/ASTEP) +#define ANG_315 40320 //(int)((float)225/ASTEP) +#define ANG_337_5 43200 //(int)((float)337.5/ASTEP) +#define ANG_360 46080 //(int)((float)360/ASTEP) +// ------------------------- * ^^^ FINE angles ^^^ * ------------------------- + + + +#define FINE2RAD( a ) (((a) * M_PI ) / ANG_180) +#define RAD2FINE( a ) (((a) * ANG_180) / M_PI) +#define FINE2DEG( a ) ((float)(a) / ANG_1) // !@# don't lose precision bits +#define FINE2DEGf( a ) ((a) / (float)ANG_1) +#define DEG2FINE( a ) ((a) * ANG_1) + +extern double SinTable[], *CosTable, TanTable[ ANG_360 + 1 ]; +extern int XnextTable[ ANG_360 + 1], YnextTable[ ANG_360 + 1 ]; +extern int ColumnAngle[640]; // + +extern int G_Build_Tables(void); + +#define TanDgr( x ) (tan( DEG2RAD( x ) )) +#define SinDgr( x ) (sin( DEG2RAD( x ) )) +#define CosDgr( x ) (cos( DEG2RAD( x ) )) + +#define ArcTanDgr( x ) (RAD2DEG( atan( x ) )) +#define ArcSinDgr( x ) (RAD2DEG( asin( x ) )) +#define ArcCosDgr( x ) (RAD2DEG( acos( x ) )) + + + +extern int NormalizeAngle( int angle ); +extern int Point2LineDist( int x, int y, int a ); +extern int LineLen2Point( int x, int y, int a ); + +extern quadrant GetQuadrant( float angle ); +extern dir4type Get4dir( float angle ); +extern dir8type Get8dir( float angle ); + +extern float TransformPoint( double Point1X, double Point1Y, double Point2X, double Point2Y ); + + + + + +#endif /* __WOLF_MATH_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_opengl.c b/wolf3d/newCode/wolf/wolf_opengl.c new file mode 100644 index 0000000..04dc67f --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_opengl.c @@ -0,0 +1,629 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_opengl.c: Wolfenstein3-D OpenGL renderer. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +// width and height in 2D +#define WIDTH_2D 640 +#define HEIGHT_2D 480 + + +float cur_x_fov, cur_y_fov; // x & y field of view (in degrees) +float ratio; // viewport width/height + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void GL_SetDefaultState( void ) +{ + + pfglClearColor( 1,0, 0.5 , 0.5 ); + pfglCullFace( GL_FRONT ); + pfglEnable( GL_TEXTURE_2D ); + + pfglEnable( GL_ALPHA_TEST ); + pfglAlphaFunc( GL_GREATER, 0.666f ); + + pfglDisable( GL_DEPTH_TEST ); + pfglDisable( GL_CULL_FACE ); + pfglDisable( GL_BLEND ); + + pfglColor4f( 1, 1, 1, 1 ); +#ifndef IPHONE + pfglPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); +#endif + pfglShadeModel( GL_FLAT ); + + + pfglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + + + + GL_UpdateSwapInterval(); + +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void R_CheckFOV( void ) +{ +/* + if(!vid_fov->modified) return; + vid_fov->modified=false; + + if( vid_fov->value<1 || vid_fov->value>179) + { + Com_Printf("Wrong FOV: %f\n", vid_fov->value); + Cvar_SetValue(vid_fov->name, (cur_x_fov>=1 && cur_x_fov<=179)?cur_x_fov:DEFAULT_FOV); + } +*/ + ratio = (float) viddef.width / (float)viddef.height; // FIXME: move somewhere + cur_x_fov = 75; + cur_y_fov = CalcFov( cur_x_fov, (float)viddef.width, (float)viddef.height ); + +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_SetGL3D( placeonplane_t viewport ) +{ + R_CheckFOV(); + + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); +#ifdef IPHONE + pfglRotatef( 90, 0, 0, 1 ); +#endif + MYgluPerspective( cur_y_fov - 2.0f, ratio, 0.2f, 64.0f ); // tweak fov in to avoid edge tile clips + pfglMatrixMode( GL_MODELVIEW ); + pfglLoadIdentity(); + + pfglRotatef( (float)(90 - FINE2DEG( viewport.angle )), 0, 1, 0 ); + pfglTranslatef( -viewport.origin[ 0 ] / FLOATTILE, 0, viewport.origin[ 1 ] / FLOATTILE ); + + pfglCullFace( GL_BACK ); + + pfglEnable( GL_DEPTH_TEST ); + pfglEnable( GL_CULL_FACE ); + pfglEnable( GL_BLEND ); + pfglDisable( GL_BLEND ); // !@# draw all the walls opaque without alpha test + pfglDisable( GL_ALPHA_TEST ); + qglDepthMask( GL_TRUE ); + + // clear depth buffer + pfglClear( GL_DEPTH_BUFFER_BIT ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_DrawBox( int x, int y, int w, int h, W32 color ) +{ + pfglDisable( GL_TEXTURE_2D ); + +// pfglEnable( GL_BLEND ); +// pfglBlendFunc( GL_SRC_COLOR, GL_DST_COLOR ); + + pfglColor4ubv( (GLubyte *) & color ); + + pfglBegin( GL_QUADS ); + + pfglVertex2i( x, y ); + pfglVertex2i( x, y + h); + pfglVertex2i( x + w, y + h ); + pfglVertex2i( x + w, y ); + + pfglEnd(); + + pfglColor3f( 1, 1, 1 ); +// pfglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +// pfglDisable( GL_BLEND ); + pfglEnable( GL_TEXTURE_2D ); +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + + north (y) + __________ + | | + west (x) | | east (x) + |________| + south (y) + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Wall( float x, float y, float z1, float z2, int type, int tex ) +{ + float x1, x2, y1, y2; + texture_t *twall; + + switch( type ) + { + // X wall + case dir4_east: + x1 = x2 = x + 1; + y1 = -1 - y; + y2 = -y; + break; + + case dir4_west: + x1 = x2 = x; + y1 = -y; + y2 = -1 - y; + break; + + // Y wall + case dir4_north: + y1 = y2 = -y - 1; + x1 = x; + x2 = x + 1; + break; + + case dir4_south: + y1 = y2 = -y; + x1 = x + 1; + x2 = x; + break; + } + + assert( tex >= 0 && tex < 1000 ); + twall = wallTextures[tex]; + if ( !twall ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", tex ); + twall = wallTextures[tex] = TM_FindTexture( name, TT_Wall ); + } + R_Bind( twall->texnum ); + + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 1.0, 0.0 ); pfglVertex3f( x1, z2, y1 ); + pfglTexCoord2f( 0.0, 0.0 ); pfglVertex3f( x2, z2, y2 ); + pfglTexCoord2f( 0.0, 1.0 ); pfglVertex3f( x2, z1, y2 ); + pfglTexCoord2f( 1.0, 1.0 ); pfglVertex3f( x1, z1, y1 ); + + pfglEnd(); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Draw_Door( int x, int y, float z1, float z2, _boolean vertical, _boolean backside, int tex, int amount ) +{ + float x1, x2, y1, y2, amt; + texture_t *twall; + + if( amount == DOOR_FULLOPEN ) + { + return; + } + + amt = (float)amount / DOOR_FULLOPEN; + + + if( vertical ) + { + x1 = x2 = (float)x + 0.5f; + y1 = -((float)y - amt); + y2 = -((float)y - amt); // -1 + if( backside ) + { + y1 -= 1; + } + else + { + y2 -= 1; + } + } + else + { + y1 = y2 = -(float)y - 0.5f; + x1 = (float)x + amt; // +1 + x2 = (float)x + amt; + if( backside ) + { + x2 += 1; + } + else + { + x1 += 1; + } + } + + assert( tex >= 0 && tex < 1000 ); + twall = wallTextures[tex]; + if ( !twall ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", tex ); + twall = wallTextures[tex] = TM_FindTexture( name, TT_Wall ); + } + + R_Bind( twall->texnum ); + + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( backside ? 0.0f : 1.0f, 0.0 ); pfglVertex3f( x1, z2, y1 ); + pfglTexCoord2f( backside ? 1.0f : 0.0f, 0.0 ); pfglVertex3f( x2, z2, y2 ); + pfglTexCoord2f( backside ? 1.0f : 0.0f, 1.0 ); pfglVertex3f( x2, z1, y2 ); + pfglTexCoord2f( backside ? 0.0f : 1.0f, 1.0 ); pfglVertex3f( x1, z1, y1 ); + + pfglEnd(); +} + + +/* +----------------------------------------------------------------------------- + Function: R_DrawSprites -Draws all visible sprites. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_DrawSprites( void ) +{ + float sina, cosa; + float Ex, Ey, Dx, Dy; + int n_sprt, n, ang; + texture_t *twall; + extern cvar_t *cropSprites; + +// build visible sprites list + n_sprt = Sprite_CreateVisList(); + if( ! n_sprt ) + { + return; // nothing to draw + } + +// prepare values for billboarding + ang = NormalizeAngle( Player.position.angle + ANG_90 ); + sina = (float)(0.5 * SinTable[ ang ]); + cosa = (float)(0.5 * CosTable[ ang ]); + + //pfglEnable( GL_ALPHA_TEST ); + pfglEnable( GL_BLEND ); + qglDepthMask( GL_FALSE ); + for( n = 0; n < n_sprt; ++n ) + { + int texnum = vislist[ n ].tex; + if( vislist[ n ].dist < MINDIST / 2 ) + { + continue; // little hack to save speed & z-buffer + } + + + + assert( texnum >= 0 && texnum < 1000 ); + twall = spriteTextures[texnum]; + if ( !twall ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "%s/%.3d.tga", spritelocation, (vislist[ n ].tex) ); + twall = spriteTextures[texnum] = TM_FindTexture( name, TT_Wall ); + } + R_Bind( twall->texnum ); + + pfglBegin( GL_QUADS ); + + if ( cropSprites->value && twall->header.numBounds > 0 ) { + // draw one or two subrects to avoid blending all the empty space + int b; + + for ( b = 0 ; b < twall->header.numBounds ; b++ ) { + // include a bit extra for filtering + float x1 = (float)(twall->header.bounds[b][0][0]-1) / (twall->header.uploadWidth-1); + float y1 = (float)(twall->header.bounds[b][0][1]-1) / (twall->header.uploadHeight-1); + float x2 = (float)(twall->header.bounds[b][1][0]+1) / (twall->header.uploadWidth-1); + float y2 = (float)(twall->header.bounds[b][1][1]+1) / (twall->header.uploadHeight-1); + if ( x1 < 0 ) { + x1 = 0; + } else if ( x2 > 1.0 ) { + x2 = 1.0; + } + if ( y1 < 0 ) { + y1 = 0; + } else if ( y2 > 1.0 ) { + y2 = 1.0; + } + Ex = vislist[ n ].x / FLOATTILE + cosa; + Ey = vislist[ n ].y / FLOATTILE + sina; + + pfglTexCoord2f( x1, y1 ); pfglVertex3f( Ex - x1 * 2*cosa, -(LOWERZCOORD + (UPPERZCOORD - LOWERZCOORD) * y1), -Ey + x1 * 2*sina ); + pfglTexCoord2f( x1, y2 ); pfglVertex3f( Ex - x1 * 2*cosa, -(LOWERZCOORD + (UPPERZCOORD - LOWERZCOORD) * y2), -Ey + x1 * 2*sina ); + pfglTexCoord2f( x2, y2 ); pfglVertex3f( Ex - x2 * 2*cosa, -(LOWERZCOORD + (UPPERZCOORD - LOWERZCOORD) * y2), -Ey + x2 * 2*sina ); + pfglTexCoord2f( x2, y1 ); pfglVertex3f( Ex - x2 * 2*cosa, -(LOWERZCOORD + (UPPERZCOORD - LOWERZCOORD) * y1), -Ey + x2 * 2*sina ); + } + } else { + Ex = Dx = vislist[ n ].x / FLOATTILE; + Ey = Dy = vislist[ n ].y / FLOATTILE; + Ex += cosa; Ey += sina; + Dx -= cosa; Dy -= sina; + + pfglTexCoord2f( 0.0, 0.0 ); pfglVertex3f( Ex, UPPERZCOORD, -Ey ); + pfglTexCoord2f( 0.0, 1.0 ); pfglVertex3f( Ex, LOWERZCOORD, -Ey ); + pfglTexCoord2f( 1.0, 1.0 ); pfglVertex3f( Dx, LOWERZCOORD, -Dy ); + pfglTexCoord2f( 1.0, 0.0 ); pfglVertex3f( Dx, UPPERZCOORD, -Dy ); + } + + pfglEnd(); + } + + //pfglDisable( GL_ALPHA_TEST ); // !@# reanable just for sprites +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_DrawWeapon( void ) +{ + char name[ 32 ]; + texture_t *tex; + static int w = 128; + static int h = 128; + static int scale = 2; + int x = (viddef.width - (128 * scale)) >> 1; + int y = viddef.height - (128 * scale) - 79; + + my_snprintf( name, sizeof( name ), "%s/%d.tga", spritelocation, Player.weapon * 5 + Player.weaponframe + SPR_KNIFEREADY ); + + tex = TM_FindTexture( name, TT_Pic ); + + + R_Bind( tex->texnum ); + + + + pfglAlphaFunc( GL_GREATER, 0.3f ); + + pfglEnable( GL_BLEND ); + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0.0f, 0.0f ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1.0f, 0.0f ); pfglVertex2i( x + w * scale, y ); + pfglTexCoord2f( 1.0f, 1.0f ); pfglVertex2i( x + w * scale, y + h * scale ); + pfglTexCoord2f( 0.0f, 1.0f ); pfglVertex2i( x, y + h * scale ); + + pfglEnd(); + + pfglDisable( GL_BLEND ); + + pfglAlphaFunc( GL_GREATER, 0.666f ); + + +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_DrawNumber( int x, int y, int number ) +{ + texture_t *tex; + int col; + float fcol; + static float w = 0.1f; + int i; + char string[ 20 ]; + W32 length; + + + my_snprintf( string, sizeof( string ), "%d", number ); + length = strlen( string ); + + tex = TM_FindTexture( "pics/N_NUMPIC.tga", TT_Pic ); + + + pfglEnable( GL_TEXTURE_2D ); + + R_Bind( tex->texnum ); + + pfglBegin( GL_QUADS ); + + for( i = length-1 ; i >= 0 ; --i ) + { + col = string[ i ] - 48; + + fcol = col * w; + + pfglTexCoord2f( fcol, 0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( fcol+w, 0 ); pfglVertex2i( x+18, y ); + pfglTexCoord2f( fcol+w, 1 ); pfglVertex2i( x+18, y+32 ); + pfglTexCoord2f( fcol, 1 ); pfglVertex2i( x, y+32 ); + + x -= 18; + } + + pfglEnd(); + +} + + +W8 wfont[ ] = { + 32, 15, 32, 32, 32, 32, 32, 12, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 16, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_put_line( int x, int y, const char *string ) +{ + texture_t *tex; + int mx = x; + int num; + float frow, fcol; + static float h = 0.25f; // (32 / 128.0f); + static float w = 0.0625f; // (32 / 512.0f); + + + tex = TM_FindTexture( "pics/L_FONTPIC.tga", TT_Pic ); + + + R_Bind( tex->texnum ); + + pfglBegin( GL_QUADS ); + + while( *string ) + { + if( *string == '\n' ) + { + mx = x; + y += 32; + ++string; + continue; + } + + num = *string; + + num &= 255; + + if( (num & 127) == 32 ) + { + mx += 32; + ++string; + continue; // space + } + + + frow = ((num >> 4) - 2) * h; + fcol = (num & 15) * w; + + + pfglTexCoord2f( fcol, frow ); pfglVertex2i( mx, y ); + pfglTexCoord2f( fcol+w, frow ); pfglVertex2i( mx+32, y ); + pfglTexCoord2f( fcol+w, frow+h ); pfglVertex2i( mx+32, y+32 ); + pfglTexCoord2f( fcol, frow+h ); pfglVertex2i( mx, y+32 ); + + + + mx += wfont[ (num & 127) - 32 ]; + ++string; + } + + pfglEnd(); +} + diff --git a/wolf3d/newCode/wolf/wolf_player.c b/wolf3d/newCode/wolf/wolf_player.c new file mode 100644 index 0000000..0ce012c --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_player.c @@ -0,0 +1,1023 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_player.c: Wolfenstein3-D player management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + +player_t Player; // player struct (pos, health etc...) + + +#define PLAYERSIZE MINDIST // player radius + + + +struct atkinf +{ + char tics, attack, frame; // attack is 1 for gun, 2 for knife + +} attackinfo[ 4 ][ 14 ] = // 4 guns, 14 frames max for every gun! +{ + { {6,0,1},{6,2,2},{6,0,3},{6,-1,4} }, + { {6,0,1},{6,1,2},{6,0,3},{6,-1,4} }, + { {6,0,1},{6,1,2},{6,3,3},{6,-1,4} }, + { {6,0,1},{6,1,2},{6,4,3},{6,-1,4} }, +}; + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: true if player can change weapons, otherwise false. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean PL_ChangeWeapon( player_t *self, int weapon ) +{ + unsigned itemflag; + + itemflag = ITEM_WEAPON_1 << weapon; + + if( self->ammo[ AMMO_BULLETS ] == 0 && weapon != WEAPON_KNIFE ) + { + Com_Printf("Not enough ammo.\n"); + return false; + } + + if( ! (self->items & itemflag) ) + { + Com_Printf( "No weapon.\n" ); + return false; + } + + self->weapon = + self->pendingweapon = weapon; + + self->attackframe = + self->attackcount = + self->weaponframe = 0; + + return true; +} + + +/* +----------------------------------------------------------------------------- + Function: Called if player pressed USE button + + Parameters: + + Returns: returns true if player used something + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean PL_Use( player_t *self, LevelData_t *lvl ) +{ + int x, y, dir; + + dir = Get4dir( FINE2RAD( self->position.angle ) ); + x = self->tilex + dx4dir[ dir ]; + y = self->tiley + dy4dir[ dir ]; + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE ) + { + return Door_TryUse( &lvl->Doors.DoorMap[ x ][ y ], Player.items ); + } + + if( lvl->tilemap[ x ][ y ] & SECRET_TILE ) + { + return PushWall_Push( x, y, dir ); + } + + if( lvl->tilemap[ x ][ y ] & ELEVATOR_TILE ) + { + int newtex; + + switch( dir ) + { + case dir4_east: + case dir4_west: + newtex = lvl->wall_tex_x[ x ][ y ] += 2; + break; + + case dir4_north: + case dir4_south: + return false; // don't allow to press elevator rails + } + + if( lvl->tilemap[ self->tilex ][ self->tiley ] & SECRETLEVEL_TILE ) + { + self->playstate = ex_secretlevel; + } + else + { + self->playstate = ex_complete; + } + Sound_StartSound( NULL, 0, CHAN_BODY, Sound_RegisterSound( "lsfx/040.wav" ), 1, ATTN_NORM, 0 ); + + iphoneStartIntermission( 0 ); + + return true; + } + + //Sound_StartSound( NULL, 0, CHAN_BODY, Sound_RegisterSound( "lsfx/020.wav" ), 1, ATTN_NORM, 0 ); + return false; +} + + + +#define STOPSPEED 0x0D00 +#define FRICTION 0.25f +#define MAXMOVE (MINDIST*2-1) + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: returns true if move ok + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean PL_TryMove( player_t *self, LevelData_t *lvl ) +{ + int xl, yl, xh, yh, x, y; + int d, n; + + xl = POS2TILE( Player.position.origin[ 0 ] - PLAYERSIZE ); + yl = POS2TILE( Player.position.origin[ 1 ] - PLAYERSIZE ); + xh = POS2TILE( Player.position.origin[ 0 ] + PLAYERSIZE ); + yh = POS2TILE( Player.position.origin[ 1 ] + PLAYERSIZE ); + + // Cheching for solid walls: + for( y = yl ; y <= yh ; ++y ) + for( x = xl ; x <= xh ; ++x ) + { + if( lvl->tilemap[ x ][ y ] & SOLID_TILE ) + return 0; + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE && + Door_Opened( &lvl->Doors, x, y) != DOOR_FULLOPEN ) { + // iphone hack to allow player to move halfway into door tiles + // if the player bounds doesn't cross the middle of the tile, let the move continue + if ( abs( Player.position.origin[0] - TILE2POS( x ) ) <= 0x9000 + && abs( Player.position.origin[1] - TILE2POS( y ) ) <= 0x9000 ) { + return 0; + } + } + } + +// check for actors + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].state >= st_die1 ) + continue; + + d = self->position.origin[ 0 ] - Guards[ n ].x; + + if( d < -MINACTORDIST || d > MINACTORDIST ) + continue; + + d = self->position.origin[ 1 ] - Guards[ n ].y; + + if( d < -MINACTORDIST || d > MINACTORDIST) + continue; + + return false; + } + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void PL_ClipMove( player_t *self, int xmove, int ymove ) +{ + int basex, basey; + + basex = self->position.origin[ 0 ]; + basey = self->position.origin[ 1 ]; + + self->position.origin[ 0 ] += xmove; + self->position.origin[ 1 ] += ymove; + if( PL_TryMove( self, r_world ) ) + { + return; // we moved as we wanted + } + + //Sound_StartSound( NULL, 0, CHAN_BODY, Sound_RegisterSound( "lsfx/000.wav" ), 1, ATTN_NORM, 0 ); + + if( xmove ) // don't bother if we don't move x! + { + self->position.origin[ 0 ] = basex + xmove; + self->position.origin[ 1 ] = basey; + if( PL_TryMove( self, r_world ) ) + { + return; // May be we'll move only X direction? + } + } + if( ymove ) // don't bother if we don't move y! + { + self->position.origin[ 0 ] = basex; + self->position.origin[ 1 ] = basey + ymove; + if( PL_TryMove( self, r_world ) ) + { + return; // May be we'll move only Y direction? + } + } + +// movement blocked; we must stay on one place... :( + self->position.origin[ 0 ] = basex; + self->position.origin[ 1 ] = basey; +} + + +/* +----------------------------------------------------------------------------- + Function: Changes player's angle and position + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void PL_ControlMovement( player_t *self, LevelData_t *lvl ) +{ + int angle, speed; + +// rotation + angle = self->position.angle; + +// if(cmd->forwardmove || cmd->sidemove) + self->movx = self->movy = 0; // clear accumulated movement + + if( Player.cmd.forwardmove ) + { + speed = tics * Player.cmd.forwardmove; + self->movx+=(int)(speed * CosTable[ angle ] ); + self->movy+=(int)(speed * SinTable[ angle ] ); + } + if( Player.cmd.sidemove ) + { + speed = tics * Player.cmd.sidemove; + self->movx += (int)( speed * SinTable[ angle ] ); + self->movy -= (int)( speed * CosTable[ angle ] ); + } + + if( ! self->movx && ! self->movy ) + return; + +#ifdef SPEAR + + funnyticount = 0; // ZERO FUNNY COUNTER IF MOVED! // FIXME! + +#endif + self->speed = self->movx + self->movy; + +// bound movement + if( self->movx > MAXMOVE ) + self->movx = MAXMOVE; + else if( self->movx < -MAXMOVE ) + self->movx = -MAXMOVE; + + if( self->movy > MAXMOVE ) + self->movy = MAXMOVE; + else if( self->movy < -MAXMOVE ) + self->movy = -MAXMOVE; + +// move player and clip movement to walls (check for no-clip mode here) + PL_ClipMove( self, self->movx, self->movy ); + self->tilex = POS2TILE( self->position.origin[ 0 ] ); + self->tiley = POS2TILE( self->position.origin[ 1 ] ); + + // pick up items easier -- any tile you touch, instead of + // just the midpoint tile + { + int x, y; + + for ( x = -1 ; x <= 1 ; x+= 2 ) { + int tilex = POS2TILE( self->position.origin[0] + x * PLAYERSIZE ); + for ( y = -1 ; y <= 1 ; y+= 2 ) { + int tiley = POS2TILE( self->position.origin[1] + y * PLAYERSIZE ); + Powerup_PickUp( tilex, tiley ); + } + } + } +// Powerup_PickUp( self->tilex, self->tiley ); + +// Checking for area change, ambush tiles and doors will have negative values + if( lvl->areas[ self->tilex ][ self->tiley ] >= 0 && + lvl->areas[ self->tilex ][ self->tiley ] != Player.areanumber ) + { + Player.areanumber = lvl->areas[ self->tilex ][ self->tiley ]; + assert( Player.areanumber >= 0 && Player.areanumber < NUMAREAS ); + Areas_ConnectAreas( Player.areanumber ); + } + + if( lvl->tilemap[ self->tilex ][ self->tiley ] & EXIT_TILE ) + { + iphoneStartIntermission( 0 ); + } + + +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void PL_PlayerAttack( player_t *self, _boolean re_attack ) +{ + struct atkinf *cur; + + self->attackcount -= tics; + while( self->attackcount <= 0 ) + { + cur = &attackinfo[ self->weapon ][ self->attackframe ]; + switch( cur->attack ) + { + case -1: + self->flags &= ~PL_FLAG_ATTCK; + if( ! self->ammo[ AMMO_BULLETS ] ) + { + self->weapon = WEAPON_KNIFE; + } + else if( self->weapon != self->pendingweapon ) + { + self->weapon = self->pendingweapon; + } + self->attackframe = self->weaponframe = 0; + return; + + case 4: + if( ! self->ammo[ AMMO_BULLETS ] ) + { + break; + } + + if( re_attack ) + { + self->attackframe -= 2; + } + + case 1: + if( ! self->ammo[ AMMO_BULLETS ] ) // can only happen with chain gun + { + self->attackframe++; + break; + } + fire_lead( self ); + self->ammo[ AMMO_BULLETS ]--; + break; + + case 2: + fire_hit( self ); + break; + + case 3: + if(self->ammo[AMMO_BULLETS] && re_attack) + self->attackframe-=2; + break; + } + + self->attackcount += cur->tics; + self->attackframe++; + self->weaponframe = attackinfo[ self->weapon ][ self->attackframe ].frame; + } + +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_Process( player_t *self, LevelData_t *lvl ) +{ + int n; + + self->madenoise = false; + + PL_ControlMovement( self, lvl ); + + if( self->flags & PL_FLAG_ATTCK ) + { + PL_PlayerAttack( self, Player.cmd.buttons & BUTTON_ATTACK ); + } + else + { + if( Player.cmd.buttons & BUTTON_USE ) + { + if(!(self->flags & PL_FLAG_REUSE) && PL_Use( self, lvl ) ) + { + self->flags|=PL_FLAG_REUSE; + } + } + else + { + self->flags &= ~PL_FLAG_REUSE; + } + + if( Player.cmd.buttons & BUTTON_ATTACK ) + { + self->flags |= PL_FLAG_ATTCK; + + self->attackframe = 0; + self->attackcount = attackinfo[ self->weapon ][ 0 ].tics; + self->weaponframe = attackinfo[ self->weapon ][ 0 ].frame; + } + } + +// process impulses + switch( Player.cmd.impulse ) + { + case 0: + break; // no impulse + + case 1: + case 2: + case 3: + case 4: + PL_ChangeWeapon( self, Player.cmd.impulse - 1 ); + break; + + case 10: // next weapon /like in Quake/ FIXME: weapprev, weapnext + self->pendingweapon=self->weapon; + for( n = 0 ; n < 4; ++n ) + { + if( ++self->weapon > WEAPON_CHAIN ) + { + self->weapon = WEAPON_KNIFE; + } + + if( PL_ChangeWeapon( self, self->weapon ) ) + { + break; + } + } + self->weapon = self->pendingweapon; + break; + + default: + Com_Printf( "Unknown Impulse: %d\n", Player.cmd.impulse ); + break; + } + +} + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_Reset(void) +{ + memset( &Player, 0, sizeof( Player ) ); + Player.playstate = ex_notingame; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_Spawn( placeonplane_t location, LevelData_t *lvl ) +{ + Player.position = location; + Player.tilex = POS2TILE( location.origin[ 0 ] ); + Player.tiley = POS2TILE( location.origin[ 1 ] ); + Player.areanumber = lvl->areas[ Player.tilex ][ Player.tiley ]; + assert( Player.areanumber >= 0 && Player.areanumber < NUMAREAS ); + if( Player.areanumber < 0 ) + { + Player.areanumber = 36; + } + + Areas_ConnectAreas( Player.areanumber ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_Give_f( void ) +{ + PL_GiveHealth( &Player, 999, 0 ); + PL_GiveAmmo( &Player, AMMO_BULLETS, 99 ); + PL_GiveWeapon( &Player, WEAPON_AUTO ); + PL_GiveWeapon( &Player, WEAPON_CHAIN ); + PL_GiveKey( &Player, KEY_GOLD ); + PL_GiveKey( &Player, KEY_SILVER ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void Cmd_God_f( void ) +{ + Player.flags ^= FL_GODMODE; + + Com_Printf( "God mode %s\n", Player.flags & FL_GODMODE ? "ON":"OFF" ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE void PL_notarget_f( void ) +{ + Player.flags ^= FL_NOTARGET; +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_Init(void) +{ + PL_Reset(); + PL_NewGame( &Player ); + + Cmd_AddCommand( "god", Cmd_God_f ); + Cmd_AddCommand( "notarget", PL_notarget_f ); + + Cmd_AddCommand( "give", Cmd_Give_f ); +} + +// ------------------------- * environment interraction * ------------------------- +#define EXTRAPOINTS 40000 // points for an extra life + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +#ifdef IPHONE +void vibrateDevice(); +#else +void vibrateDevice() {} +#endif + +PUBLIC void PL_Damage( player_t *self, entity_t *attacker, int points ) +{ + + if( self->playstate == ex_dead ) + { + return; + } + + self->LastAttacker = attacker; + + if( skill->value == gd_baby ) + { + points >>= 2; + } + + // vibe the phone + vibrateDevice(); + + // note the direction of the last hit for the directional blends + { + int dx = attacker->x - self->position.origin[0]; + int dy = attacker->y - self->position.origin[1]; + + // probably won't ever have damage from self, but check anyway + if ( dx != 0 || dy != 0 ) { + float angle = atan2f( dy, dx ); + float playerAngle = self->position.angle * 360.0f / (float)ANG_360; + float deltaAngle; + angle = angle * 180.0f / M_PI; + if ( angle < 0 ) { + angle = 360 + angle; + } + deltaAngle = angle - playerAngle; + if ( deltaAngle > 180 ) { + deltaAngle = deltaAngle - 360; + } + if ( deltaAngle < -180 ) { + deltaAngle = 360 + deltaAngle; + } +// Com_Printf( "damage: player angle: %4.0f shotAngle: %4.0f deltaAngle:%4.0f\n", playerAngle, angle, deltaAngle ); + if ( deltaAngle > 40 ) { + iphoneSetAttackDirection( 1 ); + } else if ( deltaAngle < -40 ) { + iphoneSetAttackDirection( -1 ); + } + } + } + + // do everything else but subtract health in god mode, to ease + // testing of damage feedback + if( !(self->flags & FL_GODMODE) ) + { + self->health -= points; + } + + if( self->health <= 0 ) + { + // dead + self->health = 0; + self->playstate = ex_dead; + + Sound_StartSound( NULL, 0, CHAN_BODY, Sound_RegisterSound( "lsfx/009.wav" ), 1, ATTN_NORM, 0 ); + } + + // red screen flash + iphoneStartDamageFlash( points ); + + // stop the happy grin face if shot before it times out + Player.face_gotgun = false; + + // make BJ's eyes bulge on huge hits + if( points > 30 && Player.health != 0 ) + { + Player.face_ouch = true; + Player.facecount = 0; + } +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: returns true if player needs this health. + + Notes: + gives player some HP + max can be: + 0 - natural player's health limit (100 or 150 with augment) + >0 - indicates the limit +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean PL_GiveHealth( player_t *self, int points, int max ) +{ + if( max == 0 ) + { + max = (self->items & ITEM_AUGMENT) ? 150 : 100; + } + + if( self->health >= max ) + { + return false; // doesn't need this health + } + + self->health += points; + + if( self->health > max ) + { + self->health = max; + } + + Player.face_gotgun = false; + + return true; // took it +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: returns true if player needs this ammo + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean PL_GiveAmmo( player_t *self, int type, int ammo ) +{ + int max_ammo[ AMMO_TYPES ] = { 99 }; + int max; + + max = max_ammo[ type ]; + if( self->items & ITEM_BACKPACK ) + { + max *= 2; + } + + if( self->ammo[ type ] >= max ) + { + return false; // don't need + } + + if( ! self->ammo[ type ] && ! self->attackframe ) // knife was out + { + self->weapon = self->pendingweapon; + } + + self->ammo[ type ] += ammo; + if( self->ammo[ type ] > max ) + { + self->ammo[ type ] = max; + } + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_GiveWeapon( player_t *self, int weapon ) +{ + unsigned itemflag; + + PL_GiveAmmo( self, AMMO_BULLETS, 6 ); // give some ammo with a weapon + + itemflag = ITEM_WEAPON_1 << weapon; + if( self->items & itemflag ) + { + return; // player owns this weapon + } + else + { + self->items |= itemflag; + if ( self->weapon < weapon ) { // don't switch if already using better weapon + self->weapon = self->pendingweapon = weapon; + } + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_GiveLife( player_t *self ) +{ + if( self->lives < 9 ) + { + self->lives++; + } + + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/044.wav" ), 1, ATTN_NORM, 0 ); +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_GivePoints( player_t *self, W32 points ) +{ + self->score += points; + while( self->score >= self->next_extra ) + { + self->next_extra += EXTRAPOINTS; + PL_GiveLife( self ); + } +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_GiveKey( player_t *self, int key ) +{ + self->items |= ITEM_KEY_1 << key; +} + + +/* +----------------------------------------------------------------------------- + Function: Set up player for the new game + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_NewGame( player_t *self ) +{ + memset( self, 0, sizeof( player_t ) ); + + self->health = 100; + self->ammo[ AMMO_BULLETS ] = 16; // JDC: changed for iphone 8; + self->lives = 3; + + self->weapon = self->pendingweapon = WEAPON_PISTOL; + self->items = ITEM_WEAPON_1 | ITEM_WEAPON_2; + self->next_extra = EXTRAPOINTS; +} + +/* +----------------------------------------------------------------------------- + Function: Set up player for level transition + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PL_NextLevel( player_t *self ) +{ + self->old_score = self->score; + self->attackcount = self->attackframe = self->weaponframe = 0; + self->flags = 0; + + self->items &= ~(ITEM_KEY_1 | ITEM_KEY_2 | ITEM_KEY_3 | ITEM_KEY_4); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: self -[in] Player to respawn in game world. + + Returns: returns false if no lives left + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean PL_Reborn( player_t *self ) +{ +#if 0 // removed game over from iphone version + if( --self->lives < 1 ) + { + return false; + } +#endif + + self->health = 100; + self->ammo[ AMMO_BULLETS ] = 16; // JDC: changed for iphone 8; + self->score = self->old_score; + self->attackcount = 0; + self->attackframe = 0; + self->weaponframe = 0; + self->flags = 0; + + self->weapon = self->pendingweapon = WEAPON_PISTOL; + self->items = ITEM_WEAPON_1 | ITEM_WEAPON_2; + + self->playstate = ex_playing; + + return true; +} diff --git a/wolf3d/newCode/wolf/wolf_player.h b/wolf3d/newCode/wolf/wolf_player.h new file mode 100644 index 0000000..d04d5d3 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_player.h @@ -0,0 +1,180 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_player.h: Wolfenstein3-D player management. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +/* + Notes: + This module is implemented by wolf_player.c + +*/ + +#ifndef __WOLF_PLAYER_H__ +#define __WOLF_PLAYER_H__ + +#define ITEM_KEY_1 1 +#define ITEM_KEY_2 2 +#define ITEM_KEY_3 4 +#define ITEM_KEY_4 8 +#define ITEM_WEAPON_1 16 +#define ITEM_WEAPON_2 32 +#define ITEM_WEAPON_3 64 +#define ITEM_WEAPON_4 128 +#define ITEM_WEAPON_5 256 +#define ITEM_WEAPON_6 512 +#define ITEM_WEAPON_7 1024 +#define ITEM_WEAPON_8 2048 +#define ITEM_BACKPACK (1<<12) // doubles carrying capacity +#define ITEM_AUGMENT (1<<13) // adds 50 to maximum health +#define ITEM_UNIFORM (1<<14) // allows you to pass guards +#define ITEM_AUTOMAP (1<<15) // shows unknown map ares in other color (as in DooM) +#define ITEM_FREE (1<<16) // - unused - + + +enum weapon_e +{ + WEAPON_KNIFE, + WEAPON_PISTOL, + WEAPON_AUTO, + WEAPON_CHAIN, + + WEAPON_TYPES +}; + +enum key_e +{ + KEY_GOLD, + KEY_SILVER, + KEY_FREE1, + KEY_FREE2, + + KEY_TYPES +}; + +enum ammo_e +{ + AMMO_BULLETS, + + AMMO_TYPES +}; + + + +// flags +#define PL_FLAG_REUSE 1 // use button pressed +#define PL_FLAG_ATTCK 2 // attacking +// debug (cheat codes) flags +#define FL_GODMODE (1<<4) +#define FL_NOTARGET (1<<6) + + +typedef enum state_e +{ + ex_notingame, + ex_playing, + ex_dead, + ex_secretlevel, + ex_victory, + ex_complete +/* + ex_stillplaying, + ex_completed, + ex_died, + ex_warped, + ex_resetgame, + ex_loadedgame, + ex_victorious, + ex_abort, + ex_demodone, + ex_secretlevel +*/ +} state_t; + +// ------------------------- * types * ------------------------- +// Player structure: Holds all info about player +typedef struct player_s +{ + usercmd_t cmd; // movement / action command + + placeonplane_t position; // player position + int movx, movy, speed; + int tilex, tiley; + +// stats + int health, lives, frags; + int armor; // there are 2 types. The better one is indicated by high bit set + int ammo[AMMO_TYPES]; + int old_score, score, next_extra; + unsigned items; // (keys, weapon) + int weapon, pendingweapon; +// additional info + int attackframe, attackcount, weaponframe; // attack info + unsigned flags; + int areanumber; + + _boolean madenoise; // FIXME: move to flags? + entity_t *LastAttacker; + int faceframe, facecount; // bj's face in the HUD // FIXME decide something! + _boolean face_gotgun, face_ouch; + state_t playstate; // fixme: move to gamestate + +} player_t; + +extern player_t Player; + + + + +extern void PL_Spawn( placeonplane_t location, LevelData_t *lvl ); + +extern void PL_Process( player_t *self, LevelData_t *lvl ); + +extern void PL_Damage( player_t *self, entity_t *attacker, int points ); +extern _boolean PL_GiveHealth( player_t *self, int points, int max ); +extern _boolean PL_GiveAmmo( player_t *self, int type, int ammo ); +extern void PL_GiveWeapon( player_t *self, int weapon ); +extern void PL_GiveLife( player_t *self ); +extern void PL_GivePoints( player_t *self, W32 points ); +extern void PL_GiveKey( player_t *self, int key ); + +extern void PL_NewGame( player_t *self ); +extern void PL_NextLevel( player_t *self ); +extern _boolean PL_Reborn( player_t *self ); + +extern void PL_Init( void ); +extern void PL_Reset( void ); + + +extern void fire_hit( player_t *self ); +extern void fire_lead( player_t *self ); + + +#endif /* __WOLF_PLAYER_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_powerups.c b/wolf3d/newCode/wolf/wolf_powerups.c new file mode 100644 index 0000000..ebc9331 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_powerups.c @@ -0,0 +1,427 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2001 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_pushwalls.c: Wolfenstein3-D power-up handler. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + +typedef struct powerup_s +{ + int x, y; + pow_t type; + int sprite; + struct powerup_s *prev, *next; + +} powerup_t; + +powerup_t *powerups = NULL; + + +int Pow_Texture[ pow_last ] = +{ + SPR_STAT_34, // pow_gibs + SPR_STAT_38, // pow_gibs2 + SPR_STAT_6, // pow_alpo + SPR_STAT_25, // pow_firstaid + SPR_STAT_20, // pow_key1 + SPR_STAT_21, // pow_key2 +// not used + SPR_STAT_20, // pow_key3 + SPR_STAT_20, // pow_key4 + + SPR_STAT_29, // pow_cross + SPR_STAT_30, // pow_chalice + SPR_STAT_31, // pow_bible + SPR_STAT_32, // pow_crown + SPR_STAT_26, // pow_clip + SPR_STAT_26, // pow_clip2 + SPR_STAT_27, // pow_machinegun + SPR_STAT_28, // pow_chaingun + SPR_STAT_24, // pow_food + SPR_STAT_33, // pow_fullheal +// spear + SPR_STAT_49, // pow_25clip + SPR_STAT_51, // pow_spear +}; + + + + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE powerup_t *Pow_Remove( powerup_t *powerup ) +{ + powerup_t *next; + + if( powerup == NULL ) + return NULL; + + if( powerup->prev ) + powerup->prev->next = powerup->next; + + if( powerup->next ) + powerup->next->prev = powerup->prev; + + next = powerup->next; + if( powerups == powerup ) + powerups = next; //fuck! + + MM_FREE( powerup ); + + return next; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE powerup_t *Pow_AddNew( void ) +{ + powerup_t *newp; + + newp = MM_MALLOC( sizeof( powerup_t ) ); + newp->prev = NULL; + newp->next = powerups; + + if( powerups ) + { + powerups->prev = newp; + } + + powerups = newp; + + return newp; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Powerup_Reset( void ) +{ + powerup_t *powerup = powerups; + + while( powerup ) + { + powerup = Pow_Remove( powerup ); + } + + powerups = NULL; +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: 1 if powerup is picked up, otherwise 0. + + Notes: + +----------------------------------------------------------------------------- +*/ +PRIVATE int Pow_Give( pow_t type ) +{ + static const char *keynames[] = { "Gold", "Silver", "?", "?" }; + + switch( type ) + { +// +// Keys +// + case pow_key1: + case pow_key2: + case pow_key3: + case pow_key4: + type -= pow_key1; + PL_GiveKey( &Player, type ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/012.wav" ), 1, ATTN_NORM, 0 ); + iphoneSetNotifyText( "%s key\n", keynames[ type ] ); + break; +// +// Treasure +// + case pow_cross: + PL_GiveHealth( &Player, 1, 150 ); // iphone -- trasure acts as health crumbs + PL_GivePoints( &Player, 100 ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/035.wav" ), 1, ATTN_NORM, 0 ); + if ( ++levelstate.found_treasure == levelstate.total_treasure ) { + iphoneSetNotifyText( "You found the last treasure!" ); + } + break; + + case pow_chalice: + PL_GiveHealth( &Player, 1, 150 ); // iphone -- trasure acts as health crumbs + PL_GivePoints( &Player, 500 ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/036.wav" ), 1, ATTN_NORM, 0 ); + if ( ++levelstate.found_treasure == levelstate.total_treasure ) { + iphoneSetNotifyText( "You found the last treasure!" ); + } + break; + + case pow_bible: + PL_GiveHealth( &Player, 1, 150 ); // iphone -- trasure acts as health crumbs + PL_GivePoints( &Player, 1000 ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/037.wav" ), 1, ATTN_NORM, 0 ); + if ( ++levelstate.found_treasure == levelstate.total_treasure ) { + iphoneSetNotifyText( "You found the last treasure!" ); + } + break; + + case pow_crown: + PL_GiveHealth( &Player, 1, 150 ); // iphone -- trasure acts as health crumbs + PL_GivePoints( &Player, 5000 ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/045.wav" ), 1, ATTN_NORM, 0 ); + if ( ++levelstate.found_treasure == levelstate.total_treasure ) { + iphoneSetNotifyText( "You found the last treasure!" ); + } + break; + +// +// Health +// + case pow_gibs: + if( ! PL_GiveHealth( &Player, 1, 11 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/061.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_alpo: + if( ! PL_GiveHealth( &Player, 4, 0 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/033.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_food: + if( ! PL_GiveHealth( &Player, 10, 0 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/033.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_firstaid: + if( ! PL_GiveHealth( &Player, 25, 0 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/034.wav" ), 1, ATTN_NORM, 0 ); + break; + +// +// Weapon & Ammo +// + case pow_clip: + if( ! PL_GiveAmmo( &Player, AMMO_BULLETS, 8 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/031.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_clip2: + if( ! PL_GiveAmmo( &Player, AMMO_BULLETS, 4 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/031.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_25clip: + if( ! PL_GiveAmmo( &Player, AMMO_BULLETS, 25 ) ) + { + return 0; + } + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/064.wav" ), 1, ATTN_NORM, 0 ); + break; + + case pow_machinegun: + PL_GiveWeapon( &Player, WEAPON_AUTO ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/030.wav" ), 1, ATTN_NORM, 0 ); + iphoneSetNotifyText( "Machinegun" ); + break; + + case pow_chaingun: + PL_GiveWeapon( &Player, WEAPON_CHAIN ); + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "lsfx/038.wav" ), 1, ATTN_NORM, 0 ); + iphoneSetNotifyText( "Chaingun" ); + + Player.facecount = -100; + Player.face_gotgun = true; + break; + +// +// Artifacts +// + case pow_fullheal: + PL_GiveHealth( &Player, 999, 0 ); + PL_GiveAmmo( &Player, AMMO_BULLETS, 25 ); + PL_GiveLife( &Player ); + if ( ++levelstate.found_treasure == levelstate.total_treasure ) { + iphoneSetNotifyText( "You found the last treasure!" ); + } else { + iphoneSetNotifyText( "Full Heal" ); + } + // no extra lives on iPhone Com_Printf( "Extra life!\n" ); + break; + + case pow_spear: + { + char szTextMsg[ 256 ]; + + Sound_StartSound( NULL, 0, CHAN_ITEM, Sound_RegisterSound( "sodsfx/109.wav" ), 1, ATTN_NORM, 0 ); + iphoneSetNotifyText( "Spear of Destiny" ); + + my_snprintf( szTextMsg, sizeof( szTextMsg ), + "loading ; map s%.2d.map\n", 20 ); + Cbuf_AddText( szTextMsg ); + } + break; + + default: + Com_DPrintf( "Warning: Unknown item type: %d\n", type ); + break; + } + + iphoneStartBonusFlash(); + + return 1; +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: x, y -[in] In are in TILES. + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Powerup_Spawn( int x, int y, int type, LevelData_t *lvl ) +{ + powerup_t *newp; + + lvl->tilemap[ x ][ y ] |= POWERUP_TILE; + newp = Pow_AddNew(); + newp->sprite = Sprite_GetNewSprite(); + Sprite_SetPos( newp->sprite, TILE2POS( newp->x = x ), TILE2POS( newp->y = y ), 0 ); + newp->type = type; + Sprite_SetTex( newp->sprite, -1, Pow_Texture[ type ] ); + lvl->tilemap[ x ][ y ] |= POWERUP_TILE; +// good place to update total treasure count! +} + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: x, y -[in] In are in TILES. + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Powerup_PickUp( int x, int y ) +{ + powerup_t *pow; + _boolean p_left = false, p_pick = false; + + for( pow = powerups ; pow ; pow = pow->next ) + { +check_again: + if( pow->x == x && pow->y == y) + {// got a powerup here + if( Pow_Give( pow->type ) ) //FIXME script + {// picked up this stuff, remove it! + p_pick = true; + Sprite_RemoveSprite( pow->sprite ); + pow = Pow_Remove( pow ); + if( pow ) + goto check_again; + else + break; + } + else + {// player do not need it, so may be next time! + p_left = true; + } + } + } + + if( p_left ) + { + r_world->tilemap[ x ][ y ] |= POWERUP_TILE; + } + else + { + r_world->tilemap[ x ][ y ] &= ~POWERUP_TILE; + } +} + diff --git a/wolf3d/newCode/wolf/wolf_powerups.h b/wolf3d/newCode/wolf/wolf_powerups.h new file mode 100644 index 0000000..aa87235 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_powerups.h @@ -0,0 +1,79 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_powerups.h: Wolfenstein3-D power-up handler. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +/* + Notes: + This module is implemented by wolf_powerups.c + +*/ + +#ifndef __WOLF_POWERUPS_H__ +#define __WOLF_POWERUPS_H__ + +typedef enum +{ +//please provide description + pow_gibs, // 1% if <=10%; SLURPIESND + pow_gibs2, // 1% if <=10%; SLURPIESND + pow_alpo, // 4% if <100%; HEALTH1SND + pow_firstaid, // 25% if <100%; HEALTH2SND + pow_key1, // gold key; GETKEYSND + pow_key2, // silver key; GETKEYSND + pow_key3, // not used + pow_key4, // not used + pow_cross, // 100pts; BONUS1SND + pow_chalice, // 500pts; BONUS2SND + pow_bible, // 1000pts; BONUS3SND + pow_crown, // 5000pts; BONUS4SND + pow_clip, // 8bul if <99bul; GETAMMOSND + pow_clip2, // 4bul if <99bul; GETAMMOSND + pow_machinegun, // machine gun; GETMACHINESND + pow_chaingun, // gatling gun; GETGATLINGSND + pow_food, // 10% if <100%; HEALTH1SND + pow_fullheal, // 99%, 25bul; BONUS1UPSND + pow_25clip, // 25bul if <99bul; GETAMMOBOXSND + pow_spear, // spear of destiny! + + pow_last +// add new types here (after last) + +} pow_t; + + +extern void Powerup_Reset( void ); +extern void Powerup_Spawn( int x, int y, int type, LevelData_t *lvl ); +extern void Powerup_PickUp( int x, int y ); + + +#endif /* __WOLF_POWERUPS_H__ */ + diff --git a/wolf3d/newCode/wolf/wolf_pushwalls.c b/wolf3d/newCode/wolf/wolf_pushwalls.c new file mode 100644 index 0000000..b040d7d --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_pushwalls.c @@ -0,0 +1,175 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_pushwalls.c: Wolfenstein3-D push-wall handler. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + +Pwall_t PWall; + + +/* +----------------------------------------------------------------------------- + Function: PushWall_Reset() -Reset pushwall status. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PushWall_Reset(void) +{ + memset( &PWall, 0, sizeof( Pwall_t ) ); +} + + +/* +----------------------------------------------------------------------------- + Function: PushWall_Push() -Try to move push-wall. + + Parameters: x, y -[in] Coordinates in tilemap. + dir -[in] Direction in which push-wall is intended to move. + + Returns: true if push successful, otherwise false. + + Notes: Called whenever someone tries to push a secret wall. + +----------------------------------------------------------------------------- +*/ +PUBLIC _boolean PushWall_Push( int x, int y, dir4type dir ) +{ + int dx, dy; + + + if( PWall.active ) + { + return false; // another PWall is moving [only one at a time!] + } + + dx = dx4dir[ dir ]; + dy = dy4dir[ dir ]; + + if( r_world->tilemap[ x + dx ][ y + dy ] & (SOLID_TILE | DOOR_TILE) ) + { // noway (smth is blocking) + return true; + } + +// remove secret flag & make everything needed when pushwall used! + r_world->tilemap[ x ][ y ] &= (~SECRET_TILE); + r_world->tilemap[ x ][ y ] &= (~WALL_TILE); + r_world->tilemap[ x ][ y ] |= PUSHWALL_TILE; + + if ( ++levelstate.found_secrets == levelstate.total_secrets ) { + iphoneSetNotifyText( "You found the last secret!" ); + } else { + iphoneSetNotifyText( "You found a secret!" ); + } + + if( g_version->value == SPEAROFDESTINY ) + { + Sound_StartSound( NULL, 1, CHAN_AUTO, Sound_RegisterSound( "sfx/030.wav" ), 1, ATTN_STATIC, 0 ); + } + else + { + Sound_StartSound( NULL, 1, CHAN_AUTO, Sound_RegisterSound( "sfx/034.wav" ), 1, ATTN_STATIC, 0 ); + } + +// good way to avoid stuckness; [un]comment one more down! +// it makes a tile behind pushwall unpassable + r_world->tilemap[ x + dx ][ y + dy ] |= PUSHWALL_TILE; + r_world->wall_tex_x[ x + dx ][ y + dy ] = r_world->wall_tex_x[ x ][ y ]; + r_world->wall_tex_y[ x + dx ][ y + dy ] = r_world->wall_tex_y[ x ][ y ]; + +// write down PWall info + PWall.active = true; + PWall.PWtilesmoved = PWall.PWpointsmoved = 0; + PWall.dir = dir; + PWall.x = x; PWall.y = y; + PWall.dx = dx; PWall.dy = dy; + PWall.tex_x = r_world->wall_tex_x[ x ][ y ]; + PWall.tex_y = r_world->wall_tex_y[ x ][ y ]; + + return true; +} + +/* +----------------------------------------------------------------------------- + Function: PushWall_Process() -Process push-walls. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void PushWall_Process( void ) +{ + if( ! PWall.active ) + { + return; // no active PWall to work with + } + + PWall.PWpointsmoved += tics; + + if( PWall.PWpointsmoved < 128 ) + { + return; + } + + PWall.PWpointsmoved -= 128; + PWall.PWtilesmoved++; +// Free tile + r_world->tilemap[ PWall.x ][ PWall.y ] &= (~PUSHWALL_TILE); +// Occupy new tile + PWall.x += PWall.dx; + PWall.y += PWall.dy; + +// Shall we move further? + if( r_world->tilemap[ PWall.x + PWall.dx ][ PWall.y + PWall.dy ] & (SOLID_TILE | DOOR_TILE | ACTOR_TILE | POWERUP_TILE) || + PWall.PWtilesmoved == 3 ) + { + r_world->tilemap[ PWall.x ][ PWall.y ] &= (~PUSHWALL_TILE); // wall now + r_world->tilemap[ PWall.x ][ PWall.y ] |= WALL_TILE; // wall now + r_world->wall_tex_x[ PWall.x ][ PWall.y ] = PWall.tex_x; + r_world->wall_tex_y[ PWall.x ][ PWall.y ] = PWall.tex_y; + PWall.active = false; // Free Push Wall + } + else + { + r_world->tilemap[ PWall.x + PWall.dx ][ PWall.y + PWall.dy ] |= PUSHWALL_TILE; + } + +} diff --git a/wolf3d/newCode/wolf/wolf_raycast.c b/wolf3d/newCode/wolf/wolf_raycast.c new file mode 100644 index 0000000..9321558 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_raycast.c @@ -0,0 +1,370 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_raycast.c: Wolfenstein3-D ray-casting. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + + +W8 tile_visible[ 64 ][ 64 ]; // can player see this tile? + + +/* +----------------------------------------------------------------------------- + Function: R_RayCast() -Ray cast viewport. + + Parameters: viewport -[in] Position of camera. + lvl -[in] Pointer to valid LevelData_t structure. + + Returns: Nothing. + + Notes: Marks all visible tiles in tile_visible[] array. + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_RayCast( placeonplane_t viewport, LevelData_t *lvl ) +{ + int n, x, y, angle, vx, vy; + r_trace_t trace; + + memset( tile_visible, 0, sizeof( tile_visible ) ); // clear tile visible flags + +// viewport tile coordinates + x = viewport.origin[ 0 ]; + y = viewport.origin[ 1 ]; + angle = viewport.angle; + + vx = POS2TILE( viewport.origin[ 0 ] ); + vy = POS2TILE( viewport.origin[ 1 ] ); + + trace.tile_vis = tile_visible; + trace.flags = TRACE_SIGHT | TRACE_MARK_MAP; + +// +// Ray casting +// + + // FIXME: control ray count and make angle init + for( n = 0 ; n < 640 ; ++n ) + { + trace.x = x; + trace.y = y; + trace.a = NormalizeAngle( angle + ColumnAngle[ n ] ); + + R_Trace( &trace, lvl ); + } + +// +// Rendering +// + for( x = 0 ; x < 64; ++x ) + for( y = 0 ; y < 64; ++y ) + if( tile_visible[ x ][ y ] ) + { + lvl->tileEverVisible[x][y] = 1; // for automap + if( lvl->tilemap[ x ][ y ] & DOOR_TILE ) + { + /* door */ + if( lvl->Doors.DoorMap[ x ][ y ].action != dr_open ) + { + _boolean backside = false; + + if( lvl->Doors.DoorMap[ x ][ y ].vertical ) + { + if( x < vx ) + backside = true; + } + else + { + if( y < vy ) + backside = true; + } + + R_Draw_Door( x, y, LOWERZCOORD, UPPERZCOORD, + lvl->Doors.DoorMap[ x ][ y ].vertical, + backside, + lvl->Doors.DoorMap[ x ][ y ].texture, + Door_Opened( &lvl->Doors, x, y ) ); + } + /* door sides */ + if( lvl->Doors.DoorMap[ x ][ y ].vertical ) + { + if( y <= vy ) + R_Draw_Wall( (float)x, (float)(y-1), LOWERZCOORD, UPPERZCOORD, dir4_north, TEX_PLATE ); + + if( y >= vy ) + R_Draw_Wall( (float)x, (float)(y+1), LOWERZCOORD, UPPERZCOORD, dir4_south, TEX_PLATE ); + + if( x <= vx && lvl->tilemap[ x - 1 ][ y ] & WALL_TILE ) + R_Draw_Wall( (float)(x-1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_east, lvl->wall_tex_x[ x - 1 ][ y ] ); + + if( x >= vx && lvl->tilemap[ x + 1 ][ y ] & WALL_TILE ) + R_Draw_Wall( (float)(x+1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_west, lvl->wall_tex_x[ x + 1 ][ y ] ); + } + else + { + if( x <= vx ) + R_Draw_Wall((float)(x-1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_east, TEX_PLATE+1); + + if( x >= vx ) + R_Draw_Wall((float)(x+1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_west, TEX_PLATE+1); + + if( y <= vy && lvl->tilemap[ x ][ y - 1 ] & WALL_TILE ) + R_Draw_Wall( (float)x, (float)(y-1), LOWERZCOORD, UPPERZCOORD, dir4_north, lvl->wall_tex_y[x][y-1]); + + if( y >= vy && lvl->tilemap[ x ][ y + 1 ] & WALL_TILE ) + R_Draw_Wall( (float)x, (float)(y+1), LOWERZCOORD, UPPERZCOORD, dir4_south, lvl->wall_tex_y[x][y+1]); + } + } + else + { + /* Push-Wall */ + if( (r_world->tilemap[ x ][ y ] & PUSHWALL_TILE) ) + { + float dx, dy; + + dx = PWall.dx * PWall.PWpointsmoved / 128.0f; + dy = PWall.dy * PWall.PWpointsmoved / 128.0f; + + if( PWall.x <= vx ) + R_Draw_Wall( (float)PWall.x + dx, (float)PWall.y + dy, LOWERZCOORD, UPPERZCOORD, dir4_east, PWall.tex_x ); + + if( PWall.x >= vx ) + R_Draw_Wall( (float)PWall.x + dx, (float)PWall.y + dy, LOWERZCOORD, UPPERZCOORD, dir4_west, PWall.tex_x ); + + if( PWall.y <= vy ) + R_Draw_Wall( (float)PWall.x + dx, (float)PWall.y + dy, LOWERZCOORD, UPPERZCOORD, dir4_north, PWall.tex_y ); + + if( PWall.y >= vy ) + R_Draw_Wall( (float)PWall.x + dx, (float)PWall.y + dy, LOWERZCOORD, UPPERZCOORD, dir4_south, PWall.tex_y ); + + } + /* x-wall */ + if( x <= vx && r_world->tilemap[ x - 1 ][ y ] & WALL_TILE ) + R_Draw_Wall( (float)(x-1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_east, r_world->wall_tex_x[x-1][y]); + + if( x >= vx && r_world->tilemap[ x + 1 ][ y ] & WALL_TILE ) + R_Draw_Wall( (float)(x+1), (float)y, LOWERZCOORD, UPPERZCOORD, dir4_west, r_world->wall_tex_x[x+1][y]); + + /* y-wall */ + if( y <= vy && r_world->tilemap[ x ][ y - 1 ] & WALL_TILE ) + R_Draw_Wall( (float)x, (float)(y-1), LOWERZCOORD, UPPERZCOORD, dir4_north, r_world->wall_tex_y[x][y-1]); + + if( y >= vy && r_world->tilemap[ x ][ y + 1 ] & WALL_TILE ) + R_Draw_Wall( (float)x, (float)(y+1), LOWERZCOORD, UPPERZCOORD, dir4_south, r_world->wall_tex_y[x][y+1]); + } + + + } +} + + +int x_tile_step[ 4 ] = { 1, -1, -1, 1 }; +int y_tile_step[ 4 ] = { 1, 1, -1, -1 }; + + +/* +----------------------------------------------------------------------------- + Function: R_TraceCheck() -Trace ray check. + + Parameters: + lvl -[in] Pointer to valid LevelData_t structure. + x, y -[in] In tiles. + + Returns: true to stop tracing, false otherwise. + + Notes: Tells ray casting if we hit a wall or door and to stop tracing. + +----------------------------------------------------------------------------- +*/ +PRIVATE _boolean R_TraceCheck( LevelData_t *lvl, int x, int y, int frac, int dfrac, _boolean vert, _boolean flip, r_trace_t *trace ) +{ + if( lvl->tilemap[ x ][ y ] & WALL_TILE ) + { + if( vert ) + { + trace->x = (x << TILESHIFT) + (flip ? TILEGLOBAL : 0); + trace->y = (y << TILESHIFT) + frac; + trace->flags |= TRACE_HIT_VERT; + } + else + { + trace->x = (x << TILESHIFT) + frac; + trace->y = (y << TILESHIFT) + (flip ? TILEGLOBAL : 0); + trace->flags &= ~TRACE_HIT_VERT; + } + + return true; // wall, stop tracing + } + + if( trace->tile_vis ) + { + trace->tile_vis[ x ][ y ] = true; // this tile is visible + } + + + if( lvl->tilemap[ x ][ y ] & DOOR_TILE && + lvl->Doors.DoorMap[ x ][ y ].action != dr_open ) + { + frac += dfrac >> 1; + if( POS2TILE( frac ) ) + return false; + + if( vert ) + { + if( lvl->Doors.DoorMap[ x ][ y ].action != dr_closed && + (frac >> 10) > DOOR_FULLOPEN - Door_Opened( &lvl->Doors, x, y ) ) + { + return false; // opened enough + } + + trace->x = TILE2POS( x ); + trace->y = (y << TILESHIFT) + frac; + trace->flags |= TRACE_HIT_VERT; + } + else + { + if( lvl->Doors.DoorMap[ x ][ y ].action != dr_closed && + (frac >> 10) < Door_Opened( &lvl->Doors, x, y ) ) + { + return false; // opened enough + } + + trace->y = TILE2POS( y ); + trace->x = (x << TILESHIFT) + frac; + trace->flags &= ~TRACE_HIT_VERT; + } + trace->flags |= TRACE_HIT_DOOR; + + return true; // closed door, stop tracing + } + + return false; // no intersection, go on! +} + +/* +----------------------------------------------------------------------------- + Function: R_Trace() -Trace ray. + + Parameters: + trace -[in] Pointer to valid r_trace_t structure. + lvl -[in] Pointer to valid LevelData_t structure. + + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_Trace( r_trace_t *trace, LevelData_t *lvl ) +{ + int xtilestep, ytilestep; + int xstep, ystep; + int xtile, ytile; + int xintercept, yintercept; + int YmapPos, XmapPos; + quadrant q; + +// Setup for ray casting + q = GetQuadrant( FINE2RAD( trace->a ) ); + + xtilestep = x_tile_step[ q ]; + ytilestep = y_tile_step[ q ]; + + xtile = POS2TILE( trace->x ) + xtilestep; + ytile = POS2TILE( trace->y ) + ytilestep; + + xstep = ytilestep * XnextTable[ trace->a ]; + ystep = xtilestep * YnextTable[ trace->a ]; + + xintercept = (int)( ( ((ytilestep == -1 ? ytile+1 : ytile) << TILESHIFT) - trace->y ) / TanTable[ trace->a ]) + trace->x; + yintercept = (int)( ( ((xtilestep == -1 ? xtile+1 : xtile) << TILESHIFT) - trace->x ) * TanTable[ trace->a ]) + trace->y; + + YmapPos = yintercept >> TILESHIFT; // toXray + XmapPos = xintercept >> TILESHIFT; // toYray + + if( trace->tile_vis ) + { + // this tile is visible + trace->tile_vis[ POS2TILE( trace->x ) ][ POS2TILE( trace->y ) ] = true; + } + +// +// Start of ray-casting +// + while( 1 ) + { +// +// Vertical loop // an anologue for X-Ray +// + while( ! (ytilestep == -1 && YmapPos <= ytile) && ! (ytilestep == 1 && YmapPos >= ytile) ) + { + if( xtile < 0 || xtile >= 64 || YmapPos < 0 || YmapPos >= 64 ) + { + return; + } + + if( R_TraceCheck( lvl, xtile, YmapPos, yintercept % TILEGLOBAL, ystep, true, (_boolean)(xtilestep == -1), trace ) ) + { + return; + } + + // prepare for next step + xtile += xtilestep; + yintercept += ystep; + YmapPos = yintercept >> TILESHIFT; + } + +// +// Horizontal loop // an anologue for Y-Ray +// + while( ! (xtilestep == -1 && XmapPos <= xtile) && ! (xtilestep == 1 && XmapPos >= xtile) ) + { + if( ytile < 0 || ytile >= 64 || XmapPos < 0 || XmapPos >= 64 ) + { + return; + } + + if( R_TraceCheck( lvl, XmapPos, ytile, xintercept % TILEGLOBAL, xstep, false, (_boolean)(ytilestep == -1), trace ) ) + { + return; + } + + // prepare for next step + ytile += ytilestep; + xintercept += xstep; + XmapPos = xintercept >> TILESHIFT; + } + + } // end of while( 1 ) + +} diff --git a/wolf3d/newCode/wolf/wolf_raycast.h b/wolf3d/newCode/wolf/wolf_raycast.h new file mode 100644 index 0000000..8a74c7a --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_raycast.h @@ -0,0 +1,74 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_raycast.h: Wolfenstein3-D ray-casting. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +/* + Notes: + This module is implemented by wolf_raycast.c + +*/ + +#ifndef __WOLF_RAYCAST_H__ +#define __WOLF_RAYCAST_H__ + +// marks +#define TRACE_MARK_MAP 1 // marks traced area in 'AM_AutoMap.vis' array +// obstacle levels +#define TRACE_SIGHT 2 // player sight +#define TRACE_SIGHT_AI 4 // enemy sight +#define TRACE_BULLET 8 // bullet +#define TRACE_OBJECT 16 // object + +#define TRACE_HIT_VERT 32 // vertical wall was hit +#define TRACE_HIT_DOOR 64 // door was hit +#define TRACE_HIT_PWALL 128 // pushwall was hit + +typedef struct r_trace_s +{ + int x, y; // origin + int a; // trace angle + int flags; + W8 (*tile_vis)[ 64 ]; // should point to [ 64 ][ 64 ] array + +} r_trace_t; + +#define UPPERZCOORD 0.6f +#define LOWERZCOORD -0.6f + +extern W8 tile_visible[ 64 ][ 64 ]; // can player see this tile? + + +extern void R_RayCast( placeonplane_t viewport, LevelData_t *lvl ); +extern void R_Trace( r_trace_t *trace, LevelData_t *lvl ); + + +#endif /* __WOLF_RAYCAST_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_renderer.c b/wolf3d/newCode/wolf/wolf_renderer.c new file mode 100644 index 0000000..cf11bad --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_renderer.c @@ -0,0 +1,96 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_renderer.c: Wolfenstein 3-D renderer. + * + * Author: Michael Liebscher + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +#include "../wolfiphone.h" + +LevelData_t *r_world; + + +/* +----------------------------------------------------------------------------- + Function: R_BeginRegistration -Start the rendering registration sequence. + + Parameters: map -[in] The name of the map to load. + + Returns: Nothing. + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void R_BeginRegistration( const char *map ) +{ + char fullname[ MAX_GAMEPATH ]; + + if( ! map || ! *map ) + { + return; + } + + ++texture_registration_sequence; + + + my_snprintf( fullname, sizeof( fullname ), "maps/%s.map", map ); + +// Door_ResetDoors( &r_world->Doors ); + Powerup_Reset(); + Sprite_Reset(); + Areas_InitAreas( Player.areanumber ); + PushWall_Reset(); + + memset( &levelstate, 0, sizeof( levelstate ) ); // Reset gamestate + ResetGuards(); + + r_world = Level_LoadMap( fullname ); + + if( r_world == NULL ) + { + Com_Printf( "Could not load map (%s)\n", map ); + return; + } + + levelstate.floornum = floornumber; + + if( g_version->value == SPEAROFDESTINY ) + { + if( strlen( map ) >= 2 ) + { + levelstate.floornum = atoi( map+1 ); + + if( levelstate.floornum == 20 ) + { + levelstate.floornum = 17; + } + } + } + +} diff --git a/wolf3d/newCode/wolf/wolf_renderer.h b/wolf3d/newCode/wolf/wolf_renderer.h new file mode 100644 index 0000000..689145e --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_renderer.h @@ -0,0 +1,64 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_renderer.h: Wolfenstein3-D renderer. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from Quake II, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_renderer.c and wolf_opengl.c + +*/ + +#ifndef __WOLF_RENDERER_H__ +#define __WOLF_RENDERER_H__ + +extern void R_SetGL3D( placeonplane_t viewport ); + +extern void R_DrawBox( int x, int y, int w, int h, W32 color ); + +extern void R_Draw_Door( int x, int y, float z1, float z2, _boolean vertical, _boolean backside, int tex, int amount ); +extern void R_Draw_Wall( float x, float y, float z1, float z2, int type, int tex ); + + + +extern void R_DrawSprites( void ); + +extern void R_DrawPsyched( W32 percent ); + +extern void R_DrawHUD( void ); +extern void R_DrawNumber( int x, int y, int number ); +extern void R_DrawWeapon( void ); + + +extern void R_put_line( int x, int y, const char *string ); + + +#endif /* __WOLF_RENDERER_H__ */ diff --git a/wolf3d/newCode/wolf/wolf_sprites.c b/wolf3d/newCode/wolf/wolf_sprites.c new file mode 100644 index 0000000..4313f3e --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_sprites.c @@ -0,0 +1,291 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_sprites.c: Wolfenstein3-D sprite handling. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * This code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + */ + +#include "../wolfiphone.h" + + +// nobody should see this array! +sprite_t Spr_Sprites[ MAX_SPRITES ]; +W32 n_of_sprt; + + + +/* +----------------------------------------------------------------------------- + Function: Sprite_Reset -Reset sprite status. + + Parameters: Nothing. + + Returns: Nothing. + + Notes: Called only when client must reconnect will not set remove flag! +----------------------------------------------------------------------------- +*/ +PUBLIC void Sprite_Reset( void ) +{ + n_of_sprt = 0; + memset( Spr_Sprites, 0, sizeof( Spr_Sprites ) ); +} + +/* +----------------------------------------------------------------------------- + Function: Sprite_RemoveSprite -Remove sprite. + + Parameters: sprite_id -[in] sprite id to remove. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sprite_RemoveSprite( int sprite_id ) +{ + if( sprite_id == -1 ) + { + return; + } + + Spr_Sprites[ sprite_id ].flags |= SPRT_REMOVE; +} + + +/* +----------------------------------------------------------------------------- + Function: Sprite_GetNewSprite -Get sprite index. + + Parameters: Nothing. + + Returns: "sprite id" index. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC int Sprite_GetNewSprite( void ) +{ + W32 n; + sprite_t* sprt; + + for( n = 0, sprt = Spr_Sprites ; n < n_of_sprt ; ++n, ++sprt ) + { + if( sprt->flags & SPRT_REMOVE ) + { // free spot: clear it first + memset( sprt, 0, sizeof( sprite_t ) ); + return n; + } + } + + if( n_of_sprt >= MAX_SPRITES ) + { + Com_Printf( "Warning n_of_sprt == MAX_SPRITES\n" ); + return -1; + } + + return n_of_sprt++; +} + + + +/* +----------------------------------------------------------------------------- + Function: Sprite_SetPos -Set sprite position. + + Parameters: sprite_id -[in] sprite id to change. + x, y -[in] new x, y. + angle -[in] new angle to set. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sprite_SetPos( int sprite_id, int x, int y, int angle ) +{ + if( sprite_id == -1 ) + { + return; + } + + Spr_Sprites[ sprite_id ].x = x; + Spr_Sprites[ sprite_id ].y = y; + Spr_Sprites[ sprite_id ].ang = angle; + Spr_Sprites[ sprite_id ].tilex = POS2TILE( x ); + Spr_Sprites[ sprite_id ].tiley = POS2TILE( y ); + Spr_Sprites[ sprite_id ].flags |= SPRT_CHG_POS; + + if( ! (x & HALFTILE) ) // (x%TILEGLOBAL>=HALFTILE) + { + Spr_Sprites[ sprite_id ].tilex--; + } + + if( ! (y & HALFTILE) ) + { + Spr_Sprites[ sprite_id ].tiley--; + } +} + +/* +----------------------------------------------------------------------------- + Function: Sprite_SetTex -Set sprite texture. + + Parameters: sprite_id -[in] sprite id to change. + index -[in] texture index. + tex -[in] texture to set as. + + Returns: Nothing. + + Notes: +----------------------------------------------------------------------------- +*/ +PUBLIC void Sprite_SetTex( int sprite_id, int index, int tex ) +{ + if( sprite_id == -1 ) + { + return; + } + + if( index == -1 ) // one texture for each phase + { + Spr_Sprites[ sprite_id ].tex[ 0 ] = tex; + Spr_Sprites[ sprite_id ].flags |= SPRT_ONE_TEX; + } + else + { + Spr_Sprites[ sprite_id ].tex[ index ] = tex; + } + + Spr_Sprites[ sprite_id ].flags |= SPRT_CHG_TEX; +} + + +#define MAXVISABLE 128 +visobj_t vislist[ MAXVISABLE ]; + + +/* +----------------------------------------------------------------------------- + Function: Sprite_CreateVisList -Compare function for vislist sorting. + + Parameters: vis1, vis2 -[in] Two values to compare. + + Returns: + <0 elem1 further than elem2 + 0 elem1 equal distance to elem2 + >0 elem1 closer than elem2 + + Notes: +----------------------------------------------------------------------------- +*/ +PRIVATE int Sprite_cmpVis( const void *elem1, const void *elem2 ) +{ + // macro to get distance from a void pointer to visobj_t + #define vis_dist( vis ) ( ((visobj_t *)vis)->dist ) + + if( vis_dist( elem1 ) == vis_dist( elem2 ) ) + { + return 0; // process equal distance + } + else + { + // if dist > sprite must be first + return vis_dist( elem1 ) < vis_dist( elem2 ) ? 1 : -1; + } +} + + +/* +----------------------------------------------------------------------------- + Function: Sprite_CreateVisList -Build and sort visibility list of sprites. + + Parameters: Nothing. + + Returns: Number of visible sprites. + + Notes: + List is sorted from far to near. + List is based on tile visibility array, made by raycaster. + Called only by client. +----------------------------------------------------------------------------- +*/ +PUBLIC int Sprite_CreateVisList( void ) +{ + W32 tx, ty, n, num_visible; + visobj_t *visptr; + sprite_t* sprt; + + visptr = vislist; + num_visible = 0; + + for( n = 0, sprt = Spr_Sprites; n < n_of_sprt; ++n, ++sprt ) + { + if( sprt->flags & SPRT_REMOVE ) + { + continue; + } + + tx = sprt->tilex; + ty = sprt->tiley; + + if( tx > 63 ) + tx = 63; + if( ty > 63 ) + ty = 63; + + // can be in any of 4 surrounding tiles; not 9 - see definition of tilex & tiley + if( tile_visible[ tx ][ ty ] || tile_visible[ tx + 1 ][ ty ] || + tile_visible[ tx ][ ty + 1 ] || tile_visible[ tx + 1 ][ ty + 1 ] ) + { // player spoted it + visptr->dist = LineLen2Point( sprt->x - Player.position.origin[ 0 ], + sprt->y-Player.position.origin[ 1 ], + Player.position.angle ); //FIXME viewport + visptr->x = sprt->x; + visptr->y = sprt->y; + visptr->ang = sprt->ang; + visptr->tex = sprt->tex[ 0 ]; //FIXME! + if( ++num_visible > MAXVISABLE ) + { + break; // vislist full + } + + visptr++; + } + } + +// sorting list + if( num_visible ) // do not sort if no entries + { + qsort( vislist, num_visible, sizeof( visobj_t ), Sprite_cmpVis ); + } + + return num_visible; +} + diff --git a/wolf3d/newCode/wolf/wolf_sprites.h b/wolf3d/newCode/wolf/wolf_sprites.h new file mode 100644 index 0000000..2e81a13 --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_sprites.h @@ -0,0 +1,430 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + * wolf_sprites.h: Wolfenstein3-D sprite handling. + * + * Author: Michael Liebscher + * Date: 2004 + * + * Acknowledgement: + * Portion of this code was derived from NewWolf, and was originally + * written by DarkOne the Hacker. + * + * Portion of this code was derived from Wolfenstein3-D, and was originally + * written by Id Software, Inc. + * + */ + +/* + Notes: + This module is implemented by wolf_sprites.c + +*/ + +#ifndef __WOLF_SPRITES_H__ +#define __WOLF_SPRITES_H__ + + +// +// sprite constants +// + +enum { + SPR_DEMO, + SPR_DEATHCAM, +// +// static sprites +// + SPR_STAT_0, SPR_STAT_1,SPR_STAT_2, SPR_STAT_3, + SPR_STAT_4, SPR_STAT_5,SPR_STAT_6, SPR_STAT_7, + + SPR_STAT_8, SPR_STAT_9,SPR_STAT_10,SPR_STAT_11, + SPR_STAT_12,SPR_STAT_13,SPR_STAT_14,SPR_STAT_15, + + SPR_STAT_16,SPR_STAT_17,SPR_STAT_18,SPR_STAT_19, + SPR_STAT_20,SPR_STAT_21,SPR_STAT_22,SPR_STAT_23, + + SPR_STAT_24,SPR_STAT_25,SPR_STAT_26,SPR_STAT_27, + SPR_STAT_28,SPR_STAT_29,SPR_STAT_30,SPR_STAT_31, + + SPR_STAT_32,SPR_STAT_33,SPR_STAT_34,SPR_STAT_35, + SPR_STAT_36,SPR_STAT_37,SPR_STAT_38,SPR_STAT_39, + + SPR_STAT_40,SPR_STAT_41,SPR_STAT_42,SPR_STAT_43, + SPR_STAT_44,SPR_STAT_45,SPR_STAT_46,SPR_STAT_47, + + + + + SPR_STAT_48,SPR_STAT_49,SPR_STAT_50,SPR_STAT_51, + + + + + +// +// Guard +// + SPR_GRD_S_1,SPR_GRD_S_2,SPR_GRD_S_3,SPR_GRD_S_4, + SPR_GRD_S_5,SPR_GRD_S_6,SPR_GRD_S_7,SPR_GRD_S_8, + + SPR_GRD_W1_1,SPR_GRD_W1_2,SPR_GRD_W1_3,SPR_GRD_W1_4, + SPR_GRD_W1_5,SPR_GRD_W1_6,SPR_GRD_W1_7,SPR_GRD_W1_8, + + SPR_GRD_W2_1,SPR_GRD_W2_2,SPR_GRD_W2_3,SPR_GRD_W2_4, + SPR_GRD_W2_5,SPR_GRD_W2_6,SPR_GRD_W2_7,SPR_GRD_W2_8, + + SPR_GRD_W3_1,SPR_GRD_W3_2,SPR_GRD_W3_3,SPR_GRD_W3_4, + SPR_GRD_W3_5,SPR_GRD_W3_6,SPR_GRD_W3_7,SPR_GRD_W3_8, + + SPR_GRD_W4_1,SPR_GRD_W4_2,SPR_GRD_W4_3,SPR_GRD_W4_4, + SPR_GRD_W4_5,SPR_GRD_W4_6,SPR_GRD_W4_7,SPR_GRD_W4_8, + + SPR_GRD_PAIN_1,SPR_GRD_DIE_1,SPR_GRD_DIE_2,SPR_GRD_DIE_3, + SPR_GRD_PAIN_2,SPR_GRD_DEAD, + + SPR_GRD_SHOOT1,SPR_GRD_SHOOT2,SPR_GRD_SHOOT3, + +// +// Dog +// + SPR_DOG_W1_1,SPR_DOG_W1_2,SPR_DOG_W1_3,SPR_DOG_W1_4, + SPR_DOG_W1_5,SPR_DOG_W1_6,SPR_DOG_W1_7,SPR_DOG_W1_8, + + SPR_DOG_W2_1,SPR_DOG_W2_2,SPR_DOG_W2_3,SPR_DOG_W2_4, + SPR_DOG_W2_5,SPR_DOG_W2_6,SPR_DOG_W2_7,SPR_DOG_W2_8, + + SPR_DOG_W3_1,SPR_DOG_W3_2,SPR_DOG_W3_3,SPR_DOG_W3_4, + SPR_DOG_W3_5,SPR_DOG_W3_6,SPR_DOG_W3_7,SPR_DOG_W3_8, + + SPR_DOG_W4_1,SPR_DOG_W4_2,SPR_DOG_W4_3,SPR_DOG_W4_4, + SPR_DOG_W4_5,SPR_DOG_W4_6,SPR_DOG_W4_7,SPR_DOG_W4_8, + + SPR_DOG_DIE_1,SPR_DOG_DIE_2,SPR_DOG_DIE_3,SPR_DOG_DEAD, + SPR_DOG_JUMP1,SPR_DOG_JUMP2,SPR_DOG_JUMP3, + + + +// +// SS +// + SPR_SS_S_1,SPR_SS_S_2,SPR_SS_S_3,SPR_SS_S_4, + SPR_SS_S_5,SPR_SS_S_6,SPR_SS_S_7,SPR_SS_S_8, + + SPR_SS_W1_1,SPR_SS_W1_2,SPR_SS_W1_3,SPR_SS_W1_4, + SPR_SS_W1_5,SPR_SS_W1_6,SPR_SS_W1_7,SPR_SS_W1_8, + + SPR_SS_W2_1,SPR_SS_W2_2,SPR_SS_W2_3,SPR_SS_W2_4, + SPR_SS_W2_5,SPR_SS_W2_6,SPR_SS_W2_7,SPR_SS_W2_8, + + SPR_SS_W3_1,SPR_SS_W3_2,SPR_SS_W3_3,SPR_SS_W3_4, + SPR_SS_W3_5,SPR_SS_W3_6,SPR_SS_W3_7,SPR_SS_W3_8, + + SPR_SS_W4_1,SPR_SS_W4_2,SPR_SS_W4_3,SPR_SS_W4_4, + SPR_SS_W4_5,SPR_SS_W4_6,SPR_SS_W4_7,SPR_SS_W4_8, + + SPR_SS_PAIN_1,SPR_SS_DIE_1,SPR_SS_DIE_2,SPR_SS_DIE_3, + SPR_SS_PAIN_2,SPR_SS_DEAD, + + SPR_SS_SHOOT1,SPR_SS_SHOOT2,SPR_SS_SHOOT3, + +// +// Mutant +// + SPR_MUT_S_1,SPR_MUT_S_2,SPR_MUT_S_3,SPR_MUT_S_4, + SPR_MUT_S_5,SPR_MUT_S_6,SPR_MUT_S_7,SPR_MUT_S_8, + + SPR_MUT_W1_1,SPR_MUT_W1_2,SPR_MUT_W1_3,SPR_MUT_W1_4, + SPR_MUT_W1_5,SPR_MUT_W1_6,SPR_MUT_W1_7,SPR_MUT_W1_8, + + SPR_MUT_W2_1,SPR_MUT_W2_2,SPR_MUT_W2_3,SPR_MUT_W2_4, + SPR_MUT_W2_5,SPR_MUT_W2_6,SPR_MUT_W2_7,SPR_MUT_W2_8, + + SPR_MUT_W3_1,SPR_MUT_W3_2,SPR_MUT_W3_3,SPR_MUT_W3_4, + SPR_MUT_W3_5,SPR_MUT_W3_6,SPR_MUT_W3_7,SPR_MUT_W3_8, + + SPR_MUT_W4_1,SPR_MUT_W4_2,SPR_MUT_W4_3,SPR_MUT_W4_4, + SPR_MUT_W4_5,SPR_MUT_W4_6,SPR_MUT_W4_7,SPR_MUT_W4_8, + + SPR_MUT_PAIN_1,SPR_MUT_DIE_1,SPR_MUT_DIE_2,SPR_MUT_DIE_3, + SPR_MUT_PAIN_2,SPR_MUT_DIE_4,SPR_MUT_DEAD, + + SPR_MUT_SHOOT1,SPR_MUT_SHOOT2,SPR_MUT_SHOOT3,SPR_MUT_SHOOT4, + +// +// Officer +// + SPR_OFC_S_1,SPR_OFC_S_2,SPR_OFC_S_3,SPR_OFC_S_4, + SPR_OFC_S_5,SPR_OFC_S_6,SPR_OFC_S_7,SPR_OFC_S_8, + + SPR_OFC_W1_1,SPR_OFC_W1_2,SPR_OFC_W1_3,SPR_OFC_W1_4, + SPR_OFC_W1_5,SPR_OFC_W1_6,SPR_OFC_W1_7,SPR_OFC_W1_8, + + SPR_OFC_W2_1,SPR_OFC_W2_2,SPR_OFC_W2_3,SPR_OFC_W2_4, + SPR_OFC_W2_5,SPR_OFC_W2_6,SPR_OFC_W2_7,SPR_OFC_W2_8, + + SPR_OFC_W3_1,SPR_OFC_W3_2,SPR_OFC_W3_3,SPR_OFC_W3_4, + SPR_OFC_W3_5,SPR_OFC_W3_6,SPR_OFC_W3_7,SPR_OFC_W3_8, + + SPR_OFC_W4_1,SPR_OFC_W4_2,SPR_OFC_W4_3,SPR_OFC_W4_4, + SPR_OFC_W4_5,SPR_OFC_W4_6,SPR_OFC_W4_7,SPR_OFC_W4_8, + + SPR_OFC_PAIN_1,SPR_OFC_DIE_1,SPR_OFC_DIE_2,SPR_OFC_DIE_3, + SPR_OFC_PAIN_2,SPR_OFC_DIE_4,SPR_OFC_DEAD, + + SPR_OFC_SHOOT1,SPR_OFC_SHOOT2,SPR_OFC_SHOOT3, + + + +// +// Ghosts +// + SPR_BLINKY_W1,SPR_BLINKY_W2,SPR_PINKY_W1,SPR_PINKY_W2, + SPR_CLYDE_W1,SPR_CLYDE_W2,SPR_INKY_W1,SPR_INKY_W2, + +// +// Hans +// + SPR_BOSS_W1,SPR_BOSS_W2,SPR_BOSS_W3,SPR_BOSS_W4, + SPR_BOSS_SHOOT1,SPR_BOSS_SHOOT2,SPR_BOSS_SHOOT3,SPR_BOSS_DEAD, + + SPR_BOSS_DIE1,SPR_BOSS_DIE2,SPR_BOSS_DIE3, + +// +// Schabbs +// + SPR_SCHABB_W1,SPR_SCHABB_W2,SPR_SCHABB_W3,SPR_SCHABB_W4, + SPR_SCHABB_SHOOT1,SPR_SCHABB_SHOOT2, + + SPR_SCHABB_DIE1,SPR_SCHABB_DIE2,SPR_SCHABB_DIE3,SPR_SCHABB_DEAD, + SPR_HYPO1,SPR_HYPO2,SPR_HYPO3,SPR_HYPO4, + +// +// Fake +// + SPR_FAKE_W1,SPR_FAKE_W2,SPR_FAKE_W3,SPR_FAKE_W4, + SPR_FAKE_SHOOT,SPR_FIRE1,SPR_FIRE2, + + SPR_FAKE_DIE1,SPR_FAKE_DIE2,SPR_FAKE_DIE3,SPR_FAKE_DIE4, + SPR_FAKE_DIE5,SPR_FAKE_DEAD, + +// +// Hitler +// + SPR_MECHA_W1,SPR_MECHA_W2,SPR_MECHA_W3,SPR_MECHA_W4, + SPR_MECHA_SHOOT1,SPR_MECHA_SHOOT2,SPR_MECHA_SHOOT3,SPR_MECHA_DEAD, + + SPR_MECHA_DIE1,SPR_MECHA_DIE2,SPR_MECHA_DIE3, + + SPR_HITLER_W1,SPR_HITLER_W2,SPR_HITLER_W3,SPR_HITLER_W4, + SPR_HITLER_SHOOT1,SPR_HITLER_SHOOT2,SPR_HITLER_SHOOT3,SPR_HITLER_DEAD, + + SPR_HITLER_DIE1,SPR_HITLER_DIE2,SPR_HITLER_DIE3,SPR_HITLER_DIE4, + SPR_HITLER_DIE5,SPR_HITLER_DIE6,SPR_HITLER_DIE7, + +// +// Giftmacher +// + SPR_GIFT_W1,SPR_GIFT_W2,SPR_GIFT_W3,SPR_GIFT_W4, + SPR_GIFT_SHOOT1,SPR_GIFT_SHOOT2, + + SPR_GIFT_DIE1,SPR_GIFT_DIE2,SPR_GIFT_DIE3,SPR_GIFT_DEAD, + + +// +// Rocket, smoke and small explosion +// + SPR_ROCKET_1,SPR_ROCKET_2,SPR_ROCKET_3,SPR_ROCKET_4, + SPR_ROCKET_5,SPR_ROCKET_6,SPR_ROCKET_7,SPR_ROCKET_8, + + SPR_SMOKE_1,SPR_SMOKE_2,SPR_SMOKE_3,SPR_SMOKE_4, + SPR_BOOM_1,SPR_BOOM_2,SPR_BOOM_3, + +// +// Angel of Death's DeathSparks(tm) +// + SPR_HROCKET_1,SPR_HROCKET_2,SPR_HROCKET_3,SPR_HROCKET_4, + SPR_HROCKET_5,SPR_HROCKET_6,SPR_HROCKET_7,SPR_HROCKET_8, + + SPR_HSMOKE_1,SPR_HSMOKE_2,SPR_HSMOKE_3,SPR_HSMOKE_4, + SPR_HBOOM_1,SPR_HBOOM_2,SPR_HBOOM_3, + + SPR_SPARK1,SPR_SPARK2,SPR_SPARK3,SPR_SPARK4, + + + +// +// Gretel +// + SPR_GRETEL_W1,SPR_GRETEL_W2,SPR_GRETEL_W3,SPR_GRETEL_W4, + SPR_GRETEL_SHOOT1,SPR_GRETEL_SHOOT2,SPR_GRETEL_SHOOT3,SPR_GRETEL_DEAD, + + SPR_GRETEL_DIE1,SPR_GRETEL_DIE2,SPR_GRETEL_DIE3, + +// +// Fat Face +// + SPR_FAT_W1,SPR_FAT_W2,SPR_FAT_W3,SPR_FAT_W4, + SPR_FAT_SHOOT1,SPR_FAT_SHOOT2,SPR_FAT_SHOOT3,SPR_FAT_SHOOT4, + + SPR_FAT_DIE1,SPR_FAT_DIE2,SPR_FAT_DIE3,SPR_FAT_DEAD, + +// +// bj +// + SPR_BJ_W1,SPR_BJ_W2,SPR_BJ_W3,SPR_BJ_W4, + SPR_BJ_JUMP1,SPR_BJ_JUMP2,SPR_BJ_JUMP3,SPR_BJ_JUMP4, + + +// +// SPEAR OF DESTINY +// + +// +// Trans Grosse +// + SPR_TRANS_W1,SPR_TRANS_W2,SPR_TRANS_W3,SPR_TRANS_W4, + SPR_TRANS_SHOOT1,SPR_TRANS_SHOOT2,SPR_TRANS_SHOOT3,SPR_TRANS_DEAD, + + SPR_TRANS_DIE1,SPR_TRANS_DIE2,SPR_TRANS_DIE3, + +// +// Wilhelm +// + SPR_WILL_W1,SPR_WILL_W2,SPR_WILL_W3,SPR_WILL_W4, + SPR_WILL_SHOOT1,SPR_WILL_SHOOT2,SPR_WILL_SHOOT3,SPR_WILL_SHOOT4, + + SPR_WILL_DIE1,SPR_WILL_DIE2,SPR_WILL_DIE3,SPR_WILL_DEAD, + +// +// UberMutant +// + SPR_UBER_W1,SPR_UBER_W2,SPR_UBER_W3,SPR_UBER_W4, + SPR_UBER_SHOOT1,SPR_UBER_SHOOT2,SPR_UBER_SHOOT3,SPR_UBER_SHOOT4, + + SPR_UBER_DIE1,SPR_UBER_DIE2,SPR_UBER_DIE3,SPR_UBER_DIE4, + SPR_UBER_DEAD, + +// +// Death Knight +// + SPR_DEATH_W1,SPR_DEATH_W2,SPR_DEATH_W3,SPR_DEATH_W4, + SPR_DEATH_SHOOT1,SPR_DEATH_SHOOT2,SPR_DEATH_SHOOT3,SPR_DEATH_SHOOT4, + + SPR_DEATH_DIE1,SPR_DEATH_DIE2,SPR_DEATH_DIE3,SPR_DEATH_DIE4, + SPR_DEATH_DIE5,SPR_DEATH_DIE6,SPR_DEATH_DEAD, + +// +// Ghost +// + SPR_SPECTRE_W1,SPR_SPECTRE_W2,SPR_SPECTRE_W3,SPR_SPECTRE_W4, + SPR_SPECTRE_F1,SPR_SPECTRE_F2,SPR_SPECTRE_F3,SPR_SPECTRE_F4, + +// +// Angel of Death +// + SPR_ANGEL_W1,SPR_ANGEL_W2,SPR_ANGEL_W3,SPR_ANGEL_W4, + SPR_ANGEL_SHOOT1,SPR_ANGEL_SHOOT2,SPR_ANGEL_TIRED1,SPR_ANGEL_TIRED2, + + SPR_ANGEL_DIE1,SPR_ANGEL_DIE2,SPR_ANGEL_DIE3,SPR_ANGEL_DIE4, + SPR_ANGEL_DIE5,SPR_ANGEL_DIE6,SPR_ANGEL_DIE7,SPR_ANGEL_DEAD, + + + +// +// player attack frames +// + SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3, + SPR_KNIFEATK4, + + SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3, + SPR_PISTOLATK4, + + SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3, + SPR_MACHINEGUNATK4, + + SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3, + SPR_CHAINATK4, + +}; + + + + +#define SPRT_ONE_TEX 1 +#define SPRT_NO_ROT 2 +#define SPRT_CHG_POS 4 +#define SPRT_CHG_TEX 8 +#define SPRT_REMOVE 16 + +typedef struct sprite_s +{ + vec3_t position; + int x, y, ang; +// very clever to make it not just (x>>TILESHIFT) +// but also (x>>TILESHIFT)-1 if (x%TILEWIDTH)\n" ); + return; + } + +// Com_DPrintf( "SV_GameMap( %s )\n", Cmd_Argv( 1 ) ); + + FS_CreatePath( va( "%s/save/current/", FS_Gamedir() ) ); + + // check for clearing the current savegame + map = Cmd_Argv( 1 ); + + // start up the next map + my_strlcpy( r_mapname, Cmd_Argv( 1 ), sizeof( r_mapname ) ); + + Client_PrepRefresh( r_mapname ); +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void Map_f( void ) +{ + char *map; + char expanded[ MAX_GAMEPATH ]; + + // Check to make sure the level exists. + map = Cmd_Argv( 1 ); + if( ! strstr( map, "." ) ) + { + my_snprintf( expanded, sizeof( expanded ), "maps/%s.map", map ); + } + else + { + my_snprintf( expanded, sizeof( expanded ), "maps/%s", map ); + } + + +//sv.state = ss_dead; // don't save current level when changing +// SV_WipeSavegame( "current" ); + SV_GameMap_f(); +} + diff --git a/wolf3d/newCode/wolf/wolf_weapon.c b/wolf3d/newCode/wolf/wolf_weapon.c new file mode 100644 index 0000000..4953dfa --- /dev/null +++ b/wolf3d/newCode/wolf/wolf_weapon.c @@ -0,0 +1,194 @@ +/* + + Copyright (C) 2004 Michael Liebscher + Copyright (C) 2000-2002 by DarkOne the Hacker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../wolfiphone.h" + + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void fire_hit( player_t *self ) +{ + entity_t *closest; + int dist, d1, n, shot_dist, damage; + + Sound_StartSound( NULL, 0, CHAN_WEAPON, Sound_RegisterSound( "lsfx/023.wav" ), 1, ATTN_NORM, 0 ); + +// actually fire + dist = 0x7fffffff; + closest = NULL; + + for( n = 0 ; n < NumGuards ; ++n ) + { + if( Guards[ n ].flags & FL_SHOOTABLE ) // && Guards[n].flags&FL_VISABLE + { + shot_dist = Point2LineDist( Guards[ n ].x - self->position.origin[ 0 ], Guards[ n ].y - self->position.origin[ 1 ], self->position.angle ); + + if( shot_dist > (2 * TILEGLOBAL / 3) ) + { + continue; // miss + } + + d1 = LineLen2Point( Guards[ n ].x - self->position.origin[ 0 ], Guards[ n ].y - self->position.origin[ 1 ], self->position.angle ); + + if( d1 < 0 || d1 > dist ) + { + continue; + } + + if( ! Level_CheckLine( Guards[ n ].x, Guards[ n ].y, Player.position.origin[0], Player.position.origin[1], r_world ) ) + { + //if( ! CheckLine( &Guards[ n ] ) ) + continue; // obscured + } + + dist = d1; + closest = &Guards[ n ]; + } + } + + if( ! closest || dist > TILE2POS( 1 ) ) + { + return; // missed if further than 1.5 tiles + } + + damage = US_RndT() >> 4; + + A_DamageActor( closest, damage ); // hit something +} + +/* +----------------------------------------------------------------------------- + Function: + + Parameters: + + Returns: + + Notes: + +----------------------------------------------------------------------------- +*/ +PUBLIC void fire_lead( player_t *self ) +{ + entity_t *closest; + int damage; + int dx, dy, dist; + int d1, shot_dist, n; + + switch( self->weapon ) + { + case WEAPON_PISTOL: + Sound_StartSound( NULL, 0, CHAN_WEAPON, Sound_RegisterSound( "sfx/012.wav" ), 1, ATTN_NORM, 0 ); + break; + + case WEAPON_AUTO: + Sound_StartSound( NULL, 0, CHAN_WEAPON, Sound_RegisterSound( "sfx/011.wav" ), 1, ATTN_NORM, 0 ); + break; + + case WEAPON_CHAIN: + Sound_StartSound( NULL, 0, CHAN_WEAPON, Sound_RegisterSound( "sfx/013.wav" ), 1, ATTN_NORM, 0 ); + break; + } + self->madenoise = true; + + dist = 0x7fffffffl; + closest = NULL; + + for( n = 0 ; n < NumGuards; ++n ) + { + if( Guards[ n ].flags & FL_SHOOTABLE ) // && Guards[n].flags&FL_VISABLE + { + shot_dist = Point2LineDist( Guards[ n ].x - self->position.origin[ 0 ], Guards[ n ].y - self->position.origin[ 1 ], self->position.angle ); + if( shot_dist > (2 * TILEGLOBAL / 3) ) + { + continue; // miss + } + + d1 = LineLen2Point( Guards[ n ].x - self->position.origin[ 0 ], Guards[ n ].y - self->position.origin[ 1 ], self->position.angle ); + if( d1 < 0 || d1 > dist ) + { + continue; + } + + if( ! Level_CheckLine( Guards[ n ].x, Guards[ n ].y, Player.position.origin[0], Player.position.origin[1], r_world ) ) + { + //if( ! CheckLine( &Guards[ n ] ) ) + continue; // obscured + } + + dist = d1; + closest = &Guards[ n ]; + } + } + + if( ! closest ) // missed + { + r_trace_t trace; + + trace.a = NormalizeAngle( self->position.angle - DEG2FINE( 2 ) + rand() % (DEG2FINE( 4 ) ) ); + trace.x = self->position.origin[ 0 ]; + trace.y = self->position.origin[ 1 ]; + trace.flags = TRACE_BULLET; + trace.tile_vis = NULL; + R_Trace( &trace, r_world ); + + if( trace.flags & TRACE_HIT_DOOR ) + { + Sound_StartSound( NULL, 0, CHAN_AUTO, Sound_RegisterSound( "lsfx/028.wav" ), 1, ATTN_NORM, 0 ); + } + return; + } + +// hit something + dx = ABS( closest->tilex - self->tilex ); + dy = ABS( closest->tiley - self->tiley ); + dist = max_of_2( dx, dy ); + + if( dist < 2 ) + { + damage = US_RndT() / 4; + } + else if( dist < 4 ) + { + damage = US_RndT() / 6; + } + else + { + if( US_RndT() / 12 < dist ) + { + return; // missed + } + + damage = US_RndT() / 6; + } + + A_DamageActor( closest, damage ); +} diff --git a/wolf3d/newCode/wolfiphone.h b/wolf3d/newCode/wolfiphone.h new file mode 100644 index 0000000..935a6fb --- /dev/null +++ b/wolf3d/newCode/wolfiphone.h @@ -0,0 +1,87 @@ +/* + * wolfiphone.h + * wolf3d + * + * Created by John Carmack on 3/13/09. + * Copyright 2009 idSoftware. All rights reserved. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "iphone/gles_glue.h" + +#include +#include +#include +#undef ALCAPI +#define ALCAPI + +#include "Tremor/ivorbisfile.h" + +#include "env/arch.h" +#include "env/angle.h" +#include "env/matrix.h" +#include "env/vector.h" +#include "env/mymath.h" +#include "env/common_utils.h" +#include "env/cvar.h" +#include "env/zmem.h" +#include "env/mymath.h" +#include "env/cmd.h" +#include "env/num_type.h" +#include "env/filestring.h" +#include "env/filesystem.h" +#include "env/app_def.h" +#include "env/common.h" +#include "env/video.h" +#include "env/texture_manager.h" +#include "env/font_manager.h" +#include "env/renderer.h" +#include "env/opengl_local.h" +#include "env/timer.h" +#include "env/com_string.h" +#include "env/console.h" +#include "env/sound_local.h" +#include "env/sound.h" +#include "env/memory.h" +#include "env/random_number.h" +#include "env/openal_binding.h" +#include "env/glob.h" +#include "env/opengl_local.h" +#include "env/tga.h" +#include "env/wavfile.h" +#include "env/oggfile.h" + + +#include "wolf/wolf_math.h" +#include "wolf/wolf_level.h" +#include "wolf/wolf_local.h" +#include "wolf/wolf_sprites.h" +#include "wolf/wolf_actors.h" +#include "wolf/wolf_actor_ai.h" +#include "wolf/wolf_player.h" +#include "wolf/wolf_powerups.h" +#include "wolf/wolf_raycast.h" +#include "wolf/wolf_renderer.h" + +#include "iphone/iphone_wolf.h" + diff --git a/wolf3d/readme_iWolf.txt b/wolf3d/readme_iWolf.txt new file mode 100644 index 0000000..e10572c --- /dev/null +++ b/wolf3d/readme_iWolf.txt @@ -0,0 +1,22 @@ + +The original Wolfenstein 3D code was written in late 1991 / early 1992 using 16 bit Turbo C and the TASM assembler and targeted at 286 based MSDOS systems with VGA graphics and ideally a bit of extended or expanded memory. + +I released the original source for Wolfenstein 3D many years ago, originally under a not-for-commercial purposes license, then later under the GPL. The old code is still available in various places ( http://www.btinternet.com/~belowe/ ) but it isn't very useful on modern platforms. There are several open source projects that have modernized the code so that it works on 32 bit systems and can take advantage of OpenGL acceleration. I started the iphone version with the Wolf3D Redux codebase ( http://wolf3dredux.sourceforge.net/ ), which apparently incorporated a lot of code from NewWolf ( http://newwolf.sourceforge.net/ ). + +At first, I considered trying to build the iphone version as a patch, but when I decided to turn the little research project into a commercial release (and do it in a hurry), I started making more wholesale changes. The Redux codebase had basically gutted the Quake 2 codebase and grafted Wolfenstein into it, which had some nice points, but it meant that the system code was many times as large as the actual Wolfenstein game code. It wasn't really hurting anything, and I considered leaving it all in, but it was such a mess that I finally flattened everything out and cut out about half of the environment code. No attempt was made to make this project portable, although it wouldn't be very hard to clean that up. + +In the past, Id source releases did not include any data files, and you had to extract data files from a commercially obtained version of the game if you wanted to experiment with the original game data. Because it isn't possible for users to tear open an app bundle from the App Store to get at the data, I am including it with the source code to make it easy. You are on-your-honor to buy a copy at the App Store before using the data. :-) The source code is under the GPL, but the data is still strictly copyright Id Software with no license given to distribute outside this code release package or to use for any commercial purpose. You are certainly free to replace all the data and make commercial applications, as long as the code is made available under the GPL. + +/newCode/wolf The 32 bit Wolfenstein code +/newCode/env The Quake 2 derived code +/newCode/iphone The newly written iphone code and xcode project files +/newCode/Tremor Unodified ogg Tremor code for the background music +/base Game data + +I can't say there is a lot of really good code here -- the wolf code is mutated, the quake 2 code is vestigial, and the new code was written in a hurry, but it does all hang together as a pretty fun game to play, and a good testbed for various things. + +If anyone does build another quality commercial application based on this code, let us know, and we can probably do some kind of cross linking. + +John Carmack +2009/03/20 +