]> 4ch.mooo.com Git - 16.git/blobdiff - 16/WOLFSRC/JABHACK.ASM
got 8086 port of wolf3d to work and sod to work
[16.git] / 16 / WOLFSRC / JABHACK.ASM
diff --git a/16/WOLFSRC/JABHACK.ASM b/16/WOLFSRC/JABHACK.ASM
new file mode 100755 (executable)
index 0000000..243aa9f
--- /dev/null
@@ -0,0 +1,103 @@
+; JABHACK.ASM\r
+\r
+.386C\r
+IDEAL\r
+MODEL  MEDIUM\r
+\r
+EXTRN  LDIV@:far\r
+\r
+;============================================================================\r
+\r
+DATASEG\r
+\r
+EXTRN  _intaddr:word\r
+\r
+;============================================================================\r
+\r
+CODESEG\r
+\r
+;      Hacked up Juan Jimenez's code a bit to just return 386/not 386\r
+PROC   _CheckIs386\r
+PUBLIC _CheckIs386\r
+\r
+       pushf                   ; Save flag registers, we use them here\r
+       xor     ax,ax           ; Clear AX and...\r
+       push ax                 ; ...push it onto the stack\r
+       popf                    ; Pop 0 into flag registers (all bits to 0),\r
+       pushf                   ; attempting to set bits 12-15 of flags to 0's\r
+       pop     ax                      ; Recover the save flags\r
+       and     ax,08000h       ; If bits 12-15 of flags are set to\r
+       cmp     ax,08000h       ; zero then it's 8088/86 or 80188/186\r
+       jz      not386\r
+\r
+       mov     ax,07000h       ; Try to set flag bits 12-14 to 1's\r
+       push ax                 ; Push the test value onto the stack\r
+       popf                    ; Pop it into the flag register\r
+       pushf                   ; Push it back onto the stack\r
+       pop     ax                      ; Pop it into AX for check\r
+       and     ax,07000h       ; if bits 12-14 are cleared then\r
+       jz      not386          ; the chip is an 80286\r
+\r
+       mov     ax,1            ; We now assume it's a 80386 or better\r
+       popf\r
+       retf\r
+\r
+not386:\r
+       xor     ax,ax\r
+       popf\r
+       retf\r
+\r
+       ENDP\r
+\r
+\r
+PROC   _jabhack2\r
+PUBLIC _jabhack2\r
+\r
+       jmp     @@skip\r
+\r
+@@where:\r
+       int     060h\r
+       retf\r
+\r
+@@skip:\r
+       push    es\r
+\r
+       mov     ax,seg LDIV@\r
+       mov     es,ax\r
+       mov     ax,[WORD PTR @@where]\r
+       mov     [WORD FAR es:LDIV@],ax\r
+       mov     ax,[WORD PTR @@where+2]\r
+       mov     [WORD FAR es:LDIV@+2],ax\r
+\r
+       mov     ax,offset @@jabdiv\r
+       mov     [_intaddr],ax\r
+       mov     ax,seg @@jabdiv\r
+       mov     [_intaddr+2],ax\r
+\r
+       pop     es\r
+       retf\r
+\r
+@@jabdiv:\r
+       add     sp,4    ;Nuke IRET address, but leave flags\r
+       push bp\r
+       mov     bp,sp   ;Save BP, and set it equal to stack\r
+       cli\r
+\r
+       mov     eax,[bp+8]\r
+       cdq\r
+       idiv [DWORD PTR bp+12]\r
+       mov     edx,eax\r
+       ;begin 8086 hack\r
+       ;shr    edx,16\r
+       push cx\r
+       mov cl,16\r
+       shr     edx,cl\r
+       pop cx\r
+       ;end 8086 hack\r
+       pop     bp              ;Restore BP\r
+       popf            ;Restore flags (from INT)\r
+       retf    8       ;Return to original caller\r
+\r
+       ENDP\r
+\r
+       END\r