LoginSignup
0
0

More than 5 years have passed since last update.

PC-88 z80asmでセミグラフィック

Posted at
sample.asm
; z88dk / 8801
; z80asm -b -l sample.asm

        org     $b000
start:
        call    crtset
        call    cls

        ld      hl, data
        ld      b, 160
        ld      c, 0            ; x
.loop
        push    hl
        push    bc
        ld      a, 50           ; y = 50 - (hl)
        sub     (hl)
        ld      b, a
        ld      a, (hl)
        add     a, a
        call    line
        pop     bc
        pop     hl
        inc     hl
        inc     c
        djnz    loop
.exit
        di
        halt

crtset:
        ld      hl, $e6b4
        ld      (hl), $98       ; アトリビュート
        inc     hl
        inc     hl
        inc     hl
        inc     hl
        ld      (hl), $00       ; ファンクション・キー表示スイッチ
        inc     hl
        ld      (hl), $ff       ; カラー/白黒スイッチ
        ld      b, 80
        ld      c, 25
        call    $6f6b           ; CRTSET
        ret

cls:
        xor     a
        ld      hl, $f3c8
        ld      de, 40          ; アトリビュート長さ
        ld      c, 25
.clsy
        ld      b, 80
.clsx
        ld      (hl), a
        inc     hl
        djnz    clsx
        add     hl, de
        dec     c
        jr      nz, clsy
        ret

; b=y c=x a=高さ
line:
        dec     a
        ret     m
        push    af
        push    bc
        call    pset
        pop     bc
        pop     af
        inc     b
        jp      line

; b=y c=x
pset:
        ld      a, b            ; de = y & $fc
        and     a, $fc
        ld      e, a
        ld      d, 0

        ld      hl, 0           ; hl = de * 30
        add     hl, de
        add     hl, hl
        add     hl, de
        add     hl, hl
        add     hl, de
        add     hl, hl
        add     hl, de
        add     hl, hl          ; %11110=30倍

        ld      e, c            ; hl += x / 2
        srl     e
        add     hl, de

        ld      a, b            ; a = ((x&1) ? $10 : $01) << (y&3)
        and     a, $03
        ld      b, a
        ld      a, c
        and     1
        ld      a, $01
        jr      z, pset1
        ld      a, $10
.pset1
        dec     b
        jp      m, pset2
        add     a, a
        jr      pset1
.pset2

        ld      de, $f3c8       ; *($f3c8+hl) |= a
        add     hl, de
        or      (hl)
        ld      (hl), a
        ret

data:
        defb    05,05,05,05,05,05,05,05,13,13,13,13,13,13,13,13,13,21,21,21
        defb    21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22
        defb    22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23
        defb    23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23
        defb    23,23,23,23,23,23,23,25,25,25,25,25,25,25,25,25,25,25,25,25
        defb    25,25,25,25,25,25,25,25,25,25,25,25,25,23,23,23,23,22,22,22
        defb    21,21,20,20,19,19,19,18,17,17,04,04,04,04,04,04,04,04,04,04
        defb    03,03,03,03,03,03,03,00,00,00,00,00,00,00,00,00,00,05,05,05

bin2t88 SAMPLE b000 sample.bin

mon
h]r
h]gb000

sample.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0