Enviado em 02/01/2014 - 11:51h
;--------------------------------------------------------------------
;
; A simple example using only SDL.
;
; USAGE:
; asmi test.asm
;
; BY: gokernel - gokernel@hotmail.com
;
;--------------------------------------------------------------------
library SDL ; in windows: SDL.dll
library libSDL ; in linux: libSDL.so
import SDL_Init
import SDL_SetVideoMode
import SDL_FillRect
import SDL_Flip
import SDL_PollEvent
import SDL_Delay
import SDL_Quit
long i
char *ev
char *screen
char *r ; SDL_Rect: short(x,y,w,h) sizeof 8
.S_count "mouse pos: %d %d\n"
;// <<<<< START >>>>>
push %ebp ;// index: 0
mov %esp,%ebp
sub $16,%esp ;// set to 4 arguments
movl $100,(%esp) ;// ev = malloc(100);
call malloc
mov %eax,ev
movl $8,(%esp) ;// r = malloc(8);
call malloc
mov %eax,r
mov r,%eax ; // r->x = 100 ...
movw $100,(%eax) ; short
movw $100,2(%eax)
movw $100,4(%eax)
movw $100,6(%eax)
movl $32,(%esp)
call SDL_Init
movl $0,12(%esp)
movl $32,8(%esp)
movl $600,4(%esp)
movl $800,(%esp)
call SDL_SetVideoMode
mov %eax,screen
movl $16744990,8(%esp) ;// color orange
mov r,%eax
mov %eax,4(%esp)
mov screen,%eax
mov %eax,(%esp)
call SDL_FillRect ;// SDL_FillRect (screen, r, 16744990);
mov screen,%eax
mov %eax,(%esp)
call SDL_Flip
label_top: ;//<<<<<<< main loop >>>>>>>
mov ev,%eax ;// if (SDL_PollEvent(ev)) {
mov %eax,(%esp)
call SDL_PollEvent
test %eax,%eax
je label_ok_event
;------------------- {
mov ev,%eax ; // printf("mouse pos: %d %d\n", ev->x, ev->y );
movzwl 6(%eax),%edx
mov %edx,8(%esp) ; // ev->y
;;;;; mov ev,%eax ; // NOT NEED: %eax not changed
movzwl 4(%eax),%eax
mov %eax,4(%esp) ; // ev->x
mov S_count,%eax
mov %eax,(%esp) // S_count: "mouse pos: %d %d\n"
call printf
; //** test event: SDL_KEYUP = 3
mov ev,%eax
cmpb $3,(%eax) ;// compare byte: if (ev->type == 3) {
jne label_key
jmp label_end
label_key:
;------------------- }
label_ok_event:
movl $10,(%esp)
call SDL_Delay
jmp label_top ;//<<<<<<< goto the top of main loop >>>>>>>
label_end:
call SDL_Quit
call word
leave
ret
label_fim:
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Atualizar Debian Online de uma Versão para outra
Dica para encontrar diversos jogos Indies criativos
Instalando Discord no Debian 13
Instalar driver Nvidia no Debian 13
Redimensionando, espelhando, convertendo e rotacionando imagens com script
Software livre - será que eu estou tão errado assim? (10)
Boot do PosRog so funciona em notebook (1)