📄 lcd.asm
字号:
;===============================================================================
; LCD CD Player - (C) 2000 by Thomas Bleeker [exagone]. http://exagone.cjb.net
;===============================================================================
;
; This program is a basic CD-Player with a nice LCD interface. I didn't finish
; it but the basic functions work and it shows some GDI and MCI stuff. Not all
; functions visible in the main window may work.
;
; Build with MAKE.BAT
;
; Close this program with Alt + F4
;
; Best viewed with tabstop=4 and a good editor with syntax highlighting.
;
; Thomas.
; ska-pig@gmx.net
; http://exagone.cjb.net
;
.486
.model flat,stdcall
option casemap:none
;-----------------------------------------------------------------------------
; Libraries & Include files
;-----------------------------------------------------------------------------
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\winmm.lib
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\winmm.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include prog.inc
;-----------------------------------------------------------------------------
; Prototypes
;-----------------------------------------------------------------------------
WinMain PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
WndProc PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
CreateLCDColors PROTO STDCALL
CreateLCD PROTO STDCALL :DWORD
PseudoRandom PROTO STDCALL
DrawLCD PROTO STDCALL
DrawChar PROTO STDCALL :DWORD, :DWORD, :DWORD
DrawSmallChar PROTO STDCALL :DWORD, :DWORD, :DWORD
DrawLCDText PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
CheckForButton PROTO STDCALL :DWORD, :DWORD
GetPositionFromString PROTO STDCALL :DWORD, :DWORD
GetNextNumberFromTime PROTO STDCALL
;-----------------------------------------------------------------------------
; Initialized data
;-----------------------------------------------------------------------------
.data
AppName db "LCD",0
ClassName db "LCD32",0
; The bitmapinfoheader structure used for the DC the lcd is drawn on
; before it is blitted onto the backbuffer.
; Note that the height property is set to the negated WINDOW_HEIGHT. This
; will cause the bitmap data bits being arranged in top-down order instead
; of the usual down-top order.
; The bitmap used is a 256 color bitmap. A 16-bit bitmap would be enough, but
; then 4 bits per pixel are used which are harder to work with than 8 bits
; per pixel.
LCDBITMAPINFO BITMAPINFOHEADER <SIZEOF BITMAPINFOHEADER,\
ALIGNED_WIDTH, -WINDOW_HEIGHT,\
1, 8, BI_RGB, 0, 100, 100, 16, 16>
; This is the pallette used. The first 7 colors are the colors that are used
; to paint the green background color of the LCD. The 7 colors after that are
; the same colors as the first 7 ones, but darker for use in shadows. The
; colors are not initialized here, but in the code (CreateLCDColors). This way
; the darkness can be changed. Finally, the last two colors are simply black
; and white. The other 240 colors of the 256 color bitmap are not used (see
; also the note above LCDBITMAPINFO).
LCDBaseColors db 140, 165, 148, 0 ; --+
db 148, 165, 140, 0 ; |
db 140, 156, 156, 0 ; |
db 145, 165, 138, 0 ; +- 7 LCD background
db 148, 156, 140, 0 ; | colors
db 142, 156, 140, 0 ; |
db 140, 168, 148, 0 ; --+
db 4 * 7 dup (0) ; ---- Reserved for shadow colors
db 0,0,0,0 ; ---- Black
db 255,255,255,0 ; ---- White
;LCD Characters consist of a 6x7 bit pattern like this:
; Character 'A':
;
; 011110 .oooo.
; 100001 o....o
; 100001 o....o
; 111111 oooooo
; 100001 o....o
; 100001 o....o
; 100001 o....o
;
; This pattern is stored row by row, each row of 6 bits gets two extra 0-bits on the
; right, making it a full byte.
; The following table (LCDChars) contains the most used characters. The comment after
; the lines indicate which char is described. (A=10 means that it is the character A,
; at index 10 (0-based) in list)
LCDChars db 01111000b,10000100b,10001100b,10010100b,10100100b,11000100b,01111000b ;0
db 00010000b,00110000b,00010000b,00010000b,00010000b,00010000b,00010000b ;1
db 01111000b,10000100b,00000100b,01111000b,10000000b,10000000b,11111100b ;2
db 11111000b,00000100b,00000100b,11111000b,00000100b,00000100b,11111000b ;3
db 10000100b,10000100b,10000100b,11111100b,00000100b,00000100b,00000100b ;4
db 11111100b,10000000b,10000000b,11111000b,00000100b,10000100b,01111000b ;5
db 01111000b,10000100b,10000000b,11111000b,10000100b,10000100b,01111000b ;6
db 01111100b,00001000b,00001000b,00010000b,00010000b,00100000b,00100000b ;7
db 01111000b,10000100b,10000100b,01111000b,10000100b,10000100b,01111000b ;8
db 01111000b,10000100b,10000100b,01111100b,00000100b,10000100b,01111000b ;9
db 01111000b,10000100b,10000100b,11111100b,10000100b,10000100b,10000100b ;A = 10
db 11111000b,10000100b,10000100b,11111000b,10000100b,10000100b,11111000b ;B
db 01111100b,10000000b,10000000b,10000000b,10000000b,10000000b,01111100b ;C
db 11111000b,10000100b,10000100b,10000100b,10000100b,10000100b,11111000b ;D
db 11111100b,10000000b,10000000b,11111100b,10000000b,10000000b,11111100b ;E
db 11111100b,10000000b,10000000b,11111100b,10000000b,10000000b,10000000b ;F
db 01111100b,10000000b,10000000b,10111000b,10000100b,10000100b,01111000b ;G
db 10000100b,10000100b,10000100b,11111100b,10000100b,10000100b,10000100b ;H
db 00100000b,00100000b,00100000b,00100000b,00100000b,00100000b,00100000b ;I
db 00010000b,00010000b,00010000b,00010000b,00010000b,10010000b,01100000b ;J
db 10001000b,10010000b,10100000b,11000000b,10100000b,10010000b,10001000b ;K
db 10000000b,10000000b,10000000b,10000000b,10000000b,10000000b,11111100b ;L
db 11011000b,10101000b,10101000b,10101000b,10101000b,10101000b,10101000b ;M
db 11000100b,10100100b,10100100b,10010100b,10010100b,10010100b,10001100b ;N
db 01111000b,10000100b,10000100b,10000100b,10000100b,10000100b,01111000b ;O
db 11111000b,10000100b,10000100b,11111000b,10000000b,10000000b,10000000b ;P
db 01111000b,10000100b,10000100b,10000100b,10010100b,10001100b,01111100b ;Q
db 11111000b,10000100b,10000100b,11111000b,11000000b,10110000b,10001100b ;R
db 01111000b,10000100b,10000000b,01111000b,00000100b,10000100b,01111000b ;S
db 11111000b,00100000b,00100000b,00100000b,00100000b,00100000b,00100000b ;T
db 10000100b,10000100b,10000100b,10000100b,10000100b,10000100b,01111000b ;U
db 10001000b,10001000b,10001000b,10001000b,01010000b,01010000b,00100000b ;V
db 10101000b,10101000b,10101000b,10101000b,10101000b,10101000b,01010000b ;W
db 10001000b,10001000b,01010000b,00100000b,01010000b,10001000b,10001000b ;X
db 10001000b,10001000b,10001000b,01010000b,00100000b,00100000b,00100000b ;Y
db 11111100b,00001000b,00010000b,00100000b,01000000b,10000000b,11111100b ;Z
db 00000000b,00000000b,00000000b,00000000b,00000000b,00110000b,00110000b ;. = 36
db 00000000b,00000000b,00000000b,00000000b,00110000b,00010000b,00100000b ;, = 37
db 00000000b,00110000b,00110000b,00000000b,00110000b,00110000b,00000000b ;: = 38
db 00010000b,00100000b,00100000b,00100000b,00100000b,00100000b,00010000b ;( = 39
db 00100000b,00010000b,00010000b,00010000b,00010000b,00010000b,00100000b ;) = 40
db 00000000b,00000000b,11111100b,00000000b,11111100b,00000000b,00000000b ;= = 41
db 00000000b,00000000b,00000000b,11111100b,00000000b,00000000b,00000000b ;- = 42
db 01111000b,10000100b,10110100b,11000100b,10110100b,10000100b,01111000b ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -