-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_frame.asm
More file actions
107 lines (82 loc) · 1.53 KB
/
Copy pathplot_frame.asm
File metadata and controls
107 lines (82 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
plot_frame:
ld c,WinHeight
ld l,0
ld a,(_ymappos)
[2] rra
and 00111110B ; ONLY IF mapWidth=256
ld h,a
ld de,(_xmappos)
repeat 2 ; X /8 * 2
srl d
rr e
endrepeat
res 0,e
add hl,de
ld de,_levelmap ; byte scale
add hl,de
ex de,hl ; de -> levelmap
ld hl,2*(2*32+2) ; hl -> screen
ld a,(_xmappos)
and 00000100B
ld b,a
; ld a,(_ymappos)
; and 00000100B
; rra
; add a,b
; ld ixl,a ; ixl -> scroll offset
2: ld b,WinWidth
push de
3: push de
push hl
ex de,hl
ld e,(hl)
inc hl
ld d,(hl) ; DE = meta tile
ex de,hl
[1] add hl,hl
; [3] add hl,hl
; ld a,ixl
; or l
; ld l,a
ld de,_metatable
add hl,de
ld e,(hl)
inc hl
ld d,(hl) ; DE = tile
pop hl ; HL = screen position
push hl
push bc
ld bc,(_shadowbuff)
add hl,bc ; HL = pointer to the shadow map
ld a,(hl) ; Avoid writing the same tile
cp e
inc hl
jp nz,1f
ld a,(hl)
cp d
jp nz,1f
jp 4f
1:
ld (hl),d ; rewrite the position with the actual tile in shadowbuffer
dec hl
ld (hl),e
and a
sbc hl,bc ; HL relative position in 32x24*2
; DE new 16 tile to be plotted
call plot_tile
4:
pop bc
pop hl
pop de
[2] inc hl ; the screen in WinWidthxWinHeight of uints
[2] inc de ; the levelmap is uint
djnz 3b
if (WinWidth<32)
ld de,2*(32-WinWidth) ; only if WinWidth<32
add hl,de
endif
pop de
[2] inc d ; only if mapWidth=256
dec c
jr nz,2b
ret