semgra.asm
; z88dk / 8801
; z80asm -b -l semgra.asm
tvram equ $f3c8
org $b000
start:
call crtset
call cls
call ground
ld hl, data
ld b, 160
ld c, 0 ; x
.loop
push bc
ld d, (hl)
ld a, 50
sub d
ld b, a ; y = 50 - d
rlc d ; 高さ
inc hl
ld e, (hl) ; 色
inc hl
push hl
call vline
pop hl
pop bc
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, tvram
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
ground:
ld a, $41
ld hl, tvram+120*13
ld de, 40 ; アトリビュート長さ
ld c, 12
.ground1
ld b, 80
.ground2
ld (hl), a
inc hl
djnz ground2
add hl, de
dec c
jr nz, ground1
ret
; vertical line
; b=y c=x d=高さ e=色
vline:
ld a, d
or a
ret z
push de
ld hl, pmasks
ld d, 0
add hl, de
ld a, (hl)
ld (pmask), a
call pset
.vline1
pop de
dec d
ret z
push de
call psetd
jr vline1
; point set
; b=y c=x
; use: a, de, hl
pset:
ld a, b ; de = y & $fc
and $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 de, tvram ; hl += tvram
add hl, de
ld a, b
and $03
ld e, a ; e = y & 3
ld a, c ; a = (x & 1 == 0) ? $01 : $10
and $01
ld a, $01
jr z, pset1
ld a, $10
.pset1
dec e
jp m, pset2
add a, a
jr pset1
.pset2
call psetdo
ret
; pset down
; use: a, de, hl
psetd:
ld hl, (paddr)
ld a, (pbits)
ld e, a
and $88
ld a, e
jr z, psetd1
ld de, 120
add hl, de
rlca
rlca
rlca
rlca
.psetd1
rlca
call psetdo
ret
; pset do
; hl=addr a=bits
; use: a, e
psetdo:
ld (paddr), hl
ld (pbits), a
ld e, a
ld a, (pmask)
and e
ld a, e
jr z, psetdo0
.psetdo1
or (hl)
ld (hl), a
ret
.psetdo0
cpl
and (hl)
ld (hl), a
ret
paddr: defw 0
pbits: defb 0
pmask: defb 0
pmasks: defb $ff, $5a
data:
defb 04,1,04,1,04,1,04,1,04,1,05,1,05,1,05,1,05,1,05,1,05,1,05,1,05,0,05,0,05,0,05,0
defb 05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,05,0,00,0,03,1,03,1
defb 03,1,03,1,03,1,03,1,03,0,03,0,03,0,04,1,04,1,04,1,04,1,04,1,04,1,04,1,04,1,04,0
defb 04,0,04,0,04,0,04,0,04,0,04,0,04,0,04,0,04,0,17,1,17,1,17,1,17,1,17,1,17,1,17,1
defb 18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1
defb 19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1
defb 20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1
defb 21,1,21,1,21,1,22,1,22,1,21,0,21,0,21,0,21,0,21,0,21,0,20,0,20,0,20,0,20,0,20,0
defb 19,0,19,0,19,0,19,0,19,0,18,0,18,0,18,0,18,0,17,0,17,0,17,0,17,0,17,0,16,0,16,0
defb 16,0,16,0,05,0,07,1,07,1,07,1,07,1,07,1,07,1,08,1,08,1,08,1,08,1,08,1,08,1,08,1