Changeset 50 in xtideuniversalbios


Ignore:
Timestamp:
Oct 9, 2010, 5:47:26 PM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:
Removed Memory_ExchangeSSBPwithESDI since it obviously corrupted stack.
CGA detection is now only done once when initializing Display Context.
Moved File Library defines to File.inc.

Location:
trunk/Assembly_Library
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/AssemblyLibrary.inc

    r48 r50  
    1515%include "Debug.inc"
    1616%include "DosFunctions.inc"
     17%include "File.inc"
    1718%include "Math.inc"
    1819
  • trunk/Assembly_Library/Inc/Display.inc

    r48 r50  
    22; Project name  :   AssemblyLibrary
    33; Created date  :   25.6.2010
    4 ; Last update   :   6.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for display library.
     
    110110; Display context flags
    111111FLG_CONTEXT_ATTRIBUTES      EQU     (1<<0)  ; Character output function uses attributes
     112FLG_CONTEXT_CGA             EQU     (1<<1)  ; CGA detected so prevent CGA snow
    112113
    113114
  • trunk/Assembly_Library/Inc/DosFunctions.inc

    r41 r50  
    22; Project name  :   AssemblyLibrary
    33; Created date  :   1.9.2010
    4 ; Last update   :   3.9.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for MS-DOS functions.
     
    3030; DOS errors
    3131ERR_DOS_DRIVE_NOT_READY                             EQU     15h
    32 
    33 
    34 ; File attribute flags
    35 FLG_FILEATTR_READ_ONLY          EQU     (1<<0)
    36 FLG_FILEATTR_HIDDEN             EQU     (1<<1)
    37 FLG_FILEATTR_SYSTEM             EQU     (1<<2)
    38 FLG_FILEATTR_VOLUME_LABEL       EQU     (1<<3)
    39 FLG_FILEATTR_DIRECTORY          EQU     (1<<4)
    40 FLG_FILEATTR_ARCHIVE            EQU     (1<<5)
    4132
    4233
  • trunk/Assembly_Library/Inc/Emulate.inc

    r41 r50  
    22; Project name  :   Emulation library
    33; Created date  :   21.10.2009
    4 ; Last update   :   29.7.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Macros for emulating later x86 instruction with older
     
    318318    sub     sp, %1
    319319    mov     bp, sp
    320     ;eENTER %1, 0
    321     ;sub        bp, %1          ; SS:BP now points to struct
    322320%endmacro
    323321
     
    334332    add     sp, %1
    335333    pop     bp
    336     ;add        bp, %1          ; Restore BP to what it was after eENTER
    337     ;eLEAVE
    338334%endmacro
    339335
  • trunk/Assembly_Library/Src/Display/CgaSnow.asm

    r49 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   8.10.2010
    4 ; Last update   :   8.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for preventing CGA snow.
     
    88; Section containing code
    99SECTION .text
     10
     11;--------------------------------------------------------------------
     12; CgaSnow_IsCgaPresent
     13;   Parameters:
     14;       DS:     BDA segment (zero)
     15;   Returns:
     16;       CF:     Set if CGA detected
     17;               Cleared if CGA not detected
     18;   Corrupts registers:
     19;       AX
     20;--------------------------------------------------------------------
     21ALIGN JUMP_ALIGN
     22CgaSnow_IsCgaPresent:
     23    cmp     WORD [BDA.wVidPort], CGA_STATUS_REGISTER - OFFSET_TO_CGA_STATUS_REGISTER
     24    jne     SHORT .CgaNotFound
     25    call    DisplayPage_GetColumnsToALandRowsToAH
     26    cmp     ah, [BDA.bVidRows]      ; Video rows stored only by EGA and later
     27    je      SHORT .CgaNotFound      ; Must be EGA or later
     28    stc
     29    ret
     30ALIGN JUMP_ALIGN
     31.CgaNotFound:
     32    clc
     33    ret
    1034
    1135
     
    2953ALIGN JUMP_ALIGN
    3054CgaSnow_Stosb:
    31     call    LoadAndVerifyStatusRegisterFromBDA
    32     jne     SHORT .StosbWithoutWaitSinceUnknownPort
     55    call    LoadCgaStatusRegisterAddressToDXifCgaPresent
     56    jz      SHORT .StosbWithoutWaitSinceUnknownPort
    3357
    3458    mov     ah, al
     
    4468CgaSnow_Stosw:
    4569    push    bx
    46     call    LoadAndVerifyStatusRegisterFromBDA
    47     jne     SHORT .StoswWithoutWaitSinceUnknownPort
     70    call    LoadCgaStatusRegisterAddressToDXifCgaPresent
     71    jz      SHORT .StoswWithoutWaitSinceUnknownPort
    4872
    4973    xchg    bx, ax
     
    7195ALIGN JUMP_ALIGN
    7296CgaSnow_Scasb:
    73     call    LoadAndVerifyStatusRegisterFromBDA
    74     jne     SHORT .ScasbWithoutWaitSinceUnknownPort
     97    call    LoadCgaStatusRegisterAddressToDXifCgaPresent
     98    jz      SHORT .ScasbWithoutWaitSinceUnknownPort
    7599
    76100    mov     ah, al
     
    98122ALIGN JUMP_ALIGN
    99123CgaSnow_RepMovsb:
    100     call    LoadAndVerifyStatusRegisterFromBDA
    101     jne     SHORT .RepMovsbWithoutWaitSinceUnknownPort
     124    call    LoadCgaStatusRegisterAddressToDXifCgaPresent
     125    jz      SHORT .RepMovsbWithoutWaitSinceUnknownPort
    102126
    103127.MovsbNextByte:
     
    115139
    116140;--------------------------------------------------------------------
    117 ; LoadAndVerifyStatusRegisterFromBDA
     141; LoadCgaStatusRegisterAddressToDXifCgaPresent
    118142;   Parameters:
    119143;       DS:     BDA segment (zero)
    120144;   Returns:
    121145;       DX:     CGA Status Register Address
    122 ;       ZF:     Set if CGA Base Port found in BDA
     146;       ZF:     Set if CGA not present
     147;               Cleared if CGA present
    123148;   Corrupts registers:
    124149;       Nothing
    125150;--------------------------------------------------------------------
    126151ALIGN JUMP_ALIGN
    127 LoadAndVerifyStatusRegisterFromBDA:
    128     mov     dx, [BDA.wVidPort]
    129     add     dl, OFFSET_TO_CGA_STATUS_REGISTER
    130     cmp     dx, CGA_STATUS_REGISTER
    131     je      SHORT .CheckIfEgaOrLater
    132     ret
    133 
    134 ALIGN JUMP_ALIGN
    135 .CheckIfEgaOrLater:
    136     push    ax
    137     call    DisplayPage_GetColumnsToALandRowsToAH
    138     cmp     ah, [BDA.bVidRows]      ; Video rows stored only by EGA and later
    139     lahf
    140     xor     ah, 1<<6                ; Invert ZF
    141     sahf
    142     pop     ax
     152LoadCgaStatusRegisterAddressToDXifCgaPresent:
     153    test    BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
     154    jz      SHORT .NoCgaDetected
     155    mov     dx, CGA_STATUS_REGISTER
     156ALIGN JUMP_ALIGN, ret
     157.NoCgaDetected:
    143158    ret
    144159
  • trunk/Assembly_Library/Src/Display/DisplayContext.asm

    r48 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   25.6.2010
    4 ; Last update   :   5.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for managing display context.
     
    2020ALIGN JUMP_ALIGN
    2121DisplayContext_Initialize:
    22     call    .DetectAndSetDisplaySegment
     22    call    .DetectAndSetDisplaySegment ; and .InitializeFlags
    2323    mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], DEFAULT_CHARACTER_OUTPUT
    2424    mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], CURSOR_NORMAL
    2525    mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], SCREEN_BACKGROUND_ATTRIBUTE
    26     mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
    27 
    2826    xor     ax, ax
    2927    call    DisplayCursor_SetCoordinatesFromAX
    30     jmp     SHORT DisplayContext_SynchronizeToHardware
     28    jmp     DisplayContext_SynchronizeToHardware
    3129
    3230;--------------------------------------------------------------------
     
    3735;       Nothing
    3836;   Corrupts registers:
    39 ;       Nothing
     37;       AX, DX
    4038;--------------------------------------------------------------------
    4139.DetectAndSetDisplaySegment:
    42     mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], COLOR_TEXT_SEGMENT
     40    mov     ax, COLOR_TEXT_SEGMENT
    4341    cmp     BYTE [VIDEO_BDA.bMode], MDA_TEXT_MODE
    44     jne     SHORT .Return
    45     sub     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], COLOR_TEXT_SEGMENT - MONO_TEXT_SEGMENT
    46 .Return:
     42    jne     SHORT .StoreSegmentToDisplayContext
     43    mov     ax, MONO_TEXT_SEGMENT
     44.StoreSegmentToDisplayContext:
     45    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2], ax
     46    ; Fall to InitializeFlags
     47
     48;--------------------------------------------------------------------
     49; .InitializeFlags
     50;   Parameters:
     51;       DS:     BDA segment (zero)
     52;   Returns:
     53;       Nothing
     54;   Corrupts registers:
     55;       AX, DX
     56;--------------------------------------------------------------------
     57.InitializeFlags:
     58    mov     dl, FLG_CONTEXT_ATTRIBUTES
     59    call    CgaSnow_IsCgaPresent
     60    jnc     SHORT .DoNotSetCgaFlag
     61    or      dl, FLG_CONTEXT_CGA
     62.DoNotSetCgaFlag:
     63    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], dl
    4764    ret
    4865
     
    188205;       Nothing
    189206;   Corrupts registers:
    190 ;       Nothing
     207;       BL
    191208;--------------------------------------------------------------------
    192209ALIGN JUMP_ALIGN
    193210DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL:
     211    and     bl, FLG_CONTEXT_ATTRIBUTES
     212    and     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], ~FLG_CONTEXT_ATTRIBUTES
     213    or      [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], bl
    194214    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
    195     mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], bl
    196215    ret
    197216
  • trunk/Assembly_Library/Src/File/FileIO.asm

    r41 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   1.9.2010
    4 ; Last update   :   3.9.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for file access.
    7 
    8 
    9 ; File access and sharing modes
    10 struc FILE_ACCESS
    11     .ReadOnly       resb    1
    12     .WriteOnly      resb    1
    13     .ReadAndWrite   resb    1
    14 endstruc
    15 
    16 ; Origin of file seek
    17 struc SEEK_FROM
    18     .startOfFile            resb    1
    19     .currentFilePosition    resb    1
    20     .endOfFile              resb    1
    21 endstruc
    22 
    237
    248; Section containing code
  • trunk/Assembly_Library/Src/LibraryTests.asm

    r48 r50  
    224224.AskFileFromUser:
    225225    mov     si, g_dialogInputOutput
    226     mov     WORD [si+DIALOG_INPUT.fszItems], g_szBuffer
     226    mov     WORD [si+FILE_DIALOG_IO.fszItemBuffer], g_szBuffer
    227227    mov     BYTE [si+FILE_DIALOG_IO.bDialogFlags], FLG_FILEDIALOG_DIRECTORY | FLG_FILEDIALOG_NEW | FLG_FILEDIALOG_DRIVES
    228228    mov     BYTE [si+FILE_DIALOG_IO.bFileAttributes], FLG_FILEATTR_DIRECTORY | FLG_FILEATTR_ARCHIVE
    229229    mov     WORD [si+FILE_DIALOG_IO.fpFileFilterString], .szAllFiles
    230230    mov     [si+FILE_DIALOG_IO.fpFileFilterString+2], cs
    231     mov     [si+STRING_DIALOG_IO.fpReturnBuffer+2], cs
    232231    CALL_MENU_LIBRARY GetFileNameWithIoInDSSI
    233232    cmp     BYTE [g_dialogInputOutput+FILE_DIALOG_IO.bUserCancellation], TRUE
  • trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm

    r48 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   6.8.2010
    4 ; Last update   :   7.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Common functions for many dialogs.
     
    2626    push    ds
    2727    mov     di, bp                              ; Backup parent MENU
    28     eENTER_STRUCT DIALOG_size
    29 
    3028    mov     cx, DIALOG_size
     29    eENTER_STRUCT cx
     30
    3131    call    Memory_ZeroSSBPwithSizeInCX
    3232    mov     [bp+DIALOG.fpDialogIO], si
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm

    r48 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   6.9.2010
    4 ; Last update   :   4.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Displays file dialog.
     
    114114    call    LoadItemStringBufferToESDI
    115115    call    SortDirectoryContentsStringFromESDIwithCountInCX
    116     push    ss
    117     pop     ds
    118     mov     si, bp
     116    call    Memory_CopySSBPtoDSSI
    119117    call    Dialog_EventInitializeMenuinitFromDSSI
    120118    call    GetInfoLinesToCXandDialogFlagsToAX
     
    199197ALIGN JUMP_ALIGN
    200198.ClearDLifInRootDirectory:
    201     push    es
    202     pop     ds
    203     mov     si, di
     199    call    Memory_CopyESDItoDSSI
    204200    call    Directory_WriteCurrentPathToDSSI
    205201    mov     dl, [si]
     
    511507    add     di, BYTE FILE_DIALOG_IO.szFile
    512508    mov     cx, FILENAME_BUFFER_SIZE-1
    513     cld
    514     rep movsb
     509    call    Memory_CopyCXbytesFromDSSItoESDI
    515510    xor     ax, ax
    516511    stosb                       ; Terminate with NULL
    517     jmp     CloseFileDialogAfterSuccessfullSelection
     512    jmp     SHORT CloseFileDialogAfterSuccessfullSelection
    518513
    519514;--------------------------------------------------------------------
  • trunk/Assembly_Library/Src/Util/Memory.asm

    r46 r50  
    22; Project name  :   Assembly Library
    33; Created date  :   14.7.2010
    4 ; Last update   :   1.10.2010
     4; Last update   :   9.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for memory access.
     
    6767ALIGN JUMP_ALIGN
    6868Memory_ZeroSSBPwithSizeInCX:
     69    push    es
     70    push    di
    6971    push    ax
    70 
    71     call    Memory_ExchangeSSBPwithESDI
     72    call    Memory_CopySSBPtoESDI
    7273    call    Memory_ZeroESDIwithSizeInCX
    73     call    Memory_ExchangeSSBPwithESDI
    74 
    7574    pop     ax
     75    pop     di
     76    pop     es
    7677    ret
    7778
     
    8283;       ES:DI:  Ptr to destination buffer
    8384;   Returns:
    84 ;       Nothing
     85;       DI:     Updated by number of BYTEs stored
    8586;   Corrupts registers:
    8687;       AX
     
    9899;       ES:DI:  Ptr to destination buffer
    99100;   Returns:
    100 ;       Nothing
     101;       DI:     Updated by number of BYTEs stored
    101102;   Corrupts registers:
    102103;       Nothing
     
    105106Memory_StoreCXbytesFromAccumToESDI:
    106107    OPTIMIZE_STRING_OPERATION rep, stos
    107     sub     di, cx
    108108    ret
    109109
    110110
    111111;--------------------------------------------------------------------
    112 ; Memory_ExchangeSSBPwithESDI
    113112; Memory_ExchangeDSSIwithESDI
    114113;   Parameters
    115114;       Nothing
    116115;   Returns:
    117 ;       SS:BP/DS:SI and ES:DI are exchanged.
     116;       DS:SI and ES:DI are exchanged.
    118117;   Corrupts registers:
    119118;       Nothing
    120119;--------------------------------------------------------------------
    121120ALIGN JUMP_ALIGN
    122 Memory_ExchangeSSBPwithESDI:
    123     xchg    bp, di
    124     push    ss
    125     push    es
    126     pop     ss
    127     pop     es
    128     ret
    129 
    130 ALIGN JUMP_ALIGN
    131121Memory_ExchangeDSSIwithESDI:
    132     xchg    si, di
    133122    push    ds
    134123    push    es
    135124    pop     ds
    136125    pop     es
     126    xchg    si, di
    137127    ret
    138128
     
    140130;--------------------------------------------------------------------
    141131; Memory_CopySSBPtoESDI
     132; Memory_CopySSBPtoDSSI
     133; Memory_CopyESDItoDSSI
    142134;   Parameters
    143135;       Nothing
    144136;   Returns:
    145 ;       ES:DI:      Same as SS:BP
     137;       Copies farm pointer to different segment/pointer register pair
    146138;   Corrupts registers:
    147139;       Nothing
     
    152144    pop     es
    153145    mov     di, bp
     146    ret
     147
     148ALIGN JUMP_ALIGN
     149Memory_CopySSBPtoDSSI:
     150    push    ss
     151    pop     ds
     152    mov     si, bp
     153    ret
     154
     155ALIGN JUMP_ALIGN
     156Memory_CopyESDItoDSSI:
     157    push    es
     158    pop     ds
     159    mov     si, di
    154160    ret
    155161
Note: See TracChangeset for help on using the changeset viewer.