b8

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.vgx.fr/b8
Log | Files | Refs

commit c1780262a9e66785aa72ec9e8e29a8730fe3696b
parent d81d344122b068f6dc686492294851a7ee777869
Author: Léo Villeveygoux <leo.villeveygoux@etu.u-bordeaux.fr>
Date:   Fri, 30 Jun 2017 19:43:04 +0200

draw.asm: fix drawing and add cross

Diffstat:
Mdraw.asm | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 62 insertions(+), 6 deletions(-)

diff --git a/draw.asm b/draw.asm @@ -9,9 +9,18 @@ header: db '#!/usr/bin/env b8', 0x0a times 32-$+header db 0x0 jmp [state_fun] -state_fun dd f +state_fun dd init + +init: + call inv_cross + mov eax, f + mov [state_fun], eax + ret f: + ; undraw cross + call inv_cross + ; update coords mov eax, 0 mov al, byte [input] @@ -41,35 +50,82 @@ f: jz .check_x add dx, 0x100 + ; update color .check_x: mov cl, 10000b and cl, al jz .check_no_x mov byte [pressing_x], byte 1 - jmp .check_end + jmp .check_c .check_no_x: mov cl, [pressing_x] mov byte [pressing_x], byte 0 test cl, cl - jz .check_end + jz .check_c mov cl, [selected] inc cl and cl, [palette_mask] mov byte [selected], cl - .check_end: - mov [coords], edx + ; draw pixel + .check_c + mov cl, 100000b + and cl, al + jz .check_end ; get color mov ecx, 0 mov cl, byte [selected] mov al, byte [palette + ecx] - mov edx, [coords] mov byte [pix+edx], al + + .check_end: + mov [coords], edx + + call inv_cross + ret +inv_cross: + mov edx, [coords] + + ;up + mov cx, dx + sub cx, 0x100 + call inv_pix + sub cx, 0x100 + call inv_pix + + ;down + mov cx, dx + add cx, 0x100 + call inv_pix + add cx, 0x100 + call inv_pix + + ;left + mov cx, dx + dec cx + call inv_pix + dec cx + call inv_pix + + ;right + mov cx, dx + inc cx + call inv_pix + inc cx + call inv_pix + + ret + +inv_pix: ;pass coords in cl + mov al, byte [pix+ecx] + xor al, ~1 + mov byte [pix+ecx], al + ret coords: dd 0x8080 pressing_x: db 0