T
T
Type Programmer2018-05-05 22:00:06
assembler
Type Programmer, 2018-05-05 22:00:06

Doesn't output a couple of pixels through double buffering, what's the matter (it works in the debugger and in the virtual machine)?

I am writing a program in the form of a loader that works in real time. I’m trying to figure out the graphics, namely 320x200 pixels, when working with sprites, blinking occurs, I found what I needed, the second buffer did everything as it should, and I already double-checked it 100 times in the emulator, virtual machine, it works, and when I run it on my hardware all the time that - something is wrong, then only a flooded screen with some color, then if without filling, there are a lot of oddities.

org 7c00h 
use16
jmp start

e:
mov ax,cs
mov ds,ax
mov es,ax
ret

put_clear:
mov ax,8000h
mov ds,ax
mov al,200
mov ah,al  
mov bx,0000h
put_clear0:
mov [bx],ax
add bx,02h 
cmp bx,0FFFEh
jz e
jmp put_clear0      

put_sprite:
mov ax,8000h
mov es,ax
mov di,0
mov bx,sprite
put_sprite0:
mov al,[bx]
cmp al,00h
jz e
stosb
inc bx
jmp put_sprite0

draw:
mov ax,8000h
mov ds,ax
mov ax,0A000h
mov es,ax
mov bx,0000h
mov di,0000h
draw0:   
mov al,[bx]
stosb
cmp bx,0FFFFh
jz e   
inc bx
jmp draw0

start:
call e   
mov ax,0013h
int 10h  
call put_clear  ;; Заливка каким-то цветом, в буффер
call put_sprite  ;; ложу "спрайт" в буффер
call draw ;; отображаю буффер на экран
mov ah,0
int 16h

db 250
db 250
db 250
db 200
db 200
db 200 ;; Это я так проверял баг, сделал растояние между кодом и спрайтом :D 
sprite db 50,150,50,0

I shortened the code as much as I could. To make it easier to understand what and how, but in fact, all the same code, filling in the buffer, sprite in the buffer (very simplified here), and transferring from the buffer to A000:0000.
PS: Not a very cool coder, that is, not at all, just learning!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-05-05
@MegaCraZy6

just a bunch of oddities

In put_sprite and draw I forgot to cld before the loop so that stosb increments di. Well, if you already decided to use string instructions, then why not lodsb / stosb, or not movsb, or not rep movsb, or even rep movsw?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question