⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosintrf.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 3 页
字号:
    je .nodir
    mov ah,3Bh
    int 21h
.nodir
    ret

;    mov ebx,LoadDir
;    mov edx,LoadDrive
;    call Get_Dir
NEWSYM Get_Dir
    mov [DirName],ebx
    pushad
    call ZFileGetDir
    mov eax,[DirName]
    mov ebx,eax
    mov ecx,125
.loop
    mov dl,[eax+3]
    cmp dl,'/'
    jne .noslash
    mov dl,'\'
.noslash
    mov [eax],dl
    inc eax
    loop .loop
    popad
    push edx
    mov ah,19h
    int 21h
    pop edx
    mov [edx],al
    ret

    push edx
    mov ah,47h
    mov dl,0
    mov esi,ebx
    int 21h
    mov ah,19h
    int 21h
    pop edx
    mov [edx],al
    ret

NEWSYM Get_First_Entry
    ; cx = attributes, edx = pointer to wildcard
    ; returns : DTALoc+15h, bit 4 = Dir (1) or File (0)
    ;           DTALoc+1Eh = filename, carry flag set = no more entry
    mov [ZFileFindPATH],edx
    mov dword[ZFileFindATTRIB],0
    mov [ZFileFindATTRIB],cx
    mov dword[DTALocPos],DTALoc
    pushad
    call ZFileFindFirst
    or eax,eax
    jnz .end
    popad
    clc
    ret
.end
    popad
    stc
    ret
    mov ah,4Eh
    mov al,0
    int 21h
    ret

NEWSYM Get_Next_Entry
    mov dword[DTALocPos],DTALoc
    pushad
    call ZFileFindNext
    or eax,eax
    jnz .end
    popad
    clc
    ret
.end
    popad
    stc
    ret
    mov ah,04Fh
    int 21h
    ret

NEWSYM Set_DTA_Address
    ; Only needed for dos stuff
;    mov edx,DTALoc
;    mov ah,1Ah
;    int 21h
    ret

NEWSYM Get_Memfree
    mov ax,0500h
    mov edi,edx
    int 31h
    ret

NEWSYM Output_Text       ; Output character (ah=02h) or string (ah=09h)
    ; This function usually displays an error message on-screen
    cmp ah,02h
    je .char
    cmp ah,09h
    je .string
    ret
.char
    int 21h     ; print dl
    ret
.string
    pushad
    call PrintStr       ; print edx
    popad
    ret

; Delay for CX/65536 of a second

NEWSYM delay
   in al,61h 
   and al,10h
   mov ah,al
.loopa
   in al,61h
   and al,10h
   cmp al,ah
   jz .loopa
   mov ah,al
   dec cx
   jnz .loopa
   ret

NEWSYM InitPreGame   ; Executes before starting/continuing a game
    ; set up interrupt handler
    ; get old handler pmode mode address
    ; Process stuff such as sound init, interrupt initialization
    cli
    mov ax,204h
    mov bl,09h
    int 31h
    jc near interror
    mov [oldhand9s],cx
    mov [oldhand9o],edx
    mov ax,204h
    mov bl,08h
    int 31h
    jc near interror
    mov [oldhand8s],cx
    mov [oldhand8o],edx
.nofs
    cmp byte[NoSoundReinit],1
    je .nosound
    cmp byte[soundon],0
    je .nosound
    cmp byte[DSPDisable],1
    je .nosound
    mov ax,204h
    mov bl,[SBInt]
    int 31h
    jc near Interror
    mov [oldhandSBs],cx
    mov [oldhandSBo],edx
.nosound
    sti
    ret

NEWSYM SetupPreGame   ; Executes after pre-game init, can execute multiple
                      ; times after a single InitPreGame
    ; set new handler
    cmp byte[soundon],0
    je near .nosound2
    cmp byte[DSPDisable],1
    je near .nosound2

    ; Turn off IRQ through controller
    cli
    xor dh,dh
    mov dl,[PICMaskP]
    mov cl,[SBIrq]
    and cl,07h
    mov al,01h
    shl al,cl
    mov bl,al
    in al,dx
    or al,bl
    out dx,al

    mov ax,205h
    mov bl,[SBInt]
    mov cx,cs
    mov edx,SBHandler
    int 31h
    jc near interror

    ; Turn on IRQ through controller
    xor dh,dh
    mov dl,[PICMaskP]
    mov cl,[SBIrq]
    and cl,07h
    mov al,01h
    shl al,cl
    not al
    mov bl,al
    in al,dx
    and al,bl
    out dx,al

    call InitSB
    sti
.nosound2
    cli
    mov ax,205h
    mov bl,09h
    mov cx,cs			; Requires CS rather than DS
    mov edx,handler9h
    int 31h
    jc near interror

    mov ax,205h
    mov bl,08h
    mov cx,cs			; Requires CS rather than DS
    mov edx,handler8h
    int 31h
    jc near interror
    call init60hz               ; Set timer to 60/50Hz
.nofs2
    sti
    ret

NEWSYM DeInitPostGame           ; Called after game is ended
    ; de-init interrupt handler
    cli
    mov cx,[oldhand9s]
    mov edx,[oldhand9o]
    mov ax,205h
    mov bl,09h
    int 31h
    jc near interror

    mov cx,[oldhand8s]
    mov edx,[oldhand8o]
    mov ax,205h
    mov bl,08h
    int 31h
    jc near interror
    call init18_2hz               ; Set timer to 18.2Hz
.nofs3
    sti

    ; DeINITSPC
    cmp byte[soundon],0
    je .nosoundb
    cmp byte[DSPDisable],1
    je .nosoundb
    call DeInitSPC
    mov cx,[oldhandSBs]
    mov edx,[oldhandSBo]
    mov ax,205h
    mov bl,[SBInt]
    int 31h
    jc near interror
.nosoundb
    ret

NEWSYM GUIInit
    mov ax,204h
    mov bl,09h
    int 31h
    mov [GUIoldhand9s],cx
    mov [GUIoldhand9o],edx
    mov ax,204h
    mov bl,08h
    int 31h
    mov [GUIoldhand8s],cx
    mov [GUIoldhand8o],edx
    mov ax,205h
    mov bl,09h
    mov cx,cs
    mov edx,GUIhandler9h
    int 31h
    mov ax,205h
    mov bl,08h
    mov cx,cs
    mov edx,GUIhandler8h
    int 31h
    call GUIinit36_4hz
    ret

NEWSYM GUIDeInit
    mov cx,[GUIoldhand9s]
    mov edx,[GUIoldhand9o]
    mov ax,205h
    mov bl,09h
    int 31h
    mov cx,[GUIoldhand8s]
    mov edx,[GUIoldhand8o]
    mov ax,205h
    mov bl,08h
    int 31h
    call GUIinit18_2hz
    ret

; ****************************
; Video Stuff
; ****************************

; ** Palette Functions **
NEWSYM makepal  ; 8-bit palette set
    jmp dosmakepal
NEWSYM changepal  ; 8-bit palette set (changes only)
    jmp doschangepal
NEWSYM displayfpspal
    mov al,128
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,63
    out dx,al
    out dx,al
    out dx,al
    mov al,128+64
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,0
    out dx,al
    out dx,al
    out dx,al
    ret
NEWSYM superscopepal
    mov al,128+16
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,63
    out dx,al
    xor al,al
    out dx,al
    out dx,al
    ret
NEWSYM saveselectpal
    ; set palette of colors 128,144, and 160 to white, blue, and red
    mov al,128
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,63
    out dx,al
    out dx,al
    out dx,al
    mov al,144
    mov dx,03C8h
    out dx,al
    inc dx
    xor al,al
    out dx,al
    out dx,al
    mov al,50
    out dx,al
    mov al,160
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,45
    out dx,al
    xor al,al
    out dx,al
    out dx,al
    mov al,176
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,47
    out dx,al
    xor al,al
    out dx,al
    out dx,al
    mov al,208
    mov dx,03C8h
    out dx,al
    inc dx
    mov al,50
    out dx,al
    mov al,25
    out dx,al
    xor al,al
    out dx,al
    ret

; ** init video mode functions **
NEWSYM initvideo  ; Returns 1 in videotroub if trouble occurs
    jmp dosinitvideo
NEWSYM initvideo2 ; ModeQ scanline re-init (Keep blank on non-dos ports)
    jmp dosinitvideo2
NEWSYM deinitvideo
    mov al,[previdmode]
    mov ah,0
    int 10h
    ret

; ** copy video mode functions **
NEWSYM DrawScreen               ; In-game screen render w/ triple buffer check
   jmp DosDrawScreen
NEWSYM vidpastecopyscr       ; GUI screen render
;   jmp dosvidpastecopyscr
   pushad
   xor eax,eax
   mov al,[cvidmode]
   cmp byte[GUI16VID+eax],1
   jne .no16bconv
   mov eax,[vidbuffer]
   mov ecx,224*288
   mov edx,ecx
   sub ecx,288
   dec edx
.loop
   xor ebx,ebx
   mov bl,[eax+edx]
   mov bx,[GUICPC+ebx*2]
   mov [eax+edx*2],bx
   dec edx
   loop .loop
.no16bconv
   popad
   jmp DosDrawScreenB

; ** Clear Screen function **
NEWSYM ClearScreen
   call DOSClearScreen
   ret

; ** Video Mode Variables **
SECTION .data

; Total Number of Video Modes
NEWSYM NumVideoModes, dd 11

; GUI Video Mode Names - Make sure that all names are of the same length
; and end with a NULL terminator
NEWSYM GUIVideoModeNames
db '320X240X8B  MODEX',0
db '256X256X8B  MODEQ',0
db '320X240X8B  VESA2',0
db '320X240X16B VESA2',0
db '640X480X8B  VESA2',0
db '640X480X16B VESA2',0
db '512X384X8B  VESA2',0
db '512X384X16B VESA2',0
db '640X480X16B VS1.2',0
db '320X480X8B  VESA2',0
db '320X480X16B VESA2',0
db '  0X  0X 0B VESA2',0

; Video Mode Feature Availability (1 = Available, 0 = Not Available)
; Left side starts with Video Mode 0
NEWSYM GUI16VID, db 0,0,0,1,0,1,0,1,1,0,1,0     ; 16-bit mode
NEWSYM GUINGVID, db 1,1,1,1,1,1,1,1,1,1,0,0     ; New Graphics Mode Available
NEWSYM GUISLVID, db 0,1,0,0,1,1,0,0,1,1,1,0     ; Scanlines
NEWSYM GUIINVID, db 0,0,0,0,0,1,0,0,0,0,0,0     ; Interpolation
NEWSYM GUIEAVID, db 0,0,0,0,1,0,0,0,0,0,0,0     ; Eagle
NEWSYM GUIIEVID, db 0,0,0,0,1,1,0,0,0,0,0,0     ; (Interp | Eagle)
NEWSYM GUIFSVID, db 0,0,1,1,1,1,0,0,0,0,0,0     ; Full Screen
NEWSYM GUISSVID, db 0,0,0,0,1,1,0,0,1,0,0,0     ; Small Screen
NEWSYM GUITBVID, db 0,0,1,1,1,1,1,1,0,1,1,0     ; Triple Buffering
NEWSYM GUIHSVID, db 0,0,0,0,0,1,0,0,0,0,1,0     ; Half/Quarter Scanlines
NEWSYM GUI2xVID, db 0,0,0,0,0,1,0,0,0,0,0,0     ; 2xSaI/Super Eagle Engines
NEWSYM GUIWFVID, db 0,0,0,0,0,0,0,0,0,0,0,0     ; If Windows Full Screen
NEWSYM GUII2VID, db 0,0,0,0,0,0,0,0,0,0,0,0     ; Interpolation
NEWSYM GUIM7VID, db 0,0,0,0,0,1,0,0,0,0,0,0     ; Interpolation
NEWSYM GUIBIFIL, db 0,0,0,0,0,0,0,0,0,0,0,0     ; Bilinear Filtering
NEWSYM GUITBWVID, db 0,0,0,0,0,0,0,0,0,0,0,0     ; Triple Buffering (Win)
SECTION .text

; ****************************
; Input Device Stuff
; ****************************

; Variables related to Input Device Routines:
;   pl1selk,pl1startk,pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Xk,
;   pl1Ak,pl1Lk,pl1Yk,pl1Bk,pl1Rk
;     (Change 1 to 2,3,4 for other players)
;     Each of these variables contains the corresponding key pressed value
;       for the key data
;   pressed[]
;     - This is an array of pressed/released data (bytes) where the
;       corresponding key pressed value is used as the index.  The value
;       for each entry is 0 for released and 1 for pressed.  Also, when
;       writing keyboard data to this array, be sure to first check if
;       the value of the array entry is 2 or not.  If it is 2, do not write 1
;       to that array entry. (however, you can write 0 to it)
;   As an example, to access Player 1 L button press data, it is
;     done like : pressed[pl1Lk]
;   The 3 character key description of that array entry is accessed by the
;     GUI through ScanCodeListing[pl1Lk*3]

; Note: When storing the input device configuration of a dynamic input
;   device system (ie. Win9x) rather than a static system (ie. Dos), it
;   is best to store in the name of the device and relative button
;   assignments in the configuration file, then convert it to ZSNES'
;   numerical corresponding key format after reading from it. And then
;   convert it back when writing to it back.

NEWSYM UpdateDevices                    ; One-time input device init
        call DosUpdateDevices
        ret

NEWSYM JoyRead
        call DOSJoyRead
        call SoundProcess               ; Put the sound stuff here since it's
                                        ; called 60 times per second
        ret

NEWSYM SetInputDevice
    ; eax = pointer to devices, bl = device #, bh = player # (0-4)
    ; Sets keys according to input device selected
    cmp bl,0
    jne near .nozero
    mov dword[eax],0
    mov dword[eax+4],0
    mov dword[eax+8],0
    mov dword[eax+12],0
    mov dword[eax+16],0
    mov dword[eax+20],0
    mov dword[eax+24],0
    mov dword[eax+28],0
    mov dword[eax+32],0
    mov dword[eax+36],0
    mov dword[eax+40],0
    mov dword[eax+44],0
    ret
.nozero
    cmp bl,1
    jne near .nokeyb
    cmp bh,1
    ja near .exit
    cmp bh,1
    je near .input2
    mov dword[eax],54
    mov dword[eax+4],28
    mov dword[eax+8],72
    mov dword[eax+12],80
    mov dword[eax+16],75
    mov dword[eax+20],77
    mov dword[eax+24],82
    mov dword[eax+28],71
    mov dword[eax+32],73
    mov dword[eax+36],83
    mov dword[eax+40],79
    mov dword[eax+44],81
    ret
.input2
    mov dword[eax],56
    mov dword[eax+4],29
    mov dword[eax+8],37
    mov dword[eax+12],50
    mov dword[eax+16],49
    mov dword[eax+20],51
    mov dword[eax+24],31
    mov dword[eax+28],32
    mov dword[eax+32],33
    mov dword[eax+36],44
    mov dword[eax+40],45
    mov dword[eax+44],46
    ret
.nokeyb
    cmp bl,2
    jne near .no2buttons
    xor bl,bl
    cmp byte[pl1contrl],2
    jne .nopl2a
    inc bl
.nopl2a
    cmp byte[pl2contrl],2
    jne .nopl2b
    inc bl
.nopl2b
    cmp byte[pl3contrl],2
    jne .nopl2c
    inc bl
.nopl2c
    cmp byte[pl4contrl],2
    jne .nopl2d
    inc bl
.nopl2d
    cmp byte[pl5contrl],2
    jne .nopl2e
    inc bl
.nopl2e
    cmp bl,2
    jae .2ndjoyst
    mov dword[eax+40],83h
    mov dword[eax+36],82h
    mov dword[eax+8],0CCh
    mov dword[eax+12],0CDh
    mov dword[eax+16],0CEh
    mov dword[eax+20],0CFh
    ret
.2ndjoyst
    mov dword[eax+40],85h
    mov dword[eax+36],84h
    mov dword[eax+8],0E8h
    mov dword[eax+12],0E9h
    mov dword[eax+16],0EAh
    mov dword[eax+20],0EBh
    ret
.no2buttons
    cmp bl,3
    je .4buttons
    cmp bl,4
    jne near .no4buttons

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -