Subversion Repositories Kolibri OS

Rev

Rev 8729 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8725 rgimad 1
; draw main window
2
align 4
3
proc draw_main_window stdcall
8729 rgimad 4
        DEBUGF  DBG_INFO, "draw_main_window() start\n"
8725 rgimad 5
        mcall   12, 1       ; notify about draw beginning
6
        mcall   48, 3, sys_colors, sizeof.system_colors
7
 
8
        mov     edx, [sys_colors.work]         ; background color
9
        or      edx, 0x74000000                ; window type
10
        ; DEBUGF  DBG_INFO, "mainwindow w, h  = %u, %u", GFX_COLS*GFX_PIX_SIZE + 8, GFX_ROWS*GFX_PIX_SIZE + 28
8729 rgimad 11
        mcall   0, <50, GFX_COLS*GFX_PIX_SIZE + 9>, <50, GFX_ROWS*GFX_PIX_SIZE + 28>, , , main_window_title ;
8725 rgimad 12
 
13
        stdcall draw_screen
14
 
15
        mcall   12, 2                  ; notify about draw ending
8729 rgimad 16
        DEBUGF  DBG_INFO, "draw_main_window() end\n"
8725 rgimad 17
        ret
18
endp
19
 
20
; draw screen
21
align 4
22
proc draw_screen stdcall
23
        pushad
24
        locals
25
            row_ind dd ?
26
            col_ind dd ?
27
            color   dd ?
28
        endl
29
 
30
        xor     esi, esi
31
.loop1:
32
        cmp     esi, GFX_SIZE
33
        jae     .loop1_end
34
        xor     edx, edx
35
        mov     eax, esi
36
        mov     ecx, GFX_COLS
37
        div     ecx ; eax = row index, edx = col index
38
        mov     dword [row_ind], eax
39
        mov     dword [col_ind], edx
8734 rgimad 40
        mov     dword [color], COLOR_CELL ; white
8725 rgimad 41
        cmp     byte [esi + gfx], 0 ; check if cell is 0 or not 0
42
        jne     @f
8734 rgimad 43
        mov     dword [color], COLOR_BACK ;  black
8725 rgimad 44
    @@:
45
        mov     ebx, dword [col_ind]
8734 rgimad 46
        imul    ebx, GFX_PIX_SIZE ; now ebx - x coord of rect
8725 rgimad 47
        mov     ecx, dword [row_ind]
8734 rgimad 48
        imul    ecx, GFX_PIX_SIZE ; now ecx - y coord of rect
8725 rgimad 49
        mov     edx, dword [color]
8734 rgimad 50
        stdcall imgbuf_draw_rect, ebx, ecx, edx
8725 rgimad 51
 
52
        inc     esi
53
        jmp     .loop1
54
 
55
.loop1_end:
8734 rgimad 56
        stdcall imgbuf_send_to_window
8725 rgimad 57
        popad
58
        ret
8734 rgimad 59
endp
60
 
61
; copy imgbuf contents to the emulator window
62
align 4
63
proc imgbuf_send_to_window stdcall
64
        DEBUGF  DBG_INFO, "sending to window...\n"
65
        push    eax ebx ecx edx
66
        mov     eax, 7
67
        mov     ebx, dword [imgbuf_ptr]
68
        mov     ecx, IMGBUF_WIDTH
69
        shl     ecx, 16
70
        add     ecx, IMGBUF_HEIGHT
71
        xor     edx, edx
72
        int     0x40
73
        pop     edx ecx ebx eax
74
        ret
75
endp
76
 
77
 
78
; in internal buffer draw rect filled with given color at position (rect_x, rect_y) within window
79
align 4
80
proc imgbuf_draw_rect stdcall, rect_x: dword, rect_y: dword, rect_color: dword
81
        DEBUGF  DBG_INFO, "imgbuf_draw_rect(%u, %u, %x)\n", [rect_x], [rect_y], [rect_color]
82
        push    eax ebx ecx edx esi edi ebp
83
 
84
        mov     ebx, dword [rect_y]
85
        imul    ebx, IMGBUF_WIDTH
86
        add     ebx, dword [rect_x] ; now ebx - index of first pixel of rect
87
 
88
        mov     edi, dword [imgbuf_ptr]
89
        mov     ebp, dword [rect_color]
90
 
91
        xor     ecx, ecx
92
.for_i:
93
        cmp     ecx, GFX_PIX_SIZE
94
        jae     .ret
95
 
96
        xor     edx, edx
97
.for_j:
98
        cmp     edx, GFX_PIX_SIZE
99
        jae     .for_j_end
100
 
101
        mov     esi, edx
102
 
103
        add     edx, ebx
104
        mov     eax, ecx
105
        imul    eax, IMGBUF_WIDTH
106
        add     edx, eax ; now edx is index of edx'th pixel of ecx'th row of rect
107
 
108
        lea     edx, [edx*3]
109
        add     edx, edi
110
 
111
        mov     dword [edx], ebp ; put color to pixel
112
 
113
        mov     edx, esi
114
        inc     edx
115
        jmp     .for_j
116
.for_j_end:
117
 
118
        inc     ecx
119
        jmp     .for_i
120
 
121
.ret:
122
        pop     ebp edi esi edx ecx ebx eax
123
        ret
124
endp