1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
| ;=============================================================================
; 32-bit Assembly LES3
;=============================================================================
IDEAL
P386
MODEL FLAT, C
ASSUME cs:_TEXT,ds:FLAT,es:FLAT,fs:FLAT,gs:FLAT
;=============================================================================
; CODE
;=============================================================================
CODESEG
PROC setVideoMode
ARG mode RETURNS eax
mov eax, [mode]
int 10h
ret
ENDP setVideoMode
PROC waitKey
mov eax, 0
int 16h
ret
ENDP waitKey
; Draw a rectangle at the center of the screen.
; W, H passed on stack.
PROC drawBlock1
ARG x:dword, y:dword, co:byte ;dword = 4 bytes , word = 2 bytes, byte = 8 bits
USES eax, ebx, ecx, edx, esi, edi
; Calculate posX
mov eax, 5
neg eax
add eax, [x]
shr eax, 1 ; delen door 2
mov ebx, eax ; posX is in EBX now
; Calculate posY
mov eax, 5
neg eax
add eax, [y]
shr eax, 1 ; and posY is in EAX
;eax positie Y, ebx positie X
; Calculate offset of top-left corner
mov edx, 320
mul edx ; EAX = posY * SCREENW
add eax, ebx ; EAX now contains start offset of rectangle
add eax, 0a0000h
push eax ; store for left vertical line drawing
mov ecx, 5 ; 7x lijn trekken => vierkant gevuld
mov edi, eax ; start of second line
@@FillBlock:
push ecx
push edx
mov ecx, 5 ; rect W
mov al, [co] ; color
rep stosb ; draw,STOSB stores the byte in AL
pop edx
add edi,315
pop ecx
dec ecx
jnz @@FillBlock
sub edi, 320
; done
ret
ENDP drawBlock1
; ================
; Start of program
; ================
PROC main
sti ; set The Interrupt Flag
cld ; clear The Direction Flag
push ds
pop es
call setVideoMode, 13h
mov edi, 0a0000h
; setup colors
mov esi, offset pal ; set the palette (DAC) address
mov ecx, 2 * 3 ; set color 0 and 1 (2 indexes in total, 2 * 3 bytes)
mov dx, 03c8h ; VGA DAC set port
mov al, 0 ; set start color index
out dx, al
inc dx
rep outsb
; draw
; add edi, 320*10 + 160
;mov [byte ptr edi], 1
;*********************************IDEE****************************************
;random blokje oproepen => aan de hand van een random generator. getal kiezen tussen 0-6 ( 7 blokjes in totaal)
; compare number dan jump to @@DrawXshape
; Speed of game
; spatie => roteren van blok
;*********************************IDEE****************************************
;*******************************************0 degrees ********************************************
;I-shape
;@@DrawIshape
call drawBlock1, 320,200,1 ; x,y,color
call drawBlock1, 332,200,1 ; x,y,color
call drawBlock1, 344,200,1 ; x,y,color
call drawBlock1, 356,200,1 ; x,y,color
;j-shape
;@@DrawJshape
call drawBlock1, 200,200,2 ; x,y,color
call drawBlock1, 212,200,2 ; x,y,color
call drawBlock1, 212,212,2 ; x,y,color
call drawBlock1, 212,224,2 ; x,y,color
;l-shape
;@@DrawLshape
call drawBlock1, 100,100,3 ; x,y,color
call drawBlock1, 100,112,3 ; x,y,color
call drawBlock1, 100,124,3 ; x,y,color
call drawBlock1, 112,124,3 ; x,y,color
;box
;@@DrawOshape
call drawBlock1, 150,150,4 ; x,y,color
call drawBlock1, 150,162,4 ; x,y,color
call drawBlock1, 162,150,4 ; x,y,color
call drawBlock1, 162,162,4 ; x,y,color
;z-shape
;@@DrawZshape
call drawBlock1, 80,80,5 ; x,y,color
call drawBlock1, 68,80,5 ; x,y,color
call drawBlock1, 68,68,5 ; x,y,color
call drawBlock1, 56,68,5 ; x,y,color
;t-shape
;@@DrawTshape
call drawBlock1, 40,40,6 ; x,y,color
call drawBlock1, 40,28,6 ; x,y,color
call drawBlock1, 52,28,6 ; x,y,color
call drawBlock1, 28,28,6 ; x,y,color
;s-shape
;@@DrawSshape
call drawBlock1, 80,200,7 ; x,y,color
call drawBlock1, 92,200,7 ; x,y,color
call drawBlock1, 92,188,7 ; x,y,color
call drawBlock1, 104,188,7 ; x,y,color
; wait
call waitKey
call setVideoMode, 3h
mov eax, 4c00h ; AH = 4Ch - Exit To DOS
int 21h ; DOS INT 21h
ENDP main
;=============================================================================
; DATA
;=============================================================================
DATASEG
pal db 0, 0, 0, 63, 63, 63
;=============================================================================
; STACK
;=============================================================================
STACK 10000h
END main |
Partager