commit 3ad7640c45114bb56c9c7759c56c772b5c3ab138
parent c1780262a9e66785aa72ec9e8e29a8730fe3696b
Author: Léo Villeveygoux <leo.villeveygoux@etu.u-bordeaux.fr>
Date: Fri, 30 Jun 2017 20:36:04 +0200
draw.asm: add palette selector gui
Diffstat:
M | draw.asm | | | 59 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
1 file changed, 56 insertions(+), 3 deletions(-)
diff --git a/draw.asm b/draw.asm
@@ -13,11 +13,11 @@ state_fun dd init
init:
call inv_cross
- mov eax, f
+ mov eax, draw_loop
mov [state_fun], eax
ret
-f:
+draw_loop:
; undraw cross
call inv_cross
@@ -86,6 +86,8 @@ f:
call inv_cross
+ call draw_palette
+
ret
inv_cross:
@@ -123,10 +125,61 @@ inv_cross:
inv_pix: ;pass coords in cl
mov al, byte [pix+ecx]
- xor al, ~1
+ xor al, ~0
mov byte [pix+ecx], al
ret
+draw_palette:
+ mov ecx, 0x10
+ mov edx, pix
+
+ .y_loop:
+ push ecx
+
+ mov ecx, 0x100
+
+ .x_loop:
+ push edx
+
+ ; get color id
+ mov edx, ecx
+ sar edx, 5
+
+ mov eax, 0
+ mov al, [selected]
+
+ ;spagetti party!
+ cmp al, dl
+ je .draw_selected
+
+ .draw_direct:
+ mov al, byte [palette + edx]
+ jmp .draw
+
+ .draw_selected:
+ mov eax, ecx
+ and eax, 0x1f
+ cmp eax, 3
+ jl .do_it ; overlay half columns
+
+ cmp eax, 29
+ jl .draw_direct
+
+ .do_it
+ mov al, byte [palette + edx]
+ xor al, ~0
+
+ .draw:
+ pop edx
+ mov [edx], al ; put color to screen
+ inc edx
+ loop .x_loop
+
+ pop ecx
+ loop .y_loop
+
+ ret
+
coords: dd 0x8080
pressing_x: db 0
selected: db 0