Awesome q2a theme

How to optimize the code to work with graphics?

0 like 0 dislike
Wrote code. The point is that it then you want to put into mini OS. Therefore, only interruption of the BIOS.
For the graphics output using 13-th mode, int 10h. and for the conclusion of the procedure that puts directly in the framebuffer pixel color. Did the opportunity to create a sprite ( well, sort of to sprite, you can call it that ). made to the X-coordinate could vary somosy keys "a" and "b", and to erase the old sprite re-draw the whole screen. While there is a noticeable this twink in virtual reality and not very noticeable but all the same on real hardware. How to get HELP.

#make_boot# org 7c00h use16 jmp start e: ret put_pix: push ax push dx mov ax, 0a000h mov es, ax mov ax,320 mul cx pop dx add ax,dx mov di,ax pop ax stosb ret fill_disp: mov di,0000h mov cx,0000h mov dx,0 p0: cmp dx,320 jz p1 call put_pix inc dx jmp p0 p1: cmp cx,200 jz e inc cx mov dx,0 jmp p0 e_draw: pop dx pop bx mov [x],dx mov [y],bx ret draw_sprite_nexline: inc si mov al,00h cmp al,[bx+si] jz e_draw dec si add [y],01h mov ax,[x_ret] mov [x],ax inc si jmp draw_sprite_1 draw_sprite: mov ax,bx mov dx,[x] mov bx,[y] push bx push dx mov bx,ax mov ax,[x] mov [x_ret],ax mov si,0000h draw_sprite_1: mov ax, 0a000h mov es, ax mov ax,320 mov cx,[y] mul cx mov dx,[x] add ax,dx mov di,ax mov al,[bx+si] cmp al,255 jz draw_sprite_2 stosb draw_sprite_2: inc si mov al,00h cmp al,[bx+si] jz draw_sprite_nexline add [x],1 jmp draw_sprite_1 left_sprite: sub [x],01h jmp p3 right_sprite: add [x],01h jmp p3 start mov ah, 0 mov al, 13h int 10h mov al,50 call fill_disp mov di,0000h mov si,0000h mov bx,sprite call draw_sprite p4: mov ah,00h int 16h cmp al,'a' jz left_sprite cmp al,'d' jz right_sprite p3: mov di,0000h mov si,0000h mov al,50 call fill_disp mov di,0000h mov si,0000h mov bx,sprite call draw_sprite jmp p4 x_ret dw 0 x dw 160 y dw 100 sprite db 15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,0,15,15,255,15,15,15,40,15,15,0,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,0,15,15,40,40,40,40,40,15,15,0,15,15,15,15,15,15,15,15,15,0,0
by | 39 views

1 Answer

0 like 0 dislike
to clean the screen one pixel at a time, re-computing the coordinates of the offset of each - this may compensate for 25 years of technological progress.

it is better to clean the screen as a thread so:

push 0A000h pop es xor di,di xor eax,eax mov cx,64000/4 rep stosd

specifically for sprites even better to read about double buffering and dirty rectangles

Related questions

110,608 questions
257,187 answers
40,796 users