📄 cwlib.inc
字号:
;
;EDI - Next un-used byte in buffer.
;
;All other registers preserved.
;
;-------------------------------------------------------------------------
extdef Bin2Hex:near
;-------------------------------------------------------------------------
;Name: ReadCommand
;-------------------------------------------------------------------------
;
;Read the command line tail for parameters.
;
;supports / or - or + as switch/option settings. Options and names may be in
;any order, text can be tagged onto options, names must be in correct sequence
;for current program.
;
;Each character ( 33 to 127) has an entry in OptionTable & OptionPointers.
;
;The first entry is a byte, and is 0 for OFF & none-zero for ON.
;The second entry is a pointer to any additional text specified, 0 means none.
;Entries 0-32 are reserved for text not preceded by - or + or /. These are
;intended to be file names, but neadn't be.
;All text entries are 0 terminated.
;
;OptionCounter - Total command line parameters (files & switches).
;OptionTable - Switch table, ASCII code is index to check.
;OptionPointers - Pointer table, ASCII code*4 is index to use.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;nothing.
;
;-------------------------------------------------------------------------
extdef ReadCommand:near
extdef OptionCounter:byte
extdef OptionTable:byte
extdef OptionPointers:dword
;-------------------------------------------------------------------------
;Name: Delay
;-------------------------------------------------------------------------
;
;Wait for a while.
;
;On Entry:
;
;ECX - time to wait for.
;
;-------------------------------------------------------------------------
extdef Delay:near
;-------------------------------------------------------------------------
;Name: GetKey
;-------------------------------------------------------------------------
;
;Get key press info.
;
;On Entry:
;
;none.
;
;On Exit:
;
;AL - ASCII character code.
;AH - Hardware key code.
;EAX high word - Shift keys status word from 417h.
;
;-------------------------------------------------------------------------
extdef GetKey:near
;-------------------------------------------------------------------------
;Name: WaitKey
;-------------------------------------------------------------------------
;
;Wait for a key press.
;
;On Entry:
;
;none.
;
;On Exit:
;
;EAX - Key code, same format as GetKey.
;
;-------------------------------------------------------------------------
extdef WaitKey:near
;-------------------------------------------------------------------------
;Name: NearNull
;-------------------------------------------------------------------------
;
;Dummy routine for variables that need a call value that does nothing.
;
;No entry or exit conditions, just does a RET.
;
;-------------------------------------------------------------------------
extdef NearNull:near
;-----------------------------------------------------------------------------
;Name: VideoInitialise
;-------------------------------------------------------------------------
;
;Initialise video stuff, includeing VESA support if detected.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;Carry set on error and EAX=error code.
;
;Error codes:
;
;0 - no error.
;1 - couldn't allocate selector for video memory.
;2 - not enough memory for bitmap control table.
;3 - video system not supported, ie, not (S)VGA.
;
;ALL other registers preserved.
;
;-----------------------------------------------------------------------------
extdef VideoInitialise:near
;-----------------------------------------------------------------------------
;Name: VideoRemove
;-------------------------------------------------------------------------
;
;Remove video stuff, includeing VESA support if installed.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;ALL registers preserved.
;
;-----------------------------------------------------------------------------
extdef VideoRemove:near
;-----------------------------------------------------------------------------
;Name: InitVESA
;-----------------------------------------------------------------------------
;
;Have a look for VESA INT 10h BIOS extension and if present install a patch to
;make protected mode access transparent. This is only needed if you don't use
;VideoInitialise.
;
;On Entry:
;
;nothing
;
;On Exit:
;
;Carry set on error and EAX=0 else,
;
;EAX - Address of bank switch code. Always != 0.
;
;ALL other registers preserved.
;
extdef InitVESA:near
;-----------------------------------------------------------------------------
;Name: RelVESA
;-----------------------------------------------------------------------------
;
;Release VESA BIOS patch if installed.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;
;Notes: This routine can safely be called even if InitVESA hasn't been
; called or didn't install due to lack of VESA.
;
extdef RelVESA:near
;-------------------------------------------------------------------------
;Name: SetDACs
;-------------------------------------------------------------------------
;
;Set the value's in VGA colour DAC's.
;
;On Entry:
;
;EBX - Starting DAC number.
;ECX - Number of DAC's to set.
;ESI - Pallet information
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef SetDACs:near
;-------------------------------------------------------------------------
;Name: SearchRGB
;-------------------------------------------------------------------------
;
;Find closest match in HardwarePalette to RGB value specified. Must be more
;accurate ways of doing it than this but I don't know about them!
;
;On Entry:
;
;EAX - RGB value.
;
;On Exit:
;
;EAX - Nearest pen value in HardwarePalette
;
;-------------------------------------------------------------------------
extdef SearchRGB:near
;------------------------------------------------------------------------------
;Name: RemapSystemBitmap
;------------------------------------------------------------------------------
;
;Copy and re-map "system" bitmap duplicate.
;
;On Entry:
;
;ESI - pointer to "system" bitmap table entry.
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;------------------------------------------------------------------------------
extdef RemapSystemBitmap:near
;------------------------------------------------------------------------------
;Name: RemapSystemBitmaps
;------------------------------------------------------------------------------
;
;Re-map all bitmaps registered as useing "system" palette.
;
;On Entry:
;
;nothing.
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;------------------------------------------------------------------------------
extdef RemapSystemBitmaps:near
;-------------------------------------------------------------------------
;Name: RegisterSystemBitmap
;-------------------------------------------------------------------------
;
;Register a bitmap that needs to be re-mapped whenever the hardware palette
;changes so it stays in the system palette scheme.
;
;On Entry:
;
;ESI - bitmap.
;
;On Exit:
;
;EAX - handle.
;
;ALL other registers preserved.
;
;-------------------------------------------------------------------------
extdef RegisterSystemBitmap:near
;-------------------------------------------------------------------------
;Name: ReleaseSystemBitmap
;-------------------------------------------------------------------------
;
;Release a bitmap previously regeistered with the bitmap manager. Duplicate
;memory is free'd and entry in table is marked free.
;
;On Entry:
;
;ESI - Handle
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef ReleaseSystemBitmap:near
;-------------------------------------------------------------------------
;Name: VideoSetPalette
;-------------------------------------------------------------------------
;
;Set hardware palette. Generates new system to hardware translation table
;and re-maps all "system" bitmaps.
;
;On Entry:
;
;EAX - Base
;ECX - Number.
;ESI - data.
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef VideoSetPalette:near
;-------------------------------------------------------------------------
;Name: VideoSetMode
;-------------------------------------------------------------------------
;
;Attempt to set specified video mode.
;
;On Entry:
;
;EAX - Mode.
;
;On Exit:
;
;EAX - zero on error else mode number.
;
;ALL other registers preserved.
;
;-------------------------------------------------------------------------
extdef VideoSetMode:near
;-------------------------------------------------------------------------
;Name: BuildModeList
;-------------------------------------------------------------------------
;
;Build a text list of modes in the buffer specified.
;
;On Entry:
;
;ESI - buffer to use.
;
;On Exit:
;
;nothing.
;
;All registers preserved.
;
;-------------------------------------------------------------------------
extdef BuildModeList:near
;-------------------------------------------------------------------------
;Name: VideoSys2Hard
;-------------------------------------------------------------------------
;
;Convert system pen number into hardware pen number.
;
;On Entry:
;
;AL - pen number to convert.
;
;On Exit:
;
;AL - new pen number.
;
;ALL other registers preserved.
;
;-------------------------------------------------------------------------
extdef VideoSys2Hard:near
;-------------------------------------------------------------------------
;Name: Bord
;-------------------------------------------------------------------------
;
;Change the border colour. Provided mainly for simplistic debugging.
;
;On Entry:
;
;AL - colour to set.
;
;On Exit:
;
;nothing.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef Bord:near
;-------------------------------------------------------------------------
;Name: VideoSetPixel
;-------------------------------------------------------------------------
;
;Set a pixel to specified colour. Cheats by useing VideoFillRectangle for now.
;
;On Entry:
;
;EAX - Flags, bit significant if set.
; 0 - FillValue is RGB.
;EBX - Fill value.
;ECX - X co-ord.
;EDX - Y co-ord.
;
;On Exit:
;
;nothing.
;
;All registers preserved.
;
;-------------------------------------------------------------------------
extdef VideoSetPixel:near
;-------------------------------------------------------------------------
;Name: VideoFillRectangle
;-------------------------------------------------------------------------
;
;Clear a rectangle of video memory to specified value.
;
;On Entry:
;
;C style stack with following parameters,
;
;flags - Flags, bit significant if set.
; 0 - FillValue is RGB.
;FillValue - fill value to use.
;XCoord - X co-ord to start at.
;YCoord - Y co-ord to start at.
;Wide - width to fill.
;Depth - depth to fill.
;
;On Exit:
;
;Nothing.
;
;ALL registers preserved.
;
;-------------------------------------------------------------------------
extdef VideoFillRectangle:near
;-------------------------------------------------------------------------
;Name: VideoDrawLine
;-------------------------------------------------------------------------
;
;Draw a line in specified colour between specified points.
;
;On Entry:
;
;EAX - Flags, bit significant if set.
; 0 - Fill value is RGB.
; 1 - Fill type, 0-normal, 1-store data, 2-replace data.
; 2 -/
;EBX - Fill value or data pointer depending on flags.
;ECX - start X co-ord.
;EDX - start Y co-ord.
;ESI - end X co-ord.
;EDI - end Y co-ord.
;
;On Exit:
;
;nothing.
;
;All registers preserved.
;
;Notes:
;
;If type 1 is selected it is the callers responsibility to ensure that the
;buffer pointed to by EBX is big enough.
;
;-------------------------------------------------------------------------
extdef VideoDrawLine:near
;-------------------------------------------------------------------------
;Name: VideoBlitBitmap
;-------------------------------------------------------------------------
;
;Blit a bitmap to/from video memory.
;
;On Entry:
;
;C style stack with following parameters,
;
;flags - flags, bit significant if set.
; 0 - blit video to system memory.
; 1 - OR bitmap on, chroma value is used.
;bitmap - pointer to bitmap.
;xcoord - X co-ord to blit at.
;ycoord - Y co-ord to blit at.
;xoff - X offset within bitmap.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -