From 971665a4fda4911d90fb9d499ad89254befcf46d Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 19 Jan 2001 03:34:10 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create tag 'd2x-0_0_9-pre1'. --- 3d/interp.asm | 1012 ---------------------------------------- input/ggi/event.c | 127 ----- input/ggi/init.c | 11 - input/ggi/key.c | 495 -------------------- input/ggi/mouse.c | 158 ------- input/linux/joydefs.c | 237 ---------- input/linux/joystick.c | 376 --------------- input/sdl/event.c | 54 --- input/sdl/key.c | 616 ------------------------ input/sdl/mouse.c | 234 ---------- unused/bios/findfile.c | 111 ----- 11 files changed, 3431 deletions(-) delete mode 100644 3d/interp.asm delete mode 100644 input/ggi/event.c delete mode 100644 input/ggi/init.c delete mode 100644 input/ggi/key.c delete mode 100644 input/ggi/mouse.c delete mode 100644 input/linux/joydefs.c delete mode 100644 input/linux/joystick.c delete mode 100644 input/sdl/event.c delete mode 100644 input/sdl/key.c delete mode 100644 input/sdl/mouse.c delete mode 100644 unused/bios/findfile.c diff --git a/3d/interp.asm b/3d/interp.asm deleted file mode 100644 index f459abbf..00000000 --- a/3d/interp.asm +++ /dev/null @@ -1,1012 +0,0 @@ -; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -; IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -; FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. - - -.386 - option oldstructs - - .nolist - include pstypes.inc - include psmacros.inc - include gr.inc - include 3d.inc - .list - - assume cs:_TEXT, ds:_DATA - -_DATA segment dword public USE32 'DATA' - -rcsid db "$Id: interp.asm,v 1.1.1.1 2001-01-19 03:29:58 bradleyb Exp $" - align 4 - -;table with address for each opcode -opcode_table dd op_eof ;0 = eof - dd op_defpoints ;1 = defpoints - dd op_flatpoly ;2 = flat-shaded polygon - dd op_tmappoly ;3 = texture-mapped polygon - dd op_sortnorm ;4 = sort by normal - dd op_rodbm ;5 = rod bitmap - dd op_subcall ;6 = call a subobject - dd op_defp_start ;7 = defpoints with start - dd op_glow ;8 = glow value for next poly -n_opcodes = ($-opcode_table)/4 - -bitmap_ptr dd ? -anim_angles dd ? ;pointer to angle data - -morph_points dd ? ;alternate points for morph - -;light value for the next tmap -glow_num dd -1 ;-1 means off -glow_values dd ? ;ptr to array of values - - public _highest_texture_num -_highest_texture_num dw 0 - -zero_angles fixang 0,0,0 ;vms_angvec <0,0,0> ;for if no angles specified - -rod_top_p g3s_point <> -rod_bot_p g3s_point <> - - public g3d_interp_outline,_g3d_interp_outline -_g3d_interp_outline label dword -g3d_interp_outline dd 0 - -morph_pointlist dd ?,?,? - -morph_uvls fix 3 dup (?,?,?) - -;the light for the current model -model_light fix ? - -;ptr to array of points -Interp_point_list dd ? - -MAX_POINTS_PER_POLY = 25 - -point_list dd MAX_POINTS_PER_POLY dup (?) - -MAX_INTERP_COLORS = 100 - -;this is a table of mappings from RGB15 to palette colors -interp_color_table dw MAX_INTERP_COLORS dup (?,?) - -n_interp_colors dd 0 -uninit_flag dd 0 - - -_DATA ends - - - -_TEXT segment dword public USE32 'CODE' - -;get and jump to next opcode -next macro - xor ebx,ebx - mov bx,[ebp] - ifndef NDEBUG - cmp ebx,n_opcodes - break_if ge,'Invalid opcode' - endif - mov ebx,opcode_table[ebx*4] - jmp ebx - endm - -;get and call the next opcode -call_next macro - xor ebx,ebx - mov bx,[ebp] - ifndef NDEBUG - cmp ebx,n_opcodes - break_if ge,'Invalid opcode' - endif - mov ebx,opcode_table[ebx*4] - call ebx - endm - -;give the interpreter an array of points to use -g3_set_interp_points: - mov Interp_point_list,eax - ret - -;interpreter to draw polygon model -;takes esi=ptr to object, edi=ptr to array of bitmap pointers, -;eax=ptr to anim angles, edx=light value, ebx=ptr to array of glow values -g3_draw_polygon_model: - pushm eax,ebx,ecx,edx,esi,edi,ebp - - mov ebp,esi ;ebp = interp ptr - - mov bitmap_ptr,edi ;save ptr to bitmap array - mov anim_angles,eax - mov model_light,edx - mov glow_values,ebx - - mov glow_num,-1 - -;;@@ mov depth,0 - - call_next - - popm eax,ebx,ecx,edx,esi,edi,ebp - ret - -;handlers for opcodes - -;end of a model or sub-rountine -op_eof: ret - -;define a list of points -op_defpoints: xor ecx,ecx - mov cx,2[ebp] ;num points - mov edi,Interp_point_list - lea esi,4[ebp] -rotate_loop: call g3_rotate_point - add edi,size g3s_point - add esi,size vms_vector - dec ecx - jnz rotate_loop - mov ebp,esi - next - -;define a list of points, with starting point num specified -op_defp_start: xor ecx,ecx - xor eax,eax - mov ax,w 4[ebp] ;starting point num - imulc eax,size g3s_point ;get ofs of point - add eax,Interp_point_list - mov edi,eax - mov cx,2[ebp] ;num points - lea esi,8[ebp] - jmp rotate_loop - next - -;draw a flat-shaded polygon -op_flatpoly: xor ecx,ecx - mov cx,2[ebp] ;num verts - lea esi,4[ebp] ;point - lea edi,16[ebp] ;vector - call g3_check_normal_facing - jng flat_not_facing - -;polygon is facing, so draw it - -;here the glow parameter is used for the player's headlight - test glow_num,-1 ;glow override? - js no_glow2 - mov eax,glow_num - mov esi,glow_values - mov eax,[esi+eax*4] - mov glow_num,-1 - cmp eax,-1 ;-1 means draw normal color - jne not_normal_color -;use the color specified, run through darkening table - xor ebx,ebx - mov eax,32 ;32 shades - imul model_light - sar eax,16 - or eax,eax - jns no_sat1 - xor eax,eax -no_sat1: cmp eax,32 - jl no_sat2 - mov eax,32 -no_sat2: mov bh,al ;get lighting table - xor eax,eax - mov ax,28[ebp] ;get color index - mov ax,interp_color_table[eax*4] - mov bl,al - mov al,gr_fade_table[ebx] - jmp got_color_index -not_normal_color: cmp eax,-2 ;-2 means use white - jne not_white - mov eax,255 ;hack! - jmp got_color_index -not_white: cmp eax,-3 ;-3 means don't draw polygon - je flat_not_facing -no_glow2: - - xor eax,eax - mov ax,28[ebp] ;get color index - mov ax,interp_color_table[eax*4] -got_color_index: call gr_setcolor_ ;set it - - lea esi,30[ebp] ;point number list - - ;make list of point pointers - - ifndef NDEBUG - cmp ecx,MAX_POINTS_PER_POLY - break_if ge,'Too many points in interp poly' - endif - - lea edi,point_list - xor ebx,ebx -copy_loop: xor eax,eax - mov ax,w [esi+ebx*2] ;get point number - imulc eax,size g3s_point - add eax,Interp_point_list - mov [edi+ebx*4],eax - inc ebx - cmp ebx,ecx - jne copy_loop - mov esi,edi - - call g3_draw_poly - xor ecx,ecx - mov cx,2[ebp] ;restore count - - ifndef NDEBUG - test g3d_interp_outline,-1 - jz no_outline - pushm ecx,esi - lea esi,30[ebp] - call draw_outline - popm ecx,esi -no_outline: - endif - -;polygon is not facing (or we've plotted it). jump to next opcode -flat_not_facing: and ecx,0fffffffeh - inc ecx ;adjust for pad - lea ebp,30[ebp+ecx*2] - next - -;set the glow value for the next tmap -op_glow: test glow_values,-1 - jz skip_glow - xor eax,eax - mov ax,2[ebp] - mov glow_num,eax -skip_glow: add ebp,4 - next - - -;draw a texture map -op_tmappoly: xor ecx,ecx - mov cx,2[ebp] ;num verts - lea esi,4[ebp] ;point - lea edi,16[ebp] ;normal - call g3_check_normal_facing - jng tmap_not_facing - -;polygon is facing, so draw it - - xor edx,edx - mov dx,28[ebp] ;get bitmap number - mov eax,bitmap_ptr - mov edx,[eax+edx*4] - - lea esi,30[ebp] ;point number list - mov eax,ecx - and eax,0fffffffeh - inc eax - lea ebx,30[ebp+eax*2] ;get uvl list - -;calculate light from surface normal - push esi - - test glow_num,-1 ;glow override? - js no_glow -;special glow lighting, which doesn't care about surface normal - mov eax,glow_num - mov esi,glow_values - mov eax,[esi+eax*4] - mov glow_num,-1 - jmp got_light_value -no_glow: - lea esi,View_matrix.fvec - lea edi,16[ebp] ;normal - call vm_vec_dotprod - neg eax -;scale light by model light - push edx - mov edx,eax - add eax,eax - add eax,edx ;eax *= 3 - sar eax,2 ;eax *= 3/4 - add eax,f1_0/4 ;eax = 1/4 + eax * 3/4 - fixmul model_light - pop edx -;now poke light into l values -got_light_value: pushm ecx,ebx -l_loop: mov 8[ebx],eax - add ebx,12 - dec ecx - jnz l_loop - popm ecx,ebx - pop esi - -;now draw it - ;make list of point pointers - - ifndef NDEBUG - cmp ecx,MAX_POINTS_PER_POLY - break_if ge,'Too many points in interp poly' - endif - - push ebx - lea edi,point_list - xor ebx,ebx -copy_loop2: xor eax,eax - mov ax,w [esi+ebx*2] ;get point number - imulc eax,size g3s_point - add eax,Interp_point_list - mov [edi+ebx*4],eax - inc ebx - cmp ebx,ecx - jne copy_loop2 - mov esi,edi - pop ebx - - call g3_draw_tmap - xor ecx,ecx - mov cx,2[ebp] ;restore count - - ifndef NDEBUG - test g3d_interp_outline,-1 - jz no_outline2 - pushm ecx,esi - lea esi,30[ebp] - call draw_outline - popm ecx,esi -no_outline2: - endif - -;polygon is not facing (or we've plotted it). jump to next opcode -tmap_not_facing: mov ebx,ecx - and ebx,0fffffffeh - inc ebx ;adjust for pad - lea ebp,30[ebp+ebx*2] - - mov eax,ecx - sal ecx,1 - add ecx,eax - sal ecx,2 ;ecx=ecx*12 - add ebp,ecx ;point past uvls - - next - -;sort based on surface normal -op_sortnorm: lea esi,16[ebp] ;point - lea edi,4[ebp] ;vector - call g3_check_normal_facing - jng sortnorm_not_facing - -;is facing. draw back then front - - push ebp - xor eax,eax - mov ax,30[ebp] ;get back offset - add ebp,eax - call_next - mov ebp,[esp] ;get ebp - xor eax,eax - mov ax,28[ebp] ;get front offset - add ebp,eax - call_next - pop ebp - - lea ebp,32[ebp] - next - -;is not facing. draw front then back - -sortnorm_not_facing: - push ebp - xor eax,eax - mov ax,28[ebp] ;get back offset - add ebp,eax - call_next - mov ebp,[esp] ;get ebp - xor eax,eax - mov ax,30[ebp] ;get front offset - add ebp,eax - call_next - pop ebp - - lea ebp,32[ebp] - next - -;draw a rod bitmap -op_rodbm: lea esi,20[ebp] ;bot point - lea edi,rod_bot_p - call g3_rotate_point - - lea esi,4[ebp] ;top point - lea edi,rod_top_p - call g3_rotate_point - - lea esi,rod_bot_p ;esi=bot, edi=top - mov eax,16[ebp] ;bot width - mov edx,32[ebp] ;top width - - xor ebx,ebx - mov bx,2[ebp] ;get bitmap number - mov ecx,bitmap_ptr - mov ebx,[ecx+ebx*4] - - call g3_draw_rod_tmap - - lea ebp,36[ebp] - next - - -;draw a subobject -op_subcall: xor eax,eax - mov ax,2[ebp] ;get object number - -;get ptr to angles - mov edi,anim_angles - or edi,edi - jnz angles_not_null -;angles not specified. Use zero angles - lea edi,zero_angles - jmp got_angles -angles_not_null: - imulc eax,size vms_angvec - add edi,eax -got_angles: - ;angles in edi - - lea esi,4[ebp] ;get position - call g3_start_instance_angles - - push ebp - xor eax,eax - mov ax,16[ebp] - add ebp,eax ;offset of subobject - call_next ;draw the subobject - pop ebp - - call g3_done_instance - - lea ebp,20[ebp] - next - -;takes ax, returns ax -find_color_index: push ebx - - ;first, see if color already in table - - xor ebx,ebx ;counter -look_loop: cmp ebx,n_interp_colors - je must_add_color - cmp ax,interp_color_table+2[ebx*4] - je found_color - inc ebx - jmp look_loop - -must_add_color: mov interp_color_table+2[ebx*4],ax ;save rgb15 - call gr_find_closest_color_15bpp_ - mov interp_color_table[ebx*4],ax ;save pal entry - inc n_interp_colors - -found_color: mov eax,ebx ;return index - pop ebx - ret - -;this remaps the 15bpp colors for the models into a new palette. It should -;be called whenever the palette changes -g3_remap_interp_colors: - pushm eax,ebx - - xor ebx,ebx ;index -remap_loop: cmp ebx,n_interp_colors - je done_remap - - xor eax,eax - mov ax,interp_color_table+2[ebx*4] ;get rgb15 - call gr_find_closest_color_15bpp_ - mov interp_color_table[ebx*4],ax ;store pal entry - - inc ebx - jmp remap_loop - -done_remap: popm eax,ebx - ret - - -;maps the colors back to RGB15 -g3_uninit_polygon_model: - mov uninit_flag,1 - -;initialize a polygon object -;translate colors, scale UV values -;takes esi=ptr to model -g3_init_polygon_model: - mov _highest_texture_num,-1 - - pushm eax,ebx,ecx,edx,esi,edi - call init_loop - popm eax,ebx,ecx,edx,esi,edi - - mov uninit_flag,0 - ret - - -init_loop: mov ax,[esi] ;get opcode - cmp ax,0 ;eof - jne not_eof - ret -not_eof: - -;defpoints - cmp ax,1 ;defpoints - jne not_defpoints - xor eax,eax - mov ax,2[esi] ;get count - sal eax,1 - add ax,2[esi] ;*3 - lea esi,4[esi+eax*4] - jmp init_loop -not_defpoints: - -;flat polygon - cmp ax,2 - jne not_flatpoly - ifndef NDEBUG - cmp w 2[esi],3 - break_if l,'face must have 3 or more points' - endif - ; The following 3 lines replace the above - xor eax, eax - mov ax,28[esi] ;get color - test uninit_flag,-1 - jz not_uninit -;unitialize! - mov ax,interp_color_table+2[eax*4] - jmp cont1 -not_uninit: - call find_color_index -cont1: mov 28[esi],ax ;store new color - - xor ecx,ecx - mov cx,2[esi] ;get nverts - and ecx,0fffffffeh - inc ecx ;adjust for pad - lea esi,30[esi+ecx*2] - jmp init_loop -not_flatpoly: - -;tmap polygon - cmp ax,3 - jne not_tmappoly - ifndef NDEBUG - cmp w 2[esi],3 - break_if l,'face must have 3 or more points' - endif - mov ax,28[esi] ;get bitmap number - cmp ax,_highest_texture_num - jle not_new - mov _highest_texture_num,ax -not_new: xor ecx,ecx - mov cx,2[esi] ;get nverts - mov ebx,ecx - and ebx,0fffffffeh - inc ebx ;adjust for pad - lea esi,30[esi+ebx*2] ;point at uvls - - imul ecx,12 ;size of uvls - add esi,ecx ;skip them - jmp init_loop - -;;@@init_uv_loop: mov eax,[esi] ;get u -;;@@ imul eax,64 ;times bitmap w -;;@@ mov [esi],eax -;;@@ mov eax,4[esi] ;get v -;;@@ imul eax,64 ;times bitmap h -;;@@ mov 4[esi],eax -;;@@ add esi,12 ;point at next -;;@@ dec ecx -;;@@ jnz init_uv_loop -;;@@ jmp init_loop -not_tmappoly: - -;sort - cmp ax,4 ;sortnorm - jne not_sortnorm - - push esi - xor eax,eax - mov ax,28[esi] ;get front offset - add esi,eax - call init_loop - mov esi,[esp] - xor eax,eax - mov ax,30[esi] ;get front offset - add esi,eax - call init_loop - pop esi - lea esi,32[esi] - - jmp init_loop -not_sortnorm: - cmp ax,5 - jne not_rodbm - - add esi,36 - jmp init_loop - -not_rodbm: - cmp ax,6 - jne not_subcall - - - push esi - xor eax,eax - mov ax,16[esi] ;get subobj offset - add esi,eax - call init_loop - pop esi - - add esi,20 - jmp init_loop -not_subcall: - cmp ax,7 ;defpoints - jne not_defpoints_st - xor eax,eax - mov ax,2[esi] ;get count - sal eax,1 - add ax,2[esi] ;*3 - lea esi,8[esi+eax*4] - jmp init_loop -not_defpoints_st: - cmp ax,8 - jne not_glow - add esi,4 - jmp init_loop -not_glow: - - debug_brk "Invalid opcode" - - jmp init_loop - - -;takes ecx=count, esi=ptr to point list -draw_outline: pushm eax,ebx,ecx,edx,esi,edi - - ;NO_INVERSE_TABLE xor eax,eax - ;NO_INVERSE_TABLE mov al,gr_inverse_table[7fffh] ;white - mov eax, 255 ; bright white - call gr_setcolor_ - - mov ebx,esi - - xor eax,eax - mov ax,[ebx] ;get first point - push eax ;save it - -outline_loop: xor esi,esi - xor edi,edi - mov si,[ebx] - dec ecx - jz done_loop - mov di,2[ebx] - push ebx - - imul esi,size g3s_point - add esi,Interp_point_list - imul edi,size g3s_point - add edi,Interp_point_list - - call g3_draw_line - pop ebx - - add ebx,2 - jmp outline_loop - -done_loop: pop edi ;get first point back - - imul esi,size g3s_point - add esi,Interp_point_list - imul edi,size g3s_point - add edi,Interp_point_list - - call g3_draw_line - - popm eax,ebx,ecx,edx,esi,edi - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;Special code to draw morphing objects - -;define a list of points -morph_defpoints: xor ecx,ecx - mov cx,2[ebp] ;num points - mov edi,Interp_point_list - lea esi,4[ebp] -morph_rotate_list: lea eax,[ecx*2+ecx] ;eax=npoint * 3 - lea esi,[esi+eax*4] ;point past points - push esi - mov esi,morph_points ;get alternate points -morph_rotate_loop: call g3_rotate_point - add edi,size g3s_point - add esi,size vms_vector - dec ecx - jnz morph_rotate_loop - pop esi ;restore pointer - mov ebp,esi - next - -;define a list of points, with starting point num specified -morph_defp_start: xor ecx,ecx - xor eax,eax - mov ax,w 4[ebp] ;starting point num - imulc eax,size g3s_point ;get ofs of point - add eax,Interp_point_list - mov edi,eax - mov cx,2[ebp] ;num points - lea esi,8[ebp] - jmp morph_rotate_list - -;draw a flat-shaded polygon -morph_flatpoly: xor ecx,ecx - mov cx,2[ebp] ;num verts - lea esi,4[ebp] ;point - lea edi,16[ebp] ;vector - -;set color - xor eax,eax - mov ax,28[ebp] ;get color - mov ax,interp_color_table[eax*4] - call gr_setcolor_ ;set it - -;check and draw - lea esi,30[ebp] ;point number list - - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+4,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+8,eax - - cmp ecx,3 ;3 points is good! - je flat_got3 - sub ecx,2 ;tri count - -flat_tri_loop: xor edi,edi ;no normal, must compute - pushm ecx,esi - mov ecx,3 ;always draw triangle - lea esi,morph_pointlist - call g3_check_and_draw_poly - popm ecx,esi - - mov eax,morph_pointlist+8 - mov morph_pointlist+4,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+8,eax - - dec ecx - jnz flat_tri_loop - jmp flat_done_draw - -flat_got3: - lea esi,morph_pointlist - xor edi,edi ;no normal, must compute - call g3_check_and_draw_poly - -flat_done_draw: xor ecx,ecx - mov cx,2[ebp] ;restore count - - and ecx,0fffffffeh - inc ecx ;adjust for pad - lea ebp,30[ebp+ecx*2] - next - -;draw a texture map -morph_tmappoly: xor ecx,ecx - mov cx,2[ebp] ;num verts - lea esi,4[ebp] ;point - lea edi,16[ebp] ;normal - -;get bitmap - xor edx,edx - mov dx,28[ebp] ;get bitmap number - mov eax,bitmap_ptr - mov edx,[eax+edx*4] - - lea esi,30[ebp] ;point number list - mov eax,ecx - and eax,0fffffffeh - inc eax - lea ebx,30[ebp+eax*2] ;get uvl list -;calculate light from surface normal - push esi - lea esi,View_matrix.fvec - lea edi,16[ebp] ;normal - call vm_vec_dotprod - neg eax -;scale light by model light - push edx - mov edx,eax - add eax,eax - add eax,edx ;eax *= 3 - sar eax,2 ;eax *= 3/4 - add eax,f1_0/4 ;eax = 1/4 + eax * 3/4 - fixmul model_light - - or eax,eax - jge not_zero - xor eax,eax -not_zero: - pop edx - pop esi - -;now eax=plane light value - - mov morph_uvls+8,eax - mov morph_uvls+20,eax - mov morph_uvls+32,eax - - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+4,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+8,eax - - cmp ecx,3 ;3 points is good! - jl tmap_done_draw ;something is bad, abort - je tmap_got3 - sub ecx,2 ;tri count - - push edx - - mov edx,[ebx] - mov morph_uvls,edx - mov edx,4[ebx] - mov morph_uvls+4,edx - - mov edx,12[ebx] - mov morph_uvls+12,edx - mov edx,16[ebx] - mov morph_uvls+16,edx - - mov edx,24[ebx] - mov morph_uvls+24,edx - mov edx,28[ebx] - mov morph_uvls+28,edx - - add ebx,3*12 - - pop edx - - -tmap_tri_loop: xor edi,edi ;no normal, must compute - pushm ebx,edx,ecx,esi - mov ecx,3 ;always draw triangle - lea esi,morph_pointlist - lea ebx,morph_uvls - call g3_check_and_draw_tmap - popm ebx,edx,ecx,esi - - mov eax,morph_pointlist+8 - mov morph_pointlist+4,eax - xor eax,eax - lodsw - imulc eax,size g3s_point - add eax,Interp_point_list - mov morph_pointlist+8,eax - - push edx - mov edx,morph_uvls+24 - mov morph_uvls+12,edx - mov edx,morph_uvls+28 - mov morph_uvls+16,edx - - mov edx,[ebx] - mov morph_uvls+24,edx - mov edx,4[ebx] - mov morph_uvls+28,edx - add ebx,12 - pop edx - - dec ecx - jnz tmap_tri_loop - jmp tmap_done_draw - -tmap_got3: -;poke in light values - pusha -tmap_l_loop: mov 8[ebx],eax - add ebx,12 - dec ecx - jnz tmap_l_loop - popa - - lea esi,morph_pointlist - - xor edi,edi ;no normal - call g3_check_and_draw_tmap - -tmap_done_draw: xor ecx,ecx - mov cx,2[ebp] ;restore count - -;jump to next opcode - mov ebx,ecx - and ebx,0fffffffeh - inc ebx ;adjust for pad - lea ebp,30[ebp+ebx*2] - - mov eax,ecx - sal ecx,1 - add ecx,eax - sal ecx,2 ;ecx=ecx*12 - add ebp,ecx ;point past uvls - - next - - -;interpreter to draw polygon model -;takes esi=ptr to object, edi=ptr to array of bitmap pointers, -;eax=ptr to anim angles, ebx=alternate points, edx=light value - -g3_draw_morphing_model: - pushm eax,ebx,ecx,edx,esi,edi,ebp - - mov bitmap_ptr,edi ;save ptr to bitmap array - mov anim_angles,eax - mov morph_points,ebx - mov model_light,edx - - mov ebp,esi ;ebp = interp ptr - - ;set alternate opcode pointers - - push opcode_table[1*4] ;defpoints - push opcode_table[2*4] ;flatpoly - push opcode_table[3*4] ;tmappoly - push opcode_table[7*4] ;defp_start - - mov opcode_table[1*4],offset morph_defpoints - mov opcode_table[2*4],offset morph_flatpoly - mov opcode_table[3*4],offset morph_tmappoly - mov opcode_table[7*4],offset morph_defp_start - - call_next - - pop opcode_table[7*4] ;defp_start - pop opcode_table[3*4] ;tmappoly - pop opcode_table[2*4] ;flatpoly - pop opcode_table[1*4] ;defpoints - - popm eax,ebx,ecx,edx,esi,edi,ebp - ret - -_TEXT ends - - end - diff --git a/input/ggi/event.c b/input/ggi/event.c deleted file mode 100644 index 3ba2697c..00000000 --- a/input/ggi/event.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include -#include -#include "event.h" -#include "error.h" -#include "fix.h" - -static int initialised=0; - -#ifdef GGI_VIDEO -#include -extern ggi_visual_t *screenvis; -#endif -gii_input_t inputs; - -extern void keyboard_handler(int key, ubyte state); -extern void mouse_handler_button(int button, ubyte state); -extern void mouse_handler_relative(int x, int y); -extern void mouse_handler_absolute(int x, int y); - -void event_poll() -{ - int n; - struct timeval tv; - gii_event event; - - if (!initialised) - event_init(); - if (inputs==NULL) - return; -// Error("GII error: no inputs (perhaps you need to set GII_INPUT env var)\n"); - - tv.tv_sec = 0; - tv.tv_usec = 0; - - giiEventPoll(inputs, emAll, &tv); - - n = giiEventsQueued(inputs, emAll); - - while (n-- > 0) - { - giiEventRead(inputs, &event, emAll); - switch (event.any.type) - { - case evKeyPress: - keyboard_handler(event.key.label, 1); - break; - case evKeyRelease: - keyboard_handler(event.key.label, 0); - break; - case evPtrAbsolute: - mouse_handler_absolute(event.pmove.x, event.pmove.y); - break; - case evPtrRelative: - mouse_handler_relative(event.pmove.x, event.pmove.y); - break; - case evPtrButtonPress: - mouse_handler_button(event.pbutton.button, 1); - break; - case evPtrButtonRelease: - mouse_handler_button(event.pbutton.button, 0); - break; - } - } -} - -void event_close() -{ - if (inputs) - giiClose(inputs); - giiExit(); -} - -#ifdef GII_XWIN -int gii_xwin_initialized=0; -#include -//void lock_nothing(void){return;} -void init_gii_xwin(Display *disp,Window win){ - printf("gii xwin %i %i\n",initialised,gii_xwin_initialized); - if (!initialised) - event_init(); - if (gii_xwin_initialized){ - gii_event ev; - gii_xwin_cmddata_setparam *giiargs=(gii_xwin_cmddata_setparam *) &ev.cmd.data; - memset(&ev,0,sizeof(gii_cmd_nodata_event)+sizeof(gii_xwin_cmddata_setparam)); - ev.cmd.code=GII_CMDCODE_XWINSETPARAM; - ev.any.type = evCommand; - ev.any.size=sizeof(gii_cmd_nodata_event)+sizeof(gii_xwin_cmddata_setparam); - giiargs->win=win; - giiargs->ptralwaysrel=1; - giiEventSend(inputs,&ev); - }else{ - gii_input_t inputs2; - gii_inputxwin_arg giiargs; - memset(&giiargs,0,sizeof(giiargs)); - giiargs.disp=disp; - giiargs.win=win; - giiargs.ptralwaysrel=1; - //giiargs.gglock=lock_nothing; - inputs2=giiOpen("xwin",&giiargs,NULL); - if (inputs2){ - gii_xwin_initialized=1; - if (inputs) - inputs=giiJoinInputs(inputs,inputs2); - else - inputs=inputs2; - } - } -} -#endif - -int event_init() -{ - if (!initialised){ - giiInit(); -#ifdef GGI_VIDEO - inputs = ggiJoinInputs(screenvis, NULL); -#else - inputs=giiOpen(NULL); -#endif - initialised = 1; - atexit(event_close); - } - return 0; -} diff --git a/input/ggi/init.c b/input/ggi/init.c deleted file mode 100644 index 80ccebc5..00000000 --- a/input/ggi/init.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "text.h" -#include "event.h" -#include "error.h" -#include "args.h" - -void arch_ggi_init() -{ -} diff --git a/input/ggi/key.c b/input/ggi/key.c deleted file mode 100644 index 8d4cb074..00000000 --- a/input/ggi/key.c +++ /dev/null @@ -1,495 +0,0 @@ -#include -#include -#include - -#include - -#include "event.h" -#include "error.h" -#include "key.h" -#include "timer.h" -#include "mono.h" - -//added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such -#include "d_delay.h" -//end this section addition - Matt Mueller - -#define KEY_BUFFER_SIZE 16 - -static unsigned char Installed = 0; - -//-------- Variable accessed by outside functions --------- -unsigned char keyd_buffer_type; // 0=No buffer, 1=buffer ASCII, 2=buffer scans -unsigned char keyd_repeat; -unsigned char keyd_editor_mode; -volatile unsigned char keyd_last_pressed; -volatile unsigned char keyd_last_released; -volatile unsigned char keyd_pressed[256]; -volatile int keyd_time_when_last_pressed; - -typedef struct Key_info { - ubyte state; // state of key 1 == down, 0 == up - ubyte last_state; // previous state of key - int counter; // incremented each time key is down in handler - fix timewentdown; // simple counter incremented each time in interrupt and key is down - fix timehelddown; // counter to tell how long key is down -- gets reset to 0 by key routines - ubyte downcount; // number of key counts key was down - ubyte upcount; // number of times key was released -} Key_info; - -typedef struct keyboard { - unsigned short keybuffer[KEY_BUFFER_SIZE]; - Key_info keys[256]; - fix time_pressed[KEY_BUFFER_SIZE]; - unsigned int keyhead, keytail; -} keyboard; - -static /*volatile*/ keyboard key_data; - -char * key_text[256] = { -"","ESC","1","2","3","4","5","6","7","8","9","0","-", -"=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", -"P","[","]","ƒ","LCTRL","A","S","D","F", -"G","H","J","K","L",";","'","`", -"LSHFT","\\","Z","X","C","V","B","N","M",",", -".","/","RSHFT","PAD*","LALT","SPC", -"CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", -"F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", -"PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", -"PAD.","","","","F11","F12","","","","","","","","","", -"","","","","","","","","","","","","","","","","","","","", -"","","","","","","","","","","","","","","","","","","","", -"","","","","","","","","","","","","","","","","","", -"PADƒ","RCTRL","","","","","","","","","","","","","", -"","","","","","","","","","","PAD/","","","RALT","", -"","","","","","","","","","","","","","HOME","‚","PGUP", -"","","","","","END","€","PGDN","INS", -"DEL","","","","","","","","","","","","","","","","","", -"","","","","","","","","","","","","","","","","","","","", -"","","","","","","" }; - -unsigned char ascii_table[128] = -{ 255, 255, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',255,255, - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 255, 255, - 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', - 255, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 255,'*', - 255, ' ', 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255,255, - 255, 255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255 }; - -unsigned char shifted_ascii_table[128] = -{ 255, 255, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',255,255, - 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 255, 255, - 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', - 255, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 255,255, - 255, ' ', 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255,255, - 255, 255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255 }; - -int giiKeyTranslate (int keylabel) { - switch (keylabel) - { - case GIIUC_0: return KEY_0; - case GIIUC_1: return KEY_1; - case GIIUC_2: return KEY_2; - case GIIUC_3: return KEY_3; - case GIIUC_4: return KEY_4; - case GIIUC_5: return KEY_5; - case GIIUC_6: return KEY_6; - case GIIUC_7: return KEY_7; - case GIIUC_8: return KEY_8; - case GIIUC_9: return KEY_9; - - case GIIUC_A: return KEY_A; - case GIIUC_B: return KEY_B; - case GIIUC_C: return KEY_C; - case GIIUC_D: return KEY_D; - case GIIUC_E: return KEY_E; - case GIIUC_F: return KEY_F; - case GIIUC_G: return KEY_G; - case GIIUC_H: return KEY_H; - case GIIUC_I: return KEY_I; - case GIIUC_J: return KEY_J; - case GIIUC_K: return KEY_K; - case GIIUC_L: return KEY_L; - case GIIUC_M: return KEY_M; - case GIIUC_N: return KEY_N; - case GIIUC_O: return KEY_O; - case GIIUC_P: return KEY_P; - case GIIUC_Q: return KEY_Q; - case GIIUC_R: return KEY_R; - case GIIUC_S: return KEY_S; - case GIIUC_T: return KEY_T; - case GIIUC_U: return KEY_U; - case GIIUC_V: return KEY_V; - case GIIUC_W: return KEY_W; - case GIIUC_X: return KEY_X; - case GIIUC_Y: return KEY_Y; - case GIIUC_Z: return KEY_Z; - - case GIIUC_Minus: return KEY_MINUS; - case GIIUC_Equal: return KEY_EQUAL; - case GIIUC_Slash: return KEY_DIVIDE; - case GIIUC_BackSlash: return KEY_SLASH; - case GIIUC_Comma: return KEY_COMMA; - case GIIUC_Period: return KEY_PERIOD; - case GIIUC_Semicolon: return KEY_SEMICOL; - - case GIIUC_BracketLeft: return KEY_LBRACKET; - case GIIUC_BracketRight: return KEY_RBRACKET; - - case GIIUC_Apostrophe: return KEY_RAPOSTRO; - case GIIUC_Grave: return KEY_LAPOSTRO; - - case GIIUC_Escape: return KEY_ESC; - case GIIK_Enter: return KEY_ENTER; - case GIIUC_BackSpace: return KEY_BACKSP; - case GIIUC_Tab: return KEY_TAB; - case GIIUC_Space: return KEY_SPACEBAR; - - case GIIK_NumLock: return KEY_NUMLOCK; - case GIIK_ScrollLock: return KEY_SCROLLOCK; - case GIIK_CapsLock: return KEY_CAPSLOCK; - - case GIIK_ShiftL: return KEY_LSHIFT; - case GIIK_ShiftR: return KEY_RSHIFT; - - case GIIK_AltL: return KEY_LALT; - case GIIK_AltR: return KEY_RALT; - - case GIIK_CtrlL: return KEY_LCTRL; - case GIIK_CtrlR: return KEY_RCTRL; - - case GIIK_F1: return KEY_F1; - case GIIK_F2: return KEY_F2; - case GIIK_F3: return KEY_F3; - case GIIK_F4: return KEY_F4; - case GIIK_F5: return KEY_F5; - case GIIK_F6: return KEY_F6; - case GIIK_F7: return KEY_F7; - case GIIK_F8: return KEY_F8; - case GIIK_F9: return KEY_F9; - case GIIK_F10: return KEY_F10; - case GIIK_F11: return KEY_F11; - case GIIK_F12: return KEY_F12; - - case GIIK_P0: return KEY_PAD0; - case GIIK_P1: return KEY_PAD1; - case GIIK_P2: return KEY_PAD2; - case GIIK_P3: return KEY_PAD3; - case GIIK_P4: return KEY_PAD4; - case GIIK_P5: return KEY_PAD5; - case GIIK_P6: return KEY_PAD6; - case GIIK_P7: return KEY_PAD7; - case GIIK_P8: return KEY_PAD8; - case GIIK_P9: return KEY_PAD9; - case GIIK_PMinus: return KEY_PADMINUS; - case GIIK_PPlus: return KEY_PADPLUS; - case GIIK_PDecimal: return KEY_PADPERIOD; - case GIIK_PSlash: return KEY_PADDIVIDE; - case GIIK_PAsterisk: return KEY_PADMULTIPLY; - case GIIK_PEnter: return KEY_PADENTER; - - case GIIK_Insert: return KEY_INSERT; - case GIIK_Home: return KEY_HOME; - case GIIK_PageUp: return KEY_PAGEUP; - case GIIK_Delete: return KEY_DELETE; - case GIIK_End: return KEY_END; - case GIIK_PageDown: return KEY_PAGEDOWN; - case GIIK_Up: return KEY_UP; - case GIIK_Down: return KEY_DOWN; - case GIIK_Left: return KEY_LEFT; - case GIIK_Right: return KEY_RIGHT; - - case GIIK_PrintScreen: return KEY_PRINT_SCREEN; - case GIIK_Pause: return KEY_PAUSE; - } - return 0; -} - -//killed on 10/03/98 by Matt Mueller -//unsigned char key_to_ascii(int a) -//{ -// if (!isprint(a)) return 255; -// if (a & KEY_SHIFTED) { -// return (toupper((unsigned char) a)); -// } else { -// return ((unsigned char) a); -// } -//} -//end kill -MM - -//added on 10/03/98 by Matt Mueller to fix shifted keys (copied from dos/key.c) -unsigned char key_to_ascii(int keycode) -{ - int shifted; - - shifted = keycode & KEY_SHIFTED; - keycode &= 0xFF; - - if ( keycode>=127 ) - return 255; - - if (shifted) - return shifted_ascii_table[keycode]; - else - return ascii_table[keycode]; -} -//end addition -MM - -void keyboard_handler(int button, ubyte state) -{ - ubyte key_state; - int i, keycode; - unsigned short event_key; - Key_info *key; - unsigned char temp; - - key_state = state; - event_key = giiKeyTranslate(button); - //mprintf((0,"keyboard_handler(%i,%i):%i\n",button,state,event_key)); - - //===================================================== - //Here a translation from win keycodes to mac keycodes! - //===================================================== - - for (i = 255; i >= 0; i--) { - - keycode = i; - key = &(key_data.keys[keycode]); - if (i == event_key) - state = key_state; - else - state = key->last_state; - - if ( key->last_state == state ) { - if (state) { - key->counter++; - keyd_last_pressed = keycode; - keyd_time_when_last_pressed = timer_get_fixed_seconds(); - } - } else { - if (state) { - keyd_last_pressed = keycode; - keyd_pressed[keycode] = 1; - key->downcount += state; - key->state = 1; - key->timewentdown = keyd_time_when_last_pressed = timer_get_fixed_seconds(); - key->counter++; - } else { - keyd_pressed[keycode] = 0; - keyd_last_released = keycode; - key->upcount += key->state; - key->state = 0; - key->counter = 0; - key->timehelddown += timer_get_fixed_seconds() - key->timewentdown; - } - } - if ( (state && !key->last_state) || (state && key->last_state && (key->counter > 30) && (key->counter & 0x01)) ) { - if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) - keycode |= KEY_SHIFTED; - if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]) - keycode |= KEY_ALTED; - if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) - keycode |= KEY_CTRLED; - if ( keyd_pressed[KEY_DELETE] ) - keycode |= KEY_DEBUGGED; - temp = key_data.keytail+1; - if ( temp >= KEY_BUFFER_SIZE ) temp=0; - if (temp!=key_data.keyhead) { - key_data.keybuffer[key_data.keytail] = keycode; - key_data.time_pressed[key_data.keytail] = keyd_time_when_last_pressed; - key_data.keytail = temp; - } - } - key->last_state = state; - } -} - -void key_close() -{ - Installed = 0; -} - -void key_init() -{ - Installed=1; - - keyd_time_when_last_pressed = timer_get_fixed_seconds(); - keyd_buffer_type = 1; - keyd_repeat = 1; - -// Clear the keyboard array - key_flush(); - atexit(key_close); -} - -void key_flush() -{ - int i; - fix curtime; - - if (!Installed) - key_init(); - - key_data.keyhead = key_data.keytail = 0; - - //Clear the keyboard buffer - for (i=0; i= KEY_BUFFER_SIZE ) n=0; - return n; -} - -int key_checkch() -{ - int is_one_waiting = 0; - event_poll(); - if (key_data.keytail!=key_data.keyhead) - is_one_waiting = 1; - return is_one_waiting; -} - -int key_inkey() -{ - int key = 0; - if (!Installed) - key_init(); - event_poll(); - if (key_data.keytail!=key_data.keyhead) { - key = key_data.keybuffer[key_data.keyhead]; - key_data.keyhead = add_one(key_data.keyhead); - } -//added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such -// else d_delay(1); -//end addition - Matt Mueller - return key; -} - -int key_inkey_time(fix * time) -{ - int key = 0; - - if (!Installed) - key_init(); - event_poll(); - if (key_data.keytail!=key_data.keyhead) { - key = key_data.keybuffer[key_data.keyhead]; - *time = key_data.time_pressed[key_data.keyhead]; - key_data.keyhead = add_one(key_data.keyhead); - } - return key; -} - -int key_peekkey() -{ - int key = 0; - event_poll(); - if (key_data.keytail!=key_data.keyhead) - key = key_data.keybuffer[key_data.keyhead]; - - return key; -} - -int key_getch() -{ - int dummy=0; - - if (!Installed) - return 0; -// return getch(); - - while (!key_checkch()) - dummy++; - return key_inkey(); -} - -unsigned int key_get_shift_status() -{ - unsigned int shift_status = 0; - - if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT] ) - shift_status |= KEY_SHIFTED; - - if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT] ) - shift_status |= KEY_ALTED; - - if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL] ) - shift_status |= KEY_CTRLED; - -#ifndef NDEBUG - if (keyd_pressed[KEY_DELETE]) - shift_status |=KEY_DEBUGGED; -#endif - - return shift_status; -} - -// Returns the number of seconds this key has been down since last call. -fix key_down_time(int scancode) -{ - fix time_down, time; - - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - if (!keyd_pressed[scancode]) { - time_down = key_data.keys[scancode].timehelddown; - key_data.keys[scancode].timehelddown = 0; - } else { - time = timer_get_fixed_seconds(); - time_down = time - key_data.keys[scancode].timewentdown; - key_data.keys[scancode].timewentdown = time; - } - - return time_down; -} - -unsigned int key_down_count(int scancode) -{ - int n; - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - n = key_data.keys[scancode].downcount; - key_data.keys[scancode].downcount = 0; - - return n; -} - -unsigned int key_up_count(int scancode) -{ - int n; - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - n = key_data.keys[scancode].upcount; - key_data.keys[scancode].upcount = 0; - - return n; -} - diff --git a/input/ggi/mouse.c b/input/ggi/mouse.c deleted file mode 100644 index 7bf97316..00000000 --- a/input/ggi/mouse.c +++ /dev/null @@ -1,158 +0,0 @@ -#include -#include -#include -#include -#include "fix.h" -#include "timer.h" -#include "event.h" -#include "mouse.h" - -struct mousebutton { - ubyte pressed; - fix time_went_down; - fix time_held_down; - uint num_downs; - uint num_ups; -}; - -#define MOUSE_MAX_BUTTONS 3 - -static struct mouseinfo { - struct mousebutton buttons[MOUSE_MAX_BUTTONS]; -//added on 10/17/98 by Hans de Goede for mouse functionality - int min_x, min_y; - int max_x, max_y; - int delta_x, delta_y; - int x,y; -} Mouse; - -void mouse_correct() -{ - if (Mouse.x < Mouse.min_x) - Mouse.x = Mouse.min_x; - else if (Mouse.x > Mouse.max_x) - Mouse.x = Mouse.max_x; - if (Mouse.y < Mouse.min_y) - Mouse.y = Mouse.min_y; - else if (Mouse.y > Mouse.max_y) - Mouse.y = Mouse.max_y; -} - -void mouse_handler_absolute(int x, int y) -{ - Mouse.delta_x += (x - Mouse.x); - Mouse.delta_y += (y - Mouse.y); - Mouse.x = x; - Mouse.y = y; -// mouse_correct(); -} - -void mouse_handler_relative(int x, int y) -{ - Mouse.delta_x += x; - Mouse.delta_y += y; - Mouse.x += x; - Mouse.y += y; -// mouse_correct(); -} - -void mouse_handler_button(int button, ubyte state) -{ - if (!Mouse.buttons[button].pressed && state) - { - Mouse.buttons[button].time_went_down = timer_get_fixed_seconds(); - Mouse.buttons[button].num_downs++; - } - else if (Mouse.buttons[button].pressed && !state) - { - Mouse.buttons[button].num_ups++; - } - - Mouse.buttons[button].pressed = state; -} - -void Mouse_close(void) -{ -} - -void Mouse_init(void) -{ - memset(&Mouse, 0, sizeof(Mouse)); -} - -int mouse_set_limits( int x1, int y1, int x2, int y2 ) -{ - Mouse.min_x = x1; - Mouse.max_x = x2; - Mouse.min_y = y1; - Mouse.max_y = y2; - return MOUSE_MAX_BUTTONS; -} - -void mouse_flush() // clears all mice events... -{ - Mouse.x = 0; - Mouse.y = 0; - Mouse.delta_x = 0; - Mouse.delta_y = 0; -} - -//======================================================================== -void mouse_get_pos( int *x, int *y) -{ - event_poll(); - *x = Mouse.x; - *y = Mouse.y; -} - -void mouse_get_delta( int *dx, int *dy ) -{ - event_poll(); - *dx = Mouse.delta_x; - *dy = Mouse.delta_y; - Mouse.delta_x = 0; - Mouse.delta_y = 0; -} - -int mouse_get_btns() -{ - ubyte buttons = 0; - int i; - event_poll(); - for (i = 0; i < MOUSE_MAX_BUTTONS; i++) - buttons |= (Mouse.buttons[i].pressed << i); - return buttons; -} - -void mouse_set_pos( int x, int y) -{ - Mouse.x = x; - Mouse.y = y; -} - -void mouse_get_cyberman_pos( int *x, int *y ) -{ -} - -// Returns how long this button has been down since last call. -fix mouse_button_down_time(int button) -{ - if (Mouse.buttons[button].pressed) - return (timer_get_fixed_seconds() - Mouse.buttons[button].time_went_down); - else - return 0; -} - -// Returns how many times this button has went down since last call -int mouse_button_down_count(int button) -{ - int count = Mouse.buttons[button].num_downs; - Mouse.buttons[button].num_downs = 0; - return count; -} - -// Returns 1 if this button is currently down -int mouse_button_state(int button) -{ - return Mouse.buttons[button].pressed; -} diff --git a/input/linux/joydefs.c b/input/linux/joydefs.c deleted file mode 100644 index 8e072e0d..00000000 --- a/input/linux/joydefs.c +++ /dev/null @@ -1,237 +0,0 @@ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - -#include -#include -#include -#include - -#include "pstypes.h" -#include "mono.h" -#include "key.h" -#include "joy.h" -#include "timer.h" -#include "error.h" - -#include "inferno.h" -#include "game.h" -#include "object.h" -#include "player.h" - -#include "controls.h" -#include "joydefs.h" -//#include "victor.h" -#include "render.h" -#include "palette.h" -#include "newmenu.h" -#include "args.h" -#include "text.h" -#include "kconfig.h" -#include "digi.h" -#include "playsave.h" - -int joydefs_calibrate_flag = 0; - -//added 9/6/98 Matt Mueller - not needed at all in linux code but bunches -int Joy_is_Sidewinder=0;// of main/* stuff uses it -//end addition - -void joy_delay() -{ - //int t1 = TICKER + 19/4; // Wait 1/4 second... - //stop_time(); - //while( TICKER < t1 ); - //joy_flush(); - //start_time(); -} - - -int joycal_message( char * title, char * text ) -{ - int i; - newmenu_item m[2]; - m[0].type = NM_TYPE_TEXT; m[0].text = text; - m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK; - i = newmenu_do( title, NULL, 2, m, NULL ); - if ( i < 0 ) - return 1; - return 0; -} - -extern int WriteConfigFile(); - -extern joystick_device j_joystick[4]; -extern joystick_axis j_axis[MAX_AXES]; -extern joystick_button j_button[MAX_BUTTONS]; - -void joydefs_calibrate() -{ - - int i; - int temp_values[MAX_AXES]; - char title[50]; - char text[256]; -//added/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix -//-killed- int nsticks = 0; -//end this section kill - Hans - - joydefs_calibrate_flag = 0; - - if (!joy_present) { - nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK ); - return; - } - - if (j_joystick[0].version) { - joycal_message ("No Calibration", "calibration not required for\njoystick v1.x"); - return; - } - - for (i = 0; i < j_num_axes; i += 2) { - sprintf (title, "js%d Calibration", j_axis[i].joydev); - - sprintf (text, "center joystick %d", j_axis[i].joydev); - joycal_message (title, text); - joystick_read_raw_axis (JOY_ALL_AXIS, temp_values); - j_axis[i].center_val = temp_values[i]; - j_axis[i + 1].center_val = temp_values[i + 1]; - - sprintf (text, "move joystick %d to the upper left", j_axis[i].joydev); - joycal_message (title, text); - joystick_read_raw_axis (JOY_ALL_AXIS, temp_values); - j_axis[i].min_val = temp_values[i]; - j_axis[i + 1].min_val = temp_values[i + 1]; - - sprintf (text, "move joystick %d to the lower right", j_axis[i].joydev); - joycal_message (title, text); - joystick_read_raw_axis (JOY_ALL_AXIS, temp_values); - j_axis[i].max_val = temp_values[i]; - j_axis[i + 1].max_val = temp_values[i + 1]; - - } - - WriteConfigFile (); -} - - -//char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" }; - -void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem ) -{ - int i; - int oc_type = Config_control_type; - - nitems = nitems; - last_key = last_key; - citem = citem; - - for (i=0; i<3; i++ ) - if (items[i].value) Config_control_type = i; - -//added on 10/17/98 by Hans de Goede for joystick/mouse # fix - // remap mouse, since "Flightstick Pro", "Thrustmaster FCS" - // and "Gravis Gamepad" where removed from the options - if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE; -//end this section addition - Hans - - if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) { - nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS ); - } - - if (oc_type != Config_control_type) { - switch (Config_control_type) { - // case CONTROL_NONE: - case CONTROL_JOYSTICK: - case CONTROL_FLIGHTSTICK_PRO: - case CONTROL_THRUSTMASTER_FCS: - case CONTROL_GRAVIS_GAMEPAD: - // case CONTROL_MOUSE: - // case CONTROL_CYBERMAN: - joydefs_calibrate_flag = 1; - } - kc_set_controls(); - } - -} - -extern ubyte kc_use_external_control; -extern ubyte kc_enable_external_control; -extern ubyte *kc_external_name; - -void joydefs_config() -{ -//added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix -//-killed- char xtext[128]; -//-killed- int i, old_masks, masks; - newmenu_item m[13]; -//-killed- int i1=5; -//-killed- int nitems; -//-killed- -//-killed- do { -//-killed- nitems = 6; - int i, i1=5, j, nitems=7; -//end this section kill/change - Hans - - m[0].type = NM_TYPE_RADIO; m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0; - m[1].type = NM_TYPE_RADIO; m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0; - m[2].type = NM_TYPE_RADIO; m[2].text = "MOUSE"; m[2].value = 0; m[2].group = 0; - m[3].type = NM_TYPE_TEXT; m[3].text=""; - m[4].type = NM_TYPE_MENU; m[4].text="CUSTOMIZE ABOVE"; - m[5].type = NM_TYPE_MENU; m[5].text="CUSTOMIZE KEYBOARD"; -//added on 2/5/99 by Victor Rachels for D1X keys menu - m[6].type = NM_TYPE_MENU; m[6].text="CUSTOMIZE D1X KEYS"; -//end this section addition - VR - -//added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix -//-killed- m[Config_control_type].value = 1; - - do { - - - i = Config_control_type; - if(i==CONTROL_MOUSE) i = 2; - m[i].value=1; -//end section - OE -//end this section change/addition - Hans - - i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 ); - -//added 6-15-99 Owen Evans - for (j = 0; j <= 2; j++) - if (m[j].value) - Config_control_type = j; - i = Config_control_type; - if (Config_control_type == 2) - Config_control_type = CONTROL_MOUSE; -//end added - OE - - switch(i1) { - case 4: -//added/changed on 10/17/98 by Hans de Goede for joystick/mouse # fix -//-killed- kconfig(Config_control_type, m[Config_control_type].text); - kconfig (i, m[i].text); -//end this section change - Hans - break; - case 5: - kconfig(0, "KEYBOARD"); - break; -//added on 2/5/99 by Victor Rachels for D1X keys menu - case 6: - kconfig(3, "D1X KEYS"); - break; -//end this section addition - VR - } - - } while(i1>-1); - -} diff --git a/input/linux/joystick.c b/input/linux/joystick.c deleted file mode 100644 index 6c9a1ee0..00000000 --- a/input/linux/joystick.c +++ /dev/null @@ -1,376 +0,0 @@ -#include -#include -#include -//#include "joystick.h" -#include -#include -#include - -#include "timer.h" -#include "pstypes.h" -#include "mono.h" -#include "joy.h" - -char joy_installed = 0; -char joy_present = 0; - -joystick_device j_joystick[4]; -joystick_axis j_axis[MAX_AXES]; -joystick_button j_button[MAX_BUTTONS]; - -int j_num_axes = 0, j_num_buttons = 0; -int timer_rate; - -int j_axes_in_sticks[4]; /* number of axes in the first [x] sticks */ -int j_buttons_in_sticks[4]; /* number of buttons in the first [x] sticks */ - -int joy_deadzone = 0; - -int j_Get_joydev_axis_number (int all_axis_number) { - int i, joy_axis_number = all_axis_number; - - for (i = 0; i < j_axis[all_axis_number].joydev; i++) { - joy_axis_number -= j_joystick[i].num_axes; - } - - return joy_axis_number; -} - - -int j_Get_joydev_button_number (int all_button_number) { - int i, joy_button_number = all_button_number; - - for (i = 0; i < j_button[all_button_number].joydev; i++) { - joy_button_number -= j_joystick[i].num_buttons; - } - - return joy_button_number; -} - - -int j_Update_state () { -/* int num_processed = 0, i; - struct js_event current_event; - struct JS_DATA_TYPE joy_data; - - for (i = 0; i < j_num_buttons; i++) { - //changed 6/24/1999 to finally squish the timedown bug - Owen Evans - if (j_button[i].state != j_button[i].last_state) { - if (j_button[i].state) { - j_button[i].downcount++; - j_button[i].timedown = timer_get_fixed_seconds(); - } - } - //end changed - OE - j_button[i].last_state = j_button[i].state; - } - - for (i = 0; i < 4; i++) { - if (j_joystick[i].buffer >= 0) { - if (j_joystick[i].version) { - while (read (j_joystick[i].buffer, ¤t_event, sizeof (struct js_event)) > 0) { - num_processed++; - switch (current_event.type & ~JS_EVENT_INIT) { - case JS_EVENT_AXIS: - j_axis[j_axes_in_sticks[i] + current_event.number].value = current_event.value; - break; - case JS_EVENT_BUTTON: - j_button[j_buttons_in_sticks[i] + current_event.number].state = current_event.value; - break; - } - } - } else { - read (j_joystick[i].buffer, &joy_data, JS_RETURN); - j_axis[j_axes_in_sticks[i] + 0].value = joy_data.x; - j_axis[j_axes_in_sticks[i] + 1].value = joy_data.y; - j_button[j_buttons_in_sticks[i] + 0].state = (joy_data.buttons & 0x01); - j_button[j_buttons_in_sticks[i] + 1].state = (joy_data.buttons & 0x02) >> 1; - } - } - } - - return num_processed;*/ - return 0; -} - - -void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max) { - int i; - - for (i = 0; i < 4; i++) { - j_axis[i].center_val = axis_center[i]; - j_axis[i].min_val = axis_min[i]; - j_axis[i].max_val = axis_max[i]; - } -} - - -void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max) { - int i; - - //edited 05/18/99 Matt Mueller - we should return all axes instead of j_num_axes, since they are all given to us in joy_set_cal_vals ( and because checker complains :) - for (i = 0; i < 4; i++) { - //end edit -MM - axis_center[i] = j_axis[i].center_val; - axis_min[i] = j_axis[i].min_val; - axis_max[i] = j_axis[i].max_val; - } -} - - -void joy_set_min (int axis_number, int value) { - j_axis[axis_number].min_val = value; -} - - -void joy_set_center (int axis_number, int value) { - j_axis[axis_number].center_val = value; -} - - -void joy_set_max (int axis_number, int value) { - j_axis[axis_number].max_val = value; -} - - -ubyte joy_get_present_mask () { - return 1; -} - - -void joy_set_timer_rate (int max_value) { - timer_rate = max_value; -} - - -int joy_get_timer_rate () { - return timer_rate; -} - - -void joy_flush () { - int i; - - if (!joy_installed) return; - - for (i = 0; i < j_num_buttons; i++) { - j_button[i].timedown = 0; - j_button[i].downcount = 0; - } - -} - - -ubyte joystick_read_raw_axis (ubyte mask, int *axes) { - int i; - - j_Update_state(); - - for (i = 0; i <= j_num_axes; i++) { - axes[i] = j_axis[i].value; - } - - return 0; -} - - -/* joy_init () is pretty huge, a bit klunky, and by no means pretty. But who cares? It does the job and it's only run once. */ - - -int joy_init () { - int i, j; - - if (joy_installed) return 0; - joy_flush (); - - if (!joy_installed) { - -// printf ("Initializing joystick... "); - - j_joystick[0].buffer = open ("/dev/js0", O_NONBLOCK); - j_joystick[1].buffer = open ("/dev/js1", O_NONBLOCK); - j_joystick[2].buffer = open ("/dev/js2", O_NONBLOCK); - j_joystick[3].buffer = open ("/dev/js3", O_NONBLOCK); - - if (j_joystick[0].buffer >= 0 || j_joystick[1].buffer >= 0 || j_joystick[2].buffer >= 0 || j_joystick[3].buffer >= 0) { -// printf ("found: "); - - for (i = 0; i < 4; i++) { - if (j_joystick[i].buffer >= 0) { - /* - ioctl (j_joystick[i].buffer, JSIOCGAXES, &j_joystick[i].num_axes); - ioctl (j_joystick[i].buffer, JSIOCGBUTTONS, &j_joystick[i].num_buttons); - ioctl (j_joystick[i].buffer, JSIOCGVERSION, &j_joystick[i].version); -*/ - if (!j_joystick[i].version) { - j_joystick[i].num_axes = 2; - j_joystick[i].num_buttons = 2; -// printf ("js%d (v0.x) " , i); - } else { -// printf ("js%d (v%d.%d.%d) ", i, (j_joystick[i].version & 0xff0000) >> 16, (j_joystick[i].version & 0xff00) >> 8, j_joystick[i].version & 0xff); - } - - for (j = j_num_axes; j < (j_num_axes + j_joystick[i].num_axes); j++) { - j_axis[j].joydev = i; - if (j_joystick[i].version) { - j_axis[j].center_val = 0; - j_axis[j].max_val = 32767; - j_axis[j].min_val = -32767; - } - } - for (j = j_num_buttons; j < (j_num_buttons + j_joystick[i].num_buttons); j++) { - j_button[j].joydev = i; - } - - j_num_axes += j_joystick[i].num_axes; - j_num_buttons += j_joystick[i].num_buttons; - - } else { - j_joystick[i].num_buttons = 0; - j_joystick[i].num_axes = 0; - } - - for (j = 0; j < i; j++) { - j_axes_in_sticks[i] += j_joystick[j].num_axes; - j_buttons_in_sticks[i] += j_joystick[j].num_buttons; - } - } - } else { -// printf ("no joysticks found\n"); - return 0; - } - -// printf ("\n"); - - if (j_num_axes > MAX_AXES) - j_num_axes = MAX_AXES; - if (j_num_buttons > MAX_BUTTONS) - j_num_buttons = MAX_BUTTONS; - - joy_present = 1; - joy_installed = 1; - return 1; - } - - return 1; -} - - -void joy_close() { - int i; - - if (!joy_installed) return; - - for (i = 0; i < 4; i++) { - if (j_joystick[i].buffer>=0) { - printf ("closing js%d\n", i); - close (j_joystick[i].buffer); - } - j_joystick[i].buffer=-1; - } - - joy_present=0; - joy_installed=0; -} - - -void joy_set_cen() { -} - - -int joy_get_scaled_reading(int raw, int axis_num) -{ - int d, x; - - raw -= j_axis[axis_num].center_val; - - if (raw < 0) - d = j_axis[axis_num].center_val - j_axis[axis_num].min_val; - else if (raw > 0) - d = j_axis[axis_num].max_val - j_axis[axis_num].center_val; - else - d = 0; - - if (d) - x = ((raw << 7) / d); - else - x = 0; - - if ( x < -128 ) - x = -128; - if ( x > 127 ) - x = 127; - -//added on 4/13/99 by Victor Rachels to add deadzone control - d = (joy_deadzone) * 6; - if ((x > (-1*d)) && (x < d)) - x = 0; -//end this section addition -VR - - return x; -} - - -void joy_get_pos(int *x, int *y) { - int axis[MAX_AXES]; - - if ((!joy_installed)||(!joy_present)) { *x=*y=0; return; } - - joystick_read_raw_axis (JOY_ALL_AXIS, axis); - - *x = joy_get_scaled_reading( axis[0], 0 ); - *y = joy_get_scaled_reading( axis[1], 1 ); -} - - -int joy_get_btns () { - return 0; -} - - -int joy_get_button_state (int btn) { - if(btn >= j_num_buttons) - return 0; - j_Update_state (); - - return j_button[btn].state; -} - - -int joy_get_button_down_cnt (int btn) { - int downcount; - - j_Update_state (); - - downcount = j_button[btn].downcount; - j_button[btn].downcount = 0; - - return downcount; -} - - -//changed 6/24/99 to finally squish the timedown bug - Owen Evans -fix joy_get_button_down_time(int btn) { - fix downtime; - j_Update_state (); - - if (j_button[btn].state) { - downtime = timer_get_fixed_seconds() - j_button[btn].timedown; - j_button[btn].timedown = timer_get_fixed_seconds(); - } else { - downtime = 0; - } - - return downtime; -} -//end changed - OE - -void joy_poll() { - -} - - -void joy_set_slow_reading(int flag) { - -} - diff --git a/input/sdl/event.c b/input/sdl/event.c deleted file mode 100644 index 15c72690..00000000 --- a/input/sdl/event.c +++ /dev/null @@ -1,54 +0,0 @@ -// SDL Event related stuff - -#include -#include -#include - -#include - -extern void key_handler(SDL_KeyboardEvent *event); -//added on 10/17/98 by Hans de Goede for mouse functionality -extern void mouse_button_handler(SDL_MouseButtonEvent *mbe); -extern void mouse_motion_handler(SDL_MouseMotionEvent *mme); -//end this section addition - Hans - -static int initialised=0; - -void event_poll() -{ - SDL_Event event; - while (SDL_PollEvent(&event)) - { -// if( (event.type == SDL_KEYEVENT) { -//added/changed on 10/17/98 by Hans de Goede for mouse functionality -//-killed- if( (event.type == SDL_KEYDOWN) || (event.type == SDL_KEYUP) ) { - switch(event.type) - { - case SDL_KEYDOWN: - case SDL_KEYUP: - key_handler((SDL_KeyboardEvent *)&event); - break; - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - mouse_button_handler((SDL_MouseButtonEvent *)&event); - break; - case SDL_MOUSEMOTION: - mouse_motion_handler((SDL_MouseMotionEvent *)&event); - break; -//-killed- return; -//end this section addition/change - Hans - case SDL_QUIT: { -// void quit_request(); -// quit_request(); - } break; - } - } -} - -int event_init() -{ - // We should now be active and responding to events. - initialised = 1; - - return 0; -} diff --git a/input/sdl/key.c b/input/sdl/key.c deleted file mode 100644 index 9eb590c5..00000000 --- a/input/sdl/key.c +++ /dev/null @@ -1,616 +0,0 @@ -// SDL keyboard input support - -#include -#include -#include - -#include - -#include "event.h" -#include "error.h" -#include "key.h" -#include "timer.h" - -//added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such -#include "d_delay.h" -//end this section addition - Matt Mueller - -#define KEY_BUFFER_SIZE 16 - -static unsigned char Installed = 0; - -//-------- Variable accessed by outside functions --------- -unsigned char keyd_buffer_type; // 0=No buffer, 1=buffer ASCII, 2=buffer scans -unsigned char keyd_repeat; -unsigned char keyd_editor_mode; -volatile unsigned char keyd_last_pressed; -volatile unsigned char keyd_last_released; -volatile unsigned char keyd_pressed[256]; -volatile int keyd_time_when_last_pressed; - -typedef struct Key_info { - ubyte state; // state of key 1 == down, 0 == up - ubyte last_state; // previous state of key - int counter; // incremented each time key is down in handler - fix timewentdown; // simple counter incremented each time in interrupt and key is down - fix timehelddown; // counter to tell how long key is down -- gets reset to 0 by key routines - ubyte downcount; // number of key counts key was down - ubyte upcount; // number of times key was released -} Key_info; - -typedef struct keyboard { - unsigned short keybuffer[KEY_BUFFER_SIZE]; - Key_info keys[256]; - fix time_pressed[KEY_BUFFER_SIZE]; - unsigned int keyhead, keytail; -} keyboard; - -static keyboard key_data; - -typedef struct key_props { - char *key_text; - unsigned char ascii_value; - unsigned char shifted_ascii_value; - SDLKey sym; -} key_props; - -key_props key_properties[256] = { -{ "", 255, 255, -1 }, -{ "ESC", 255, 255, SDLK_ESCAPE }, -{ "1", '1', '!', SDLK_1 }, -{ "2", '2', '@', SDLK_2 }, -{ "3", '3', '#', SDLK_3 }, -{ "4", '4', '$', SDLK_4 }, -{ "5", '5', '%', SDLK_5 }, -{ "6", '6', '^', SDLK_6 }, -{ "7", '7', '&', SDLK_7 }, -{ "8", '8', '*', SDLK_8 }, -{ "9", '9', '(', SDLK_9 }, -{ "0", '0', ')', SDLK_0 }, -{ "-", '-', '_', SDLK_MINUS }, -{ "=", '=', '+', SDLK_EQUALS }, -{ "BSPC", 255, 255, SDLK_BACKSPACE }, -{ "TAB", 255, 255, SDLK_TAB }, -{ "Q", 'q', 'Q', SDLK_q }, -{ "W", 'w', 'W', SDLK_w }, -{ "E", 'e', 'E', SDLK_e }, -{ "R", 'r', 'R', SDLK_r }, -{ "T", 't', 'T', SDLK_t }, -{ "Y", 'y', 'Y', SDLK_y }, -{ "U", 'u', 'U', SDLK_u }, -{ "I", 'i', 'I', SDLK_i }, -{ "O", 'o', 'O', SDLK_o }, -{ "P", 'p', 'P', SDLK_p }, -{ "[", '[', '{', SDLK_LEFTBRACKET }, -{ "]", ']', '}', SDLK_RIGHTBRACKET }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "ƒ", 255, 255, SDLK_RETURN }, -//end edit -MM -{ "LCTRL", 255, 255, SDLK_LCTRL }, -{ "A", 'a', 'A', SDLK_a }, -{ "S", 's', 'S', SDLK_s }, -{ "D", 'd', 'D', SDLK_d }, -{ "F", 'f', 'F', SDLK_f }, -{ "G", 'g', 'G', SDLK_g }, -{ "H", 'h', 'H', SDLK_h }, -{ "J", 'j', 'J', SDLK_j }, -{ "K", 'k', 'K', SDLK_k }, -{ "L", 'l', 'L', SDLK_l }, -//edited 06/08/99 Matt Mueller - set to correct sym -{ ";", ';', ':', SDLK_SEMICOLON }, -//end edit -MM -{ "'", '\'', '"', SDLK_QUOTE }, -//edited 06/08/99 Matt Mueller - set to correct sym -{ "`", '`', '~', SDLK_BACKQUOTE }, -//end edit -MM -{ "LSHFT", 255, 255, SDLK_LSHIFT }, -{ "\\", '\\', '|', SDLK_BACKSLASH }, -{ "Z", 'z', 'Z', SDLK_z }, -{ "X", 'x', 'X', SDLK_x }, -{ "C", 'c', 'C', SDLK_c }, -{ "V", 'v', 'V', SDLK_v }, -{ "B", 'b', 'B', SDLK_b }, -{ "N", 'n', 'N', SDLK_n }, -{ "M", 'm', 'M', SDLK_m }, -//edited 06/08/99 Matt Mueller - set to correct syms -{ ",", ',', '<', SDLK_COMMA }, -{ ".", '.', '>', SDLK_PERIOD }, -{ "/", '/', '?', SDLK_SLASH }, -//end edit -MM -{ "RSHFT", 255, 255, SDLK_RSHIFT }, -{ "PAD*", '*', 255, SDLK_KP_MULTIPLY }, -{ "LALT", 255, 255, SDLK_LALT }, -{ "SPC", ' ', ' ', SDLK_SPACE }, -{ "CPSLK", 255, 255, SDLK_CAPSLOCK }, -{ "F1", 255, 255, SDLK_F1 }, -{ "F2", 255, 255, SDLK_F2 }, -{ "F3", 255, 255, SDLK_F3 }, -{ "F4", 255, 255, SDLK_F4 }, -{ "F5", 255, 255, SDLK_F5 }, -{ "F6", 255, 255, SDLK_F6 }, -{ "F7", 255, 255, SDLK_F7 }, -{ "F8", 255, 255, SDLK_F8 }, -{ "F9", 255, 255, SDLK_F9 }, -{ "F10", 255, 255, SDLK_F10 }, -{ "NMLCK", 255, 255, SDLK_NUMLOCK }, -{ "SCLK", 255, 255, SDLK_SCROLLOCK }, -{ "PAD7", 255, 255, SDLK_KP7 }, -{ "PAD8", 255, 255, SDLK_KP8 }, -{ "PAD9", 255, 255, SDLK_KP9 }, -{ "PAD-", 255, 255, SDLK_KP_MINUS }, -{ "PAD4", 255, 255, SDLK_KP4 }, -{ "PAD5", 255, 255, SDLK_KP5 }, -{ "PAD6", 255, 255, SDLK_KP6 }, -{ "PAD+", 255, 255, SDLK_KP_PLUS }, -{ "PAD1", 255, 255, SDLK_KP1 }, -{ "PAD2", 255, 255, SDLK_KP2 }, -{ "PAD3", 255, 255, SDLK_KP3 }, -{ "PAD0", 255, 255, SDLK_KP0 }, -{ "PAD.", 255, 255, SDLK_KP_PERIOD }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "F11", 255, 255, SDLK_F11 }, -{ "F12", 255, 255, SDLK_F12 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - add pause ability -{ "PAUSE", 255, 255, SDLK_PAUSE }, -//end edit -MM -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "PADƒ", 255, 255, SDLK_KP_ENTER }, -//end edit -MM -//edited 06/08/99 Matt Mueller - set to correct sym -{ "RCTRL", 255, 255, SDLK_RCTRL }, -//end edit -MM -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "PAD/", 255, 255, SDLK_KP_DIVIDE }, -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - add printscreen ability -{ "PRSCR", 255, 255, SDLK_PRINT }, -//end edit -MM -{ "RALT", 255, 255, SDLK_RALT }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "HOME", 255, 255, SDLK_HOME }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "UP", 255, 255, SDLK_UP }, -//end edit -MM -{ "PGUP", 255, 255, SDLK_PAGEUP }, -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "LEFT", 255, 255, SDLK_LEFT }, -//end edit -MM -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "RIGHT", 255, 255, SDLK_RIGHT }, -//end edit -MM -{ "", 255, 255, -1 }, -//edited 06/08/99 Matt Mueller - set to correct key_text -{ "END", 255, 255, SDLK_END }, -//end edit -MM -{ "DOWN", 255, 255, SDLK_DOWN }, -{ "PGDN", 255, 255, SDLK_PAGEDOWN }, -{ "INS", 255, 255, SDLK_INSERT }, -{ "DEL", 255, 255, SDLK_DELETE }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -{ "", 255, 255, -1 }, -}; - -char *key_text[256]; - -void key_buid_key_text(void) -{ -} - -unsigned char key_to_ascii(int keycode ) -{ - int shifted; - - shifted = keycode & KEY_SHIFTED; - keycode &= 0xFF; - - if (shifted) - return key_properties[keycode].shifted_ascii_value; - else - return key_properties[keycode].ascii_value; -} - -void key_handler(SDL_KeyboardEvent *event) -{ - ubyte state; - int i, keycode, event_key, key_state; - Key_info *key; - unsigned char temp; - - event_key = event->keysym.sym; - - key_state = (event->state == SDL_PRESSED); // !(wInfo & KF_UP); - //===================================================== - //Here a translation from win keycodes to mac keycodes! - //===================================================== - - for (i = 255; i >= 0; i--) { - - keycode = i; - key = &(key_data.keys[keycode]); - if (key_properties[i].sym == event_key) - state = key_state; - else - state = key->last_state; - - if ( key->last_state == state ) { - if (state) { - key->counter++; - keyd_last_pressed = keycode; - keyd_time_when_last_pressed = timer_get_fixed_seconds(); - } - } else { - if (state) { - keyd_last_pressed = keycode; - keyd_pressed[keycode] = 1; - key->downcount += state; - key->state = 1; - key->timewentdown = keyd_time_when_last_pressed = timer_get_fixed_seconds(); - key->counter++; - } else { - keyd_pressed[keycode] = 0; - keyd_last_released = keycode; - key->upcount += key->state; - key->state = 0; - key->counter = 0; - key->timehelddown += timer_get_fixed_seconds() - key->timewentdown; - } - } - if ( (state && !key->last_state) || (state && key->last_state && (key->counter > 30) && (key->counter & 0x01)) ) { - if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) - keycode |= KEY_SHIFTED; - if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]) - keycode |= KEY_ALTED; - if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) - keycode |= KEY_CTRLED; - if ( keyd_pressed[KEY_DELETE] ) - keycode |= KEY_DEBUGGED; - temp = key_data.keytail+1; - if ( temp >= KEY_BUFFER_SIZE ) temp=0; - if (temp!=key_data.keyhead) { - key_data.keybuffer[key_data.keytail] = keycode; - key_data.time_pressed[key_data.keytail] = keyd_time_when_last_pressed; - key_data.keytail = temp; - } - } - key->last_state = state; - } -} - -void key_close() -{ - Installed = 0; -} - -void key_init() -{ - int i; - - if (Installed) return; - - Installed=1; - - keyd_time_when_last_pressed = timer_get_fixed_seconds(); - keyd_buffer_type = 1; - keyd_repeat = 1; - - for(i=0; i<256; i++) - key_text[i] = key_properties[i].key_text; - - // Clear the keyboard array - key_flush(); - atexit(key_close); -} - -void key_flush() -{ - int i; - fix curtime; - - if (!Installed) - key_init(); - - key_data.keyhead = key_data.keytail = 0; - - //Clear the keyboard buffer - for (i=0; i= KEY_BUFFER_SIZE ) n=0; - return n; -} - -int key_checkch() -{ - int is_one_waiting = 0; - event_poll(); - if (key_data.keytail!=key_data.keyhead) - is_one_waiting = 1; - return is_one_waiting; -} - -int key_inkey() -{ - int key = 0; - if (!Installed) - key_init(); - event_poll(); - if (key_data.keytail!=key_data.keyhead) { - key = key_data.keybuffer[key_data.keyhead]; - key_data.keyhead = add_one(key_data.keyhead); - } -//added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such - else d_delay(1); -//end addition - Matt Mueller - - return key; -} - -int key_inkey_time(fix * time) -{ - int key = 0; - - if (!Installed) - key_init(); - event_poll(); - if (key_data.keytail!=key_data.keyhead) { - key = key_data.keybuffer[key_data.keyhead]; - *time = key_data.time_pressed[key_data.keyhead]; - key_data.keyhead = add_one(key_data.keyhead); - } - return key; -} - -int key_peekkey() -{ - int key = 0; - event_poll(); - if (key_data.keytail!=key_data.keyhead) - key = key_data.keybuffer[key_data.keyhead]; - - return key; -} - -int key_getch() -{ - int dummy=0; - - if (!Installed) - return 0; -// return getch(); - - while (!key_checkch()) - dummy++; - return key_inkey(); -} - -unsigned int key_get_shift_status() -{ - unsigned int shift_status = 0; - - if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT] ) - shift_status |= KEY_SHIFTED; - - if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT] ) - shift_status |= KEY_ALTED; - - if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL] ) - shift_status |= KEY_CTRLED; - -#ifndef NDEBUG - if (keyd_pressed[KEY_DELETE]) - shift_status |=KEY_DEBUGGED; -#endif - - return shift_status; -} - -// Returns the number of seconds this key has been down since last call. -fix key_down_time(int scancode) -{ - fix time_down, time; - - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - if (!keyd_pressed[scancode]) { - time_down = key_data.keys[scancode].timehelddown; - key_data.keys[scancode].timehelddown = 0; - } else { - time = timer_get_fixed_seconds(); - time_down = time - key_data.keys[scancode].timewentdown; - key_data.keys[scancode].timewentdown = time; - } - - return time_down; -} - -unsigned int key_down_count(int scancode) -{ - int n; - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - n = key_data.keys[scancode].downcount; - key_data.keys[scancode].downcount = 0; - - return n; -} - -unsigned int key_up_count(int scancode) -{ - int n; - event_poll(); - if ((scancode<0)|| (scancode>255)) return 0; - - n = key_data.keys[scancode].upcount; - key_data.keys[scancode].upcount = 0; - - return n; -} diff --git a/input/sdl/mouse.c b/input/sdl/mouse.c deleted file mode 100644 index c0f01830..00000000 --- a/input/sdl/mouse.c +++ /dev/null @@ -1,234 +0,0 @@ -// SDL mouse driver. - -#include -#include -#include -#include "fix.h" -#include "timer.h" -#include "event.h" -#include "mouse.h" - -struct mousebutton { - ubyte pressed; - fix time_went_down; - fix time_held_down; - uint num_downs; - uint num_ups; -}; - -static struct mouseinfo { - struct mousebutton buttons[MOUSE_MAX_BUTTONS]; -//added on 10/17/98 by Hans de Goede for mouse functionality - int min_x, min_y; - int max_x, max_y; - int delta_x, delta_y; - int x,y; -//end this section addition - Hans -} Mouse; - -//added on 10/17/98 by Hans de Goede for mouse functionality -void d_mouse_init(void) -{ - memset(&Mouse,0,sizeof(Mouse)); -} - -//added/changed on 10/17/98 by Hans de Goede for mouse functionality -//void mouse_handler(SDL_MouseButtonEvent *mbe) -void mouse_button_handler(SDL_MouseButtonEvent *mbe) -{ - // to bad, SDL buttons use a different mapping as descent expects, - // this is atleast true and tested for the first three buttons - int button_remap[11] = { - MB_LEFT, - MB_MIDDLE, - MB_RIGHT, - MB_Z_UP, - MB_Z_DOWN, - MB_PITCH_BACKWARD, - MB_PITCH_FORWARD, - MB_BANK_LEFT, - MB_BANK_RIGHT, - MB_HEAD_LEFT, - MB_HEAD_RIGHT }; - - int button = button_remap[mbe->button - 1]; // -1 since SDL seems to start counting at 1 - - if (mbe->state == SDL_PRESSED) { -// Mouse.buttons[mbe->button].pressed = 1; -// Mouse.buttons[mbe->button].time_went_down = timer_get_fixed_seconds(); -// Mouse.buttons[mbe->button].num_downs++; - Mouse.buttons[button].pressed = 1; - Mouse.buttons[button].time_went_down = timer_get_fixed_seconds(); - Mouse.buttons[button].num_downs++; - } else { -// Mouse.buttons[mbe->button].pressed = 0; -// Mouse.buttons[mbe->button].time_held_down += timer_get_fixed_seconds() - Mouse.buttons[mbe->button].time_went_down; -// Mouse.buttons[mbe->button].num_ups++; - Mouse.buttons[button].pressed = 0; - Mouse.buttons[button].time_held_down += timer_get_fixed_seconds() - Mouse.buttons[mbe->button].time_went_down; - Mouse.buttons[button].num_ups++; -//end this section addition/change - Hans - } -} - -//added on 10/17/98 by Hans de Goede for mouse functionality -void mouse_motion_handler(SDL_MouseMotionEvent *mme) -{ - Mouse.delta_x += mme->xrel; - Mouse.delta_y += mme->yrel; - Mouse.x += mme->xrel; - Mouse.y += mme->yrel; - if (Mouse.x > Mouse.max_x) Mouse.x = Mouse.max_x; - else if (Mouse.x < Mouse.min_x) Mouse.x = Mouse.min_x; - if (Mouse.y > Mouse.max_y) Mouse.y = Mouse.max_y; - else if (Mouse.y < Mouse.min_y) Mouse.y = Mouse.min_y; -} -//end this section addition - Hans - - -int mouse_set_limits( int x1, int y1, int x2, int y2 ) -{ -//added on 10/17/98 by Hans de Goede for mouse functionality -//-killed- // Shrug... -//-killed- event_poll(); - Mouse.min_x = x1; - Mouse.min_y = y1; - Mouse.max_x = x2; - Mouse.max_y = y2; -//end this section addition - Hans - return 0; -} - -void mouse_flush() // clears all mice events... -{ - int i; - fix current_time; - - event_poll(); - - current_time = timer_get_fixed_seconds(); - for (i=0; i Mouse.max_x) Mouse.x = Mouse.max_x; - else if (Mouse.x < Mouse.min_x) Mouse.x = Mouse.min_x; - if (Mouse.y > Mouse.max_y) Mouse.y = Mouse.max_y; - else if (Mouse.y < Mouse.min_y) Mouse.y = Mouse.min_y; -//end this section change - Hans -} - -void mouse_get_cyberman_pos( int *x, int *y ) -{ - // Shrug... - event_poll(); -} - -// Returns how long this button has been down since last call. -fix mouse_button_down_time(int button) -{ - fix time_down, time; - - event_poll(); - - if (!Mouse.buttons[button].pressed) { - time_down = Mouse.buttons[button].time_held_down; - Mouse.buttons[button].time_held_down = 0; - } else { - time = timer_get_fixed_seconds(); - time_down = time - Mouse.buttons[button].time_held_down; - Mouse.buttons[button].time_held_down = time; - } - return time_down; -} - -// Returns how many times this button has went down since last call -int mouse_button_down_count(int button) -{ - int count; - - event_poll(); - - count = Mouse.buttons[button].num_downs; - Mouse.buttons[button].num_downs = 0; - - return count; -} - -// Returns 1 if this button is currently down -int mouse_button_state(int button) -{ - event_poll(); - return Mouse.buttons[button].pressed; -} - - diff --git a/unused/bios/findfile.c b/unused/bios/findfile.c deleted file mode 100644 index f4f6f9f4..00000000 --- a/unused/bios/findfile.c +++ /dev/null @@ -1,111 +0,0 @@ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - - -#pragma off (unreferenced) -static char rcsid[] = "$Id: findfile.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $"; -#pragma on (unreferenced) - -#include -#include - -#include "findfile.h" - - -// Global Variables ---------------------------------------------------------- - -static int _FileFindFlag = 0; -static struct find_t _FileFindStruct; - - - -// Functions - -int FileFindFirst(char *search_str, FILEFINDSTRUCT *ffstruct) -{ - unsigned retval; - - if (_FileFindFlag) return -1; - - retval = _dos_findfirst(search_str, 0, &_FileFindStruct); - if (retval) return (int)retval; - else { - ffstruct->size = _FileFindStruct.size; - strcpy(ffstruct->name, _FileFindStruct.name); - _FileFindFlag = 1; - return (int)retval; - } -} - - -int FileFindNext(FILEFINDSTRUCT *ffstruct) -{ - unsigned retval; - - if (!_FileFindFlag) return -1; - - retval = _dos_findnext(&_FileFindStruct); - if (retval) return (int)retval; - else { - ffstruct->size = _FileFindStruct.size; - strcpy(ffstruct->name, _FileFindStruct.name); - return (int)retval; - } -} - - -int FileFindClose(void) -{ - unsigned retval = 0; - - if (!_FileFindFlag) return -1; - - if (retval) return (int)retval; - else { - _FileFindFlag = 0; - return (int)retval; - } -} - - -//returns 0 if no error -int GetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct) -{ - return _dos_getftime(filehandle, &ftstruct->date, &ftstruct->time); - -} - - -//returns 0 if no error -int SetFileDateTime(int filehandle, FILETIMESTRUCT *ftstruct) -{ - return _dos_setftime(filehandle, ftstruct->date, ftstruct->time); -} - -// returns -1 if error -// Gets bytes free on current drive -int GetDiskFree () - { - struct diskfree_t dfree; - unsigned drive; - - _dos_getdrive(&drive); - if (!_dos_getdiskfree(drive, &dfree)) - return (dfree.avail_clusters * dfree.sectors_per_cluster * dfree.bytes_per_sector); - - return (-1); - } - - - - -- 2.39.2