ZX Spectrum > PROGRAMOWANIE

CALL INCHL

<< < (2/3) > >>

appblue:
wiem wiem ... to prawda jeśli obrazek jest pełnoekranowy (jak w podanym przykładzie), ale korzystając z tej metody można byłoby np. wyświetlić mniejszy obrazek w prawym dolnym rogu ekranu, co już nie jest takie proste przy kopiowaniu 1:1

matofesi:
No właśnie o to chodzi, że procedura ma sens jeśli potrzebujesz przerzucić liniową grafikę w ekran mając tylko adres początkowy. Jeśli przerzucamy w różne miejsca trudne do przewidzenia (sprite'y w grze albo coś podobnego), to wtedy ma sens. Jeśli przerzucamy w miejsca, które da się z góry zaplanować to albo piszemy kod tak, żeby szybciutko przerzucał uwzględniając fakt, że wiemy gdzie albo robimy tablicę i przerzucamy według stablicowanych adresów.

appblue:
Zgadzam się ze wszystkim co piszecie.

Moim głównym celem było pokazanie procedury w pewnym kontekście w ramach zamkniętego przykładu, który osoby początkujące mogą skopiować i skompilować do pliku .TAP, a następnie pobawić się trochę modyfikując np. parametry.

Sam przy tym miałem trochę zabawy, bo ten obrazek znalazłem w formacie PNG, więc musiałem go przeskalować w GIMP-ie do odpowiedniego formatu i skonwertować kolory do B/W. Następnie wyeksportowałem obrazek do struktury w ANSI C (nie wiedziałem, że GIMP ma taką opcję) i napisałem prosty program w C, który generuje sekwencję poleceń DW z obrazkiem :)

appblue:
pod wpływem krytyki, ośmieliłem się trochę zmienić kod i wprowadzić logo w ruch ;)


--- Kod: ---    org 32768

start:
    ; clear screen
    ld  hl, 16384
    ld  de, 16385
    ld  bc, 6143
    ld  (hl), 0
    ldir

    ;; red ink color
    ld   hl, 22528
    ld   de, 22529
    ld   bc, 767
    ld   (hl), %01000010
    ldir

    ;; black border
    xor a
    out(254), a

    ld  ix, tab
anim:
    halt

again:
    ld  a, (ix+0)
    cp  255
    jr  nz, next
    ld  ix, tab
    jr  again

next:
    inc ix

    ld  b, a
    ld  de, 16384 + 1920 + 8
move:
    call inc_de
    djnz move                           ; should use table instead repeated call to inc_de :(

    ld  hl, img
    ld  bc, 128*16
loop:
    push de

    ; copy one image line
    rept 16
    ldi                    ; (HL) --byte--> (DE), HL++, DE++, BC--
    endm

    pop de
    call inc_de

    ld  a, b
    or  c
    jr  nz, loop

    jp  anim

inc_de:
    inc d
    ld  a, d
    and 7
    ret nz
    ld  a, e
    add a,32
    ld  e, a
    ret c
    ld  a, d
    sub 8
    ld  d, a
    ret

tab:
    ; generated with following Python snippet:
    ;   > 'db ' + ','.join(map(lambda i:str(15-int(15*abs(math.sin(3.14*i/31)))), range(32)))
    db 15,14,12,11,10,8,7,6,5,4,3,2,1,1,1,1,1,1,1,1,2,3,4,5,6,7,8,10,11,12,14,15
    db 255

img:
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $E0, $20, $04, $07, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $C0, $20, $04, $03, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $C0, $20, $04, $03, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $C0, $20, $04, $03, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $C0, $20, $04, $03, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $80, $20, $04, $01, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $80, $20, $04, $01, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $80, $20, $04, $01, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $00, $60, $06, $00, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $00, $60, $06, $00, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FE, $00, $60, $06, $00, $7F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FE, $00, $60, $06, $00, $7F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FC, $00, $E0, $07, $00, $3F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $F8, $00, $E0, $07, $00, $1F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $F0, $01, $E0, $07, $80, $0F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $F0, $01, $E0, $07, $80, $0F, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $E0, $01, $E0, $07, $80, $07, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $C0, $03, $E0, $07, $C0, $03, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $80, $07, $E0, $07, $E0, $01, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $00, $07, $E0, $07, $E0, $00, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FC, $00, $0F, $E0, $07, $F0, $00, $3F, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $F8, $00, $1F, $E0, $07, $F8, $00, $1F, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $E0, $00, $1F, $E0, $07, $F8, $00, $07, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $80, $00, $3F, $E0, $07, $FC, $00, $01, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FE, $00, $00, $7F, $E0, $07, $FE, $00, $00, $7F, $FF, $C0, $00
DB $00, $03, $FF, $F0, $00, $00, $FF, $E0, $07, $FF, $00, $00, $0F, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $01, $FF, $E0, $07, $FF, $80, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $03, $FF, $E0, $07, $FF, $C0, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $07, $FF, $E0, $07, $FF, $E0, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $0F, $FF, $E0, $07, $FF, $F0, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $3F, $FF, $E0, $07, $FF, $FC, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $00, $7F, $FF, $E0, $07, $FF, $FE, $00, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $01, $FF, $FF, $E0, $07, $FF, $FF, $80, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $07, $FF, $FF, $E0, $07, $FF, $FF, $E0, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $1F, $FF, $FF, $E0, $07, $FF, $FF, $F8, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $FF, $FF, $FF, $E0, $07, $FF, $FF, $FF, $07, $FF, $C0, $00
DB $00, $03, $FF, $E7, $FF, $FF, $FF, $E0, $07, $FF, $FF, $FF, $E7, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $F1, $F0, $00, $0F, $8F, $FF, $80, $FF, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $C0, $F0, $00, $0F, $07, $FF, $00, $3F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $C0, $70, $00, $0E, $03, $FE, $00, $1F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $80, $70, $00, $0E, $03, $FC, $00, $0F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $80, $70, $00, $0C, $01, $FC, $00, $07, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $80, $30, $00, $0C, $01, $FC, $00, $03, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $80, $3F, $81, $FC, $01, $FC, $1F, $03, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $00, $3F, $81, $FC, $00, $FC, $1F, $83, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $00, $1F, $81, $F8, $00, $FC, $1F, $83, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $00, $1F, $81, $F8, $00, $FC, $1F, $83, $07, $FF, $C0, $00
DB $00, $03, $FF, $FE, $04, $1F, $81, $F8, $20, $FC, $1F, $83, $07, $FF, $C0, $00
DB $00, $03, $FF, $FE, $04, $1F, $81, $F0, $20, $7C, $1F, $03, $07, $FF, $C0, $00
DB $00, $03, $FF, $FE, $04, $0F, $81, $F0, $20, $7C, $1C, $03, $07, $FF, $C0, $00
DB $00, $03, $FF, $FE, $0C, $0F, $81, $F0, $30, $7C, $18, $07, $07, $FF, $C0, $00
DB $00, $03, $FF, $FC, $0E, $0F, $81, $F0, $70, $3C, $10, $0F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FC, $0E, $07, $81, $E0, $70, $3C, $00, $1F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FC, $00, $07, $81, $E0, $00, $3C, $00, $7F, $07, $FF, $C0, $00
DB $00, $03, $FF, $FC, $00, $07, $81, $E0, $00, $1C, $10, $7F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F8, $00, $03, $81, $E0, $00, $1C, $10, $3F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F8, $00, $03, $81, $C0, $00, $1C, $18, $1F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F8, $00, $03, $81, $C0, $00, $1C, $18, $1F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F0, $3F, $83, $81, $C1, $FC, $0C, $1C, $0F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F0, $3F, $81, $81, $81, $FC, $0C, $1E, $0F, $07, $FF, $C0, $00
DB $00, $03, $FF, $F0, $3F, $81, $81, $81, $FE, $0C, $1E, $07, $07, $FF, $C0, $00
DB $00, $03, $FF, $F0, $7F, $C1, $81, $81, $FE, $04, $1F, $03, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $7F, $C0, $81, $83, $FE, $04, $1F, $83, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $7F, $C0, $81, $03, $FF, $04, $1F, $81, $07, $FF, $C0, $00
DB $00, $03, $FF, $E0, $FF, $E0, $C3, $07, $FF, $06, $1F, $C1, $07, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $03, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00

    end 32768

--- Koniec kodu ---

tooloud:
a teraz na boki niech się rusza :)

Nawigacja

[0] Indeks wiadomości

[#] Następna strona

[*] Poprzednia strona

Idź do wersji pełnej