1.386p 2.model small 3 4 5 SC_INDEX = 03C4h 6 SC_MAPMASK = 2 7 GC_INDEX = 03CEh 8 GC_MODE = 5 9 10 11 UPDATEWIDE = 20 12 UPDATEHIGH = 13 13 14 MaxJoyValue = 5000 15 16.DATA 17 18 19EXTRN _bufferofs :DWORD 20EXTRN _displayofs :DWORD 21EXTRN _ylookup :DWORD 22EXTRN _linewidth :DWORD 23EXTRN _blockstarts :DWORD ;offsets from drawofs for each update block 24 25EXTRN _Joy_xb : BYTE 26EXTRN _Joy_yb : BYTE 27EXTRN _Joy_xs : BYTE 28EXTRN _Joy_ys : BYTE 29EXTRN _Joy_x : WORD 30EXTRN _Joy_y : WORD 31 32EXTRN _update :DWORD 33 34 35 36.CODE 37 38ALIGN 4 39 40;================= 41; 42; VH_UpdateScreen 43; 44;================= 45 46PROC VH_UpdateScreen_ 47PUBLIC VH_UpdateScreen_ 48 49 pushad 50 51 mov edx,SC_INDEX 52 mov eax,SC_MAPMASK+15*256 53 54; write through all planes 55 56 out dx, ax 57 58 mov edx, GC_INDEX 59 mov al, GC_MODE 60 out dx, al 61 62 inc dx 63 in al, dx 64 and al, 252 65 or al, 1 66 out dx, al 67 68 mov ebx, UPDATEWIDE*UPDATEHIGH-1 ; bx is the tile number 69 mov edx, [_linewidth] 70 71; 72; see if the tile needs to be copied 73; 74@@checktile: 75 test [_update+ebx],1 76 jnz @@copytile 77@@next: 78 dec ebx 79 jns @@checktile 80 81; 82; done 83; 84 mov dx, GC_INDEX+1 85 in al, dx 86 and al, NOT 3 87 or al, 0 88 out dx, al 89 90 91 popad 92 93 ret 94 95; 96; copy a tile 97; 98@@copytile: 99 mov [BYTE PTR _update+ebx], 0 100 mov esi, [_blockstarts+ebx*4] 101 mov edi, esi 102 add esi, [_bufferofs] 103 add edi, [_displayofs] 104 105; mov ax, SCREENSEG 106; mov ds, ax 107 108REPT 16 109 mov al, [esi] 110 mov [edi], al 111 mov al, [esi+1] 112 mov [edi+1], al 113 mov al, [esi+2] 114 mov [edi+2], al 115 mov al, [esi+3] 116 mov [edi+3], al 117 add esi, edx 118 add edi, edx 119ENDM 120 121 jmp @@next 122 123ENDP VH_UpdateScreen_ 124 125 126ALIGN 4 127 128;================= 129; 130; JoyStick_Vals 131; 132;================= 133 134PROC JoyStick_Vals_ 135PUBLIC JoyStick_Vals_ 136 137 138; Read the absolute joystick values 139 140 pushf ; Save some registers 141 push ebp 142 cli ; Make sure an interrupt doesn't screw the timings 143 144 mov dx, 0201h 145 in al, dx 146 out dx, al ; Clear the resistors 147 148 mov ah, BYTE PTR [_Joy_xb] ; Get masks into registers 149 mov ch, BYTE PTR [_Joy_yb] 150 151 xor si, si ; Clear count registers 152 xor di, di 153 xor bh, bh ; Clear high byte of bx for later 154 155 mov ebp, MaxJoyValue 156 157 @@LOOP: 158 in al, dx ; Get bits indicating whether all are finished 159 160 dec ebp ; Check bounding register 161 jz done ; We have a silly value - abort 162 163 mov bl, al ; Duplicate the bits 164 and bl, ah ; Mask off useless bits (in [xb]) 165 add si, bx ; Possibly increment count register 166 mov cl, bl ; Save for testing later 167 168 mov bl, al 169 and bl, ch ; [yb] 170 add di, bx 171 172 add cl, bl 173 jnz @@LOOP ; If both bits were 0, drop out 174 175 done: 176 177 mov cl, [_Joy_xs] ; Get the number of bits to shift 178 shr si, cl ; and shift the count that many times 179 180 mov cl, [_Joy_ys] 181 shr di, cl 182 183 mov [_Joy_x], si ; Store the values into the variables 184 mov [_Joy_y], di 185 186 pop ebp 187 popf ; Restore the registers 188 189 ret 190 191ENDP JoyStick_Vals_ 192 193 194END 195 196