2016-06-19 2 views
0

У меня есть проект, который нужно сделать в ассамблеи в школе, и мне нужно скопировать пиксели, которые я написал в таблице символов (картинка, которую я открыл), на другую картинку в том же браузер (мой код при запуске, когда открывается изображение, создает новое изображение, которое то же самое, а затем мне нужно после того, как я закрою слово в изображении таблицы слов, чтобы скопировать раскрашенные пиксели на изображение копии) кто-то знает, как это сделать ? это мой код, который открывает изображение, и позволяет игроку 1 крутить слова в таблице фотографии, которая является карточкой игры, и если слово legal и player 2 принимают слово, поэтому ход переходит к игроку 2, и если нет , я хочу код, чтобы скопировать игровую карту на другую картину я сохранил и создалКопирование изображения курсора из одной картинки в другую сборку

IDEAL 
MODEL small 
STACK 100h 
DATASEG 
color db 2 
color2 db 14 
message db 'IS The Word Legal?$' 
filename db 'open.bmp',0 
filehandle dw ? 
Header db 54 dup (0) 
Palette db 256*4 dup (0) 
ScrLine db 320 dup (0) 
ErrorMsg db 'Error', 13, 10,'$' 
cxval dw ? 
dxval dw ? 
colorval db ? 
filename2 db 'yoav.bmp',0 ;The new file 
filehandle2 dw ? 
CODESEG 
proc OpenFile 
    ; Open file 
    mov ah, 3Dh 
    xor al, al 
    mov dx, offset filename 
    int 21h 
    jc openerror 
    mov [filehandle], ax 
    ret 
openerror: 
    mov dx, offset ErrorMsg 
    mov ah, 9h 
    int 21h 
    ret 
endp OpenFile 
proc ReadHeader 
    ; Read BMP file header, 54 bytes 
    mov ah,3fh 
    mov bx, [filehandle] 
    mov cx,54 
    mov dx,offset Header 
    int 21h 
    ret 
endp ReadHeader 
proc ReadPalette 
; Read BMP file color palette, 256 colors * 4 bytes (400h) 
    mov ah,3fh 
    mov cx,400h 
    mov dx,offset Palette 
    int 21h 
    ret 
endp ReadPalette 
proc CopyPal 
; Copy the colors palette to the video memory 
; The number of the first color should be sent to port 3C8h 
; The palette is sent to port 3C9h 
    mov si,offset Palette 
    mov cx,256 
    mov dx,3C8h 
    mov al,0 
    ; Copy starting color to port 3C8h 
    out dx,al 
    ; Copy palette itself to port 3C9h 
    inc dx 
PalLoop: 
    ; Note: Colors in a BMP file are saved as BGR values rather than RGB. 
    mov al,[si+2] ; Get red value. 
    shr al,2 ; Max. is 255, but video palette maximal 
    ; value is 63. Therefore dividing by 4. 
    out dx,al ; Send it. 
    mov al,[si+1] ; Get green value. 
    shr al,2 
    out dx,al ; Send it. 
    mov al,[si] ; Get blue value. 
    shr al,2 
    out dx,al ; Send it. 
    add si,4 ; Point to next color. 
    ; (There is a null chr. after every color.) 
    loop PalLoop 
    ret 
endp CopyPal 
proc OpenOutputFile 
; Open the output file 
    mov ah, 3Dh 
    mov al, 2h 
    mov dx, offset filename2 
    int 21h 
    jc openerror3 
    mov [filehandle2], ax 
    ret 
openerror3: 
    mov dx, offset ErrorMsg 
    mov ah, 9h 
    int 21h 
    jmp exit 
    ret 
endp OpenOutputFile 

proc CreateAndOpenOutputFile 
; Create file 
    mov ah, 3Ch 
    mov cx, 0 
    mov dx, offset filename2 
    int 21h 
    jc openerror2 
    call OpenOutputFile 
    ret 
openerror2: 
    mov dx, offset ErrorMsg 
    mov ah, 9h 
    int 21h 
    jmp exit 
    ret 
endp CreateAndOpenOutputFile 
proc WriteOutputFileHeader 
; Write BMP file header, 54 bytes into the output file 
    mov ah,40h 
    mov bx, [filehandle2] 
    mov cx, 54 
    mov dx,offset Header 
    int 21h 
    ret 
endp WriteOutputFileHeader 
proc WriteOutputFilePalette 
; Write BMP file color palette, 256 colors * 4 bytes (400h) into the output file 
    mov ah,40h 
    mov bx, [filehandle2] 
    mov cx, 400h 
    mov dx,offset Palette 
    int 21h 
    ret 
endp WriteOutputFilePalette 
proc CopyInputFileBitmap 
; BMP graphics are saved upside-down. 
; Read the graphic line by line (200 lines in VGA format), 
; displaying the lines from bottom to top. 
    mov ax, 0A000h 
    mov es, ax 
    mov cx,200 
PrintBMPLoop: 
    push cx 
    ; di = cx*320, point to the correct screen line 
    mov di,cx 

    shl cx,6 
    shl di,8 
    add di,cx 

    ; Read one line 
    mov ah,3fh 
    mov bx, [filehandle] 
    mov cx,320 
    mov dx,offset ScrLine 
    int 21h 
    Change: 
    ;copy the data into the output file 
    mov ah, 40h 
    mov bx, [filehandle2] 
    mov cx, 320 
    mov dx, offset ScrLine 
    int 21h 
loadImage: 
    ; Copy one line into video memory 
    cld ; Clear direction flag, for movsb 
    mov cx,320 
    mov si,offset ScrLine 
    rep movsb ; Copy line to the screen 
       ;rep movsb is same as the following code: 
       ;mov es:di, ds:si 
       ;inc si 
       ;inc di 
       ;dec cx 
       ;loop until cx=0 
    pop cx 
    loop PrintBMPLoop 
    ret 
endp CopyInputFileBitmap 
proc CloseInputFile 
; Close the input file 
    mov ah,3Eh 
    mov bx, [filehandle] 
    int 21h 
    ret 
endp CloseInputFile 

proc CloseOutputFile 
; Close the output file 
    mov ah,3Eh 
    mov bx, [filehandle2] 
    int 21h 
    ret 
endp CloseOutputFile 

start: 
    mov ax, @data 
    mov ds, ax 
    ; Graphic mode 
    mov ax, 13h 
    int 10h 
    ; Process BMP file 
    call OpenFile 
    call ReadHeader 
    call ReadPalette 
    call CopyPal 
    call CreateAndOpenOutputFile 
    call WriteOutputFileHeader 
    call WriteOutputFilePalette 
    call CopyInputFileBitmap 
    call CloseInputFile 
    call CloseOutputFile 
    jmp Mouse 
MessagePrint2: 
    mov dx, offset message 
    mov ah, 9 
    int 21h 
    mov dl,10 
    mov ah, 2 
    int 21h 
    mov ah, 1 
    int 21h 
    xor cx, cx 
    mov cl, 79h 
    cmp cl,al 
    je MouseLp 
    mov cl, 6Eh 
    cmp cl, al 
    je NextTurn 
Mouse: 
    mov ax, 0h 
    int 33h 
    mov ax, 1h 
    int 33h 
MouseLp: 
    mov ax, 3h 
    int 33h 
    cmp bx, 01h 
    jne MouseLp 
Draw: 
    shr cx, 1 
    sub dx, 1 
    mov bh, 0h 
    mov al,[color] 
    mov ah, 0Ch 
    int 10h 
    mov ax, 3h 
    int 33h 
    cmp bx, 01h 
    je Draw 
    jmp MessagePrint 
MessagePrint: 
    mov dx, offset message 
    mov ah, 9 
    int 21h 
    mov dl,10 
    mov ah, 2 
    int 21h 
    mov ah, 1 
    int 21h 
    xor cx, cx 
    mov cl, 79h 
    cmp cl,al 
    je NextTurn 
    mov cl, 6Eh 
    cmp cl, al 
    jne go 
go: 
    jmp MouseLp 
NextTurn: 
    mov ax, 0h 
    int 33h 
    mov ax, 1h 
    int 33h 
MouseLpA: 
    mov ax, 3h 
    int 33h 
    cmp bx, 01h 
    jne MouseLpA 
DrawA: 
    shr cx, 1 
    sub dx, 1 
    mov bh, 0h 
    mov al,[color2] 
    mov ah, 0Ch 
    int 10h 
    mov ax, 3h 
    int 33h 
    cmp bx, 01h 
    je DrawA 
    jmp MessagePrint2 
exit: 
    mov ax, 4c00h 
    int 21h 
END start 
+1

Я думаю, вам стоит прочитать [this] (http://stackoverflow.com/help/how-to-ask) и немного переработать свой вопрос. – Wilt

ответ

1

Ваш вопрос остается неясным (лучше всего повторно фраза его), но глядя на ваш коде показывает эти вопросы:

proc CreateAndOpenOutputFile 
    ; Create file 
    mov ah, 3Ch 
    mov cx, 0 
    mov dx, offset filename2 
    int 21h 
    jc openerror2 
    call OpenOutputFile 
    ret 

Когда файл создан, он также открытое значение означает, что вы получаете ручку. Вам не нужно иметь call OpenOutputFile в вашем коде. DOS автоматически открывал файл с обычными разрешениями на чтение и запись. Сохраните ручку, хотя: mov [filehandle2], ax


mov cx,200 
PrintBMPLoop: 
    push cx 
    ; di = cx*320, point to the correct screen line 
    mov di,cx 
    shl cx,6 
    shl di,8 
    add di,cx 

Это будет указывать ниже экрана 320x200 на первой итерации PrintBMPLoop! Перед использованием вы должны вычесть 320 из DI. В качестве альтернативы использовать dec cx в начале расчета:

push cx 
    dec cx 
    mov di, cx 
    shl cx, 6 
    shl di, 8 
    add di, cx 

я не вникать в интерактивную часть вашей программы, потому что вопрос не намекает, что это проблема.

Смежные вопросы