DEVICE ZXSPECTRUM128
include "../../_sdk/sys_h.asm"
STACK=0x4000
scrbase=0x8000
macro NEXTCOLUMN
bit 6,h
set 6,h
jr z,1f;shapes_linehorR_incxok
ld a,h
xor 0x60
ld h,a
and 0x20
jr nz,1f;shapes_linehorR_incxok
inc hl
1;shapes_linehorR_incxok
endm
org PROGSTART
begin
ld sp,STACK
OS_HIDEFROMPARENT
ld e,0
OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
ld e,0 ;color byte 0bRLrrrlll
OS_CLS
ld a,(user_scr0_low) ;ok
SETPG32KLOW
ld a,(user_scr0_high) ;ok
SETPG32KHIGH
;01 89 01 ;low+0x0000
; 23 ab 23 ;high+0x0000
; 45 cd ;low+0x2000
; 67 ef ;high+0x2000
;ld hl,0x8000
;ld b,10
;ld c,0xff
;hl=scraddr
;c=color byte 0bRLrrrlll
;b=wid/2
;call drawhorline
;jr $
ld l,1
ld e,10
ld hx,0b00111111 ;fill color byte 0bRLrrrlll
ld lx,0b00000000 ;11111111 ;brush color byte 0bRLrrrlll
ld b,100-1 ;hgt-1
ld c,159 ;wid/2
;l=x/2
;e=y
;lx=brush color byte 0bRLrrrlll
;hx=fill color byte 0bRLrrrlll
;b=hgt-1
;c=wid/2
call drawwindow
jr $
QUIT
xytoscraddr
;l=x/2
;e=y (не портится)
;screen pages are mapped in 2 CPU windows
;addr = tY(y) + tX(x)
ld h,tx/256
ld d,ty/256
ld a,(de) ;(y*40)
add a,(hl) ;x div 4
ld (xytoscraddr_l),a
inc d
inc h
ld a,(de) ;'(y*40)
adc a,(hl) ;f(x mod 4)
ld h,a
xytoscraddr_l=$+1
ld l,0
ret
if 1==0
prpixel
;bc=x (не портится)
;e=y (не портится)
;screen pages are mapped in 2 CPU windows
;addr = tY(y) + tX(x)
push bc
ld a,b
rra
ld a,c
rra
ld l,a
;ld d,ty/256
;ld h,tx/256
ld a,(de) ;(y*40)
jr c,prpixel_r
add a,(hl) ;x div 4
ld c,a
inc d
inc h
ld a,(de) ;'(y*40)
adc a,(hl) ;f(x mod 4)
ld b,a
ld a,(bc)
and 0xb8 ;keep right pixel ;иначе надо cls перед redraw
prpixel_color_l=$+1
or 0;lx
ld (bc),a
dec h
dec d
pop bc
ret
prpixel_r
add a,(hl) ;x div 4
ld c,a
inc d
inc h
ld a,(de) ;'(y*40)
adc a,(hl) ;f(x mod 4)
ld b,a
ld a,(bc)
and 0x47 ;keep left pixel ;иначе надо cls перед redraw
prpixel_color_r=$+1
or 0;lx
ld (bc),a
dec h
dec d
pop bc
ret
endif
drawwindow
;l=x/2
;e=y
ld hy,e
ld a,l
ld ly,a
;ly=x/2
;hy=y
call xytoscraddr
;hl=screen addr
;lx=brush color byte 0bRLrrrlll
;hx=fill color byte 0bRLrrrlll
;b=hgt-1
;c=wid/2
push bc
push hl
drawwindowfill0
push bc
push hl
ld c,hx ;ld c,0b11111111 ;color byte 0bRLrrrlll
call drawverline
pop hl
NEXTCOLUMN
pop bc
dec c
jr nz,drawwindowfill0
pop hl ;screen addr
pop bc
push bc
push bc
push hl
call drawbox
pop hl
pop bc
NEXTCOLUMN
ld de,40*2
add hl,de ;второй бокс внутри первого
dec c
dec c
ld a,b
sub 4
ld b,a
call drawbox
pop bc ;b=hgt-1, c=wid/2
;ly=x/2
;hy=y
ld e,hy
inc e
call drawwindowhormarks
ld a,hy
add a,b ;+hgt-1
dec a
ld e,a
call drawwindowhormarks
push bc
call drawwindowvermarks
pop bc
ld a,ly
add a,c ;wid/2
dec a
ld ly,a
call drawwindowvermarks
ret
drawwindowvermarks
;ly=x/2
;hy=y
;b=hgt-1
;lx=color byte 0bRLrrrlll
ld a,ly
ld l,a
ld a,hy
add a,6
ld e,a
;l=x/2
;e=y
call xytoscraddr
ld a,lx
ld (hl),a
ld a,ly
ld l,a
ld a,hy
add a,b ;+hgt-1
sub 6
ld e,a
;l=x/2
;e=y
call xytoscraddr
ld a,lx
ld (hl),a
ret
drawwindowhormarks
;ly=x/2
;e=y
;c=wid/2
ld a,ly
add a,3
ld l,a
;l=x/2
;e=y
call xytoscraddr
ld a,lx
xor hx
and 0b01000111 ;color byte 0bRLrrrlll
xor hx
ld (hl),a
ld a,ly
add a,c ;+wid/2
sub 3+1
ld l,a
;l=x/2
;e=y
call xytoscraddr
ld a,lx
xor hx
and 0b10111000 ;color byte 0bRLrrrlll
xor hx
ld (hl),a
ret
drawbox
;hl=screen addr
;lx=color byte 0bRLrrrlll
;b=hgt-1
;c=wid/2
push bc
push hl
push bc
ld a,lx
xor hx
and 0b01000111 ;color byte 0bRLrrrlll
xor hx
ld c,a
call drawverline ;left line
pop bc
ld b,c ;wid/2
ex (sp),hl
ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
push bc
call drawhorline ;top line
pop bc ;b=wid/2, c=color byte 0bRLrrrlll
ex (sp),hl ;bottom of left line
call drawhorline ;bottom line
pop hl ;rightmost byte of top line
ld de,40
add hl,de
pop bc
dec b ;b=hgt/2
ld a,lx
xor hx
and 0b10111000 ;color byte 0bRLrrrlll
xor hx
ld c,a
;call drawverline ;right line
;ret
drawverline
;hl=scraddr
;c=color byte 0bRLrrrlll
;b=hgt
ld de,40
drawverline0
ld (hl),c
add hl,de
djnz drawverline0
ret
drawhorline
;hl=scraddr
;c=color byte 0bRLrrrlll
;b=wid/2
ld de,0x4000
jr drawhorline0go
drawhorline0
NEXTCOLUMN
drawhorline0go
ld (hl),c
djnz drawhorline0
ret
align 256
tx
dup 256
db ($&0xff)/4
edup
dup 64
db 0x80
db 0xc0
db 0xa0
db 0xe0
edup
ty
dup 200
db 0xff&(($&0xff)*40)
edup
ds 56,0xff&8000
dup 200
db (($&0xff)*40)/256
edup
ds 56,8000/256
end
savebin "gfxtest.com",begin,end-begin