├── .gitattributes ├── .gitignore ├── LICENSE ├── Makefile ├── additionalparts ├── compile-flags.cmake ├── crt.S-replace ├── kendryte.ld └── readme.md ├── banner.bnr ├── cia.rsf ├── icon.bin ├── icon.png ├── keyboardOverlay.bin ├── make_cia.sh ├── readme.md ├── source ├── Makefile ├── adivtab.h ├── anorm_dots.h ├── anorms.h ├── block16.h ├── block8.h ├── board_config.h ├── bspfile.h ├── ccsbcs.c ├── cd_null.c ├── cdaudio.h ├── chase.c ├── cl_demo.c ├── cl_input.c ├── cl_main.c ├── cl_parse.c ├── cl_tent.c ├── client.h ├── cmd.c ├── cmd.h ├── common.c ├── common.h ├── conproc.h ├── console.c ├── console.h ├── crc.c ├── crc.h ├── ctr.h ├── cvar.c ├── cvar.h ├── d_edge.c ├── d_fill.c ├── d_iface.h ├── d_ifacea.h ├── d_init.c ├── d_local.h ├── d_modech.c ├── d_part.c ├── d_polyse.c ├── d_scan.c ├── d_sky.c ├── d_sprite.c ├── d_surf.c ├── d_vars.c ├── d_zpoint.c ├── diskio.c ├── diskio.h ├── draw.c ├── draw.h ├── dualshock2.c ├── dualshock2.h ├── ff.c ├── ff.h ├── ffconf.h ├── file.c ├── font.h ├── host.c ├── host_cmd.c ├── in_ctr.c ├── input.h ├── integer.h ├── k210.c ├── keys.c ├── keys.h ├── lcd.c ├── lcd.h ├── mathlib.c ├── mathlib.h ├── menu.c ├── menu.h ├── model.c ├── model.h ├── modelgen.h ├── mpdosock.h ├── net.h ├── net_bsd.c ├── net_dgrm.c ├── net_dgrm.h ├── net_loop.c ├── net_loop.h ├── net_main.c ├── net_mp.h ├── net_udp.h ├── net_vcr.c ├── net_vcr.h ├── nonintel.c ├── nt35310.c ├── nt35310.h ├── pr_cmds.c ├── pr_comp.h ├── pr_edict.c ├── pr_exec.c ├── progdefs.h ├── progdefs.q1 ├── progdefs.q2 ├── progs.h ├── protocol.h ├── quakedef.h ├── r_aclip.c ├── r_alias.c ├── r_bsp.c ├── r_draw.c ├── r_edge.c ├── r_efrag.c ├── r_light.c ├── r_local.h ├── r_main.c ├── r_misc.c ├── r_part.c ├── r_shared.h ├── r_sky.c ├── r_sprite.c ├── r_surf.c ├── r_vars.c ├── render.h ├── resource.h ├── sbar.c ├── sbar.h ├── screen.c ├── screen.h ├── sdcard.c ├── sdcard.h ├── server.h ├── snd_ctr.c ├── snd_dma.c ├── snd_mem.c ├── snd_mix.c ├── sound.h ├── source ├── spritegn.h ├── sv_main.c ├── sv_move.c ├── sv_phys.c ├── sv_user.c ├── sys.h ├── sys_ctr.c ├── touch_ctr.h ├── vid.h ├── vid_ctr.c ├── view.c ├── view.h ├── vregset.h ├── wad.c ├── wad.h ├── winquake.h ├── world.c ├── world.h ├── zone.c └── zone.h ├── tf.xml └── touchOverlay.bin /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | 46 | *~ 47 | *.o 48 | GPATH 49 | GRTAGS 50 | GTAGS 51 | a.out 52 | *.exe 53 | *.bat 54 | *.dll 55 | *.com 56 | opengl32.old 57 | id1 58 | *.vxd 59 | source/docs 60 | *.pif 61 | *.dat 62 | *.wad -------------------------------------------------------------------------------- /additionalparts/compile-flags.cmake: -------------------------------------------------------------------------------- 1 | add_compile_flags(LD 2 | -nostartfiles 3 | -static 4 | -Wl,--gc-sections 5 | -Wl,-static 6 | -Wl,--start-group 7 | -Wl,--whole-archive 8 | -Wl,--no-whole-archive 9 | -Wl,--end-group 10 | -Wl,-EL 11 | -Wl,--no-relax 12 | -T ${SDK_ROOT}/lds/kendryte.ld 13 | ) 14 | 15 | # C Flags Settings 16 | add_compile_flags(BOTH 17 | -mcmodel=medany 18 | -fno-common 19 | -ffunction-sections 20 | -fdata-sections 21 | -fno-exceptions 22 | -fstrict-volatile-bitfields 23 | -fno-zero-initialized-in-bss 24 | -Os 25 | -ggdb 26 | ) 27 | 28 | add_compile_flags(C -std=gnu11 -Wno-pointer-to-int-cast) 29 | add_compile_flags(CXX -std=gnu++17) 30 | 31 | if (BUILDING_SDK) 32 | add_compile_flags(BOTH 33 | -Wall 34 | # -Werror=all 35 | -Wno-stringop-truncation 36 | -Wno-error=maybe-uninitialized 37 | -Wno-error=nonnull 38 | -Wno-error=parentheses 39 | -Wno-error=unused-value 40 | -Wno-error=format-overflow 41 | -Wno-error=unused-function 42 | -Wno-error=unused-but-set-variable 43 | -Wno-error=unused-variable 44 | -Wno-error=deprecated-declarations 45 | -Wno-error=restrict 46 | -Wno-error=trigraphs 47 | -Wextra 48 | -Wno-unused-parameter 49 | -Wno-sign-compare 50 | -Wno-error=missing-braces 51 | -Wno-error=return-type 52 | -Wno-error=pointer-sign 53 | -Wno-missing-braces 54 | -Wno-strict-aliasing 55 | -Wno-implicit-fallthrough 56 | -Wno-missing-field-initializers 57 | -Wno-int-to-pointer-cast 58 | ) 59 | 60 | add_compile_flags(C -Wno-old-style-declaration) 61 | else () 62 | add_compile_flags(BOTH -L${SDK_ROOT}/include/) 63 | endif () 64 | 65 | -------------------------------------------------------------------------------- /additionalparts/readme.md: -------------------------------------------------------------------------------- 1 | ### stack memory 2 | This program needs lot of stack memory(need 512KB, but 32KB in original SDK configulation). 3 | Use these files to expand stack memory. 4 | 5 | crt.S ... new startup routine, override `lib/bsp/crt.S` 6 | kendryte.ld ... new linker script, override `lds/kendryte.ld` 7 | 8 | ### compile flags 9 | This source code is too old, so use new `compile-flags.cmake` in the `cmake` directory. 10 | -------------------------------------------------------------------------------- /banner.bnr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elect-gombe/quake-k210/1538fee4f0a5e77dad21216e4760e7ce0be66e0d/banner.bnr -------------------------------------------------------------------------------- /icon.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elect-gombe/quake-k210/1538fee4f0a5e77dad21216e4760e7ce0be66e0d/icon.bin -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elect-gombe/quake-k210/1538fee4f0a5e77dad21216e4760e7ce0be66e0d/icon.png -------------------------------------------------------------------------------- /keyboardOverlay.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elect-gombe/quake-k210/1538fee4f0a5e77dad21216e4760e7ce0be66e0d/keyboardOverlay.bin -------------------------------------------------------------------------------- /make_cia.sh: -------------------------------------------------------------------------------- 1 | makerom -f cia -o ctrQuake.cia -elf ctrQuake.elf -rsf cia.rsf -banner banner.bnr -icon icon.bin -exefslogo -target t -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Quake for k210 2 | Dualshock2 is now supported! I've tested E1 at shareware mode. 3 | The framerate is very stable(25~70fps), and it definitely playable. 4 | 5 | Note that controls and brightness can change at options menu. 6 | ## Default key configulation 7 | ### buttons 8 | - Start ... Enter 9 | - Select ... Esc 10 | - directional button ... Arrow 11 | Other buttons are as it's name. (L1, L2, L3, R1, ..., Circle, ...) 12 | 13 | ### Analog sticks 14 | This functions is fixed by code. 15 | - Left stick ... Move 16 | - Right stick ... Camera 17 | 18 | ## build 19 | - Stack memory is expanded, 20 | - compile error is supressed by compile flags 21 | visit `additionalparts/readme.md` to build this program. 22 | 23 | ## install 24 | 1. copy id1/pak?.pak to your SD. You can DL the package file in the official Quake shareware, or use full package file(s). 25 | 2. connect your dualshock2 to k210. 26 | See `source/k210.c`. 27 | ```c 28 | fpioa_set_function(18, FUNC_GPIOHS0 + DS2_CS); //Dualshock2 ss 29 | fpioa_set_function(19, FUNC_GPIOHS0 + DS2_CLK); //clk 30 | fpioa_set_function(21, FUNC_GPIOHS0 + DS2_MOSI); //mosi--DO/CMD 31 | fpioa_set_function(20, FUNC_GPIOHS0 + DS2_MISO); //miso--DI/DAT 32 | ``` 33 | 3. Set each of jump, Atack and switch weapon function to the button(s). 34 | 35 | ## implementation note 36 | - AI memory is used in general purpose. 37 | 38 | ## todo 39 | - [X] fix stack setup. use `_sp0`, `_sp1`, etc. => done 40 | - [X] key input, use game controller. => done 41 | - [ ] Sound controller 42 | - [ ] save (file write functions) 43 | - [ ] key asign (plz set up your configulation at option menu.) 44 | - [ ] Adjust stick sensitiveness 45 | 46 | ## Credits 47 | ### original crtQuake (3DS port) 48 | Felipe Izzo (MasterFeizz) - Main developer 49 | Rinnegatamante - Sound enhancements 50 | ## Thanks to 51 | Id Software - Source code of Quake 52 | -------------------------------------------------------------------------------- /source/Makefile: -------------------------------------------------------------------------------- 1 | OBJ = chase.o \ 2 | cl_demo.o \ 3 | cl_input.o \ 4 | cl_main.o \ 5 | cl_parse.o \ 6 | cl_tent.o \ 7 | cmd.o \ 8 | common.o \ 9 | console.o \ 10 | crc.o \ 11 | cvar.o \ 12 | host.o \ 13 | host_cmd.o \ 14 | keys.o \ 15 | mathlib.o \ 16 | menu.o \ 17 | net_dgrm.o \ 18 | net_loop.o \ 19 | net_main.o \ 20 | net_vcr.o \ 21 | pr_cmds.o \ 22 | pr_edict.o \ 23 | pr_exec.o \ 24 | r_part.o \ 25 | sbar.o \ 26 | sv_main.o \ 27 | sv_move.o \ 28 | sv_phys.o \ 29 | sv_user.o \ 30 | view.o \ 31 | wad.o \ 32 | world.o \ 33 | zone.o \ 34 | sys_ctr.o \ 35 | d_edge.o \ 36 | d_fill.o \ 37 | d_init.o \ 38 | d_modech.o \ 39 | d_part.o \ 40 | d_polyse.o \ 41 | d_scan.o \ 42 | d_sky.o \ 43 | d_sprite.o \ 44 | d_surf.o \ 45 | d_vars.o \ 46 | d_zpoint.o \ 47 | draw.o \ 48 | model.o \ 49 | nonintel.o \ 50 | r_aclip.o \ 51 | r_alias.o \ 52 | r_bsp.o \ 53 | r_draw.o \ 54 | r_edge.o \ 55 | r_efrag.o \ 56 | r_light.o \ 57 | r_main.o \ 58 | r_misc.o \ 59 | r_sky.o \ 60 | r_sprite.o \ 61 | r_surf.o \ 62 | r_vars.o \ 63 | screen.o \ 64 | snd_dma.o \ 65 | snd_mix.o \ 66 | snd_mem.o \ 67 | snd_ctr.o \ 68 | vid_ctr.o \ 69 | net_bsd.o \ 70 | net_udpctr.o \ 71 | in_ctr.o \ 72 | cd_null.o \ 73 | lcd.o 74 | 75 | CFLAGS = -Og -g3 -DPC -DUSE_SDL 76 | .SUFFIXES: .c .o 77 | 78 | # プライマリターゲット 79 | a.out: $(OBJ) 80 | $(CC) $^ -lm -lSDL2 81 | 82 | # サフィックスルール 83 | .c.o: 84 | gcc $(CFLAGS) -c $< 85 | -------------------------------------------------------------------------------- /source/block16.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | LEnter16_16: 21 | movb (%esi),%al 22 | movb (%esi,%ebx,),%cl 23 | movb %dh,%ah 24 | addl %ebp,%edx 25 | movb %dh,%ch 26 | leal (%esi,%ebx,2),%esi 27 | movw 0x12345678(,%eax,2),%ax 28 | LBPatch0: 29 | addl %ebp,%edx 30 | movw %ax,(%edi) 31 | movw 0x12345678(,%ecx,2),%cx 32 | LBPatch1: 33 | movw %cx,2(%edi) 34 | addl $0x4,%edi 35 | 36 | movb (%esi),%al 37 | movb (%esi,%ebx,),%cl 38 | movb %dh,%ah 39 | addl %ebp,%edx 40 | movb %dh,%ch 41 | leal (%esi,%ebx,2),%esi 42 | movw 0x12345678(,%eax,2),%ax 43 | LBPatch2: 44 | addl %ebp,%edx 45 | movw %ax,(%edi) 46 | movw 0x12345678(,%ecx,2),%cx 47 | LBPatch3: 48 | movw %cx,2(%edi) 49 | addl $0x4,%edi 50 | 51 | movb (%esi),%al 52 | movb (%esi,%ebx,),%cl 53 | movb %dh,%ah 54 | addl %ebp,%edx 55 | movb %dh,%ch 56 | leal (%esi,%ebx,2),%esi 57 | movw 0x12345678(,%eax,2),%ax 58 | LBPatch4: 59 | addl %ebp,%edx 60 | movw %ax,(%edi) 61 | movw 0x12345678(,%ecx,2),%cx 62 | LBPatch5: 63 | movw %cx,2(%edi) 64 | addl $0x4,%edi 65 | 66 | movb (%esi),%al 67 | movb (%esi,%ebx,),%cl 68 | movb %dh,%ah 69 | addl %ebp,%edx 70 | movb %dh,%ch 71 | leal (%esi,%ebx,2),%esi 72 | movw 0x12345678(,%eax,2),%ax 73 | LBPatch6: 74 | addl %ebp,%edx 75 | movw %ax,(%edi) 76 | movw 0x12345678(,%ecx,2),%cx 77 | LBPatch7: 78 | movw %cx,2(%edi) 79 | addl $0x4,%edi 80 | 81 | LEnter8_16: 82 | movb (%esi),%al 83 | movb (%esi,%ebx,),%cl 84 | movb %dh,%ah 85 | addl %ebp,%edx 86 | movb %dh,%ch 87 | leal (%esi,%ebx,2),%esi 88 | movw 0x12345678(,%eax,2),%ax 89 | LBPatch8: 90 | addl %ebp,%edx 91 | movw %ax,(%edi) 92 | movw 0x12345678(,%ecx,2),%cx 93 | LBPatch9: 94 | movw %cx,2(%edi) 95 | addl $0x4,%edi 96 | 97 | movb (%esi),%al 98 | movb (%esi,%ebx,),%cl 99 | movb %dh,%ah 100 | addl %ebp,%edx 101 | movb %dh,%ch 102 | leal (%esi,%ebx,2),%esi 103 | movw 0x12345678(,%eax,2),%ax 104 | LBPatch10: 105 | addl %ebp,%edx 106 | movw %ax,(%edi) 107 | movw 0x12345678(,%ecx,2),%cx 108 | LBPatch11: 109 | movw %cx,2(%edi) 110 | addl $0x4,%edi 111 | 112 | LEnter4_16: 113 | movb (%esi),%al 114 | movb (%esi,%ebx,),%cl 115 | movb %dh,%ah 116 | addl %ebp,%edx 117 | movb %dh,%ch 118 | leal (%esi,%ebx,2),%esi 119 | movw 0x12345678(,%eax,2),%ax 120 | LBPatch12: 121 | addl %ebp,%edx 122 | movw %ax,(%edi) 123 | movw 0x12345678(,%ecx,2),%cx 124 | LBPatch13: 125 | movw %cx,2(%edi) 126 | addl $0x4,%edi 127 | 128 | LEnter2_16: 129 | movb (%esi),%al 130 | movb (%esi,%ebx,),%cl 131 | movb %dh,%ah 132 | addl %ebp,%edx 133 | movb %dh,%ch 134 | leal (%esi,%ebx,2),%esi 135 | movw 0x12345678(,%eax,2),%ax 136 | LBPatch14: 137 | addl %ebp,%edx 138 | movw %ax,(%edi) 139 | movw 0x12345678(,%ecx,2),%cx 140 | LBPatch15: 141 | movw %cx,2(%edi) 142 | addl $0x4,%edi 143 | -------------------------------------------------------------------------------- /source/block8.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | LEnter16_8: 21 | movb (%esi),%al 22 | movb (%esi,%ebx,),%cl 23 | movb %dh,%ah 24 | addl %ebp,%edx 25 | movb %dh,%ch 26 | leal (%esi,%ebx,2),%esi 27 | movb 0x12345678(%eax),%al 28 | LBPatch0: 29 | addl %ebp,%edx 30 | movb %al,(%edi) 31 | movb 0x12345678(%ecx),%cl 32 | LBPatch1: 33 | movb %cl,1(%edi) 34 | addl $0x2,%edi 35 | 36 | movb (%esi),%al 37 | movb (%esi,%ebx,),%cl 38 | movb %dh,%ah 39 | addl %ebp,%edx 40 | movb %dh,%ch 41 | leal (%esi,%ebx,2),%esi 42 | movb 0x12345678(%eax),%al 43 | LBPatch2: 44 | addl %ebp,%edx 45 | movb %al,(%edi) 46 | movb 0x12345678(%ecx),%cl 47 | LBPatch3: 48 | movb %cl,1(%edi) 49 | addl $0x2,%edi 50 | 51 | movb (%esi),%al 52 | movb (%esi,%ebx,),%cl 53 | movb %dh,%ah 54 | addl %ebp,%edx 55 | movb %dh,%ch 56 | leal (%esi,%ebx,2),%esi 57 | movb 0x12345678(%eax),%al 58 | LBPatch4: 59 | addl %ebp,%edx 60 | movb %al,(%edi) 61 | movb 0x12345678(%ecx),%cl 62 | LBPatch5: 63 | movb %cl,1(%edi) 64 | addl $0x2,%edi 65 | 66 | movb (%esi),%al 67 | movb (%esi,%ebx,),%cl 68 | movb %dh,%ah 69 | addl %ebp,%edx 70 | movb %dh,%ch 71 | leal (%esi,%ebx,2),%esi 72 | movb 0x12345678(%eax),%al 73 | LBPatch6: 74 | addl %ebp,%edx 75 | movb %al,(%edi) 76 | movb 0x12345678(%ecx),%cl 77 | LBPatch7: 78 | movb %cl,1(%edi) 79 | addl $0x2,%edi 80 | 81 | LEnter8_8: 82 | movb (%esi),%al 83 | movb (%esi,%ebx,),%cl 84 | movb %dh,%ah 85 | addl %ebp,%edx 86 | movb %dh,%ch 87 | leal (%esi,%ebx,2),%esi 88 | movb 0x12345678(%eax),%al 89 | LBPatch8: 90 | addl %ebp,%edx 91 | movb %al,(%edi) 92 | movb 0x12345678(%ecx),%cl 93 | LBPatch9: 94 | movb %cl,1(%edi) 95 | addl $0x2,%edi 96 | 97 | movb (%esi),%al 98 | movb (%esi,%ebx,),%cl 99 | movb %dh,%ah 100 | addl %ebp,%edx 101 | movb %dh,%ch 102 | leal (%esi,%ebx,2),%esi 103 | movb 0x12345678(%eax),%al 104 | LBPatch10: 105 | addl %ebp,%edx 106 | movb %al,(%edi) 107 | movb 0x12345678(%ecx),%cl 108 | LBPatch11: 109 | movb %cl,1(%edi) 110 | addl $0x2,%edi 111 | 112 | LEnter4_8: 113 | movb (%esi),%al 114 | movb (%esi,%ebx,),%cl 115 | movb %dh,%ah 116 | addl %ebp,%edx 117 | movb %dh,%ch 118 | leal (%esi,%ebx,2),%esi 119 | movb 0x12345678(%eax),%al 120 | LBPatch12: 121 | addl %ebp,%edx 122 | movb %al,(%edi) 123 | movb 0x12345678(%ecx),%cl 124 | LBPatch13: 125 | movb %cl,1(%edi) 126 | addl $0x2,%edi 127 | 128 | LEnter2_8: 129 | movb (%esi),%al 130 | movb (%esi,%ebx,),%cl 131 | movb %dh,%ah 132 | addl %ebp,%edx 133 | movb %dh,%ch 134 | leal (%esi,%ebx,2),%esi 135 | movb 0x12345678(%eax),%al 136 | LBPatch14: 137 | addl %ebp,%edx 138 | movb %al,(%edi) 139 | movb 0x12345678(%ecx),%cl 140 | LBPatch15: 141 | movb %cl,1(%edi) 142 | addl $0x2,%edi 143 | 144 | -------------------------------------------------------------------------------- /source/board_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOARD_CONFIG_ 2 | #define _BOARD_CONFIG_ 3 | 4 | #define OV5640 0 5 | #define OV2640 1 6 | 7 | #define BOARD_KD233 0 8 | #define BOARD_LICHEEDAN 1 9 | #define BOARD_K61 0 10 | 11 | #if (OV5640 && OV2640) || (!OV5640 && !OV2640) 12 | #error ov sensor only choose one 13 | #endif 14 | 15 | #if (BOARD_LICHEEDAN && BOARD_KD233) || (BOARD_LICHEEDAN && BOARD_K61) || (BOARD_K61 && BOARD_KD233) || (!BOARD_LICHEEDAN && !BOARD_KD233 && !BOARD_K61) 16 | #error board only choose one 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /source/cd_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #include "quakedef.h" 21 | 22 | void CDAudio_Play(byte track, qboolean looping) 23 | { 24 | } 25 | 26 | 27 | void CDAudio_Stop(void) 28 | { 29 | } 30 | 31 | 32 | void CDAudio_Pause(void) 33 | { 34 | } 35 | 36 | 37 | void CDAudio_Resume(void) 38 | { 39 | } 40 | 41 | 42 | void CDAudio_Update(void) 43 | { 44 | } 45 | 46 | 47 | int CDAudio_Init(void) 48 | { 49 | return 0; 50 | } 51 | 52 | 53 | void CDAudio_Shutdown(void) 54 | { 55 | } -------------------------------------------------------------------------------- /source/cdaudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | int CDAudio_Init(void); 22 | void CDAudio_Play(byte track, qboolean looping); 23 | void CDAudio_Stop(void); 24 | void CDAudio_Pause(void); 25 | void CDAudio_Resume(void); 26 | void CDAudio_Shutdown(void); 27 | void CDAudio_Update(void); 28 | -------------------------------------------------------------------------------- /source/chase.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // chase.c -- chase camera code 21 | 22 | #include "quakedef.h" 23 | 24 | cvar_t chase_back = {"chase_back", "100"}; 25 | cvar_t chase_up = {"chase_up", "16"}; 26 | cvar_t chase_right = {"chase_right", "0"}; 27 | cvar_t chase_active = {"chase_active", "0"}; 28 | 29 | vec3_t chase_pos; 30 | vec3_t chase_angles; 31 | 32 | vec3_t chase_dest; 33 | vec3_t chase_dest_angles; 34 | 35 | 36 | void Chase_Init (void) 37 | { 38 | Cvar_RegisterVariable (&chase_back); 39 | Cvar_RegisterVariable (&chase_up); 40 | Cvar_RegisterVariable (&chase_right); 41 | Cvar_RegisterVariable (&chase_active); 42 | } 43 | 44 | void Chase_Reset (void) 45 | { 46 | // for respawning and teleporting 47 | // start position 12 units behind head 48 | } 49 | qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace); 50 | 51 | void TraceLine (vec3_t start, vec3_t end, vec3_t impact) 52 | { 53 | trace_t trace; 54 | 55 | memset (&trace, 0, sizeof(trace)); 56 | SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace); 57 | 58 | VectorCopy (trace.endpos, impact); 59 | } 60 | 61 | void Chase_Update (void) 62 | { 63 | int i; 64 | float dist; 65 | vec3_t forward, up, right; 66 | vec3_t dest, stop; 67 | 68 | 69 | // if can't see player, reset 70 | AngleVectors (cl.viewangles, forward, right, up); 71 | 72 | // calc exact destination 73 | for (i=0 ; i<3 ; i++) 74 | chase_dest[i] = r_refdef.vieworg[i] 75 | - forward[i]*chase_back.value 76 | - right[i]*chase_right.value; 77 | chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; 78 | 79 | // find the spot the player is looking at 80 | VectorMA (r_refdef.vieworg, 4096, forward, dest); 81 | TraceLine (r_refdef.vieworg, dest, stop); 82 | 83 | // calculate pitch to look at the same spot from camera 84 | VectorSubtract (stop, r_refdef.vieworg, stop); 85 | dist = DotProduct (stop, forward); 86 | if (dist < 1) 87 | dist = 1; 88 | r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; 89 | 90 | // move towards destination 91 | VectorCopy (chase_dest, r_refdef.vieworg); 92 | } 93 | 94 | -------------------------------------------------------------------------------- /source/cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // cmd.h -- Command buffer and command execution 22 | 23 | //=========================================================================== 24 | 25 | /* 26 | 27 | Any number of commands can be added in a frame, from several different sources. 28 | Most commands come from either keybindings or console line input, but remote 29 | servers can also send across commands and entire text files can be execed. 30 | 31 | The + command line options are also added to the command buffer. 32 | 33 | The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute (); 34 | 35 | */ 36 | 37 | 38 | void Cbuf_Init (void); 39 | // allocates an initial text buffer that will grow as needed 40 | 41 | void Cbuf_AddText (char *text); 42 | // as new commands are generated from the console or keybindings, 43 | // the text is added to the end of the command buffer. 44 | 45 | void Cbuf_InsertText (char *text); 46 | // when a command wants to issue other commands immediately, the text is 47 | // inserted at the beginning of the buffer, before any remaining unexecuted 48 | // commands. 49 | 50 | void Cbuf_Execute (void); 51 | // Pulls off \n terminated lines of text from the command buffer and sends 52 | // them through Cmd_ExecuteString. Stops when the buffer is empty. 53 | // Normally called once per frame, but may be explicitly invoked. 54 | // Do not call inside a command function! 55 | 56 | //=========================================================================== 57 | 58 | /* 59 | 60 | Command execution takes a null terminated string, breaks it into tokens, 61 | then searches for a command or variable that matches the first token. 62 | 63 | Commands can come from three sources, but the handler functions may choose 64 | to dissallow the action or forward it to a remote server if the source is 65 | not apropriate. 66 | 67 | */ 68 | 69 | typedef void (*xcommand_t) (void); 70 | 71 | typedef enum 72 | { 73 | src_client, // came in over a net connection as a clc_stringcmd 74 | // host_client will be valid during this state. 75 | src_command // from the command buffer 76 | } cmd_source_t; 77 | 78 | extern cmd_source_t cmd_source; 79 | 80 | void Cmd_Init (void); 81 | 82 | void Cmd_AddCommand (char *cmd_name, xcommand_t function); 83 | // called by the init functions of other parts of the program to 84 | // register commands and functions to call for them. 85 | // The cmd_name is referenced later, so it should not be in temp memory 86 | 87 | qboolean Cmd_Exists (char *cmd_name); 88 | // used by the cvar code to check for cvar / command name overlap 89 | 90 | char *Cmd_CompleteCommand (char *partial); 91 | // attempts to match a partial command for automatic command line completion 92 | // returns NULL if nothing fits 93 | 94 | int Cmd_Argc (void); 95 | char *Cmd_Argv (int arg); 96 | char *Cmd_Args (void); 97 | // The functions that execute commands get their parameters with these 98 | // functions. Cmd_Argv () will return an empty string, not a NULL 99 | // if arg > argc, so string operations are allways safe. 100 | 101 | int Cmd_CheckParm (char *parm); 102 | // Returns the position (1 to argc-1) in the command's argument list 103 | // where the given parameter apears, or 0 if not present 104 | 105 | void Cmd_TokenizeString (char *text); 106 | // Takes a null terminated string. Does not need to be /n terminated. 107 | // breaks the string up into arg tokens. 108 | 109 | void Cmd_ExecuteString (char *text, cmd_source_t src); 110 | // Parses a single line of text into arguments and tries to execute it. 111 | // The text can come from the command buffer, a remote client, or stdin. 112 | 113 | void Cmd_ForwardToServer (void); 114 | // adds the current command line as a clc_stringcmd to the client message. 115 | // things like godmode, noclip, etc, are commands directed to the server, 116 | // so when they are typed in at the console, they will need to be forwarded. 117 | 118 | void Cmd_Print (char *text); 119 | // used by command functions to send output to either the graphics console or 120 | // passed as a print message to the client 121 | 122 | -------------------------------------------------------------------------------- /source/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // comndef.h -- general definitions 21 | 22 | //Debug function for 3DS 23 | #define DEBUG(func) (printf("%s\n", #func), func) 24 | 25 | #if !defined BYTE_DEFINED 26 | typedef unsigned char byte; 27 | #define BYTE_DEFINED 1 28 | #endif 29 | 30 | #undef true 31 | #undef false 32 | 33 | typedef enum {false, true} qboolean; 34 | 35 | //============================================================================ 36 | 37 | typedef struct sizebuf_s 38 | { 39 | qboolean allowoverflow; // if false, do a Sys_Error 40 | qboolean overflowed; // set to true if the buffer size failed 41 | byte *data; 42 | int maxsize; 43 | int cursize; 44 | } sizebuf_t; 45 | 46 | void SZ_Alloc (sizebuf_t *buf, int startsize); 47 | void SZ_Free (sizebuf_t *buf); 48 | void SZ_Clear (sizebuf_t *buf); 49 | void *SZ_GetSpace (sizebuf_t *buf, int length); 50 | void SZ_Write (sizebuf_t *buf, void *data, int length); 51 | void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf 52 | 53 | //============================================================================ 54 | 55 | typedef struct link_s 56 | { 57 | struct link_s *prev, *next; 58 | } link_t; 59 | 60 | 61 | void ClearLink (link_t *l); 62 | void RemoveLink (link_t *l); 63 | void InsertLinkBefore (link_t *l, link_t *before); 64 | void InsertLinkAfter (link_t *l, link_t *after); 65 | 66 | // (type *)STRUCT_FROM_LINK(link_t *link, type, member) 67 | // ent = STRUCT_FROM_LINK(link,entity_t,order) 68 | // FIXME: remove this mess! 69 | #define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) 70 | 71 | //============================================================================ 72 | 73 | #ifndef NULL 74 | #define NULL ((void *)0) 75 | #endif 76 | 77 | #define Q_MAXCHAR ((char)0x7f) 78 | #define Q_MAXSHORT ((short)0x7fff) 79 | #define Q_MAXINT ((int)0x7fffffff) 80 | #define Q_MAXLONG ((int)0x7fffffff) 81 | #define Q_MAXFLOAT ((int)0x7fffffff) 82 | 83 | #define Q_MINCHAR ((char)0x80) 84 | #define Q_MINSHORT ((short)0x8000) 85 | #define Q_MININT ((int)0x80000000) 86 | #define Q_MINLONG ((int)0x80000000) 87 | #define Q_MINFLOAT ((int)0x7fffffff) 88 | 89 | //============================================================================ 90 | 91 | extern qboolean bigendien; 92 | 93 | extern short (*BigShort) (short l); 94 | extern short (*LittleShort) (short l); 95 | extern int (*BigLong) (int l); 96 | extern int (*LittleLong) (int l); 97 | extern float (*BigFloat) (float l); 98 | extern float (*LittleFloat) (float l); 99 | 100 | //============================================================================ 101 | 102 | void MSG_WriteChar (sizebuf_t *sb, int c); 103 | void MSG_WriteByte (sizebuf_t *sb, int c); 104 | void MSG_WriteShort (sizebuf_t *sb, int c); 105 | void MSG_WriteLong (sizebuf_t *sb, int c); 106 | void MSG_WriteFloat (sizebuf_t *sb, float f); 107 | void MSG_WriteString (sizebuf_t *sb, char *s); 108 | void MSG_WriteCoord (sizebuf_t *sb, float f); 109 | void MSG_WriteAngle (sizebuf_t *sb, float f); 110 | 111 | extern int msg_readcount; 112 | extern qboolean msg_badread; // set if a read goes beyond end of message 113 | 114 | void MSG_BeginReading (void); 115 | int MSG_ReadChar (void); 116 | int MSG_ReadByte (void); 117 | int MSG_ReadShort (void); 118 | int MSG_ReadLong (void); 119 | float MSG_ReadFloat (void); 120 | char *MSG_ReadString (void); 121 | 122 | float MSG_ReadCoord (void); 123 | float MSG_ReadAngle (void); 124 | 125 | extern char com_token[1024]; 126 | extern qboolean com_eof; 127 | 128 | char *COM_Parse (char *data); 129 | 130 | 131 | extern int com_argc; 132 | extern char **com_argv; 133 | 134 | int COM_CheckParm (char *parm); 135 | void COM_Init (char *path); 136 | void COM_InitArgv (int argc, char **argv); 137 | 138 | char *COM_SkipPath (char *pathname); 139 | void COM_StripExtension (char *in, char *out); 140 | void COM_FileBase (char *in, char *out); 141 | void COM_DefaultExtension (char *path, char *extension); 142 | 143 | char *va(char *format, ...); 144 | // does a varargs printf into a temp buffer 145 | 146 | 147 | //============================================================================ 148 | 149 | extern int com_filesize; 150 | struct cache_user_s; 151 | 152 | extern char com_gamedir[MAX_OSPATH]; 153 | 154 | void COM_WriteFile (char *filename, void *data, int len); 155 | int COM_OpenFile (char *filename, int *hndl); 156 | int COM_FOpenFile (char *filename, FILE **file); 157 | void COM_CloseFile (int h); 158 | 159 | byte *COM_LoadStackFile (char *path, void *buffer, int bufsize); 160 | byte *COM_LoadTempFile (char *path); 161 | byte *COM_LoadHunkFile (char *path); 162 | void COM_LoadCacheFile (char *path, struct cache_user_s *cu); 163 | 164 | 165 | extern struct cvar_s registered; 166 | 167 | extern qboolean standard_quake, rogue, hipnotic; 168 | -------------------------------------------------------------------------------- /source/conproc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // conproc.h 21 | 22 | #define CCOM_WRITE_TEXT 0x2 23 | // Param1 : Text 24 | 25 | #define CCOM_GET_TEXT 0x3 26 | // Param1 : Begin line 27 | // Param2 : End line 28 | 29 | #define CCOM_GET_SCR_LINES 0x4 30 | // No params 31 | 32 | #define CCOM_SET_SCR_LINES 0x5 33 | // Param1 : Number of lines 34 | 35 | void InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild); 36 | void DeinitConProc (void); 37 | 38 | -------------------------------------------------------------------------------- /source/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // 22 | // console 23 | // 24 | extern int con_totallines; 25 | extern int con_backscroll; 26 | extern qboolean con_forcedup; // because no entities to refresh 27 | extern qboolean con_initialized; 28 | extern byte *con_chars; 29 | extern int con_notifylines; // scan lines to clear for notify lines 30 | 31 | void Con_DrawCharacter (int cx, int line, int num); 32 | 33 | void Con_CheckResize (void); 34 | void Con_Init (void); 35 | void Con_DrawConsole (int lines, qboolean drawinput); 36 | void Con_Print (char *txt); 37 | void Con_Printf (char *fmt, ...); 38 | void Con_DPrintf (char *fmt, ...); 39 | void Con_SafePrintf (char *fmt, ...); 40 | void Con_Clear_f (void); 41 | void Con_DrawNotify (void); 42 | void Con_ClearNotify (void); 43 | void Con_ToggleConsole_f (void); 44 | 45 | void Con_NotifyBox (char *text); // during startup for sound / cd warnings 46 | 47 | -------------------------------------------------------------------------------- /source/crc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* crc.c */ 21 | 22 | #include "quakedef.h" 23 | #include "crc.h" 24 | 25 | // this is a 16 bit, non-reflected CRC using the polynomial 0x1021 26 | // and the initial and final xor values shown below... in other words, the 27 | // CCITT standard CRC used by XMODEM 28 | 29 | #define CRC_INIT_VALUE 0xffff 30 | #define CRC_XOR_VALUE 0x0000 31 | 32 | static unsigned short crctable[256] = 33 | { 34 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 35 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 36 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 37 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 38 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 39 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 40 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 41 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 42 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 43 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 44 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 45 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 46 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 47 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 48 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 49 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 50 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 51 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 52 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 53 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 54 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 55 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 56 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 57 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 58 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 59 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 60 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 61 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 62 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 63 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 64 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 65 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 66 | }; 67 | 68 | void CRC_Init(unsigned short *crcvalue) 69 | { 70 | *crcvalue = CRC_INIT_VALUE; 71 | } 72 | 73 | void CRC_ProcessByte(unsigned short *crcvalue, byte data) 74 | { 75 | *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; 76 | } 77 | 78 | unsigned short CRC_Value(unsigned short crcvalue) 79 | { 80 | return crcvalue ^ CRC_XOR_VALUE; 81 | } -------------------------------------------------------------------------------- /source/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* crc.h */ 21 | 22 | void CRC_Init(unsigned short *crcvalue); 23 | void CRC_ProcessByte(unsigned short *crcvalue, byte data); 24 | unsigned short CRC_Value(unsigned short crcvalue); 25 | -------------------------------------------------------------------------------- /source/ctr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Felipe Izzo 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* crc.h */ 21 | #ifndef __CTR__ 22 | #define __CTR__ 23 | 24 | //extern u8 isN3DS; 25 | 26 | void ctrDrawTouchOverlay(); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /source/cvar.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // cvar.c -- dynamic variable tracking 21 | 22 | #include "quakedef.h" 23 | 24 | cvar_t *cvar_vars; 25 | char *cvar_null_string = ""; 26 | 27 | /* 28 | ============ 29 | Cvar_FindVar 30 | ============ 31 | */ 32 | cvar_t *Cvar_FindVar (char *var_name) 33 | { 34 | cvar_t *var; 35 | 36 | for (var=cvar_vars ; var ; var=var->next) 37 | if (!strcmp (var_name, var->name)) 38 | return var; 39 | 40 | return NULL; 41 | } 42 | 43 | /* 44 | ============ 45 | Cvar_VariableValue 46 | ============ 47 | */ 48 | float Cvar_VariableValue (char *var_name) 49 | { 50 | cvar_t *var; 51 | 52 | var = Cvar_FindVar (var_name); 53 | if (!var) 54 | return 0; 55 | return atof (var->string); 56 | } 57 | 58 | 59 | /* 60 | ============ 61 | Cvar_VariableString 62 | ============ 63 | */ 64 | char *Cvar_VariableString (char *var_name) 65 | { 66 | cvar_t *var; 67 | 68 | var = Cvar_FindVar (var_name); 69 | if (!var) 70 | return cvar_null_string; 71 | return var->string; 72 | } 73 | 74 | 75 | /* 76 | ============ 77 | Cvar_CompleteVariable 78 | ============ 79 | */ 80 | char *Cvar_CompleteVariable (char *partial) 81 | { 82 | cvar_t *cvar; 83 | int len; 84 | 85 | len = strlen(partial); 86 | 87 | if (!len) 88 | return NULL; 89 | 90 | // check functions 91 | for (cvar=cvar_vars ; cvar ; cvar=cvar->next) 92 | if (!strncmp (partial,cvar->name, len)) 93 | return cvar->name; 94 | 95 | return NULL; 96 | } 97 | 98 | 99 | /* 100 | ============ 101 | Cvar_Set 102 | ============ 103 | */ 104 | void Cvar_Set (char *var_name, char *value) 105 | { 106 | cvar_t *var; 107 | qboolean changed; 108 | 109 | var = Cvar_FindVar (var_name); 110 | if (!var) 111 | { // there is an error in C code if this happens 112 | Con_Printf ("Cvar_Set: variable %s not found\n", var_name); 113 | return; 114 | } 115 | 116 | changed = strcmp(var->string, value); 117 | 118 | Z_Free (var->string); // free the old value string 119 | 120 | var->string = Z_Malloc (strlen(value)+1); 121 | strcpy (var->string, value); 122 | var->value = atof (var->string); 123 | if (var->server && changed) 124 | { 125 | if (sv.active) 126 | SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string); 127 | } 128 | } 129 | 130 | /* 131 | ============ 132 | Cvar_SetValue 133 | ============ 134 | */ 135 | void Cvar_SetValue (char *var_name, float value) 136 | { 137 | char val[32]; 138 | 139 | sprintf (val, "%f",value); 140 | Cvar_Set (var_name, val); 141 | } 142 | 143 | 144 | /* 145 | ============ 146 | Cvar_RegisterVariable 147 | 148 | Adds a freestanding variable to the variable list. 149 | ============ 150 | */ 151 | void Cvar_RegisterVariable (cvar_t *variable) 152 | { 153 | char *oldstr; 154 | 155 | // first check to see if it has allready been defined 156 | if (Cvar_FindVar (variable->name)) 157 | { 158 | Con_Printf ("Can't register variable %s, allready defined\n", variable->name); 159 | return; 160 | } 161 | 162 | // check for overlap with a command 163 | if (Cmd_Exists (variable->name)) 164 | { 165 | Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name); 166 | return; 167 | } 168 | 169 | // copy the value off, because future sets will Z_Free it 170 | oldstr = variable->string; 171 | variable->string = Z_Malloc (strlen(variable->string)+1); 172 | strcpy (variable->string, oldstr); 173 | variable->value = atof (variable->string); 174 | 175 | // link the variable in 176 | variable->next = cvar_vars; 177 | cvar_vars = variable; 178 | } 179 | 180 | /* 181 | ============ 182 | Cvar_Command 183 | 184 | Handles variable inspection and changing from the console 185 | ============ 186 | */ 187 | qboolean Cvar_Command (void) 188 | { 189 | cvar_t *v; 190 | 191 | // check variables 192 | v = Cvar_FindVar (Cmd_Argv(0)); 193 | if (!v) 194 | return false; 195 | 196 | // perform a variable print or set 197 | if (Cmd_Argc() == 1) 198 | { 199 | Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string); 200 | return true; 201 | } 202 | 203 | Cvar_Set (v->name, Cmd_Argv(1)); 204 | return true; 205 | } 206 | 207 | 208 | /* 209 | ============ 210 | Cvar_WriteVariables 211 | 212 | Writes lines containing "set variable value" for all variables 213 | with the archive flag set to true. 214 | ============ 215 | */ 216 | void Cvar_WriteVariables (FILE *f) 217 | { 218 | cvar_t *var; 219 | 220 | for (var = cvar_vars ; var ; var = var->next) 221 | if (var->archive) 222 | fprintf (f, "%s \"%s\"\n", var->name, var->string); 223 | } 224 | 225 | -------------------------------------------------------------------------------- /source/cvar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // cvar.h 21 | 22 | /* 23 | 24 | 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 25 | in C code. 26 | 27 | it is sufficient to initialize a cvar_t with just the first two fields, or 28 | you can add a ,true flag for variables that you want saved to the configuration 29 | file when the game is quit: 30 | 31 | cvar_t r_draworder = {"r_draworder","1"}; 32 | cvar_t scr_screensize = {"screensize","1",true}; 33 | 34 | Cvars must be registered before use, or they will have a 0 value instead of the float interpretation of the string. Generally, all cvar_t declarations should be registered in the apropriate init function before any console commands are executed: 35 | Cvar_RegisterVariable (&host_framerate); 36 | 37 | 38 | C code usually just references a cvar in place: 39 | if ( r_draworder.value ) 40 | 41 | It could optionally ask for the value to be looked up for a string name: 42 | if (Cvar_VariableValue ("r_draworder")) 43 | 44 | Interpreted prog code can access cvars with the cvar(name) or 45 | cvar_set (name, value) internal functions: 46 | teamplay = cvar("teamplay"); 47 | cvar_set ("registered", "1"); 48 | 49 | The user can access cvars from the console in two ways: 50 | r_draworder prints the current value 51 | r_draworder 0 sets the current value to 0 52 | Cvars are restricted from having the same names as commands to keep this 53 | interface from being ambiguous. 54 | */ 55 | 56 | typedef struct cvar_s 57 | { 58 | char *name; 59 | char *string; 60 | qboolean archive; // set to true to cause it to be saved to vars.rc 61 | qboolean server; // notifies players when changed 62 | float value; 63 | struct cvar_s *next; 64 | } cvar_t; 65 | 66 | void Cvar_RegisterVariable (cvar_t *variable); 67 | // registers a cvar that allready has the name, string, and optionally the 68 | // archive elements set. 69 | 70 | void Cvar_Set (char *var_name, char *value); 71 | // equivelant to " " typed at the console 72 | 73 | void Cvar_SetValue (char *var_name, float value); 74 | // expands value to a string and calls Cvar_Set 75 | 76 | float Cvar_VariableValue (char *var_name); 77 | // returns 0 if not defined or non numeric 78 | 79 | char *Cvar_VariableString (char *var_name); 80 | // returns an empty string if not defined 81 | 82 | char *Cvar_CompleteVariable (char *partial); 83 | // attempts to match a partial variable name for command line completion 84 | // returns NULL if nothing fits 85 | 86 | qboolean Cvar_Command (void); 87 | // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known 88 | // command. Returns true if the command was a variable reference that 89 | // was handled. (print or change) 90 | 91 | void Cvar_WriteVariables (FILE *f); 92 | // Writes lines containing "set variable value" for all variables 93 | // with the archive flag set to true. 94 | 95 | cvar_t *Cvar_FindVar (char *var_name); 96 | 97 | extern cvar_t *cvar_vars; 98 | -------------------------------------------------------------------------------- /source/d_fill.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_clear: clears a specified rectangle to the specified color 21 | 22 | #include "quakedef.h" 23 | 24 | 25 | /* 26 | ================ 27 | D_FillRect 28 | ================ 29 | */ 30 | void D_FillRect (vrect_t *rect, int color) 31 | { 32 | int rx, ry, rwidth, rheight; 33 | unsigned char *dest; 34 | unsigned *ldest; 35 | 36 | rx = rect->x; 37 | ry = rect->y; 38 | rwidth = rect->width; 39 | rheight = rect->height; 40 | 41 | if (rx < 0) 42 | { 43 | rwidth += rx; 44 | rx = 0; 45 | } 46 | if (ry < 0) 47 | { 48 | rheight += ry; 49 | ry = 0; 50 | } 51 | if (rx+rwidth > vid.width) 52 | rwidth = vid.width - rx; 53 | if (ry+rheight > vid.height) 54 | rheight = vid.height - rx; 55 | 56 | if (rwidth < 1 || rheight < 1) 57 | return; 58 | 59 | dest = ((byte *)vid.buffer + ry*vid.rowbytes + rx); 60 | 61 | if (((rwidth & 0x03) == 0) && (((long)dest & 0x03) == 0)) 62 | { 63 | // faster aligned dword clear 64 | ldest = (unsigned *)dest; 65 | color += color << 16; 66 | 67 | rwidth >>= 2; 68 | color += color << 8; 69 | 70 | for (ry=0 ; ry 3) 145 | d_minmip = 3; 146 | else if (d_minmip < 0) 147 | d_minmip = 0; 148 | 149 | for (i=0 ; i<(NUM_MIPS-1) ; i++) 150 | d_scalemip[i] = basemip[i] * d_mipscale.value; 151 | 152 | #if id386 153 | if (d_subdiv16.value) 154 | d_drawspans = D_DrawSpans16; 155 | else 156 | d_drawspans = D_DrawSpans8; 157 | #else 158 | if (cvar && cvar->value == 1.0f) 159 | d_drawspans = D_DrawSpans16QbDither; 160 | else 161 | d_drawspans = D_DrawSpans16Qb; 162 | #endif 163 | 164 | d_aflatcolor = 0; 165 | } 166 | 167 | 168 | /* 169 | =============== 170 | D_UpdateRects 171 | =============== 172 | */ 173 | void D_UpdateRects (vrect_t *prect) 174 | { 175 | 176 | // the software driver draws these directly to the vid buffer 177 | 178 | UNUSED(prect); 179 | } 180 | 181 | -------------------------------------------------------------------------------- /source/d_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_local.h: private rasterization driver defs 21 | 22 | #include "r_shared.h" 23 | 24 | // 25 | // TODO: fine-tune this; it's based on providing some overage even if there 26 | // is a 2k-wide scan, with subdivision every 8, for 256 spans of 12 bytes each 27 | // 28 | #define SCANBUFFERPAD 0x1000 29 | 30 | #define R_SKY_SMASK 0x007F0000 31 | #define R_SKY_TMASK 0x007F0000 32 | 33 | #define DS_SPAN_LIST_END -128 34 | 35 | #define SURFCACHE_SIZE_AT_320X200 600*1024 36 | 37 | typedef struct surfcache_s 38 | { 39 | struct surfcache_s *next; 40 | struct surfcache_s **owner; // NULL is an empty chunk of memory 41 | int lightadj[MAXLIGHTMAPS]; // checked for strobe flush 42 | int dlight; 43 | int size; // including header 44 | unsigned width; 45 | unsigned height; // DEBUG only needed for debug 46 | float mipscale; 47 | struct texture_s *texture; // checked for animating textures 48 | byte data[4]; // width*height elements 49 | } surfcache_t; 50 | 51 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 52 | typedef struct sspan_s 53 | { 54 | int u, v, count; 55 | } sspan_t; 56 | 57 | extern cvar_t d_subdiv16; 58 | 59 | extern float scale_for_mip; 60 | 61 | extern qboolean d_roverwrapped; 62 | extern surfcache_t *sc_rover; 63 | extern surfcache_t *d_initial_rover; 64 | 65 | extern float d_sdivzstepu, d_tdivzstepu, d_zistepu; 66 | extern float d_sdivzstepv, d_tdivzstepv, d_zistepv; 67 | extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin; 68 | 69 | extern 70 | fixed16_t sadjust, tadjust; 71 | extern 72 | fixed16_t bbextents, bbextentt; 73 | 74 | 75 | void D_DrawSpans8 (espan_t *pspans); 76 | void D_DrawSpans16 (espan_t *pspans); 77 | void D_DrawZSpans (espan_t *pspans); 78 | void Turbulent8 (espan_t *pspan); 79 | void D_SpriteDrawSpans (sspan_t *pspan); 80 | 81 | void D_DrawSpans16Qb(espan_t *pspans); 82 | void D_DrawSpans16QbDither(espan_t *pspans); 83 | 84 | void D_DrawSkyScans8 (espan_t *pspan); 85 | void D_DrawSkyScans16 (espan_t *pspan); 86 | 87 | void R_ShowSubDiv (void); 88 | //void (*prealspandrawer)(void); 89 | surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel); 90 | 91 | extern int D_MipLevelForScale (float scale); 92 | 93 | #if id386 94 | extern void D_PolysetAff8Start (void); 95 | extern void D_PolysetAff8End (void); 96 | #endif 97 | 98 | extern short *d_pzbuffer; 99 | extern unsigned int d_zrowbytes, d_zwidth; 100 | 101 | extern int *d_pscantable; 102 | extern int d_scantable[MAXHEIGHT]; 103 | 104 | extern int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 105 | 106 | extern int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 107 | 108 | extern pixel_t *d_viewbuffer; 109 | 110 | extern short *zspantable[MAXHEIGHT]; 111 | 112 | extern int d_minmip; 113 | extern float d_scalemip[3]; 114 | 115 | extern void (*d_drawspans) (espan_t *pspan); 116 | 117 | -------------------------------------------------------------------------------- /source/d_modech.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_modech.c: called when mode has just changed 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; 26 | 27 | int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; 28 | 29 | int d_scantable[MAXHEIGHT]; 30 | short *zspantable[MAXHEIGHT]; 31 | 32 | /* 33 | ================ 34 | D_Patch 35 | ================ 36 | */ 37 | void D_Patch (void) 38 | { 39 | #if id386 40 | 41 | static qboolean protectset8 = false; 42 | 43 | if (!protectset8) 44 | { 45 | Sys_MakeCodeWriteable ((int)D_PolysetAff8Start, 46 | (int)D_PolysetAff8End - (int)D_PolysetAff8Start); 47 | protectset8 = true; 48 | } 49 | 50 | #endif // id386 51 | } 52 | 53 | 54 | /* 55 | ================ 56 | D_ViewChanged 57 | ================ 58 | */ 59 | void D_ViewChanged (void) 60 | { 61 | int rowbytes; 62 | 63 | if (r_dowarp) 64 | rowbytes = WARP_WIDTH; 65 | else 66 | rowbytes = vid.rowbytes; 67 | 68 | scale_for_mip = xscale; 69 | if (yscale > xscale) 70 | scale_for_mip = yscale; 71 | 72 | d_zrowbytes = vid.width * 2; 73 | d_zwidth = vid.width; 74 | 75 | d_pix_min = r_refdef.vrect.width / 320; 76 | if (d_pix_min < 1) 77 | d_pix_min = 1; 78 | 79 | d_pix_max = (int)((float)r_refdef.vrect.width / (320.0 / 4.0) + 0.5); 80 | d_pix_shift = 8 - (int)((float)r_refdef.vrect.width / 320.0 + 0.5); 81 | if (d_pix_max < 1) 82 | d_pix_max = 1; 83 | 84 | if (pixelAspect > 1.4) 85 | d_y_aspect_shift = 1; 86 | else 87 | d_y_aspect_shift = 0; 88 | 89 | d_vrectx = r_refdef.vrect.x; 90 | d_vrecty = r_refdef.vrect.y; 91 | d_vrectright_particle = r_refdef.vrectright - d_pix_max; 92 | d_vrectbottom_particle = 93 | r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift); 94 | 95 | { 96 | int i; 97 | 98 | for (i=0 ; iorg, r_origin, local); 65 | 66 | transformed[0] = DotProduct(local, r_pright); 67 | transformed[1] = DotProduct(local, r_pup); 68 | transformed[2] = DotProduct(local, r_ppn); 69 | 70 | if (transformed[2] < PARTICLE_Z_CLIP) 71 | return; 72 | 73 | // project the point 74 | // FIXME: preadjust xcenter and ycenter 75 | zi = 1.0 / transformed[2]; 76 | u = (int)(xcenter + zi * transformed[0] + 0.5); 77 | v = (int)(ycenter - zi * transformed[1] + 0.5); 78 | 79 | if ((v > d_vrectbottom_particle) || 80 | (u > d_vrectright_particle) || 81 | (v < d_vrecty) || 82 | (u < d_vrectx)) 83 | { 84 | return; 85 | } 86 | 87 | pz = d_pzbuffer + (d_zwidth * v) + u; 88 | pdest = d_viewbuffer + d_scantable[v] + u; 89 | izi = (int)(zi * 0x8000); 90 | 91 | pix = izi >> d_pix_shift; 92 | 93 | if (pix < d_pix_min) 94 | pix = d_pix_min; 95 | else if (pix > d_pix_max) 96 | pix = d_pix_max; 97 | 98 | switch (pix) 99 | { 100 | case 1: 101 | count = 1 << d_y_aspect_shift; 102 | 103 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 104 | { 105 | if (pz[0] <= izi) 106 | { 107 | pz[0] = izi; 108 | pdest[0] = pparticle->color; 109 | } 110 | } 111 | break; 112 | 113 | case 2: 114 | count = 2 << d_y_aspect_shift; 115 | 116 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 117 | { 118 | if (pz[0] <= izi) 119 | { 120 | pz[0] = izi; 121 | pdest[0] = pparticle->color; 122 | } 123 | 124 | if (pz[1] <= izi) 125 | { 126 | pz[1] = izi; 127 | pdest[1] = pparticle->color; 128 | } 129 | } 130 | break; 131 | 132 | case 3: 133 | count = 3 << d_y_aspect_shift; 134 | 135 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 136 | { 137 | if (pz[0] <= izi) 138 | { 139 | pz[0] = izi; 140 | pdest[0] = pparticle->color; 141 | } 142 | 143 | if (pz[1] <= izi) 144 | { 145 | pz[1] = izi; 146 | pdest[1] = pparticle->color; 147 | } 148 | 149 | if (pz[2] <= izi) 150 | { 151 | pz[2] = izi; 152 | pdest[2] = pparticle->color; 153 | } 154 | } 155 | break; 156 | 157 | case 4: 158 | count = 4 << d_y_aspect_shift; 159 | 160 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 161 | { 162 | if (pz[0] <= izi) 163 | { 164 | pz[0] = izi; 165 | pdest[0] = pparticle->color; 166 | } 167 | 168 | if (pz[1] <= izi) 169 | { 170 | pz[1] = izi; 171 | pdest[1] = pparticle->color; 172 | } 173 | 174 | if (pz[2] <= izi) 175 | { 176 | pz[2] = izi; 177 | pdest[2] = pparticle->color; 178 | } 179 | 180 | if (pz[3] <= izi) 181 | { 182 | pz[3] = izi; 183 | pdest[3] = pparticle->color; 184 | } 185 | } 186 | break; 187 | 188 | default: 189 | count = pix << d_y_aspect_shift; 190 | 191 | for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) 192 | { 193 | for (i=0 ; icolor; 199 | } 200 | } 201 | } 202 | break; 203 | } 204 | } 205 | 206 | #endif // !id386 207 | 208 | -------------------------------------------------------------------------------- /source/d_sky.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_sky.c 21 | 22 | #include "quakedef.h" 23 | #include "r_local.h" 24 | #include "d_local.h" 25 | 26 | #define SKY_SPAN_SHIFT 5 27 | #define SKY_SPAN_MAX (1 << SKY_SPAN_SHIFT) 28 | 29 | 30 | /* 31 | ================= 32 | D_Sky_uv_To_st 33 | ================= 34 | */ 35 | void D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t) 36 | { 37 | float wu, wv, temp; 38 | vec3_t end; 39 | 40 | if (r_refdef.vrect.width >= r_refdef.vrect.height) 41 | temp = (float)r_refdef.vrect.width; 42 | else 43 | temp = (float)r_refdef.vrect.height; 44 | 45 | wu = 8192.0 * (float)(u-((int)vid.width>>1)) / temp; 46 | wv = 8192.0 * (float)(((int)vid.height>>1)-v) / temp; 47 | 48 | end[0] = 4096*vpn[0] + wu*vright[0] + wv*vup[0]; 49 | end[1] = 4096*vpn[1] + wu*vright[1] + wv*vup[1]; 50 | end[2] = 4096*vpn[2] + wu*vright[2] + wv*vup[2]; 51 | end[2] *= 3; 52 | VectorNormalize (end); 53 | 54 | temp = skytime*skyspeed; // TODO: add D_SetupFrame & set this there 55 | *s = (int)((temp + 6*(SKYSIZE/2-1)*end[0]) * 0x10000); 56 | *t = (int)((temp + 6*(SKYSIZE/2-1)*end[1]) * 0x10000); 57 | } 58 | 59 | 60 | /* 61 | ================= 62 | D_DrawSkyScans8 63 | ================= 64 | */ 65 | void D_DrawSkyScans8 (espan_t *pspan) 66 | { 67 | int count, spancount, u, v; 68 | unsigned char *pdest; 69 | fixed16_t s, t, snext, tnext, sstep, tstep; 70 | int spancountminus1; 71 | 72 | sstep = 0; // keep compiler happy 73 | tstep = 0; // ditto 74 | 75 | do 76 | { 77 | pdest = (unsigned char *)((byte *)d_viewbuffer + 78 | (screenwidth * pspan->v) + pspan->u); 79 | 80 | count = pspan->count; 81 | 82 | // calculate the initial s & t 83 | u = pspan->u; 84 | v = pspan->v; 85 | D_Sky_uv_To_st (u, v, &s, &t); 86 | 87 | do 88 | { 89 | if (count >= SKY_SPAN_MAX) 90 | spancount = SKY_SPAN_MAX; 91 | else 92 | spancount = count; 93 | 94 | count -= spancount; 95 | 96 | if (count) 97 | { 98 | u += spancount; 99 | 100 | // calculate s and t at far end of span, 101 | // calculate s and t steps across span by shifting 102 | D_Sky_uv_To_st (u, v, &snext, &tnext); 103 | 104 | sstep = (snext - s) >> SKY_SPAN_SHIFT; 105 | tstep = (tnext - t) >> SKY_SPAN_SHIFT; 106 | } 107 | else 108 | { 109 | // calculate s and t at last pixel in span, 110 | // calculate s and t steps across span by division 111 | spancountminus1 = (float)(spancount - 1); 112 | 113 | if (spancountminus1 > 0) 114 | { 115 | u += spancountminus1; 116 | D_Sky_uv_To_st (u, v, &snext, &tnext); 117 | 118 | sstep = (snext - s) / spancountminus1; 119 | tstep = (tnext - t) / spancountminus1; 120 | } 121 | } 122 | 123 | do 124 | { 125 | *pdest++ = r_skysource[((t & R_SKY_TMASK) >> 8) + 126 | ((s & R_SKY_SMASK) >> 16)]; 127 | s += sstep; 128 | t += tstep; 129 | } while (--spancount > 0); 130 | 131 | s = snext; 132 | t = tnext; 133 | 134 | } while (count > 0); 135 | 136 | } while ((pspan = pspan->pnext) != NULL); 137 | } 138 | 139 | -------------------------------------------------------------------------------- /source/d_vars.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_vars.c: global refresh variables 21 | 22 | #if !id386 23 | 24 | #include "quakedef.h" 25 | 26 | // all global and static refresh variables are collected in a contiguous block 27 | // to avoid cache conflicts. 28 | 29 | //------------------------------------------------------- 30 | // global refresh variables 31 | //------------------------------------------------------- 32 | 33 | // FIXME: make into one big structure, like cl or sv 34 | // FIXME: do separately for refresh engine and driver 35 | 36 | float d_sdivzstepu, d_tdivzstepu, d_zistepu; 37 | float d_sdivzstepv, d_tdivzstepv, d_zistepv; 38 | float d_sdivzorigin, d_tdivzorigin, d_ziorigin; 39 | 40 | fixed16_t sadjust, tadjust, bbextents, bbextentt; 41 | 42 | pixel_t *cacheblock; 43 | int cachewidth; 44 | pixel_t *d_viewbuffer; 45 | short *d_pzbuffer; 46 | unsigned int d_zrowbytes; 47 | unsigned int d_zwidth; 48 | 49 | #endif // !id386 50 | 51 | -------------------------------------------------------------------------------- /source/d_zpoint.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // d_zpoint.c: software driver module for drawing z-buffered points 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | 26 | /* 27 | ===================== 28 | D_DrawZPoint 29 | ===================== 30 | */ 31 | void D_DrawZPoint (void) 32 | { 33 | byte *pdest; 34 | short *pz; 35 | int izi; 36 | 37 | pz = d_pzbuffer + (d_zwidth * r_zpointdesc.v) + r_zpointdesc.u; 38 | pdest = d_viewbuffer + d_scantable[r_zpointdesc.v] + r_zpointdesc.u; 39 | izi = (int)(r_zpointdesc.zi * 0x8000); 40 | 41 | if (*pz <= izi) 42 | { 43 | *pz = izi; 44 | *pdest = r_zpointdesc.color; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /source/diskio.c: -------------------------------------------------------------------------------- 1 | #if !defined(PC) 2 | /*-----------------------------------------------------------------------*/ 3 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */ 4 | /*-----------------------------------------------------------------------*/ 5 | /* If a working storage control module is available, it should be */ 6 | /* attached to the FatFs via a glue function rather than modifying it. */ 7 | /* This is an example of glue functions to attach various exsisting */ 8 | /* storage control modules to the FatFs module with a defined API. */ 9 | /*-----------------------------------------------------------------------*/ 10 | 11 | #include "diskio.h" /* FatFs lower layer API */ 12 | #include "sdcard.h" 13 | 14 | /* Definitions of physical drive number for each drive */ 15 | #define M0 0 /* Example: Map MMC/SD card to physical drive 0 */ 16 | 17 | 18 | /*-----------------------------------------------------------------------*/ 19 | /* Get Drive Status */ 20 | /*-----------------------------------------------------------------------*/ 21 | 22 | DSTATUS disk_status(BYTE pdrv) 23 | { 24 | return 0; 25 | } 26 | 27 | 28 | 29 | /*-----------------------------------------------------------------------*/ 30 | /* Inidialize a Drive */ 31 | /*-----------------------------------------------------------------------*/ 32 | 33 | DSTATUS disk_initialize(BYTE pdrv) 34 | { 35 | if (sd_init() == 0) 36 | return 0; 37 | return STA_NOINIT; 38 | } 39 | 40 | 41 | 42 | /*-----------------------------------------------------------------------*/ 43 | /* Read Sector(s) */ 44 | /*-----------------------------------------------------------------------*/ 45 | 46 | DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count) 47 | { 48 | if (sd_read_sector_dma(buff, sector, count) == 0) 49 | return RES_OK; 50 | return RES_ERROR; 51 | } 52 | 53 | 54 | 55 | /*-----------------------------------------------------------------------*/ 56 | /* Write Sector(s) */ 57 | /*-----------------------------------------------------------------------*/ 58 | 59 | DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count) 60 | { 61 | if (sd_write_sector_dma((BYTE *)buff, sector, count) == 0) 62 | return RES_OK; 63 | return RES_ERROR; 64 | } 65 | 66 | 67 | 68 | /*-----------------------------------------------------------------------*/ 69 | /* Miscellaneous Functions */ 70 | /*-----------------------------------------------------------------------*/ 71 | 72 | DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff) 73 | { 74 | DRESULT res = RES_ERROR; 75 | 76 | switch (cmd) { 77 | /* Make sure that no pending write process */ 78 | case CTRL_SYNC: 79 | res = RES_OK; 80 | break; 81 | /* Get number of sectors on the disk (DWORD) */ 82 | case GET_SECTOR_COUNT: 83 | *(DWORD *)buff = (cardinfo.SD_csd.DeviceSize + 1) << 10; 84 | res = RES_OK; 85 | break; 86 | /* Get R/W sector size (WORD) */ 87 | case GET_SECTOR_SIZE: 88 | *(WORD *)buff = cardinfo.CardBlockSize; 89 | res = RES_OK; 90 | break; 91 | /* Get erase block size in unit of sector (DWORD) */ 92 | case GET_BLOCK_SIZE: 93 | *(DWORD *)buff = cardinfo.CardBlockSize; 94 | res = RES_OK; 95 | break; 96 | default: 97 | res = RES_PARERR; 98 | } 99 | return res; 100 | } 101 | #endif 102 | -------------------------------------------------------------------------------- /source/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "integer.h" 13 | 14 | 15 | /* Status of Disk Functions */ 16 | typedef BYTE DSTATUS; 17 | 18 | /* Results of Disk Functions */ 19 | typedef enum { 20 | RES_OK = 0, /* 0: Successful */ 21 | RES_ERROR, /* 1: R/W Error */ 22 | RES_WRPRT, /* 2: Write Protected */ 23 | RES_NOTRDY, /* 3: Not Ready */ 24 | RES_PARERR /* 4: Invalid Parameter */ 25 | } DRESULT; 26 | 27 | 28 | /*---------------------------------------*/ 29 | /* Prototypes for disk control functions */ 30 | 31 | 32 | DSTATUS disk_initialize (BYTE pdrv); 33 | DSTATUS disk_status (BYTE pdrv); 34 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 35 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 36 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 37 | 38 | 39 | /* Disk Status Bits (DSTATUS) */ 40 | 41 | #define STA_NOINIT 0x01 /* Drive not initialized */ 42 | #define STA_NODISK 0x02 /* No medium in the drive */ 43 | #define STA_PROTECT 0x04 /* Write protected */ 44 | 45 | 46 | /* Command code for disk_ioctrl fucntion */ 47 | 48 | /* Generic command (Used by FatFs) */ 49 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 50 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 51 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 52 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 53 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 54 | 55 | /* Generic command (Not used by FatFs) */ 56 | #define CTRL_POWER 5 /* Get/Set power status */ 57 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 58 | #define CTRL_EJECT 7 /* Eject media */ 59 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 60 | 61 | /* MMC/SDC specific ioctl command */ 62 | #define MMC_GET_TYPE 10 /* Get card type */ 63 | #define MMC_GET_CSD 11 /* Get CSD */ 64 | #define MMC_GET_CID 12 /* Get CID */ 65 | #define MMC_GET_OCR 13 /* Get OCR */ 66 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 67 | #define ISDIO_READ 55 /* Read data form SD iSDIO register */ 68 | #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ 69 | #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /source/draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // draw.h -- these are the only functions outside the refresh allowed 22 | // to touch the vid buffer 23 | 24 | extern qpic_t *draw_disc; // also used on sbar 25 | 26 | void Draw_Init (void); 27 | void Draw_Character (int x, int y, int num); 28 | void Draw_DebugChar (char num); 29 | void Draw_Pic (int x, int y, qpic_t *pic); 30 | void Draw_TransPic (int x, int y, qpic_t *pic); 31 | void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation); 32 | void Draw_ConsoleBackground (int lines); 33 | void Draw_BeginDisc (void); 34 | void Draw_EndDisc (void); 35 | void Draw_TileClear (int x, int y, int w, int h); 36 | void Draw_Fill (int x, int y, int w, int h, int c); 37 | void Draw_FadeScreen (void); 38 | void Draw_String (int x, int y, char *str); 39 | qpic_t *Draw_PicFromWad (char *name); 40 | qpic_t *Draw_CachePic (char *path); 41 | -------------------------------------------------------------------------------- /source/dualshock2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Dualshock 2 controller functions. 3 | * 4 | * forked from https://github.com/sipeed/MaixPy/blob/master/ports/k210-freertos/platform/drivers/include/ps2.h 5 | */ 6 | #ifndef __PS2_H 7 | #define __PS2_H 8 | 9 | #include 10 | #include 11 | 12 | /* clang-format off */ 13 | #define CTRL_CLK 10 14 | #define CTRL_CLK_HIGH 10 15 | #define CTRL_BYTE_DELAY 5 16 | 17 | //These are our button constants 18 | #define PSB_SELECT 0x0001 19 | #define PSB_L3 0x0002 20 | #define PSB_R3 0x0004 21 | #define PSB_START 0x0008 22 | #define PSB_PAD_UP 0x0010 23 | #define PSB_PAD_RIGHT 0x0020 24 | #define PSB_PAD_DOWN 0x0040 25 | #define PSB_PAD_LEFT 0x0080 26 | #define PSB_L2 0x0100 27 | #define PSB_R2 0x0200 28 | #define PSB_L1 0x0400 29 | #define PSB_R1 0x0800 30 | #define PSB_GREEN 0x1000 31 | #define PSB_RED 0x2000 32 | #define PSB_BLUE 0x4000 33 | #define PSB_PINK 0x8000 34 | #define PSB_TRIANGLE 0x1000 35 | #define PSB_CIRCLE 0x2000 36 | #define PSB_CROSS 0x4000 37 | #define PSB_SQUARE 0x8000 38 | 39 | //Guitar button constants 40 | #define UP_STRUM 0x0010 41 | #define DOWN_STRUM 0x0040 42 | #define STAR_POWER 0x0100 43 | #define GREEN_FRET 0x0200 44 | #define YELLOW_FRET 0x1000 45 | #define RED_FRET 0x2000 46 | #define BLUE_FRET 0x4000 47 | #define ORANGE_FRET 0x8000 48 | #define WHAMMY_BAR 8 49 | 50 | //These are stick values 51 | #define PSS_RX 5 52 | #define PSS_RY 6 53 | #define PSS_LX 7 54 | #define PSS_LY 8 55 | 56 | //These are analog buttons 57 | #define PSAB_PAD_RIGHT 9 58 | #define PSAB_PAD_UP 11 59 | #define PSAB_PAD_DOWN 12 60 | #define PSAB_PAD_LEFT 10 61 | #define PSAB_L2 19 62 | #define PSAB_R2 20 63 | #define PSAB_L1 17 64 | #define PSAB_R1 18 65 | #define PSAB_GREEN 13 66 | #define PSAB_RED 14 67 | #define PSAB_BLUE 15 68 | #define PSAB_PINK 16 69 | #define PSAB_TRIANGLE 13 70 | #define PSAB_CIRCLE 14 71 | #define PSAB_CROSS 15 72 | #define PSAB_SQUARE 16 73 | 74 | #define DS2_CS 0 75 | #define DS2_CLK 1 76 | #define DS2_MOSI 2 77 | #define DS2_MISO 3 78 | 79 | #define SET(x, y) (x |= (1 << y)) 80 | #define CLR(x, y) (x &= (~(1 << y))) 81 | #define CHK(x, y) (x & (1 << y)) 82 | #define TOG(x, y) (x ^= (1 << y)) 83 | 84 | extern unsigned int buttons; 85 | 86 | /* clang-format on */ 87 | uint8_t PS2X_Button(uint16_t button); 88 | uint8_t PS2X_Analog(uint8_t button); 89 | void PS2X_confg_io(uint8_t cs, uint8_t clk, uint8_t mosi, uint8_t miso); 90 | uint8_t PS2X_read_gamepad(uint8_t motor1, uint8_t motor2); 91 | uint8_t PS2X_config_gamepad(uint8_t pressures, uint8_t rumble); 92 | uint8_t PS2X_readType(void); 93 | void PS2X_enableRumble(void); 94 | void PS2X_enableRumble(void); 95 | void PS2X_reconfig_gamepad(void); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /source/file.c: -------------------------------------------------------------------------------- 1 | #include "ff.h" 2 | #include 3 | #include 4 | 5 | FILE *myfopen(const char *filename,const char *atr){ 6 | FIL *f = malloc(sizeof(FIL)); 7 | if(f==NULL)return 0; 8 | 9 | FRESULT r=f_open(f,filename,FA_READ); 10 | if(r){ 11 | if(r)printf("fatfs open err%d\n",r); 12 | free(f); 13 | return 0; 14 | } 15 | 16 | return (FILE*)f; 17 | } 18 | 19 | size_t myfread(void *ptr,size_t s,size_t nm,FILE *f){ 20 | int n; 21 | FRESULT r; 22 | r = f_read((FIL*)f,ptr,s*nm,&n); 23 | if(r)printf("fatfs read err%d\n",r); 24 | return n/s; 25 | } 26 | 27 | int myfclose(FILE *f){ 28 | f_close((FIL*)f); 29 | free(f); 30 | return 0; 31 | } 32 | 33 | int myfseek(FILE *f,long ofs,int whence){ 34 | FRESULT r; 35 | if(whence == SEEK_SET){ 36 | r= f_lseek((FIL*)f,ofs); 37 | }else if(whence == SEEK_CUR){ 38 | r= f_lseek((FIL*)f,ofs+f_tell((FIL*)f)); 39 | }else if(whence == SEEK_END){ 40 | r= f_lseek((FIL*)f,f_size((FIL*)f)); 41 | }else{ 42 | printf("error not implemented\n"); 43 | } 44 | if(r)printf("fatfs seek err%d\n",r); 45 | return r; 46 | } 47 | 48 | long myftell(FILE *f){ 49 | return f_tell((FIL*)f); 50 | } 51 | 52 | int mygetc(FILE *f){ 53 | char c; 54 | int n; 55 | FRESULT r; 56 | r = f_read((FIL*)f,&c,1,&n); 57 | if(r==0&&n==1) return c; 58 | return EOF; 59 | } 60 | -------------------------------------------------------------------------------- /source/in_ctr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Felipe Izzo 3 | Copyright (C) 1996-1997 Id Software, Inc. 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | See the GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | // in_ctr.c -- for the Nintendo 3DS 23 | 24 | #include "quakedef.h" 25 | 26 | #include "ctr.h" 27 | #include "dualshock2.h" 28 | 29 | 30 | void IN_Init (void) 31 | { 32 | } 33 | 34 | void IN_Shutdown (void) 35 | { 36 | } 37 | 38 | void IN_Commands (void) 39 | { 40 | } 41 | 42 | extern uint8_t keyboardToggled; 43 | 44 | void IN_Move (usercmd_t *cmd) 45 | { 46 | { 47 | float yaw,pitch; 48 | yaw = PS2X_Analog(PSS_RX)-0x80; 49 | pitch = PS2X_Analog(PSS_RY)-0x80; 50 | if(fabs(yaw) < 25.f)yaw = 0.f; 51 | if(fabs(pitch) < 25.f)pitch = 0.f; 52 | yaw /= 128.f; 53 | pitch /= 128.f; 54 | yaw*=3; 55 | pitch*=3; 56 | cl.viewangles[YAW] -= yaw; 57 | cl.viewangles[PITCH] += pitch; 58 | } 59 | { 60 | float forward,side; 61 | forward = PS2X_Analog(PSS_LY)-0x80; 62 | side = PS2X_Analog(PSS_LX)-0x80; 63 | if(fabs(forward) < 25.f)forward = 0.f; 64 | if(fabs(side) < 25.f)side = 0.f; 65 | forward /= -128.f; 66 | side /= 128.f; 67 | cmd->forwardmove += forward*cl_forwardspeed.value*2; 68 | cmd->sidemove += side*cl_forwardspeed.value*2; 69 | } 70 | 71 | if(!lookspring.value) 72 | V_StopPitchDrift (); 73 | } 74 | -------------------------------------------------------------------------------- /source/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // input.h -- external (non-keyboard) input devices 21 | 22 | void IN_Init (void); 23 | 24 | void IN_Shutdown (void); 25 | 26 | void IN_Commands (void); 27 | // oportunity for devices to stick commands on the script buffer 28 | 29 | void IN_Move (usercmd_t *cmd); 30 | // add additional movement on top of the keyboard move cmd 31 | 32 | void IN_ClearStates (void); 33 | // restores all button and position states to defaults 34 | 35 | -------------------------------------------------------------------------------- /source/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | typedef unsigned __int64 QWORD; 13 | 14 | 15 | #else /* Embedded platform */ 16 | 17 | /* These types MUST be 16-bit or 32-bit */ 18 | typedef int INT; 19 | typedef unsigned int UINT; 20 | 21 | /* This type MUST be 8-bit */ 22 | typedef unsigned char BYTE; 23 | 24 | /* These types MUST be 16-bit */ 25 | typedef short SHORT; 26 | typedef unsigned short WORD; 27 | typedef unsigned short WCHAR; 28 | 29 | /* These types MUST be 32-bit */ 30 | typedef long LONG; 31 | typedef unsigned long DWORD; 32 | 33 | /* This type MUST be 64-bit (Remove this for C89 compatibility) */ 34 | typedef unsigned long long QWORD; 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /source/k210.c: -------------------------------------------------------------------------------- 1 | #ifndef PC 2 | /* Copyright 2018 Canaan Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "fpioa.h" 19 | #include "lcd.h" 20 | #include "sysctl.h" 21 | #include "nt35310.h" 22 | #include "board_config.h" 23 | #include 24 | #include 25 | #include "gpiohs.h" 26 | #include "sdcard.h" 27 | #include "ff.h" 28 | #include "dualshock2.h" 29 | 30 | //uint32_t g_lcd_gram[LCD_X_MAX * LCD_Y_MAX / 2] __attribute__((aligned(128))); 31 | 32 | static void io_set_power(void) 33 | { 34 | #if BOARD_LICHEEDAN 35 | sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18); 36 | sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18); 37 | #else 38 | sysctl_set_power_mode(SYSCTL_POWER_BANK1, SYSCTL_POWER_V18); 39 | #endif 40 | } 41 | 42 | // overclock and voltageboost suported XD 43 | //use to configure core voltage. 44 | #define CORE_VOLTAGE_GPIONUM (6) 45 | int set_cpu_freq(uint32_t f){//MHz 46 | if(f<600){ 47 | gpiohs_set_drive_mode(CORE_VOLTAGE_GPIONUM, GPIO_DM_INPUT); 48 | gpiohs_set_pin(CORE_VOLTAGE_GPIONUM, GPIO_PV_LOW); 49 | }else{ 50 | gpiohs_set_drive_mode(CORE_VOLTAGE_GPIONUM, GPIO_DM_INPUT); 51 | } 52 | //Wait for voltage setting done. 53 | for(volatile int i=0;i<1000;i++); 54 | #define MHz *1000000 55 | return sysctl_cpu_set_freq(f MHz)/1000000; 56 | #undef MHz 57 | } 58 | 59 | static void io_mux_init(void) 60 | { 61 | #if BOARD_LICHEEDAN 62 | fpioa_set_function(27, FUNC_SPI1_SCLK); 63 | fpioa_set_function(28, FUNC_SPI1_D0); 64 | fpioa_set_function(26, FUNC_SPI1_D1); 65 | fpioa_set_function(29, FUNC_GPIOHS7); 66 | 67 | fpioa_set_function(11, FUNC_GPIOHS0 + CORE_VOLTAGE_GPIONUM); 68 | fpioa_set_function(38, FUNC_GPIOHS0 + DCX_GPIONUM); 69 | fpioa_set_function(36, FUNC_SPI0_SS3); 70 | fpioa_set_function(39, FUNC_SPI0_SCLK); 71 | fpioa_set_function(37, FUNC_GPIOHS0 + RST_GPIONUM); 72 | sysctl_set_spi0_dvp_data(1); 73 | 74 | fpioa_set_function(18, FUNC_GPIOHS0 + DS2_CS); //Dualshock2 ss 75 | fpioa_set_function(19, FUNC_GPIOHS0 + DS2_CLK); //clk 76 | fpioa_set_function(21, FUNC_GPIOHS0 + DS2_MOSI); //mosi--DO/CMD 77 | fpioa_set_function(20, FUNC_GPIOHS0 + DS2_MISO); //miso--DI/DAT 78 | #else 79 | #error todo 80 | fpioa_set_function(8, FUNC_GPIOHS0 + DCX_GPIONUM); 81 | fpioa_set_function(6, FUNC_SPI0_SS3); 82 | fpioa_set_function(7, FUNC_SPI0_SCLK); 83 | sysctl_set_spi0_dvp_data(1); 84 | #endif 85 | } 86 | 87 | uint64_t get_time(void) 88 | { 89 | uint64_t v_cycle = read_cycle(); 90 | return v_cycle * 1000000 / sysctl_clock_get_freq(SYSCTL_CLOCK_CPU); 91 | } 92 | 93 | void quake_main(int argc,char **argv); 94 | 95 | extern char _heap_end[]; 96 | extern char _tp1[]; 97 | extern char _tp0[]; 98 | extern char _sp1[]; 99 | extern char _sp0[]; 100 | 101 | void ds2readcore(void){// dualshock 2 controller handler 102 | //reading only XD 103 | printf("read task begin\n"); 104 | while(1){ 105 | } 106 | } 107 | 108 | int main(void) 109 | { 110 | #define PLL1_OUTPUT_FREQ 400000000UL 111 | /* sysctl_pll_set_freq(SYSCTL_PLL0, PLL0_OUTPUT_FREQ); */ 112 | sysctl_pll_set_freq(SYSCTL_PLL1, PLL1_OUTPUT_FREQ); 113 | sysctl_clock_enable(SYSCTL_CLOCK_AI); 114 | FATFS sdfs; 115 | io_mux_init(); 116 | #if BOARD_LICHEEDAN 117 | #if defined(OVER_VOLTAGE) 118 | gpiohs_set_drive_mode(CORE_VOLTAGE_GPIONUM, GPIO_DM_INPUT); 119 | gpiohs_set_pin(CORE_VOLTAGE_GPIONUM, GPIO_PV_LOW); 120 | //overclock settings, edit if you want 121 | #define MHz *1000000 122 | usleep(100000); 123 | sysctl_cpu_set_freq(600 MHz); 124 | usleep(100000); 125 | #undef MHz 126 | #endif 127 | io_set_power(); 128 | lcd_init(); 129 | lcd_set_direction(DIR_YX_RLDU); 130 | #else 131 | lcd_set_direction(DIR_YX_RLUD); 132 | #endif 133 | 134 | PS2X_confg_io(DS2_CS,DS2_CLK,DS2_MOSI,DS2_MISO); 135 | PS2X_config_gamepad(0,0); 136 | register_core1(ds2readcore, 0); 137 | 138 | /* SD card init */ 139 | if (sd_init()) 140 | { 141 | printf("Fail to init SD card\n"); 142 | return -1; 143 | } 144 | 145 | /* mount file system to SD card */ 146 | if (f_mount(&sdfs, _T("0:"), 1)) 147 | { 148 | printf("Fail to mount file system\n"); 149 | return -1; 150 | } 151 | 152 | /* system start */ 153 | printf("heap end:%p\n",_heap_end); 154 | { 155 | int n; 156 | printf("current stack :%p\n",&n); 157 | } 158 | printf("stack start:%p\n",_tp0); 159 | printf("stack end:%p\n",_tp1); 160 | printf("stack start:%p\n",_sp0); 161 | printf("stack end:%p\n",_sp1); 162 | printf("system start\n"); 163 | quake_main(0,0); 164 | while(1); 165 | } 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /source/keys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // 22 | // these are the key numbers that should be passed to Key_Event 23 | // 24 | #define K_TAB 9 25 | #define K_ENTER 13 26 | #define K_ESCAPE 27 27 | #define K_SPACE 32 28 | 29 | // normal keys should be passed as lowercased ascii 30 | 31 | #define K_BACKSPACE 127 32 | #define K_UPARROW 128 33 | #define K_DOWNARROW 129 34 | #define K_LEFTARROW 130 35 | #define K_RIGHTARROW 131 36 | 37 | #define K_ALT 132 38 | #define K_CTRL 133 39 | #define K_SHIFT 134 40 | #define K_F1 135 41 | #define K_F2 136 42 | #define K_F3 137 43 | #define K_F4 138 44 | #define K_F5 139 45 | #define K_F6 140 46 | #define K_F7 141 47 | #define K_F8 142 48 | #define K_F9 143 49 | #define K_F10 144 50 | #define K_F11 145 51 | #define K_F12 146 52 | #define K_INS 147 53 | #define K_DEL 148 54 | #define K_PGDN 149 55 | #define K_PGUP 150 56 | #define K_HOME 151 57 | #define K_END 152 58 | 59 | #define K_PAUSE 255 60 | 61 | // 62 | // mouse buttons generate virtual keys 63 | // 64 | #define K_MOUSE1 200 65 | #define K_MOUSE2 201 66 | #define K_MOUSE3 202 67 | 68 | // 69 | // joystick buttons 70 | // 71 | #define K_JOY1 203 72 | #define K_JOY2 204 73 | #define K_JOY3 205 74 | #define K_JOY4 206 75 | 76 | // 77 | // aux keys are for multi-buttoned joysticks to generate so they can use 78 | // the normal binding process 79 | // 80 | #define K_AUX1 207 81 | #define K_AUX2 208 82 | #define K_AUX3 209 83 | #define K_AUX4 210 84 | #define K_AUX5 211 85 | #define K_AUX6 212 86 | #define K_AUX7 213 87 | #define K_AUX8 214 88 | #define K_AUX9 215 89 | #define K_AUX10 216 90 | #define K_AUX11 217 91 | #define K_AUX12 218 92 | #define K_AUX13 219 93 | #define K_AUX14 220 94 | #define K_AUX15 221 95 | #define K_AUX16 222 96 | #define K_AUX17 223 97 | #define K_AUX18 224 98 | #define K_AUX19 225 99 | #define K_AUX20 226 100 | #define K_AUX21 227 101 | #define K_AUX22 228 102 | #define K_AUX23 229 103 | #define K_AUX24 230 104 | #define K_AUX25 231 105 | #define K_AUX26 232 106 | #define K_AUX27 233 107 | #define K_AUX28 234 108 | #define K_AUX29 235 109 | #define K_AUX30 236 110 | #define K_AUX31 237 111 | #define K_AUX32 238 112 | 113 | // JACK: Intellimouse(c) Mouse Wheel Support 114 | 115 | #define K_MWHEELUP 239 116 | #define K_MWHEELDOWN 240 117 | 118 | 119 | 120 | typedef enum {key_game, key_console, key_message, key_menu} keydest_t; 121 | 122 | extern keydest_t key_dest; 123 | extern char *keybindings[256]; 124 | extern int key_repeats[256]; 125 | extern int key_count; // incremented every key event 126 | extern int key_lastpress; 127 | 128 | void Key_Event (int key, qboolean down); 129 | void Key_Init (void); 130 | void Key_WriteBindings (FILE *f); 131 | void Key_SetBinding (int keynum, char *binding); 132 | void Key_ClearStates (void); 133 | -------------------------------------------------------------------------------- /source/lcd.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 Canaan Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | #ifndef _LCD_H_ 16 | #define _LCD_H_ 17 | 18 | 19 | #ifdef __cplusplus 20 | extern "C"{ 21 | #endif 22 | 23 | 24 | #include 25 | 26 | /* clang-format off */ 27 | #define LCD_X_MAX (240) 28 | #define LCD_Y_MAX (320) 29 | 30 | #define BLACK 0x0000 31 | #define NAVY 0x000F 32 | #define DARKGREEN 0x03E0 33 | #define DARKCYAN 0x03EF 34 | #define MAROON 0x7800 35 | #define PURPLE 0x780F 36 | #define OLIVE 0x7BE0 37 | #define LIGHTGREY 0xC618 38 | #define DARKGREY 0x7BEF 39 | #define BLUE 0x001F 40 | #define GREEN 0x07E0 41 | #define CYAN 0x07FF 42 | #define RED 0xF800 43 | #define MAGENTA 0xF81F 44 | #define YELLOW 0xFFE0 45 | #define WHITE 0xFFFF 46 | #define ORANGE 0xFD20 47 | #define GREENYELLOW 0xAFE5 48 | #define PINK 0xF81F 49 | #define USER_COLOR 0xAA55 50 | /* clang-format on */ 51 | 52 | typedef enum _lcd_dir 53 | { 54 | DIR_XY_RLUD = 0x00, 55 | DIR_YX_RLUD = 0x20, 56 | DIR_XY_LRUD = 0x40, 57 | DIR_YX_LRUD = 0x60, 58 | DIR_XY_RLDU = 0x80, 59 | DIR_YX_RLDU = 0xA0, 60 | DIR_XY_LRDU = 0xC0, 61 | DIR_YX_LRDU = 0xE0, 62 | DIR_XY_MASK = 0x20, 63 | DIR_MASK = 0xE0, 64 | } lcd_dir_t; 65 | 66 | typedef struct _lcd_ctl 67 | { 68 | uint8_t mode; 69 | uint8_t dir; 70 | uint16_t width; 71 | uint16_t height; 72 | } lcd_ctl_t; 73 | 74 | void lcd_polling_enable(void); 75 | void lcd_interrupt_enable(void); 76 | void lcd_init(void); 77 | void lcd_clear(uint16_t color); 78 | void lcd_set_direction(lcd_dir_t dir); 79 | void lcd_set_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); 80 | void lcd_draw_point(uint16_t x, uint16_t y, uint16_t color); 81 | void lcd_draw_string(uint16_t x, uint16_t y, char *str, uint16_t color); 82 | void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t *ptr); 83 | void lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t width, uint16_t color); 84 | void lcd_ram_draw_string(char *str, uint32_t *ptr, uint16_t font_color, uint16_t bg_color); 85 | 86 | void lcd_boxfill(uint16_t color,uint16_t x,uint16_t y,uint16_t w,uint16_t h); 87 | void lcd_ram_draw_string_width(char *str, uint32_t *ptr, uint16_t font_color, uint16_t bg_color,uint16_t width); 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /source/mathlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // mathlib.h 21 | 22 | typedef float vec_t; 23 | typedef vec_t vec3_t[3]; 24 | typedef vec_t vec5_t[5]; 25 | 26 | typedef int fixed4_t; 27 | typedef int fixed8_t; 28 | typedef int fixed16_t; 29 | 30 | #ifndef M_PI 31 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 32 | #endif 33 | 34 | struct mplane_s; 35 | 36 | extern vec3_t vec3_origin; 37 | extern int nanmask; 38 | 39 | #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) 40 | 41 | #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 42 | #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} 43 | #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} 44 | #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} 45 | 46 | void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc); 47 | 48 | vec_t _DotProduct (vec3_t v1, vec3_t v2); 49 | void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); 50 | void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out); 51 | void _VectorCopy (vec3_t in, vec3_t out); 52 | 53 | int VectorCompare (vec3_t v1, vec3_t v2); 54 | vec_t Length (vec3_t v); 55 | void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross); 56 | float VectorNormalize (vec3_t v); // returns vector length 57 | void VectorInverse (vec3_t v); 58 | void VectorScale (vec3_t in, vec_t scale, vec3_t out); 59 | int Q_log2(int val); 60 | 61 | void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); 62 | void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); 63 | 64 | void FloorDivMod (double numer, double denom, int *quotient, 65 | int *rem); 66 | fixed16_t Invert24To16(fixed16_t val); 67 | int GreatestCommonDivisor (int i1, int i2); 68 | 69 | void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 70 | int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); 71 | float anglemod(float a); 72 | 73 | 74 | 75 | #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ 76 | (((p)->type < 3)? \ 77 | ( \ 78 | ((p)->dist <= (emins)[(p)->type])? \ 79 | 1 \ 80 | : \ 81 | ( \ 82 | ((p)->dist >= (emaxs)[(p)->type])?\ 83 | 2 \ 84 | : \ 85 | 3 \ 86 | ) \ 87 | ) \ 88 | : \ 89 | BoxOnPlaneSide( (emins), (emaxs), (p))) 90 | -------------------------------------------------------------------------------- /source/menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // 22 | // the net drivers should just set the apropriate bits in m_activenet, 23 | // instead of having the menu code look through their internal tables 24 | // 25 | #define MNET_IPX 1 26 | #define MNET_TCP 2 27 | 28 | extern int m_activenet; 29 | 30 | // 31 | // menus 32 | // 33 | void M_Init (void); 34 | void M_Keydown (int key); 35 | void M_Draw (void); 36 | void M_ToggleMenu_f (void); 37 | 38 | 39 | -------------------------------------------------------------------------------- /source/modelgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // modelgen.h: header file for model generation program 22 | // 23 | 24 | // ********************************************************* 25 | // * This file must be identical in the modelgen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via model files. * 28 | // ********************************************************* 29 | 30 | #ifdef INCLUDELIBS 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "cmdlib.h" 38 | #include "scriplib.h" 39 | #include "trilib.h" 40 | #include "lbmlib.h" 41 | #include "mathlib.h" 42 | 43 | #endif 44 | 45 | #define ALIAS_VERSION 6 46 | 47 | #define ALIAS_ONSEAM 0x0020 48 | 49 | // must match definition in spritegn.h 50 | #ifndef SYNCTYPE_T 51 | #define SYNCTYPE_T 52 | typedef enum {ST_SYNC=0, ST_RAND } synctype_t; 53 | #endif 54 | 55 | typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; 56 | 57 | typedef enum { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t; 58 | 59 | typedef struct { 60 | int ident; 61 | int version; 62 | vec3_t scale; 63 | vec3_t scale_origin; 64 | float boundingradius; 65 | vec3_t eyeposition; 66 | int numskins; 67 | int skinwidth; 68 | int skinheight; 69 | int numverts; 70 | int numtris; 71 | int numframes; 72 | synctype_t synctype; 73 | int flags; 74 | float size; 75 | } mdl_t; 76 | 77 | // TODO: could be shorts 78 | 79 | typedef struct { 80 | int onseam; 81 | int s; 82 | int t; 83 | } stvert_t; 84 | 85 | typedef struct dtriangle_s { 86 | int facesfront; 87 | int vertindex[3]; 88 | } dtriangle_t; 89 | 90 | #define DT_FACES_FRONT 0x0010 91 | 92 | // This mirrors trivert_t in trilib.h, is present so Quake knows how to 93 | // load this data 94 | 95 | typedef struct { 96 | byte v[3]; 97 | byte lightnormalindex; 98 | } trivertx_t; 99 | 100 | typedef struct { 101 | trivertx_t bboxmin; // lightnormal isn't used 102 | trivertx_t bboxmax; // lightnormal isn't used 103 | char name[16]; // frame name from grabbing 104 | } daliasframe_t; 105 | 106 | typedef struct { 107 | int numframes; 108 | trivertx_t bboxmin; // lightnormal isn't used 109 | trivertx_t bboxmax; // lightnormal isn't used 110 | } daliasgroup_t; 111 | 112 | typedef struct { 113 | int numskins; 114 | } daliasskingroup_t; 115 | 116 | typedef struct { 117 | float interval; 118 | } daliasinterval_t; 119 | 120 | typedef struct { 121 | float interval; 122 | } daliasskininterval_t; 123 | 124 | typedef struct { 125 | int type; 126 | } daliasframetype_t; 127 | 128 | typedef struct { 129 | int type; 130 | } daliasskintype_t; 131 | 132 | #define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I') 133 | // little-endian "IDPO" 134 | -------------------------------------------------------------------------------- /source/net_bsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #include "quakedef.h" 21 | #include "net_loop.h" 22 | #include "net_dgrm.h" 23 | 24 | net_driver_t net_drivers[MAX_NET_DRIVERS] = 25 | { 26 | { 27 | "Loopback", 28 | false, 29 | Loop_Init, 30 | Loop_Listen, 31 | Loop_SearchForHosts, 32 | Loop_Connect, 33 | Loop_CheckNewConnections, 34 | Loop_GetMessage, 35 | Loop_SendMessage, 36 | Loop_SendUnreliableMessage, 37 | Loop_CanSendMessage, 38 | Loop_CanSendUnreliableMessage, 39 | Loop_Close, 40 | Loop_Shutdown 41 | } 42 | , 43 | { 44 | "Datagram", 45 | false, 46 | Datagram_Init, 47 | Datagram_Listen, 48 | Datagram_SearchForHosts, 49 | Datagram_Connect, 50 | Datagram_CheckNewConnections, 51 | Datagram_GetMessage, 52 | Datagram_SendMessage, 53 | Datagram_SendUnreliableMessage, 54 | Datagram_CanSendMessage, 55 | Datagram_CanSendUnreliableMessage, 56 | Datagram_Close, 57 | Datagram_Shutdown 58 | } 59 | }; 60 | 61 | int net_numdrivers = 2; 62 | 63 | #include "net_udp.h" 64 | 65 | net_landriver_t net_landrivers[MAX_NET_DRIVERS] = 66 | { 67 | /* 68 | { 69 | "UDP", 70 | false, 71 | 0, 72 | UDP_Init, 73 | UDP_Shutdown, 74 | UDP_Listen, 75 | UDP_OpenSocket, 76 | UDP_CloseSocket, 77 | UDP_Connect, 78 | UDP_CheckNewConnections, 79 | UDP_Read, 80 | UDP_Write, 81 | UDP_Broadcast, 82 | UDP_AddrToString, 83 | UDP_StringToAddr, 84 | UDP_GetSocketAddr, 85 | UDP_GetNameFromAddr, 86 | UDP_GetAddrFromName, 87 | UDP_AddrCompare, 88 | UDP_GetSocketPort, 89 | UDP_SetSocketPort 90 | }*/ 91 | }; 92 | 93 | int net_numlandrivers = 1; 94 | -------------------------------------------------------------------------------- /source/net_dgrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_dgrm.h 21 | 22 | 23 | int Datagram_Init (void); 24 | void Datagram_Listen (qboolean state); 25 | void Datagram_SearchForHosts (qboolean xmit); 26 | qsocket_t *Datagram_Connect (char *host); 27 | qsocket_t *Datagram_CheckNewConnections (void); 28 | int Datagram_GetMessage (qsocket_t *sock); 29 | int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data); 30 | int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 31 | qboolean Datagram_CanSendMessage (qsocket_t *sock); 32 | qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock); 33 | void Datagram_Close (qsocket_t *sock); 34 | void Datagram_Shutdown (void); 35 | -------------------------------------------------------------------------------- /source/net_loop.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_loop.h 21 | 22 | int Loop_Init (void); 23 | void Loop_Listen (qboolean state); 24 | void Loop_SearchForHosts (qboolean xmit); 25 | qsocket_t *Loop_Connect (char *host); 26 | qsocket_t *Loop_CheckNewConnections (void); 27 | int Loop_GetMessage (qsocket_t *sock); 28 | int Loop_SendMessage (qsocket_t *sock, sizebuf_t *data); 29 | int Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data); 30 | qboolean Loop_CanSendMessage (qsocket_t *sock); 31 | qboolean Loop_CanSendUnreliableMessage (qsocket_t *sock); 32 | void Loop_Close (qsocket_t *sock); 33 | void Loop_Shutdown (void); 34 | -------------------------------------------------------------------------------- /source/net_mp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_mpath.h 21 | 22 | int MPATH_Init (void); 23 | void MPATH_Shutdown (void); 24 | void MPATH_Listen (qboolean state); 25 | int MPATH_OpenSocket (int port); 26 | int MPATH_CloseSocket (int socket); 27 | int MPATH_Connect (int socket, struct qsockaddr *addr); 28 | int MPATH_CheckNewConnections (void); 29 | int MPATH_Read (int socket, byte *buf, int len, struct qsockaddr *addr); 30 | int MPATH_Write (int socket, byte *buf, int len, struct qsockaddr *addr); 31 | int MPATH_Broadcast (int socket, byte *buf, int len); 32 | char *MPATH_AddrToString (struct qsockaddr *addr); 33 | int MPATH_StringToAddr (char *string, struct qsockaddr *addr); 34 | int MPATH_GetSocketAddr (int socket, struct qsockaddr *addr); 35 | int MPATH_GetNameFromAddr (struct qsockaddr *addr, char *name); 36 | int MPATH_GetAddrFromName (char *name, struct qsockaddr *addr); 37 | int MPATH_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2); 38 | int MPATH_GetSocketPort (struct qsockaddr *addr); 39 | int MPATH_SetSocketPort (struct qsockaddr *addr, int port); 40 | -------------------------------------------------------------------------------- /source/net_udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_udp.h 21 | 22 | int UDP_Init (void); 23 | void UDP_Shutdown (void); 24 | void UDP_Listen (qboolean state); 25 | int UDP_OpenSocket (int port); 26 | int UDP_CloseSocket (int socket); 27 | int UDP_Connect (int socket, struct qsockaddr *addr); 28 | int UDP_CheckNewConnections (void); 29 | int UDP_Read (int socket, byte *buf, int len, struct qsockaddr *addr); 30 | int UDP_Write (int socket, byte *buf, int len, struct qsockaddr *addr); 31 | int UDP_Broadcast (int socket, byte *buf, int len); 32 | char *UDP_AddrToString (struct qsockaddr *addr); 33 | int UDP_StringToAddr (char *string, struct qsockaddr *addr); 34 | int UDP_GetSocketAddr (int socket, struct qsockaddr *addr); 35 | int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name); 36 | int UDP_GetAddrFromName (char *name, struct qsockaddr *addr); 37 | int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2); 38 | int UDP_GetSocketPort (struct qsockaddr *addr); 39 | int UDP_SetSocketPort (struct qsockaddr *addr, int port); 40 | -------------------------------------------------------------------------------- /source/net_vcr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_vcr.c 21 | 22 | #include "quakedef.h" 23 | #include "net_vcr.h" 24 | 25 | extern int vcrFile; 26 | 27 | // This is the playback portion of the VCR. It reads the file produced 28 | // by the recorder and plays it back to the host. The recording contains 29 | // everything necessary (events, timestamps, and data) to duplicate the game 30 | // from the viewpoint of everything above the network layer. 31 | 32 | static struct 33 | { 34 | double time; 35 | int op; 36 | long session; 37 | } next; 38 | 39 | int VCR_Init (void) 40 | { 41 | net_drivers[0].Init = VCR_Init; 42 | 43 | net_drivers[0].SearchForHosts = VCR_SearchForHosts; 44 | net_drivers[0].Connect = VCR_Connect; 45 | net_drivers[0].CheckNewConnections = VCR_CheckNewConnections; 46 | net_drivers[0].QGetMessage = VCR_GetMessage; 47 | net_drivers[0].QSendMessage = VCR_SendMessage; 48 | net_drivers[0].CanSendMessage = VCR_CanSendMessage; 49 | net_drivers[0].Close = VCR_Close; 50 | net_drivers[0].Shutdown = VCR_Shutdown; 51 | 52 | Sys_FileRead(vcrFile, &next, sizeof(next)); 53 | return 0; 54 | } 55 | 56 | void VCR_ReadNext (void) 57 | { 58 | if (Sys_FileRead(vcrFile, &next, sizeof(next)) == 0) 59 | { 60 | next.op = 255; 61 | Sys_Error ("=== END OF PLAYBACK===\n"); 62 | } 63 | if (next.op < 1 || next.op > VCR_MAX_MESSAGE) 64 | Sys_Error ("VCR_ReadNext: bad op"); 65 | } 66 | 67 | 68 | void VCR_Listen (qboolean state) 69 | { 70 | } 71 | 72 | 73 | void VCR_Shutdown (void) 74 | { 75 | } 76 | 77 | 78 | int VCR_GetMessage (qsocket_t *sock) 79 | { 80 | int ret; 81 | 82 | if (host_time != next.time || next.op != VCR_OP_GETMESSAGE || next.session != *(long *)(&sock->driverdata)) 83 | Sys_Error ("VCR missmatch"); 84 | 85 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 86 | if (ret != 1) 87 | { 88 | VCR_ReadNext (); 89 | return ret; 90 | } 91 | 92 | Sys_FileRead(vcrFile, &net_message.cursize, sizeof(int)); 93 | Sys_FileRead(vcrFile, net_message.data, net_message.cursize); 94 | 95 | VCR_ReadNext (); 96 | 97 | return 1; 98 | } 99 | 100 | 101 | int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data) 102 | { 103 | int ret; 104 | 105 | if (host_time != next.time || next.op != VCR_OP_SENDMESSAGE || next.session != *(long *)(&sock->driverdata)) 106 | Sys_Error ("VCR missmatch"); 107 | 108 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 109 | 110 | VCR_ReadNext (); 111 | 112 | return ret; 113 | } 114 | 115 | 116 | qboolean VCR_CanSendMessage (qsocket_t *sock) 117 | { 118 | qboolean ret; 119 | 120 | if (host_time != next.time || next.op != VCR_OP_CANSENDMESSAGE || next.session != *(long *)(&sock->driverdata)) 121 | Sys_Error ("VCR missmatch"); 122 | 123 | Sys_FileRead(vcrFile, &ret, sizeof(int)); 124 | 125 | VCR_ReadNext (); 126 | 127 | return ret; 128 | } 129 | 130 | 131 | void VCR_Close (qsocket_t *sock) 132 | { 133 | } 134 | 135 | 136 | void VCR_SearchForHosts (qboolean xmit) 137 | { 138 | } 139 | 140 | 141 | qsocket_t *VCR_Connect (char *host) 142 | { 143 | return NULL; 144 | } 145 | 146 | 147 | qsocket_t *VCR_CheckNewConnections (void) 148 | { 149 | qsocket_t *sock; 150 | 151 | if (host_time != next.time || next.op != VCR_OP_CONNECT) 152 | Sys_Error ("VCR missmatch"); 153 | 154 | if (!next.session) 155 | { 156 | VCR_ReadNext (); 157 | return NULL; 158 | } 159 | 160 | sock = NET_NewQSocket (); 161 | *(long *)(&sock->driverdata) = next.session; 162 | 163 | Sys_FileRead (vcrFile, sock->address, NET_NAMELEN); 164 | VCR_ReadNext (); 165 | 166 | return sock; 167 | } 168 | -------------------------------------------------------------------------------- /source/net_vcr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // net_vcr.h 21 | 22 | #define VCR_OP_CONNECT 1 23 | #define VCR_OP_GETMESSAGE 2 24 | #define VCR_OP_SENDMESSAGE 3 25 | #define VCR_OP_CANSENDMESSAGE 4 26 | #define VCR_MAX_MESSAGE 4 27 | 28 | int VCR_Init (void); 29 | void VCR_Listen (qboolean state); 30 | void VCR_SearchForHosts (qboolean xmit); 31 | qsocket_t *VCR_Connect (char *host); 32 | qsocket_t *VCR_CheckNewConnections (void); 33 | int VCR_GetMessage (qsocket_t *sock); 34 | int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data); 35 | qboolean VCR_CanSendMessage (qsocket_t *sock); 36 | void VCR_Close (qsocket_t *sock); 37 | void VCR_Shutdown (void); 38 | -------------------------------------------------------------------------------- /source/nonintel.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // nonintel.c: code for non-Intel processors only 22 | // 23 | 24 | #include "quakedef.h" 25 | #include "r_local.h" 26 | #include "d_local.h" 27 | 28 | #if !id386 29 | 30 | /* 31 | ================ 32 | R_Surf8Patch 33 | ================ 34 | */ 35 | void R_Surf8Patch () 36 | { 37 | // we only patch code on Intel 38 | } 39 | 40 | 41 | /* 42 | ================ 43 | R_Surf16Patch 44 | ================ 45 | */ 46 | void R_Surf16Patch () 47 | { 48 | // we only patch code on Intel 49 | } 50 | 51 | 52 | /* 53 | ================ 54 | R_SurfacePatch 55 | ================ 56 | */ 57 | void R_SurfacePatch (void) 58 | { 59 | // we only patch code on Intel 60 | } 61 | 62 | 63 | #endif // !id386 64 | 65 | -------------------------------------------------------------------------------- /source/nt35310.c: -------------------------------------------------------------------------------- 1 | #ifndef PC 2 | /* Copyright 2018 Canaan Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "nt35310.h" 17 | #include "gpiohs.h" 18 | #include "spi.h" 19 | #include "unistd.h" 20 | #include "board_config.h" 21 | 22 | static void init_dcx(void) 23 | { 24 | gpiohs_set_drive_mode(DCX_GPIONUM, GPIO_DM_OUTPUT); 25 | gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_HIGH); 26 | } 27 | 28 | static void set_dcx_control(void) 29 | { 30 | gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_LOW); 31 | } 32 | 33 | static void set_dcx_data(void) 34 | { 35 | gpiohs_set_pin(DCX_GPIONUM, GPIO_PV_HIGH); 36 | } 37 | 38 | #if BOARD_LICHEEDAN 39 | static void init_rst(void) 40 | { 41 | gpiohs_set_drive_mode(RST_GPIONUM, GPIO_DM_OUTPUT); 42 | gpiohs_set_pin(RST_GPIONUM, GPIO_PV_LOW); 43 | usleep(100000); 44 | gpiohs_set_pin(RST_GPIONUM, GPIO_PV_HIGH); 45 | usleep(100000); 46 | } 47 | #endif 48 | 49 | void tft_hard_init(void) 50 | { 51 | init_dcx(); 52 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0); 53 | #if BOARD_LICHEEDAN 54 | init_rst(); 55 | spi_set_clk_rate(SPI_CHANNEL, 20000000); 56 | #else 57 | spi_set_clk_rate(SPI_CHANNEL, 25000000); 58 | #endif 59 | } 60 | 61 | void tft_write_command(uint8_t cmd) 62 | { 63 | set_dcx_control(); 64 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0); 65 | spi_init_non_standard(SPI_CHANNEL, 8/*instrction length*/, 0/*address length*/, 0/*wait cycles*/, 66 | SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/); 67 | spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1,SPI_TRANS_CHAR); 68 | } 69 | 70 | void tft_write_byte(uint8_t *data_buf, uint32_t length) 71 | { 72 | set_dcx_data(); 73 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0); 74 | spi_init_non_standard(SPI_CHANNEL, 8/*instrction length*/, 0/*address length*/, 0/*wait cycles*/, 75 | SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/); 76 | spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR); 77 | } 78 | 79 | void tft_write_half(uint16_t *data_buf, uint32_t length) 80 | { 81 | set_dcx_data(); 82 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0); 83 | spi_init_non_standard(SPI_CHANNEL, 16/*instrction length*/, 0/*address length*/, 0/*wait cycles*/, 84 | SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/); 85 | spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length, SPI_TRANS_SHORT); 86 | } 87 | 88 | void tft_write_word(uint32_t *data_buf, uint32_t length, uint32_t flag) 89 | { 90 | set_dcx_data(); 91 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0); 92 | 93 | spi_init_non_standard(SPI_CHANNEL, 0/*instrction length*/, 32/*address length*/, 0/*wait cycles*/, 94 | SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/); 95 | spi_send_data_normal_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length, SPI_TRANS_INT); 96 | } 97 | 98 | void tft_fill_data(uint32_t *data_buf, uint32_t length) 99 | { 100 | set_dcx_data(); 101 | spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0); 102 | spi_init_non_standard(SPI_CHANNEL, 0/*instrction length*/, 32/*address length*/, 0/*wait cycles*/, 103 | SPI_AITM_AS_FRAME_FORMAT/*spi address trans mode*/); 104 | spi_fill_data_dma(DMAC_CHANNEL0, SPI_CHANNEL, SPI_SLAVE_SELECT,data_buf, length); 105 | } 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /source/nt35310.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 Canaan Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | #ifndef _NT35310_H_ 16 | #define _NT35310_H_ 17 | 18 | #include 19 | 20 | /* clang-format off */ 21 | #define NO_OPERATION 0x00 22 | #define SOFTWARE_RESET 0x01 23 | #define READ_ID 0x04 24 | #define READ_STATUS 0x09 25 | #define READ_POWER_MODE 0x0A 26 | #define READ_MADCTL 0x0B 27 | #define READ_PIXEL_FORMAT 0x0C 28 | #define READ_IMAGE_FORMAT 0x0D 29 | #define READ_SIGNAL_MODE 0x0E 30 | #define READ_SELT_DIAG_RESULT 0x0F 31 | #define SLEEP_ON 0x10 32 | #define SLEEP_OFF 0x11 33 | #define PARTIAL_DISPALY_ON 0x12 34 | #define NORMAL_DISPALY_ON 0x13 35 | #define INVERSION_DISPALY_OFF 0x20 36 | #define INVERSION_DISPALY_ON 0x21 37 | #define GAMMA_SET 0x26 38 | #define DISPALY_OFF 0x28 39 | #define DISPALY_ON 0x29 40 | #define HORIZONTAL_ADDRESS_SET 0x2A 41 | #define VERTICAL_ADDRESS_SET 0x2B 42 | #define MEMORY_WRITE 0x2C 43 | #define COLOR_SET 0x2D 44 | #define MEMORY_READ 0x2E 45 | #define PARTIAL_AREA 0x30 46 | #define VERTICAL_SCROL_DEFINE 0x33 47 | #define TEAR_EFFECT_LINE_OFF 0x34 48 | #define TEAR_EFFECT_LINE_ON 0x35 49 | #define MEMORY_ACCESS_CTL 0x36 50 | #define VERTICAL_SCROL_S_ADD 0x37 51 | #define IDLE_MODE_OFF 0x38 52 | #define IDLE_MODE_ON 0x39 53 | #define PIXEL_FORMAT_SET 0x3A 54 | #define WRITE_MEMORY_CONTINUE 0x3C 55 | #define READ_MEMORY_CONTINUE 0x3E 56 | #define SET_TEAR_SCANLINE 0x44 57 | #define GET_SCANLINE 0x45 58 | #define WRITE_BRIGHTNESS 0x51 59 | #define READ_BRIGHTNESS 0x52 60 | #define WRITE_CTRL_DISPALY 0x53 61 | #define READ_CTRL_DISPALY 0x54 62 | #define WRITE_BRIGHTNESS_CTL 0x55 63 | #define READ_BRIGHTNESS_CTL 0x56 64 | #define WRITE_MIN_BRIGHTNESS 0x5E 65 | #define READ_MIN_BRIGHTNESS 0x5F 66 | #define READ_ID1 0xDA 67 | #define READ_ID2 0xDB 68 | #define READ_ID3 0xDC 69 | #define RGB_IF_SIGNAL_CTL 0xB0 70 | #define NORMAL_FRAME_CTL 0xB1 71 | #define IDLE_FRAME_CTL 0xB2 72 | #define PARTIAL_FRAME_CTL 0xB3 73 | #define INVERSION_CTL 0xB4 74 | #define BLANK_PORCH_CTL 0xB5 75 | #define DISPALY_FUNCTION_CTL 0xB6 76 | #define ENTRY_MODE_SET 0xB7 77 | #define BACKLIGHT_CTL1 0xB8 78 | #define BACKLIGHT_CTL2 0xB9 79 | #define BACKLIGHT_CTL3 0xBA 80 | #define BACKLIGHT_CTL4 0xBB 81 | #define BACKLIGHT_CTL5 0xBC 82 | #define BACKLIGHT_CTL7 0xBE 83 | #define BACKLIGHT_CTL8 0xBF 84 | #define POWER_CTL1 0xC0 85 | #define POWER_CTL2 0xC1 86 | #define VCOM_CTL1 0xC5 87 | #define VCOM_CTL2 0xC7 88 | #define NV_MEMORY_WRITE 0xD0 89 | #define NV_MEMORY_PROTECT_KEY 0xD1 90 | #define NV_MEMORY_STATUS_READ 0xD2 91 | #define READ_ID4 0xD3 92 | #define POSITIVE_GAMMA_CORRECT 0xE0 93 | #define NEGATIVE_GAMMA_CORRECT 0xE1 94 | #define DIGITAL_GAMMA_CTL1 0xE2 95 | #define DIGITAL_GAMMA_CTL2 0xE3 96 | #define INTERFACE_CTL 0xF6 97 | 98 | #define DCX_GPIONUM (5) 99 | #define RST_GPIONUM (4) 100 | 101 | #define SPI_CHANNEL 0 102 | #define SPI_SLAVE_SELECT 3 103 | /* clang-format on */ 104 | 105 | void tft_hard_init(void); 106 | void tft_write_command(uint8_t cmd); 107 | void tft_write_byte(uint8_t *data_buf, uint32_t length); 108 | void tft_write_half(uint16_t *data_buf, uint32_t length); 109 | void tft_write_word(uint32_t *data_buf, uint32_t length, uint32_t flag); 110 | void tft_fill_data(uint32_t *data_buf, uint32_t length); 111 | 112 | #endif 113 | 114 | -------------------------------------------------------------------------------- /source/pr_comp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // this file is shared by quake and qcc 22 | 23 | typedef int func_t; 24 | typedef int string_t; 25 | 26 | typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; 27 | 28 | 29 | #define OFS_NULL 0 30 | #define OFS_RETURN 1 31 | #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors 32 | #define OFS_PARM1 7 33 | #define OFS_PARM2 10 34 | #define OFS_PARM3 13 35 | #define OFS_PARM4 16 36 | #define OFS_PARM5 19 37 | #define OFS_PARM6 22 38 | #define OFS_PARM7 25 39 | #define RESERVED_OFS 28 40 | 41 | 42 | enum { 43 | OP_DONE, 44 | OP_MUL_F, 45 | OP_MUL_V, 46 | OP_MUL_FV, 47 | OP_MUL_VF, 48 | OP_DIV_F, 49 | OP_ADD_F, 50 | OP_ADD_V, 51 | OP_SUB_F, 52 | OP_SUB_V, 53 | 54 | OP_EQ_F, 55 | OP_EQ_V, 56 | OP_EQ_S, 57 | OP_EQ_E, 58 | OP_EQ_FNC, 59 | 60 | OP_NE_F, 61 | OP_NE_V, 62 | OP_NE_S, 63 | OP_NE_E, 64 | OP_NE_FNC, 65 | 66 | OP_LE, 67 | OP_GE, 68 | OP_LT, 69 | OP_GT, 70 | 71 | OP_LOAD_F, 72 | OP_LOAD_V, 73 | OP_LOAD_S, 74 | OP_LOAD_ENT, 75 | OP_LOAD_FLD, 76 | OP_LOAD_FNC, 77 | 78 | OP_ADDRESS, 79 | 80 | OP_STORE_F, 81 | OP_STORE_V, 82 | OP_STORE_S, 83 | OP_STORE_ENT, 84 | OP_STORE_FLD, 85 | OP_STORE_FNC, 86 | 87 | OP_STOREP_F, 88 | OP_STOREP_V, 89 | OP_STOREP_S, 90 | OP_STOREP_ENT, 91 | OP_STOREP_FLD, 92 | OP_STOREP_FNC, 93 | 94 | OP_RETURN, 95 | OP_NOT_F, 96 | OP_NOT_V, 97 | OP_NOT_S, 98 | OP_NOT_ENT, 99 | OP_NOT_FNC, 100 | OP_IF, 101 | OP_IFNOT, 102 | OP_CALL0, 103 | OP_CALL1, 104 | OP_CALL2, 105 | OP_CALL3, 106 | OP_CALL4, 107 | OP_CALL5, 108 | OP_CALL6, 109 | OP_CALL7, 110 | OP_CALL8, 111 | OP_STATE, 112 | OP_GOTO, 113 | OP_AND, 114 | OP_OR, 115 | 116 | OP_BITAND, 117 | OP_BITOR 118 | }; 119 | 120 | 121 | typedef struct statement_s 122 | { 123 | unsigned short op; 124 | short a,b,c; 125 | } dstatement_t; 126 | 127 | typedef struct 128 | { 129 | unsigned short type; // if DEF_SAVEGLOBGAL bit is set 130 | // the variable needs to be saved in savegames 131 | unsigned short ofs; 132 | int s_name; 133 | } ddef_t; 134 | #define DEF_SAVEGLOBAL (1<<15) 135 | 136 | #define MAX_PARMS 8 137 | 138 | typedef struct 139 | { 140 | int first_statement; // negative numbers are builtins 141 | int parm_start; 142 | int locals; // total ints of parms + locals 143 | 144 | int profile; // runtime 145 | 146 | int s_name; 147 | int s_file; // source file defined in 148 | 149 | int numparms; 150 | byte parm_size[MAX_PARMS]; 151 | } dfunction_t; 152 | 153 | 154 | #define PROG_VERSION 6 155 | typedef struct 156 | { 157 | int version; 158 | int crc; // check of header file 159 | 160 | int ofs_statements; 161 | int numstatements; // statement 0 is an error 162 | 163 | int ofs_globaldefs; 164 | int numglobaldefs; 165 | 166 | int ofs_fielddefs; 167 | int numfielddefs; 168 | 169 | int ofs_functions; 170 | int numfunctions; // function 0 is an empty 171 | 172 | int ofs_strings; 173 | int numstrings; // first string is a null string 174 | 175 | int ofs_globals; 176 | int numglobals; 177 | 178 | int entityfields; 179 | } dprograms_t; 180 | 181 | -------------------------------------------------------------------------------- /source/progdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #ifdef QUAKE2 21 | #include "progdefs.q2" 22 | #else 23 | #include "progdefs.q1" 24 | #endif 25 | -------------------------------------------------------------------------------- /source/progdefs.q1: -------------------------------------------------------------------------------- 1 | 2 | /* file generated by qcc, do not modify */ 3 | 4 | typedef struct 5 | { int pad[28]; 6 | int self; 7 | int other; 8 | int world; 9 | float time; 10 | float frametime; 11 | float force_retouch; 12 | string_t mapname; 13 | float deathmatch; 14 | float coop; 15 | float teamplay; 16 | float serverflags; 17 | float total_secrets; 18 | float total_monsters; 19 | float found_secrets; 20 | float killed_monsters; 21 | float parm1; 22 | float parm2; 23 | float parm3; 24 | float parm4; 25 | float parm5; 26 | float parm6; 27 | float parm7; 28 | float parm8; 29 | float parm9; 30 | float parm10; 31 | float parm11; 32 | float parm12; 33 | float parm13; 34 | float parm14; 35 | float parm15; 36 | float parm16; 37 | vec3_t v_forward; 38 | vec3_t v_up; 39 | vec3_t v_right; 40 | float trace_allsolid; 41 | float trace_startsolid; 42 | float trace_fraction; 43 | vec3_t trace_endpos; 44 | vec3_t trace_plane_normal; 45 | float trace_plane_dist; 46 | int trace_ent; 47 | float trace_inopen; 48 | float trace_inwater; 49 | int msg_entity; 50 | func_t main; 51 | func_t StartFrame; 52 | func_t PlayerPreThink; 53 | func_t PlayerPostThink; 54 | func_t ClientKill; 55 | func_t ClientConnect; 56 | func_t PutClientInServer; 57 | func_t ClientDisconnect; 58 | func_t SetNewParms; 59 | func_t SetChangeParms; 60 | } globalvars_t; 61 | 62 | typedef struct 63 | { 64 | float modelindex; 65 | vec3_t absmin; 66 | vec3_t absmax; 67 | float ltime; 68 | float movetype; 69 | float solid; 70 | vec3_t origin; 71 | vec3_t oldorigin; 72 | vec3_t velocity; 73 | vec3_t angles; 74 | vec3_t avelocity; 75 | vec3_t punchangle; 76 | string_t classname; 77 | string_t model; 78 | float frame; 79 | float skin; 80 | float effects; 81 | vec3_t mins; 82 | vec3_t maxs; 83 | vec3_t size; 84 | func_t touch; 85 | func_t use; 86 | func_t think; 87 | func_t blocked; 88 | float nextthink; 89 | int groundentity; 90 | float health; 91 | float frags; 92 | float weapon; 93 | string_t weaponmodel; 94 | float weaponframe; 95 | float currentammo; 96 | float ammo_shells; 97 | float ammo_nails; 98 | float ammo_rockets; 99 | float ammo_cells; 100 | float items; 101 | float takedamage; 102 | int chain; 103 | float deadflag; 104 | vec3_t view_ofs; 105 | float button0; 106 | float button1; 107 | float button2; 108 | float impulse; 109 | float fixangle; 110 | vec3_t v_angle; 111 | float idealpitch; 112 | string_t netname; 113 | int enemy; 114 | float flags; 115 | float colormap; 116 | float team; 117 | float max_health; 118 | float teleport_time; 119 | float armortype; 120 | float armorvalue; 121 | float waterlevel; 122 | float watertype; 123 | float ideal_yaw; 124 | float yaw_speed; 125 | int aiment; 126 | int goalentity; 127 | float spawnflags; 128 | string_t target; 129 | string_t targetname; 130 | float dmg_take; 131 | float dmg_save; 132 | int dmg_inflictor; 133 | int owner; 134 | vec3_t movedir; 135 | string_t message; 136 | float sounds; 137 | string_t noise; 138 | string_t noise1; 139 | string_t noise2; 140 | string_t noise3; 141 | } entvars_t; 142 | 143 | #define PROGHEADER_CRC 5927 144 | -------------------------------------------------------------------------------- /source/progdefs.q2: -------------------------------------------------------------------------------- 1 | 2 | /* file generated by qcc, do not modify */ 3 | 4 | typedef struct 5 | { int pad[28]; 6 | int self; 7 | int other; 8 | int world; 9 | float time; 10 | float frametime; 11 | float force_retouch; 12 | string_t mapname; 13 | string_t startspot; 14 | float deathmatch; 15 | float coop; 16 | float teamplay; 17 | float serverflags; 18 | float total_secrets; 19 | float total_monsters; 20 | float found_secrets; 21 | float killed_monsters; 22 | float parm1; 23 | float parm2; 24 | float parm3; 25 | float parm4; 26 | float parm5; 27 | float parm6; 28 | float parm7; 29 | float parm8; 30 | float parm9; 31 | float parm10; 32 | float parm11; 33 | float parm12; 34 | float parm13; 35 | float parm14; 36 | float parm15; 37 | float parm16; 38 | vec3_t v_forward; 39 | vec3_t v_up; 40 | vec3_t v_right; 41 | float trace_allsolid; 42 | float trace_startsolid; 43 | float trace_fraction; 44 | vec3_t trace_endpos; 45 | vec3_t trace_plane_normal; 46 | float trace_plane_dist; 47 | int trace_ent; 48 | float trace_inopen; 49 | float trace_inwater; 50 | int msg_entity; 51 | string_t null; 52 | func_t main; 53 | func_t StartFrame; 54 | func_t PlayerPreThink; 55 | func_t PlayerPostThink; 56 | func_t ClientKill; 57 | func_t ClientConnect; 58 | func_t PutClientInServer; 59 | func_t ClientDisconnect; 60 | func_t SetNewParms; 61 | func_t SetChangeParms; 62 | } globalvars_t; 63 | 64 | typedef struct 65 | { 66 | float modelindex; 67 | vec3_t absmin; 68 | vec3_t absmax; 69 | float ltime; 70 | float movetype; 71 | float solid; 72 | vec3_t origin; 73 | vec3_t oldorigin; 74 | vec3_t velocity; 75 | vec3_t angles; 76 | vec3_t avelocity; 77 | vec3_t basevelocity; 78 | vec3_t punchangle; 79 | string_t classname; 80 | string_t model; 81 | float frame; 82 | float skin; 83 | float effects; 84 | float drawPercent; 85 | float gravity; 86 | float mass; 87 | float light_level; 88 | vec3_t mins; 89 | vec3_t maxs; 90 | vec3_t size; 91 | func_t touch; 92 | func_t use; 93 | func_t think; 94 | func_t blocked; 95 | float nextthink; 96 | int groundentity; 97 | float health; 98 | float frags; 99 | float weapon; 100 | string_t weaponmodel; 101 | float weaponframe; 102 | float currentammo; 103 | float ammo_shells; 104 | float ammo_nails; 105 | float ammo_rockets; 106 | float ammo_cells; 107 | float items; 108 | float items2; 109 | float takedamage; 110 | int chain; 111 | float deadflag; 112 | vec3_t view_ofs; 113 | float button0; 114 | float button1; 115 | float button2; 116 | float impulse; 117 | float fixangle; 118 | vec3_t v_angle; 119 | float idealpitch; 120 | float pitch_speed; 121 | string_t netname; 122 | int enemy; 123 | float flags; 124 | float colormap; 125 | float team; 126 | float max_health; 127 | float teleport_time; 128 | float armortype; 129 | float armorvalue; 130 | float waterlevel; 131 | float watertype; 132 | float ideal_yaw; 133 | float yaw_speed; 134 | int aiment; 135 | int goalentity; 136 | float spawnflags; 137 | string_t target; 138 | string_t targetname; 139 | float dmg_take; 140 | float dmg_save; 141 | int dmg_inflictor; 142 | int owner; 143 | vec3_t movedir; 144 | string_t message; 145 | float sounds; 146 | string_t noise; 147 | string_t noise1; 148 | string_t noise2; 149 | string_t noise3; 150 | float dmg; 151 | float dmgtime; 152 | float air_finished; 153 | float pain_finished; 154 | float radsuit_finished; 155 | float speed; 156 | } entvars_t; 157 | 158 | #define PROGHEADER_CRC 31586 159 | -------------------------------------------------------------------------------- /source/progs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | #include "pr_comp.h" // defs shared with qcc 22 | #include "progdefs.h" // generated by program cdefs 23 | 24 | typedef union eval_s 25 | { 26 | string_t string; 27 | float _float; 28 | float vector[3]; 29 | func_t function; 30 | int _int; 31 | int edict; 32 | } eval_t; 33 | 34 | #define MAX_ENT_LEAFS 16 35 | typedef struct edict_s 36 | { 37 | qboolean free; 38 | link_t area; // linked to a division node or leaf 39 | 40 | int num_leafs; 41 | short leafnums[MAX_ENT_LEAFS]; 42 | 43 | entity_state_t baseline; 44 | 45 | float freetime; // sv.time when the object was freed 46 | entvars_t v; // C exported fields from progs 47 | // other fields from progs come immediately after 48 | } edict_t; 49 | #define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) 50 | 51 | //============================================================================ 52 | 53 | extern dprograms_t *progs; 54 | extern dfunction_t *pr_functions; 55 | extern char *pr_strings; 56 | extern ddef_t *pr_globaldefs; 57 | extern ddef_t *pr_fielddefs; 58 | extern dstatement_t *pr_statements; 59 | extern globalvars_t *pr_global_struct; 60 | extern float *pr_globals; // same as pr_global_struct 61 | 62 | extern int pr_edict_size; // in bytes 63 | 64 | //============================================================================ 65 | 66 | void PR_Init (void); 67 | 68 | void PR_ExecuteProgram (func_t fnum); 69 | void PR_LoadProgs (void); 70 | 71 | void PR_Profile_f (void); 72 | 73 | edict_t *ED_Alloc (void); 74 | void ED_Free (edict_t *ed); 75 | 76 | char *ED_NewString (char *string); 77 | // returns a copy of the string allocated from the server's string heap 78 | 79 | void ED_Print (edict_t *ed); 80 | void ED_Write (FILE *f, edict_t *ed); 81 | char *ED_ParseEdict (char *data, edict_t *ent); 82 | 83 | void ED_WriteGlobals (FILE *f); 84 | void ED_ParseGlobals (char *data); 85 | 86 | void ED_LoadFromFile (char *data); 87 | 88 | //define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size)) 89 | //define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts)/pr_edict_size) 90 | 91 | edict_t *EDICT_NUM(int n); 92 | int NUM_FOR_EDICT(edict_t *e); 93 | 94 | #define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size)) 95 | 96 | #define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts) 97 | #define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) 98 | 99 | //============================================================================ 100 | 101 | #define G_FLOAT(o) (pr_globals[o]) 102 | #define G_INT(o) (*(int *)&pr_globals[o]) 103 | #define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int *)&pr_globals[o])) 104 | #define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) 105 | #define G_VECTOR(o) (&pr_globals[o]) 106 | #define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o]) 107 | #define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) 108 | 109 | #define E_FLOAT(e,o) (((float*)&e->v)[o]) 110 | #define E_INT(e,o) (*(int *)&((float*)&e->v)[o]) 111 | #define E_VECTOR(e,o) (&((float*)&e->v)[o]) 112 | #define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)&e->v)[o]) 113 | 114 | extern int type_size[8]; 115 | 116 | typedef void (*builtin_t) (void); 117 | extern builtin_t *pr_builtins; 118 | extern int pr_numbuiltins; 119 | 120 | extern int pr_argc; 121 | 122 | extern qboolean pr_trace; 123 | extern dfunction_t *pr_xfunction; 124 | extern int pr_xstatement; 125 | 126 | extern unsigned short pr_crc; 127 | 128 | void PR_RunError (char *error, ...); 129 | 130 | void ED_PrintEdicts (void); 131 | void ED_PrintNum (int ent); 132 | 133 | eval_t *GetEdictFieldValue(edict_t *ed, char *field); 134 | 135 | -------------------------------------------------------------------------------- /source/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // protocol.h -- communications protocols 21 | 22 | #define PROTOCOL_VERSION 15 23 | 24 | // if the high bit of the servercmd is set, the low bits are fast update flags: 25 | #define U_MOREBITS (1<<0) 26 | #define U_ORIGIN1 (1<<1) 27 | #define U_ORIGIN2 (1<<2) 28 | #define U_ORIGIN3 (1<<3) 29 | #define U_ANGLE2 (1<<4) 30 | #define U_NOLERP (1<<5) // don't interpolate movement 31 | #define U_FRAME (1<<6) 32 | #define U_SIGNAL (1<<7) // just differentiates from other updates 33 | 34 | // svc_update can pass all of the fast update bits, plus more 35 | #define U_ANGLE1 (1<<8) 36 | #define U_ANGLE3 (1<<9) 37 | #define U_MODEL (1<<10) 38 | #define U_COLORMAP (1<<11) 39 | #define U_SKIN (1<<12) 40 | #define U_EFFECTS (1<<13) 41 | #define U_LONGENTITY (1<<14) 42 | 43 | 44 | #define SU_VIEWHEIGHT (1<<0) 45 | #define SU_IDEALPITCH (1<<1) 46 | #define SU_PUNCH1 (1<<2) 47 | #define SU_PUNCH2 (1<<3) 48 | #define SU_PUNCH3 (1<<4) 49 | #define SU_VELOCITY1 (1<<5) 50 | #define SU_VELOCITY2 (1<<6) 51 | #define SU_VELOCITY3 (1<<7) 52 | //define SU_AIMENT (1<<8) AVAILABLE BIT 53 | #define SU_ITEMS (1<<9) 54 | #define SU_ONGROUND (1<<10) // no data follows, the bit is it 55 | #define SU_INWATER (1<<11) // no data follows, the bit is it 56 | #define SU_WEAPONFRAME (1<<12) 57 | #define SU_ARMOR (1<<13) 58 | #define SU_WEAPON (1<<14) 59 | 60 | // a sound with no channel is a local only sound 61 | #define SND_VOLUME (1<<0) // a byte 62 | #define SND_ATTENUATION (1<<1) // a byte 63 | #define SND_LOOPING (1<<2) // a long 64 | 65 | 66 | // defaults for clientinfo messages 67 | #define DEFAULT_VIEWHEIGHT 22 68 | 69 | 70 | // game types sent by serverinfo 71 | // these determine which intermission screen plays 72 | #define GAME_COOP 0 73 | #define GAME_DEATHMATCH 1 74 | 75 | //================== 76 | // note that there are some defs.qc that mirror to these numbers 77 | // also related to svc_strings[] in cl_parse 78 | //================== 79 | 80 | // 81 | // server to client 82 | // 83 | #define svc_bad 0 84 | #define svc_nop 1 85 | #define svc_disconnect 2 86 | #define svc_updatestat 3 // [byte] [long] 87 | #define svc_version 4 // [long] server version 88 | #define svc_setview 5 // [short] entity number 89 | #define svc_sound 6 // 90 | #define svc_time 7 // [float] server time 91 | #define svc_print 8 // [string] null terminated string 92 | #define svc_stufftext 9 // [string] stuffed into client's console buffer 93 | // the string should be \n terminated 94 | #define svc_setangle 10 // [angle3] set the view angle to this absolute value 95 | 96 | #define svc_serverinfo 11 // [long] version 97 | // [string] signon string 98 | // [string]..[0]model cache 99 | // [string]...[0]sounds cache 100 | #define svc_lightstyle 12 // [byte] [string] 101 | #define svc_updatename 13 // [byte] [string] 102 | #define svc_updatefrags 14 // [byte] [short] 103 | #define svc_clientdata 15 // 104 | #define svc_stopsound 16 // 105 | #define svc_updatecolors 17 // [byte] [byte] 106 | #define svc_particle 18 // [vec3] 107 | #define svc_damage 19 108 | 109 | #define svc_spawnstatic 20 110 | // svc_spawnbinary 21 111 | #define svc_spawnbaseline 22 112 | 113 | #define svc_temp_entity 23 114 | 115 | #define svc_setpause 24 // [byte] on / off 116 | #define svc_signonnum 25 // [byte] used for the signon sequence 117 | 118 | #define svc_centerprint 26 // [string] to put in center of the screen 119 | 120 | #define svc_killedmonster 27 121 | #define svc_foundsecret 28 122 | 123 | #define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten 124 | 125 | #define svc_intermission 30 // [string] music 126 | #define svc_finale 31 // [string] music [string] text 127 | 128 | #define svc_cdtrack 32 // [byte] track [byte] looptrack 129 | #define svc_sellscreen 33 130 | 131 | #define svc_cutscene 34 132 | 133 | // 134 | // client to server 135 | // 136 | #define clc_bad 0 137 | #define clc_nop 1 138 | #define clc_disconnect 2 139 | #define clc_move 3 // [usercmd_t] 140 | #define clc_stringcmd 4 // [string] message 141 | 142 | 143 | // 144 | // temp entity events 145 | // 146 | #define TE_SPIKE 0 147 | #define TE_SUPERSPIKE 1 148 | #define TE_GUNSHOT 2 149 | #define TE_EXPLOSION 3 150 | #define TE_TAREXPLOSION 4 151 | #define TE_LIGHTNING1 5 152 | #define TE_LIGHTNING2 6 153 | #define TE_WIZSPIKE 7 154 | #define TE_KNIGHTSPIKE 8 155 | #define TE_LIGHTNING3 9 156 | #define TE_LAVASPLASH 10 157 | #define TE_TELEPORT 11 158 | #define TE_EXPLOSION2 12 159 | 160 | // PGM 01/21/97 161 | #define TE_BEAM 13 162 | // PGM 01/21/97 163 | 164 | #ifdef QUAKE2 165 | #define TE_IMPLOSION 14 166 | #define TE_RAILTRAIL 15 167 | #endif 168 | -------------------------------------------------------------------------------- /source/r_shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | #ifndef GLQUAKE 21 | // r_shared.h: general refresh-related stuff shared between the refresh and the 22 | // driver 23 | 24 | // FIXME: clean up and move into d_iface.h 25 | 26 | #ifndef _R_SHARED_H_ 27 | #define _R_SHARED_H_ 28 | 29 | #define MAXVERTS 16 // max points in a surface polygon 30 | #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate 31 | // polygon (while processing) 32 | // !!! if this is changed, it must be changed in d_ifacea.h too !!! 33 | #define MAXHEIGHT 1024 34 | #define MAXWIDTH 1280 35 | #define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH) 36 | 37 | #define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE) 38 | 39 | #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to 40 | // be farther away than anything in 41 | // the scene 42 | 43 | //=================================================================== 44 | 45 | extern void R_DrawLine (polyvert_t *polyvert0, polyvert_t *polyvert1); 46 | 47 | extern int cachewidth; 48 | extern pixel_t *cacheblock; 49 | extern int screenwidth; 50 | 51 | extern float pixelAspect; 52 | 53 | extern int r_drawnpolycount; 54 | 55 | extern cvar_t r_clearcolor; 56 | 57 | extern int sintable[SIN_BUFFER_SIZE]; 58 | extern int intsintable[SIN_BUFFER_SIZE]; 59 | 60 | extern vec3_t vup, base_vup; 61 | extern vec3_t vpn, base_vpn; 62 | extern vec3_t vright, base_vright; 63 | extern entity_t *currententity; 64 | 65 | #define NUMSTACKEDGES 2400 66 | #define MINEDGES NUMSTACKEDGES 67 | #define NUMSTACKSURFACES 800 68 | #define MINSURFACES NUMSTACKSURFACES 69 | #define MAXSPANS 3000 70 | 71 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 72 | typedef struct espan_s 73 | { 74 | int u, v, count; 75 | struct espan_s *pnext; 76 | } espan_t; 77 | 78 | // FIXME: compress, make a union if that will help 79 | // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte 80 | typedef struct surf_s 81 | { 82 | struct surf_s *next; // active surface stack in r_edge.c 83 | struct surf_s *prev; // used in r_edge.c for active surf stack 84 | struct espan_s *spans; // pointer to linked list of spans to draw 85 | int key; // sorting key (BSP order) 86 | int last_u; // set during tracing 87 | int spanstate; // 0 = not in span 88 | // 1 = in span 89 | // -1 = in inverted span (end before 90 | // start) 91 | int flags; // currentface flags 92 | void *data; // associated data like msurface_t 93 | entity_t *entity; 94 | float nearzi; // nearest 1/z on surface, for mipmapping 95 | qboolean insubmodel; 96 | float d_ziorigin, d_zistepu, d_zistepv; 97 | 98 | int pad[2]; // to 64 bytes 99 | } surf_t; 100 | 101 | extern surf_t *surfaces, *surface_p, *surf_max; 102 | 103 | // surfaces are generated in back to front order by the bsp, so if a surf 104 | // pointer is greater than another one, it should be drawn in front 105 | // surfaces[1] is the background, and is used as the active surface stack. 106 | // surfaces[0] is a dummy, because index 0 is used to indicate no surface 107 | // attached to an edge_t 108 | 109 | //=================================================================== 110 | 111 | extern vec3_t sxformaxis[4]; // s axis transformed into viewspace 112 | extern vec3_t txformaxis[4]; // t axis transformed into viewspac 113 | 114 | extern vec3_t modelorg, base_modelorg; 115 | 116 | extern float xcenter, ycenter; 117 | extern float xscale, yscale; 118 | extern float xscaleinv, yscaleinv; 119 | extern float xscaleshrink, yscaleshrink; 120 | 121 | extern int d_lightstylevalue[256]; // 8.8 frac of base light value 122 | 123 | extern void TransformVector (vec3_t in, vec3_t out); 124 | extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, 125 | fixed8_t endvertu, fixed8_t endvertv); 126 | 127 | extern int r_skymade; 128 | extern void R_MakeSky (void); 129 | 130 | extern int ubasestep, errorterm, erroradjustup, erroradjustdown; 131 | 132 | // flags in finalvert_t.flags 133 | #define ALIAS_LEFT_CLIP 0x0001 134 | #define ALIAS_TOP_CLIP 0x0002 135 | #define ALIAS_RIGHT_CLIP 0x0004 136 | #define ALIAS_BOTTOM_CLIP 0x0008 137 | #define ALIAS_Z_CLIP 0x0010 138 | // !!! if this is changed, it must be changed in d_ifacea.h too !!! 139 | #define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h; 140 | // must be kept in sync 141 | #define ALIAS_XY_CLIP_MASK 0x000F 142 | 143 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 144 | typedef struct edge_s 145 | { 146 | fixed16_t u; 147 | fixed16_t u_step; 148 | struct edge_s *prev, *next; 149 | unsigned short surfs[2]; 150 | struct edge_s *nextremove; 151 | float nearzi; 152 | medge_t *owner; 153 | } edge_t; 154 | 155 | #endif // _R_SHARED_H_ 156 | 157 | #endif // GLQUAKE 158 | -------------------------------------------------------------------------------- /source/r_vars.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // r_vars.c: global refresh variables 21 | 22 | #include "quakedef.h" 23 | 24 | #if !id386 25 | 26 | // all global and static refresh variables are collected in a contiguous block 27 | // to avoid cache conflicts. 28 | 29 | //------------------------------------------------------- 30 | // global refresh variables 31 | //------------------------------------------------------- 32 | 33 | // FIXME: make into one big structure, like cl or sv 34 | // FIXME: do separately for refresh engine and driver 35 | 36 | int r_bmodelactive; 37 | 38 | #endif // !id386 39 | 40 | -------------------------------------------------------------------------------- /source/render.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // refresh.h -- public interface to refresh functions 22 | 23 | #define MAXCLIPPLANES 11 24 | 25 | #define TOP_RANGE 16 // soldier uniform colors 26 | #define BOTTOM_RANGE 96 27 | 28 | //============================================================================= 29 | 30 | typedef struct efrag_s 31 | { 32 | struct mleaf_s *leaf; 33 | struct efrag_s *leafnext; 34 | struct entity_s *entity; 35 | struct efrag_s *entnext; 36 | } efrag_t; 37 | 38 | 39 | typedef struct entity_s 40 | { 41 | qboolean forcelink; // model changed 42 | 43 | int update_type; 44 | 45 | entity_state_t baseline; // to fill in defaults in updates 46 | 47 | double msgtime; // time of last update 48 | vec3_t msg_origins[2]; // last two updates (0 is newest) 49 | vec3_t origin; 50 | vec3_t msg_angles[2]; // last two updates (0 is newest) 51 | vec3_t angles; 52 | struct model_s *model; // NULL = no model 53 | struct efrag_s *efrag; // linked list of efrags 54 | int frame; 55 | float syncbase; // for client-side animations 56 | byte *colormap; 57 | int effects; // light, particals, etc 58 | int skinnum; // for Alias models 59 | int visframe; // last frame this entity was 60 | // found in an active leaf 61 | 62 | int dlightframe; // dynamic lighting 63 | int dlightbits; 64 | 65 | // FIXME: could turn these into a union 66 | int trivial_accept; 67 | struct mnode_s *topnode; // for bmodels, first world node 68 | // that splits bmodel, or NULL if 69 | // not split 70 | } entity_t; 71 | 72 | // !!! if this is changed, it must be changed in asm_draw.h too !!! 73 | typedef struct 74 | { 75 | vrect_t vrect; // subwindow in video for refresh 76 | // FIXME: not need vrect next field here? 77 | vrect_t aliasvrect; // scaled Alias version 78 | int vrectright, vrectbottom; // right & bottom screen coords 79 | int aliasvrectright, aliasvrectbottom; // scaled Alias versions 80 | float vrectrightedge; // rightmost right edge we care about, 81 | // for use in edge list 82 | float fvrectx, fvrecty; // for floating-point compares 83 | float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping 84 | int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20 85 | int vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20 86 | float fvrectright_adj, fvrectbottom_adj; 87 | // right and bottom edges, for clamping 88 | float fvrectright; // rightmost edge, for Alias clamping 89 | float fvrectbottom; // bottommost edge, for Alias clamping 90 | float horizontalFieldOfView; // at Z = 1.0, this many X is visible 91 | // 2.0 = 90 degrees 92 | float xOrigin; // should probably allways be 0.5 93 | float yOrigin; // between be around 0.3 to 0.5 94 | 95 | vec3_t vieworg; 96 | vec3_t viewangles; 97 | 98 | float fov_x, fov_y; 99 | 100 | int ambientlight; 101 | } refdef_t; 102 | 103 | 104 | // 105 | // refresh 106 | // 107 | extern int reinit_surfcache; 108 | 109 | 110 | extern refdef_t r_refdef; 111 | extern vec3_t r_origin, vpn, vright, vup; 112 | 113 | extern struct texture_s *r_notexture_mip; 114 | 115 | 116 | void R_Init (void); 117 | void R_InitTextures (void); 118 | void R_InitEfrags (void); 119 | void R_RenderView (void); // must set r_refdef first 120 | void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect); 121 | // called whenever r_refdef or vid change 122 | void R_InitSky (struct texture_s *mt); // called at level load 123 | 124 | void R_AddEfrags (entity_t *ent); 125 | void R_RemoveEfrags (entity_t *ent); 126 | 127 | void R_NewMap (void); 128 | 129 | 130 | void R_ParseParticleEffect (void); 131 | void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count); 132 | void R_RocketTrail (vec3_t start, vec3_t end, int type); 133 | 134 | #ifdef QUAKE2 135 | void R_DarkFieldParticles (entity_t *ent); 136 | #endif 137 | void R_EntityParticles (entity_t *ent); 138 | void R_BlobExplosion (vec3_t org); 139 | void R_ParticleExplosion (vec3_t org); 140 | void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength); 141 | void R_LavaSplash (vec3_t org); 142 | void R_TeleportSplash (vec3_t org); 143 | 144 | void R_PushDlights (void); 145 | 146 | 147 | // 148 | // surface cache related 149 | // 150 | extern int reinit_surfcache; // if 1, surface cache is currently empty and 151 | extern qboolean r_cache_thrash; // set if thrashing the surface cache 152 | 153 | int D_SurfaceCacheForRes (int width, int height); 154 | void D_FlushCaches (void); 155 | void D_DeleteSurfaceCache (void); 156 | void D_InitCaches (void *buffer, int size); 157 | void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj); 158 | 159 | -------------------------------------------------------------------------------- /source/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by winquake.rc 4 | // 5 | #define IDS_STRING1 1 6 | #define IDI_ICON2 1 7 | #define IDD_DIALOG1 108 8 | #define IDD_PROGRESS 109 9 | #define IDC_PROGRESS 1000 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 111 16 | #define _APS_NEXT_COMMAND_VALUE 40001 17 | #define _APS_NEXT_CONTROL_VALUE 1004 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /source/sbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | 21 | // the status bar is only redrawn if something has changed, but if anything 22 | // does, the entire thing will be redrawn for the next vid.numpages frames. 23 | 24 | #define SBAR_HEIGHT 24 25 | 26 | extern int sb_lines; // scan lines to draw 27 | 28 | void Sbar_Init (void); 29 | 30 | void Sbar_Changed (void); 31 | // call whenever any of the client stats represented on the sbar changes 32 | 33 | void Sbar_Draw (void); 34 | // called every frame by screen 35 | 36 | void Sbar_IntermissionOverlay (void); 37 | // called each frame after the level has been completed 38 | 39 | void Sbar_FinaleOverlay (void); 40 | -------------------------------------------------------------------------------- /source/screen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // screen.h 21 | 22 | void SCR_Init (void); 23 | 24 | void SCR_UpdateScreen (void); 25 | 26 | 27 | void SCR_SizeUp (void); 28 | void SCR_SizeDown (void); 29 | void SCR_BringDownConsole (void); 30 | void SCR_CenterPrint (char *str); 31 | 32 | void SCR_BeginLoadingPlaque (void); 33 | void SCR_EndLoadingPlaque (void); 34 | 35 | int SCR_ModalMessage (char *text); 36 | 37 | extern float scr_con_current; 38 | extern float scr_conlines; // lines of console to display 39 | 40 | extern int scr_fullupdate; // set to 0 to force full redraw 41 | extern int sb_lines; 42 | 43 | extern int clearnotify; // set to 0 whenever notify text is drawn 44 | extern qboolean scr_disabled_for_loading; 45 | extern qboolean scr_skipupdate; 46 | 47 | extern cvar_t scr_viewsize; 48 | 49 | extern cvar_t scr_viewsize; 50 | 51 | // only the refresh window will be updated unless these variables are flagged 52 | extern int scr_copytop; 53 | extern int scr_copyeverything; 54 | 55 | extern qboolean block_drawing; 56 | 57 | void SCR_UpdateWholeScreen (void); 58 | -------------------------------------------------------------------------------- /source/sdcard.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDCARD_H 2 | #define _SDCARD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "stdint.h" 9 | 10 | /** 11 | * @brief Card Specific Data: CSD Register 12 | */ 13 | typedef struct { 14 | uint8_t CSDStruct; /*!< CSD structure */ 15 | uint8_t SysSpecVersion; /*!< System specification version */ 16 | uint8_t Reserved1; /*!< Reserved */ 17 | uint8_t TAAC; /*!< Data read access-time 1 */ 18 | uint8_t NSAC; /*!< Data read access-time 2 in CLK cycles */ 19 | uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ 20 | uint16_t CardComdClasses; /*!< Card command classes */ 21 | uint8_t RdBlockLen; /*!< Max. read data block length */ 22 | uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ 23 | uint8_t WrBlockMisalign; /*!< Write block misalignment */ 24 | uint8_t RdBlockMisalign; /*!< Read block misalignment */ 25 | uint8_t DSRImpl; /*!< DSR implemented */ 26 | uint8_t Reserved2; /*!< Reserved */ 27 | uint32_t DeviceSize; /*!< Device Size */ 28 | uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ 29 | uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ 30 | uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ 31 | uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ 32 | uint8_t DeviceSizeMul; /*!< Device size multiplier */ 33 | uint8_t EraseGrSize; /*!< Erase group size */ 34 | uint8_t EraseGrMul; /*!< Erase group size multiplier */ 35 | uint8_t WrProtectGrSize; /*!< Write protect group size */ 36 | uint8_t WrProtectGrEnable; /*!< Write protect group enable */ 37 | uint8_t ManDeflECC; /*!< Manufacturer default ECC */ 38 | uint8_t WrSpeedFact; /*!< Write speed factor */ 39 | uint8_t MaxWrBlockLen; /*!< Max. write data block length */ 40 | uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ 41 | uint8_t Reserved3; /*!< Reserded */ 42 | uint8_t ContentProtectAppli; /*!< Content protection application */ 43 | uint8_t FileFormatGrouop; /*!< File format group */ 44 | uint8_t CopyFlag; /*!< Copy flag (OTP) */ 45 | uint8_t PermWrProtect; /*!< Permanent write protection */ 46 | uint8_t TempWrProtect; /*!< Temporary write protection */ 47 | uint8_t FileFormat; /*!< File Format */ 48 | uint8_t ECC; /*!< ECC code */ 49 | uint8_t CSD_CRC; /*!< CSD CRC */ 50 | uint8_t Reserved4; /*!< always 1*/ 51 | } SD_CSD; 52 | 53 | /** 54 | * @brief Card Identification Data: CID Register 55 | */ 56 | typedef struct { 57 | uint8_t ManufacturerID; /*!< ManufacturerID */ 58 | uint16_t OEM_AppliID; /*!< OEM/Application ID */ 59 | uint32_t ProdName1; /*!< Product Name part1 */ 60 | uint8_t ProdName2; /*!< Product Name part2*/ 61 | uint8_t ProdRev; /*!< Product Revision */ 62 | uint32_t ProdSN; /*!< Product Serial Number */ 63 | uint8_t Reserved1; /*!< Reserved1 */ 64 | uint16_t ManufactDate; /*!< Manufacturing Date */ 65 | uint8_t CID_CRC; /*!< CID CRC */ 66 | uint8_t Reserved2; /*!< always 1 */ 67 | } SD_CID; 68 | 69 | /** 70 | * @brief SD Card information 71 | */ 72 | typedef struct { 73 | SD_CSD SD_csd; 74 | SD_CID SD_cid; 75 | uint64_t CardCapacity; /*!< Card Capacity */ 76 | uint32_t CardBlockSize; /*!< Card Block Size */ 77 | } SD_CardInfo; 78 | 79 | extern SD_CardInfo cardinfo; 80 | 81 | uint8_t sd_init(void); 82 | uint8_t sd_read_sector(uint8_t *data_buff, uint32_t sector, uint32_t count); 83 | uint8_t sd_write_sector(uint8_t *data_buff, uint32_t sector, uint32_t count); 84 | uint8_t sd_read_sector_dma(uint8_t *data_buff, uint32_t sector, uint32_t count); 85 | uint8_t sd_write_sector_dma(uint8_t *data_buff, uint32_t sector, uint32_t count); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /source/snd_ctr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Rinnegatamante 3 | Copyright (C) 2015 Felipe Izzo 4 | Copyright (C) 1996-1997 Id Software, Inc. 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU General Public License for more details. 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | #include 19 | #include "quakedef.h" 20 | 21 | #define TICKS_PER_SEC 268111856LL 22 | #define QUAKE_SAMPLERATE 32000 23 | #define CSND_SAMPLERATE 32730 24 | #define CSND_BUFSIZE 16384 25 | #define DSP_BUFSIZE 16384 26 | qboolean isDSP = true; 27 | uint32_t SAMPLERATE = QUAKE_SAMPLERATE<<1; 28 | uint32_t *audiobuffer; 29 | uint64_t initial_tick; 30 | uint64_t csnd_pause_tick;//For fixing sound desync on resume 31 | int snd_inited; 32 | 33 | /* static aptHookCookie csndAptCookie; */ 34 | 35 | //Used to fix csnd problems when pressing the home button 36 | /* static void csndAptHook(APT_HookType hook, void* param) */ 37 | /* { */ 38 | /* switch (hook) */ 39 | /* { */ 40 | /* case APTHOOK_ONWAKEUP: */ 41 | /* break; */ 42 | /* case APTHOOK_ONRESTORE: */ 43 | /* initial_tick += (svcGetSystemTick() - csnd_pause_tick); */ 44 | /* CSND_SetPlayState(0x08, 1); */ 45 | /* CSND_UpdateInfo(0); */ 46 | /* break; */ 47 | 48 | /* case APTHOOK_ONSLEEP: */ 49 | /* break; */ 50 | /* case APTHOOK_ONSUSPEND: */ 51 | /* CSND_SetPlayState(0x08, 0); */ 52 | /* CSND_UpdateInfo(0); */ 53 | /* csnd_pause_tick = svcGetSystemTick(); */ 54 | /* break; */ 55 | 56 | /* default: */ 57 | /* break; */ 58 | /* } */ 59 | /* } */ 60 | 61 | // createDspBlock: Create a new block for DSP service 62 | /* void createDspBlock(ndspWaveBuf* waveBuf, u16 bps, u32 size, u8 loop, u32* data){ */ 63 | /* waveBuf->data_vaddr = (void*)data; */ 64 | /* waveBuf->nsamples = size / bps; */ 65 | /* waveBuf->looping = loop; */ 66 | /* waveBuf->offset = 0; */ 67 | /* DSP_FlushDataCache(data, size); */ 68 | /* } */ 69 | 70 | qboolean SNDDMA_Init(void) 71 | { 72 | /* snd_initialized = 0; */ 73 | 74 | return 0; //mute 75 | 76 | 77 | /* Fill the audio DMA information block */ 78 | shm = &sn; 79 | shm->splitbuffer = 0; 80 | shm->samplebits = 16; 81 | shm->speed = QUAKE_SAMPLERATE; 82 | SAMPLERATE = QUAKE_SAMPLERATE; 83 | shm->channels = 1; 84 | shm->samples = CSND_BUFSIZE; 85 | shm->samplepos = 0; 86 | shm->submission_chunk = 1; 87 | shm->buffer = audiobuffer; 88 | 89 | initial_tick = svcGetSystemTick(); 90 | 91 | snd_initialized = 1; 92 | return 1; 93 | } 94 | 95 | int SNDDMA_GetDMAPos(void) 96 | { 97 | /* if(!snd_initialized) */ 98 | /* return 0; */ 99 | 100 | /* u64 delta = (svcGetSystemTick() - initial_tick); */ 101 | /* u64 samplepos = delta * (SAMPLERATE) / TICKS_PER_SEC; */ 102 | /* shm->samplepos = samplepos; */ 103 | /* return samplepos; */ 104 | return 0; 105 | } 106 | 107 | void SNDDMA_Shutdown(void) 108 | { 109 | /* if(snd_initialized){ */ 110 | /* if (isDSP){ */ 111 | /* ndspChnWaveBufClear(0x08); */ 112 | /* ndspExit(); */ 113 | /* free(waveBuf); */ 114 | /* }else{ */ 115 | /* CSND_SetPlayState(0x08, 0); */ 116 | /* CSND_UpdateInfo(0); */ 117 | /* csndExit(); */ 118 | /* #ifdef _3DS_CIA */ 119 | /* aptUnhook(&csndAptCookie); */ 120 | /* #endif */ 121 | /* } */ 122 | /* linearFree(audiobuffer); */ 123 | /* } */ 124 | } 125 | 126 | /* 127 | ============== 128 | SNDDMA_Submit 129 | Send sound to device if buffer isn't really the dma buffer 130 | =============== 131 | */ 132 | void SNDDMA_Submit(void) 133 | { 134 | /* if (snd_initialized){ */ 135 | /* if (isDSP) DSP_FlushDataCache(audiobuffer, DSP_BUFSIZE<<2); */ 136 | /* else CSND_FlushDataCache(audiobuffer, CSND_BUFSIZE); */ 137 | /* } */ 138 | } 139 | -------------------------------------------------------------------------------- /source/sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // sound.h -- client sound i/o functions 21 | 22 | #ifndef __SOUND__ 23 | #define __SOUND__ 24 | 25 | #define DEFAULT_SOUND_PACKET_VOLUME 255 26 | #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 27 | 28 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 29 | typedef struct 30 | { 31 | int left; 32 | int right; 33 | } portable_samplepair_t; 34 | 35 | typedef struct sfx_s 36 | { 37 | char name[MAX_QPATH]; 38 | cache_user_t cache; 39 | } sfx_t; 40 | 41 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 42 | typedef struct 43 | { 44 | int length; 45 | int loopstart; 46 | int speed; 47 | int width; 48 | int stereo; 49 | byte data[1]; // variable sized 50 | } sfxcache_t; 51 | 52 | typedef struct 53 | { 54 | qboolean gamealive; 55 | qboolean soundalive; 56 | qboolean splitbuffer; 57 | int channels; 58 | int samples; // mono samples in buffer 59 | int submission_chunk; // don't mix less than this # 60 | int samplepos; // in mono samples 61 | int samplebits; 62 | int speed; 63 | unsigned char *buffer; 64 | } dma_t; 65 | 66 | // !!! if this is changed, it much be changed in asm_i386.h too !!! 67 | typedef struct 68 | { 69 | sfx_t *sfx; // sfx number 70 | int leftvol; // 0-255 volume 71 | int rightvol; // 0-255 volume 72 | int end; // end time in global paintsamples 73 | int pos; // sample position in sfx 74 | int looping; // where to loop, -1 = no looping 75 | int entnum; // to allow overriding a specific sound 76 | int entchannel; // 77 | vec3_t origin; // origin of sound effect 78 | vec_t dist_mult; // distance multiplier (attenuation/clipK) 79 | int master_vol; // 0-255 master volume 80 | } channel_t; 81 | 82 | typedef struct 83 | { 84 | int rate; 85 | int width; 86 | int channels; 87 | int loopstart; 88 | int samples; 89 | int dataofs; // chunk starts this many bytes from file start 90 | } wavinfo_t; 91 | 92 | void S_Init (void); 93 | void S_Startup (void); 94 | void S_Shutdown (void); 95 | void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); 96 | void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation); 97 | void S_StopSound (int entnum, int entchannel); 98 | void S_StopAllSounds(qboolean clear); 99 | void S_ClearBuffer (void); 100 | void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); 101 | void S_ExtraUpdate (void); 102 | 103 | sfx_t *S_PrecacheSound (char *sample); 104 | void S_TouchSound (char *sample); 105 | void S_ClearPrecache (void); 106 | void S_BeginPrecaching (void); 107 | void S_EndPrecaching (void); 108 | void S_PaintChannels(int endtime); 109 | void S_InitPaintChannels (void); 110 | 111 | // picks a channel based on priorities, empty slots, number of channels 112 | channel_t *SND_PickChannel(int entnum, int entchannel); 113 | 114 | // spatializes a channel 115 | void SND_Spatialize(channel_t *ch); 116 | 117 | // initializes cycling through a DMA buffer and returns information on it 118 | qboolean SNDDMA_Init(void); 119 | 120 | // gets the current DMA position 121 | int SNDDMA_GetDMAPos(void); 122 | 123 | // shutdown the DMA xfer. 124 | void SNDDMA_Shutdown(void); 125 | 126 | // ==================================================================== 127 | // User-setable variables 128 | // ==================================================================== 129 | 130 | #define MAX_CHANNELS 128 131 | #define MAX_DYNAMIC_CHANNELS 8 132 | 133 | 134 | extern channel_t channels[MAX_CHANNELS]; 135 | // 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds 136 | // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc 137 | // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds 138 | 139 | extern int total_channels; 140 | 141 | // 142 | // Fake dma is a synchronous faking of the DMA progress used for 143 | // isolating performance in the renderer. The fakedma_updates is 144 | // number of times S_Update() is called per second. 145 | // 146 | 147 | extern qboolean fakedma; 148 | extern int fakedma_updates; 149 | extern int paintedtime; 150 | extern vec3_t listener_origin; 151 | extern vec3_t listener_forward; 152 | extern vec3_t listener_right; 153 | extern vec3_t listener_up; 154 | extern volatile dma_t *shm; 155 | extern volatile dma_t sn; 156 | extern vec_t sound_nominal_clip_dist; 157 | 158 | extern cvar_t loadas8bit; 159 | extern cvar_t bgmvolume; 160 | extern cvar_t volume; 161 | 162 | extern qboolean snd_initialized; 163 | 164 | extern int snd_blocked; 165 | 166 | void S_LocalSound (char *s); 167 | sfxcache_t *S_LoadSound (sfx_t *s); 168 | 169 | wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength); 170 | 171 | void SND_InitScaletable (void); 172 | void SNDDMA_Submit(void); 173 | 174 | void S_AmbientOff (void); 175 | void S_AmbientOn (void); 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /source/spritegn.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // spritegn.h: header file for sprite generation program 22 | // 23 | 24 | // ********************************************************** 25 | // * This file must be identical in the spritegen directory * 26 | // * and in the Quake directory, because it's used to * 27 | // * pass data from one to the other via .spr files. * 28 | // ********************************************************** 29 | 30 | //------------------------------------------------------- 31 | // This program generates .spr sprite package files. 32 | // The format of the files is as follows: 33 | // 34 | // dsprite_t file header structure 35 | // 36 | // 37 | // dspriteframe_t frame header structure 38 | // sprite bitmap 39 | // 40 | // dspriteframe_t frame header structure 41 | // sprite bitmap 42 | // 43 | //------------------------------------------------------- 44 | 45 | #ifdef INCLUDELIBS 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include "cmdlib.h" 53 | #include "scriplib.h" 54 | #include "dictlib.h" 55 | #include "trilib.h" 56 | #include "lbmlib.h" 57 | #include "mathlib.h" 58 | 59 | #endif 60 | 61 | #define SPRITE_VERSION 1 62 | 63 | // must match definition in modelgen.h 64 | #ifndef SYNCTYPE_T 65 | #define SYNCTYPE_T 66 | typedef enum {ST_SYNC=0, ST_RAND } synctype_t; 67 | #endif 68 | 69 | // TODO: shorten these? 70 | typedef struct { 71 | int ident; 72 | int version; 73 | int type; 74 | float boundingradius; 75 | int width; 76 | int height; 77 | int numframes; 78 | float beamlength; 79 | synctype_t synctype; 80 | } dsprite_t; 81 | 82 | #define SPR_VP_PARALLEL_UPRIGHT 0 83 | #define SPR_FACING_UPRIGHT 1 84 | #define SPR_VP_PARALLEL 2 85 | #define SPR_ORIENTED 3 86 | #define SPR_VP_PARALLEL_ORIENTED 4 87 | 88 | typedef struct { 89 | int origin[2]; 90 | int width; 91 | int height; 92 | } dspriteframe_t; 93 | 94 | typedef struct { 95 | int numframes; 96 | } dspritegroup_t; 97 | 98 | typedef struct { 99 | float interval; 100 | } dspriteinterval_t; 101 | 102 | typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t; 103 | 104 | typedef struct { 105 | int type; 106 | } dspriteframetype_t; 107 | 108 | #define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I') 109 | // little-endian "IDSP" 110 | -------------------------------------------------------------------------------- /source/sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // sys.h -- non-portable functions 21 | 22 | // 23 | // file IO 24 | // 25 | 26 | // returns the file size 27 | // return -1 if file is not present 28 | // the file should be in BINARY mode for stupid OSs that care 29 | int Sys_FileOpenRead (char *path, int *hndl); 30 | 31 | int Sys_FileOpenWrite (char *path); 32 | void Sys_FileClose (int handle); 33 | void Sys_FileSeek (int handle, int position); 34 | int Sys_FileRead (int handle, void *dest, int count); 35 | int Sys_FileWrite (int handle, void *data, int count); 36 | int Sys_FileTime (char *path); 37 | void Sys_mkdir (char *path); 38 | 39 | // 40 | // memory protection 41 | // 42 | void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length); 43 | 44 | // 45 | // system IO 46 | // 47 | void Sys_DebugLog(char *file, char *fmt, ...); 48 | 49 | void Sys_Error (char *error, ...); 50 | // an error will cause the entire program to exit 51 | 52 | void Sys_Printf (char *fmt, ...); 53 | // send text to the console 54 | 55 | void Sys_Quit (void); 56 | 57 | double Sys_FloatTime (void); 58 | 59 | char *Sys_ConsoleInput (void); 60 | 61 | void Sys_Sleep (void); 62 | // called to yield for a little bit so as 63 | // not to hog cpu when paused or debugging 64 | 65 | void Sys_SendKeyEvents (void); 66 | // Perform Key_Event () callbacks until the input que is empty 67 | 68 | void Sys_LowFPPrecision (void); 69 | void Sys_HighFPPrecision (void); 70 | void Sys_SetFPCW (void); 71 | 72 | -------------------------------------------------------------------------------- /source/touch_ctr.h: -------------------------------------------------------------------------------- 1 | #ifndef __TOUCH__ 2 | #define __TOUCH__ 3 | 4 | //Touchscreen mode identifiers 5 | #define TMODE_TOUCHPAD 1 6 | #define TMODE_KEYBOARD 2 7 | #define TMODE_SETTINGS 3 8 | 9 | void Touch_TouchpadTap(); 10 | void Touch_KeyboardTap(); 11 | void Touch_ProcessTap(); 12 | void Touch_DrawOverlay(); 13 | void Touch_Init(); 14 | void Touch_Update(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /source/vid.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // vid.h -- video driver defs 21 | 22 | #define VID_CBITS 6 23 | #define VID_GRADES (1 << VID_CBITS) 24 | 25 | // a pixel can be one, two, or four bytes 26 | typedef byte pixel_t; 27 | 28 | typedef struct vrect_s 29 | { 30 | int x,y,width,height; 31 | struct vrect_s *pnext; 32 | } vrect_t; 33 | 34 | typedef struct 35 | { 36 | pixel_t *buffer; // invisible buffer 37 | pixel_t *colormap; // 256 * VID_GRADES size 38 | unsigned short *colormap16; // 256 * VID_GRADES size 39 | int fullbright; // index of first fullbright color 40 | unsigned rowbytes; // may be > width if displayed in a window 41 | unsigned width; 42 | unsigned height; 43 | float aspect; // width / height -- < 0 is taller than wide 44 | int numpages; 45 | int recalc_refdef; // if true, recalc vid-based stuff 46 | pixel_t *conbuffer; 47 | int conrowbytes; 48 | unsigned conwidth; 49 | unsigned conheight; 50 | int maxwarpwidth; 51 | int maxwarpheight; 52 | pixel_t *direct; // direct drawing to framebuffer, if not 53 | // NULL 54 | } viddef_t; 55 | 56 | extern viddef_t vid; // global video state 57 | extern unsigned short d_8to16table[256]; 58 | extern unsigned d_8to24table[256]; 59 | extern void (*vid_menudrawfn)(void); 60 | extern void (*vid_menukeyfn)(int key); 61 | extern float separation_distance; 62 | 63 | void VID_SetPalette (unsigned char *palette); 64 | // called at startup and after any gamma correction 65 | 66 | void VID_ShiftPalette (unsigned char *palette); 67 | // called for bonus and pain flashes, and for underwater color changes 68 | 69 | void VID_Init (unsigned char *palette); 70 | // Called at startup to set up translation tables, takes 256 8 bit RGB values 71 | // the palette data will go away after the call, so it must be copied off if 72 | // the video driver will need it again 73 | 74 | void VID_Shutdown (void); 75 | // Called at shutdown 76 | 77 | void VID_Update (vrect_t *rects); 78 | // flushes the given rectangles from the view buffer to the screen 79 | 80 | int VID_SetMode (int modenum, unsigned char *palette); 81 | // sets the mode; only used by the Quake engine for resetting to mode 0 (the 82 | // base mode) on memory allocation failures 83 | 84 | void VID_SetBuffer(int buffer); 85 | 86 | void VID_HandlePause (qboolean pause); 87 | // called only on Win32, when pause happens, so the mouse can be released 88 | 89 | -------------------------------------------------------------------------------- /source/vid_ctr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Felipe Izzo 3 | Copyright (C) 1996-1997 Id Software, Inc. 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | See the GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | #include "quakedef.h" 23 | #include "d_local.h" 24 | 25 | #include "ctr.h" 26 | 27 | extern 28 | viddef_t vid; // global video state 29 | 30 | int basewidth, baseheight; 31 | 32 | byte *vid_buffer; 33 | short *zbuffer; 34 | //byte surfcache[512*1024]; 35 | float separation_distance; 36 | 37 | uint16_t d_8to16table[256]; 38 | uint32_t surfcache[1024*128]; 39 | 40 | void VID_SetPalette (unsigned char *palette) 41 | { 42 | int i; 43 | uint8_t *pal = palette; 44 | uint16_t *table = d_8to16table; 45 | unsigned r, g, b; 46 | for(i=0; i<256; i++){ 47 | r = pal[0]; 48 | g = pal[1]; 49 | b = pal[2]; 50 | table[0] = ((r>>3)<<11)+((g>>2)<<5)+(b>>3); 51 | table++; 52 | pal += 3; 53 | } 54 | } 55 | 56 | void VID_ShiftPalette (unsigned char *palette) 57 | { 58 | VID_SetPalette(palette); 59 | } 60 | 61 | void VID_Init (unsigned char *palette) 62 | { 63 | baseheight = 240; 64 | basewidth = 320; 65 | 66 | vid_buffer = malloc(sizeof(byte) * basewidth * baseheight); //Left buffer 67 | zbuffer = malloc(sizeof(short) * basewidth * baseheight); 68 | 69 | vid.maxwarpwidth = vid.width = vid.conwidth = basewidth; 70 | vid.maxwarpheight = vid.height = vid.conheight = baseheight; 71 | vid.aspect = 1.0; 72 | vid.numpages = 1; 73 | vid.colormap = host_colormap; 74 | vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048)); 75 | vid.buffer = vid.conbuffer = vid_buffer; 76 | vid.rowbytes = vid.conrowbytes = basewidth; 77 | VID_SetPalette(palette); 78 | d_pzbuffer = zbuffer; 79 | D_InitCaches (surfcache, sizeof(surfcache)); 80 | } 81 | 82 | void VID_SetBuffer (int buffer) 83 | { 84 | vid.conbuffer = vid.buffer = vid_buffer; 85 | } 86 | 87 | void VID_Shutdown (void) 88 | { 89 | free(vid_buffer); 90 | free(zbuffer); 91 | } 92 | 93 | extern float g_fps[32]; 94 | extern int g_fpsp; 95 | 96 | void VID_Update (vrect_t *rects){ 97 | static double oldtime; 98 | double time; 99 | /* int x,y; */ 100 | /* char buff[12000]=""; */ 101 | /* char tmp[128]; */ 102 | /* int r,g,b; */ 103 | // printf("\033[1;1H"); 104 | // printf("screen=%d->%dx%d\n",rects->x,rects->height,rects->width); 105 | double Sys_FloatTime (void); 106 | 107 | time = Sys_FloatTime(); 108 | g_fps[g_fpsp++&0x1F] = 1.f/(time - oldtime); 109 | lcd_draw_pic_palette(0,vid_buffer,d_8to16table); 110 | oldtime = time; 111 | /* for(y = rects->x; y < rects->height; y+=2){ */ 112 | /* buff[0]=0; */ 113 | /* for(x = rects->x; x < rects->width; x+=2){ */ 114 | /* // table[0] = ((r>>3)<<11)+((g>>2)<<5)+(b>>3); */ 115 | /* r = d_8to16table[vid_buffer[0][y*basewidth + x]]>>11; */ 116 | /* g = (d_8to16table[vid_buffer[0][y*basewidth + x]]>>5)&0x3F; */ 117 | /* b = d_8to16table[vid_buffer[0][y*basewidth + x]]&0x1F; */ 118 | /* sprintf(tmp,"\033[48;2;%d;%d;%dm ",r*8,g*4,b*8);strcat(buff,tmp); */ 119 | /* // left_fb[((x*240) + (239 -y))] = d_8to16table[vid_buffer[0][y*basewidth + x]]; */ 120 | /* } */ 121 | /* puts(buff); */ 122 | /* } */ 123 | } 124 | 125 | /* 126 | ================ 127 | D_BeginDirectRect 128 | ================ 129 | */ 130 | void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height) 131 | { 132 | } 133 | 134 | 135 | /* 136 | ================ 137 | D_EndDirectRect 138 | ================ 139 | */ 140 | void D_EndDirectRect (int x, int y, int width, int height) 141 | { 142 | } 143 | -------------------------------------------------------------------------------- /source/view.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // view.h 21 | 22 | extern cvar_t v_gamma; 23 | 24 | extern byte gammatable[256]; // palette is sent through this 25 | extern byte ramps[3][256]; 26 | extern float v_blend[4]; 27 | 28 | extern cvar_t lcd_x; 29 | 30 | 31 | void V_Init (void); 32 | void V_RenderView (void); 33 | float V_CalcRoll (vec3_t angles, vec3_t velocity); 34 | void V_UpdatePalette (void); 35 | 36 | -------------------------------------------------------------------------------- /source/vregset.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // 21 | // vregset.h: header file for video register-setting interpreter 22 | // 23 | 24 | // 25 | // registers & subregisters 26 | // 27 | #define MISC_OUTPUT 0x3C2 28 | 29 | #define SC_INDEX 0x3C4 30 | #define SC_DATA 0x3C5 31 | #define SYNC_RESET 0 32 | #define MAP_MASK 2 33 | #define MEMORY_MODE 4 34 | 35 | #define GC_INDEX 0x3CE 36 | #define GC_DATA 0x3CF 37 | #define READ_MAP 4 38 | #define GRAPHICS_MODE 5 39 | #define MISCELLANOUS 6 40 | 41 | #define CRTC_INDEX 0x3D4 42 | #define CRTC_DATA 0x3D5 43 | #define MAX_SCAN_LINE 9 44 | #define UNDERLINE 0x14 45 | #define MODE_CONTROL 0x17 46 | 47 | // 48 | // register-set commands 49 | // 50 | #define VRS_END 0 51 | #define VRS_BYTE_OUT 1 52 | #define VRS_BYTE_RMW 2 53 | #define VRS_WORD_OUT 3 54 | 55 | void VideoRegisterSet (int *pregset); 56 | 57 | -------------------------------------------------------------------------------- /source/wad.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // wad.c 21 | 22 | #include "quakedef.h" 23 | 24 | int wad_numlumps; 25 | lumpinfo_t *wad_lumps; 26 | byte *wad_base; 27 | 28 | void SwapPic (qpic_t *pic); 29 | 30 | /* 31 | ================== 32 | W_CleanupName 33 | 34 | Lowercases name and pads with spaces and a terminating 0 to the length of 35 | lumpinfo_t->name. 36 | Used so lumpname lookups can proceed rapidly by comparing 4 chars at a time 37 | Space padding is so names can be printed nicely in tables. 38 | Can safely be performed in place. 39 | ================== 40 | */ 41 | void W_CleanupName (char *in, char *out) 42 | { 43 | int i; 44 | int c; 45 | 46 | for (i=0 ; i<16 ; i++ ) 47 | { 48 | c = in[i]; 49 | if (!c) 50 | break; 51 | 52 | if (c >= 'A' && c <= 'Z') 53 | c += ('a' - 'A'); 54 | out[i] = c; 55 | } 56 | 57 | for ( ; i< 16 ; i++ ) 58 | out[i] = 0; 59 | } 60 | 61 | 62 | 63 | /* 64 | ==================== 65 | W_LoadWadFile 66 | ==================== 67 | */ 68 | void W_LoadWadFile (char *filename) 69 | { 70 | lumpinfo_t *lump_p; 71 | wadinfo_t *header; 72 | unsigned i; 73 | int infotableofs; 74 | 75 | wad_base = COM_LoadHunkFile (filename); 76 | if (!wad_base) 77 | Sys_Error ("W_LoadWadFile: couldn't load %s", filename); 78 | 79 | header = (wadinfo_t *)wad_base; 80 | 81 | if (header->identification[0] != 'W' 82 | || header->identification[1] != 'A' 83 | || header->identification[2] != 'D' 84 | || header->identification[3] != '2') 85 | Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename); 86 | 87 | wad_numlumps = LittleLong(header->numlumps); 88 | infotableofs = LittleLong(header->infotableofs); 89 | wad_lumps = (lumpinfo_t *)(wad_base + infotableofs); 90 | 91 | for (i=0, lump_p = wad_lumps ; ifilepos = LittleLong(lump_p->filepos); 94 | lump_p->size = LittleLong(lump_p->size); 95 | W_CleanupName (lump_p->name, lump_p->name); 96 | if (lump_p->type == TYP_QPIC) 97 | SwapPic ( (qpic_t *)(wad_base + lump_p->filepos)); 98 | } 99 | } 100 | 101 | 102 | /* 103 | ============= 104 | W_GetLumpinfo 105 | ============= 106 | */ 107 | lumpinfo_t *W_GetLumpinfo (char *name) 108 | { 109 | int i; 110 | lumpinfo_t *lump_p; 111 | char clean[16]; 112 | 113 | W_CleanupName (name, clean); 114 | 115 | for (lump_p=wad_lumps, i=0 ; iname)) 118 | return lump_p; 119 | } 120 | 121 | Sys_Error ("W_GetLumpinfo: %s not found", name); 122 | return NULL; 123 | } 124 | 125 | void *W_GetLumpName (char *name) 126 | { 127 | lumpinfo_t *lump; 128 | 129 | lump = W_GetLumpinfo (name); 130 | 131 | return (void *)(wad_base + lump->filepos); 132 | } 133 | 134 | void *W_GetLumpNum (int num) 135 | { 136 | lumpinfo_t *lump; 137 | 138 | if (num < 0 || num > wad_numlumps) 139 | Sys_Error ("W_GetLumpNum: bad number: %i", num); 140 | 141 | lump = wad_lumps + num; 142 | 143 | return (void *)(wad_base + lump->filepos); 144 | } 145 | 146 | /* 147 | ============================================================================= 148 | 149 | automatic byte swapping 150 | 151 | ============================================================================= 152 | */ 153 | 154 | void SwapPic (qpic_t *pic) 155 | { 156 | pic->width = LittleLong(pic->width); 157 | pic->height = LittleLong(pic->height); 158 | } 159 | -------------------------------------------------------------------------------- /source/wad.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // wad.h 21 | 22 | //=============== 23 | // TYPES 24 | //=============== 25 | 26 | #define CMP_NONE 0 27 | #define CMP_LZSS 1 28 | 29 | #define TYP_NONE 0 30 | #define TYP_LABEL 1 31 | 32 | #define TYP_LUMPY 64 // 64 + grab command number 33 | #define TYP_PALETTE 64 34 | #define TYP_QTEX 65 35 | #define TYP_QPIC 66 36 | #define TYP_SOUND 67 37 | #define TYP_MIPTEX 68 38 | 39 | typedef struct 40 | { 41 | int width, height; 42 | byte data[4]; // variably sized 43 | } qpic_t; 44 | 45 | 46 | 47 | typedef struct 48 | { 49 | char identification[4]; // should be WAD2 or 2DAW 50 | int numlumps; 51 | int infotableofs; 52 | } wadinfo_t; 53 | 54 | typedef struct 55 | { 56 | int filepos; 57 | int disksize; 58 | int size; // uncompressed 59 | char type; 60 | char compression; 61 | char pad1, pad2; 62 | char name[16]; // must be null terminated 63 | } lumpinfo_t; 64 | 65 | extern int wad_numlumps; 66 | extern lumpinfo_t *wad_lumps; 67 | extern byte *wad_base; 68 | 69 | void W_LoadWadFile (char *filename); 70 | void W_CleanupName (char *in, char *out); 71 | lumpinfo_t *W_GetLumpinfo (char *name); 72 | void *W_GetLumpName (char *name); 73 | void *W_GetLumpNum (int num); 74 | 75 | void SwapPic (qpic_t *pic); 76 | -------------------------------------------------------------------------------- /source/winquake.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // winquake.h: Win32-specific Quake header file 21 | 22 | #pragma warning( disable : 4229 ) // mgraph gets this 23 | 24 | #include 25 | #define WM_MOUSEWHEEL 0x020A 26 | 27 | #ifndef SERVERONLY 28 | #include 29 | #include 30 | #ifndef GLQUAKE 31 | #include 32 | #endif 33 | #endif 34 | 35 | extern HINSTANCE global_hInstance; 36 | extern int global_nCmdShow; 37 | 38 | #ifndef SERVERONLY 39 | 40 | extern LPDIRECTDRAW lpDD; 41 | extern qboolean DDActive; 42 | extern LPDIRECTDRAWSURFACE lpPrimary; 43 | extern LPDIRECTDRAWSURFACE lpFrontBuffer; 44 | extern LPDIRECTDRAWSURFACE lpBackBuffer; 45 | extern LPDIRECTDRAWPALETTE lpDDPal; 46 | extern LPDIRECTSOUND pDS; 47 | extern LPDIRECTSOUNDBUFFER pDSBuf; 48 | 49 | extern DWORD gSndBufSize; 50 | //#define SNDBUFSIZE 65536 51 | 52 | void VID_LockBuffer (void); 53 | void VID_UnlockBuffer (void); 54 | 55 | #endif 56 | 57 | typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t; 58 | 59 | extern modestate_t modestate; 60 | 61 | extern HWND mainwindow; 62 | extern qboolean ActiveApp, Minimized; 63 | 64 | extern qboolean WinNT; 65 | 66 | int VID_ForceUnlockedAndReturnState (void); 67 | void VID_ForceLockState (int lk); 68 | 69 | void IN_ShowMouse (void); 70 | void IN_DeactivateMouse (void); 71 | void IN_HideMouse (void); 72 | void IN_ActivateMouse (void); 73 | void IN_RestoreOriginalMouseState (void); 74 | void IN_SetQuakeMouseState (void); 75 | void IN_MouseEvent (int mstate); 76 | 77 | extern qboolean winsock_lib_initialized; 78 | 79 | extern cvar_t _windowed_mouse; 80 | 81 | extern int window_center_x, window_center_y; 82 | extern RECT window_rect; 83 | 84 | extern qboolean mouseinitialized; 85 | extern HWND hwnd_dialog; 86 | 87 | extern HANDLE hinput, houtput; 88 | 89 | void IN_UpdateClipCursor (void); 90 | void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify); 91 | 92 | void S_BlockSound (void); 93 | void S_UnblockSound (void); 94 | 95 | void VID_SetDefaultMode (void); 96 | 97 | int (PASCAL FAR *pWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData); 98 | int (PASCAL FAR *pWSACleanup)(void); 99 | int (PASCAL FAR *pWSAGetLastError)(void); 100 | SOCKET (PASCAL FAR *psocket)(int af, int type, int protocol); 101 | int (PASCAL FAR *pioctlsocket)(SOCKET s, long cmd, u_long FAR *argp); 102 | int (PASCAL FAR *psetsockopt)(SOCKET s, int level, int optname, 103 | const char FAR * optval, int optlen); 104 | int (PASCAL FAR *precvfrom)(SOCKET s, char FAR * buf, int len, int flags, 105 | struct sockaddr FAR *from, int FAR * fromlen); 106 | int (PASCAL FAR *psendto)(SOCKET s, const char FAR * buf, int len, int flags, 107 | const struct sockaddr FAR *to, int tolen); 108 | int (PASCAL FAR *pclosesocket)(SOCKET s); 109 | int (PASCAL FAR *pgethostname)(char FAR * name, int namelen); 110 | struct hostent FAR * (PASCAL FAR *pgethostbyname)(const char FAR * name); 111 | struct hostent FAR * (PASCAL FAR *pgethostbyaddr)(const char FAR * addr, 112 | int len, int type); 113 | int (PASCAL FAR *pgetsockname)(SOCKET s, struct sockaddr FAR *name, 114 | int FAR * namelen); 115 | -------------------------------------------------------------------------------- /source/world.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | // world.h 21 | 22 | typedef struct 23 | { 24 | vec3_t normal; 25 | float dist; 26 | } plane_t; 27 | 28 | typedef struct 29 | { 30 | qboolean allsolid; // if true, plane is not valid 31 | qboolean startsolid; // if true, the initial point was in a solid area 32 | qboolean inopen, inwater; 33 | float fraction; // time completed, 1.0 = didn't hit anything 34 | vec3_t endpos; // final position 35 | plane_t plane; // surface normal at impact 36 | edict_t *ent; // entity the surface is on 37 | } trace_t; 38 | 39 | 40 | #define MOVE_NORMAL 0 41 | #define MOVE_NOMONSTERS 1 42 | #define MOVE_MISSILE 2 43 | 44 | 45 | void SV_ClearWorld (void); 46 | // called after the world model has been loaded, before linking any entities 47 | 48 | void SV_UnlinkEdict (edict_t *ent); 49 | // call before removing an entity, and before trying to move one, 50 | // so it doesn't clip against itself 51 | // flags ent->v.modified 52 | 53 | void SV_LinkEdict (edict_t *ent, qboolean touch_triggers); 54 | // Needs to be called any time an entity changes origin, mins, maxs, or solid 55 | // flags ent->v.modified 56 | // sets ent->v.absmin and ent->v.absmax 57 | // if touchtriggers, calls prog functions for the intersected triggers 58 | 59 | int SV_PointContents (vec3_t p); 60 | int SV_TruePointContents (vec3_t p); 61 | // returns the CONTENTS_* value from the world at the given point. 62 | // does not check any entities at all 63 | // the non-true version remaps the water current contents to content_water 64 | 65 | edict_t *SV_TestEntityPosition (edict_t *ent); 66 | 67 | trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict); 68 | // mins and maxs are reletive 69 | 70 | // if the entire move stays in a solid volume, trace.allsolid will be set 71 | 72 | // if the starting point is in a solid, it will be allowed to move out 73 | // to an open area 74 | 75 | // nomonsters is used for line of sight or edge testing, where mosnters 76 | // shouldn't be considered solid objects 77 | 78 | // passedict is explicitly excluded from clipping checks (normally NULL) 79 | -------------------------------------------------------------------------------- /source/zone.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1996-1997 Id Software, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /* 21 | memory allocation 22 | 23 | 24 | H_??? The hunk manages the entire memory block given to quake. It must be 25 | contiguous. Memory can be allocated from either the low or high end in a 26 | stack fashion. The only way memory is released is by resetting one of the 27 | pointers. 28 | 29 | Hunk allocations should be given a name, so the Hunk_Print () function 30 | can display usage. 31 | 32 | Hunk allocations are guaranteed to be 16 byte aligned. 33 | 34 | The video buffers are allocated high to avoid leaving a hole underneath 35 | server allocations when changing to a higher video mode. 36 | 37 | 38 | Z_??? Zone memory functions used for small, dynamic allocations like text 39 | strings from command input. There is only about 48K for it, allocated at 40 | the very bottom of the hunk. 41 | 42 | Cache_??? Cache memory is for objects that can be dynamically loaded and 43 | can usefully stay persistant between levels. The size of the cache 44 | fluctuates from level to level. 45 | 46 | To allocate a cachable object 47 | 48 | 49 | Temp_??? Temp memory is used for file loading and surface caching. The size 50 | of the cache memory is adjusted so that there is a minimum of 512k remaining 51 | for temp memory. 52 | 53 | 54 | ------ Top of Memory ------- 55 | 56 | high hunk allocations 57 | 58 | <--- high hunk reset point held by vid 59 | 60 | video buffer 61 | 62 | z buffer 63 | 64 | surface cache 65 | 66 | <--- high hunk used 67 | 68 | cachable memory 69 | 70 | <--- low hunk used 71 | 72 | client and server low hunk allocations 73 | 74 | <-- low hunk reset point held by host 75 | 76 | startup hunk allocations 77 | 78 | Zone block 79 | 80 | ----- Bottom of Memory ----- 81 | 82 | 83 | 84 | */ 85 | 86 | void Memory_Init (void *buf, int size); 87 | 88 | void Z_Free (void *ptr); 89 | void *Z_Malloc (int size); // returns 0 filled memory 90 | void *Z_TagMalloc (int size, int tag); 91 | 92 | void Z_DumpHeap (void); 93 | void Z_CheckHeap (void); 94 | int Z_FreeMemory (void); 95 | 96 | void *Hunk_Alloc (int size); // returns 0 filled memory 97 | void *Hunk_AllocName (int size, char *name); 98 | 99 | void *Hunk_HighAllocName (int size, char *name); 100 | 101 | int Hunk_LowMark (void); 102 | void Hunk_FreeToLowMark (int mark); 103 | 104 | int Hunk_HighMark (void); 105 | void Hunk_FreeToHighMark (int mark); 106 | 107 | void *Hunk_TempAlloc (int size); 108 | 109 | void Hunk_Check (void); 110 | 111 | typedef struct cache_user_s 112 | { 113 | void *data; 114 | } cache_user_t; 115 | 116 | void Cache_Flush (void); 117 | 118 | void *Cache_Check (cache_user_t *c); 119 | // returns the cached data, and moves to the head of the LRU list 120 | // if present, otherwise returns NULL 121 | 122 | void Cache_Free (cache_user_t *c); 123 | 124 | void *Cache_Alloc (cache_user_t *c, int size, char *name); 125 | // Returns NULL if all purgable data was tossed and there still 126 | // wasn't enough room. 127 | 128 | void Cache_Report (void); 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /tf.xml: -------------------------------------------------------------------------------- 1 | 2 | Team Fortress 3 | /3ds/ctrQuake/ctrQuake.3dsx 4 | -game fortress 5 | 6 | -------------------------------------------------------------------------------- /touchOverlay.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elect-gombe/quake-k210/1538fee4f0a5e77dad21216e4760e7ce0be66e0d/touchOverlay.bin --------------------------------------------------------------------------------