Skip to content

Commit f8d065c

Browse files
authored
Merge pull request #190 from boriel/bugfix/attr
Bugfix/attr
2 parents 5bc9cca + 6cc7766 commit f8d065c

68 files changed

Lines changed: 3491 additions & 583 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

library-asm/attr.asm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ __SET_ATTR:
4444
PROC
4545

4646
call __ATTR_ADDR
47+
48+
__SET_ATTR2: ; Sets attr from ATTR_T to (HL) which points to the scr address
4749
ld de, (ATTR_T) ; E = ATTR_T, D = MASK_T
4850

4951
ld a, d
@@ -61,3 +63,17 @@ __SET_ATTR:
6163
ENDP
6264

6365

66+
; Sets the attribute at a given screen pixel address in hl
67+
; HL contains the address in RAM for a given pixel (not a coordinate)
68+
SET_PIXEL_ADDR_ATTR:
69+
;; gets ATTR position with offset given in SCREEN_ADDR
70+
ld a, h
71+
rrca
72+
rrca
73+
rrca
74+
and 3
75+
or 18h
76+
ld h, a
77+
ld de, (SCREEN_ADDR)
78+
add hl, de ;; Final screen addr
79+
jp __SET_ATTR2

library-asm/bright.asm

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,38 @@
66
BRIGHT:
77
ld de, ATTR_P
88

9+
PROC
10+
LOCAL IS_TR
11+
LOCAL IS_ZERO
12+
913
__SET_BRIGHT:
1014
; Another entry. This will set the bright flag at location pointer by DE
11-
and 1 ; # Convert to 0/1
15+
cp 8
16+
jr z, IS_TR
17+
18+
; # Convert to 0/1
19+
or a
20+
jr z, IS_ZERO
21+
ld a, 0x40
1222

13-
rrca
14-
rrca
23+
IS_ZERO:
1524
ld b, a ; Saves the color
1625
ld a, (de)
1726
and 0BFh ; Clears previous value
1827
or b
1928
ld (de), a
2029
ret
2130

31+
IS_TR: ; transparent
32+
inc de ; Points DE to MASK_T or MASK_P
33+
ld a, (de)
34+
or 0x40; Set bit 6 to enable transparency
35+
ld (de), a
36+
ret
37+
2238

2339
; Sets the BRIGHT flag passed in A register in the ATTR_T variable
2440
BRIGHT_TMP:
2541
ld de, ATTR_T
2642
jr __SET_BRIGHT
27-
43+
ENDP

library-asm/draw.asm

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include once <in_screen.asm>
1010

1111
#include once <cls.asm>
12+
#include once <attr.asm>
1213

1314
#include once <SP/PixelDown.asm>
1415
#include once <SP/PixelUp.asm>
@@ -36,7 +37,6 @@ __DRAW_ERROR:
3637
DRAW:
3738
;; ENTRY POINT
3839

39-
LOCAL PIXEL_ADDR
4040
LOCAL COORDS
4141
LOCAL __DRAW_SETUP1, __DRAW_START, __PLOTOVER, __PLOTINVERSE
4242

@@ -208,7 +208,7 @@ __DRAW4:
208208

209209
DY1: ; y += yi
210210
inc b
211-
call __INCY ; This address will be dyncamically updated
211+
call __INCY ; This address will be dynamically updated
212212
ld a, e ; Restores A reg.
213213
call __FASTPLOT
214214

@@ -272,7 +272,6 @@ __DRAW6_LOOP:
272272
ld (COORDS), bc
273273
ret
274274
275-
PIXEL_ADDR EQU 22ACh
276275
COORDS EQU 5C7Dh
277276

278277
__DRAW_END:
@@ -313,21 +312,9 @@ __PLOTOVER:
313312

314313
push hl
315314
push de
316-
;; gets ATTR position with offset given in SCREEN_ADDR
317-
ld a, h
318-
rrca
319-
rrca
320-
rrca
321-
and 3
322-
or 18h
323-
ld h, a
324-
ld de, (SCREEN_ADDR)
325-
add hl, de ;; Final screen addr
326-
327-
LOCAL PO_ATTR_2
328-
PO_ATTR_2 EQU 0BE4h ; Another entry to PO_ATTR
329-
call PO_ATTR_2 ; This will update attr accordingly. Beware, uses IY
330-
315+
push bc
316+
call SET_PIXEL_ADDR_ATTR
317+
pop bc
331318
pop de
332319
pop hl
333320

library-asm/flash.asm

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,39 @@
55

66
FLASH:
77
ld de, ATTR_P
8+
9+
PROC
10+
LOCAL IS_TR
11+
LOCAL IS_ZERO
12+
813
__SET_FLASH:
914
; Another entry. This will set the flash flag at location pointer by DE
10-
and 1 ; # Convert to 0/1
15+
cp 8
16+
jr z, IS_TR
17+
18+
; # Convert to 0/1
19+
or a
20+
jr z, IS_ZERO
21+
ld a, 0x80
1122

12-
rrca
23+
IS_ZERO:
1324
ld b, a ; Saves the color
1425
ld a, (de)
1526
and 07Fh ; Clears previous value
1627
or b
1728
ld (de), a
1829
ret
1930

31+
IS_TR: ; transparent
32+
inc de ; Points DE to MASK_T or MASK_P
33+
ld a, (de)
34+
or 0x80; Set bit 7 to enable transparency
35+
ld (de), a
36+
ret
2037

2138
; Sets the FLASH flag passed in A register in the ATTR_T variable
2239
FLASH_TMP:
2340
ld de, ATTR_T
2441
jr __SET_FLASH
42+
ENDP
2543

library-asm/plot.asm

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include once <error.asm>
88
#include once <in_screen.asm>
99
#include once <cls.asm>
10+
#include once <attr.asm>
1011

1112
PLOT:
1213
PROC
@@ -64,21 +65,7 @@ __PLOT_OVER1:
6465
LOCAL __PLOT_END
6566
__PLOT_END:
6667
ld (hl), a
67-
68-
;; gets ATTR position with offset given in SCREEN_ADDR
69-
ld a, h
70-
rrca
71-
rrca
72-
rrca
73-
and 3
74-
or 18h
75-
ld h, a
76-
ld de, (SCREEN_ADDR)
77-
add hl, de ;; Final screen addr
78-
79-
LOCAL PO_ATTR_2
80-
PO_ATTR_2 EQU 0BE4h ; Another entry to PO_ATTR
81-
jp PO_ATTR_2 ; This will update attr accordingly. Beware, uses IY
68+
jp SET_PIXEL_ADDR_ATTR
8269

8370
__PLOT_ERR:
8471
jp __OUT_OF_SCREEN_ERR ; Spent 3 bytes, but saves 3 T-States at (#1)

tests/functional/arrbase1.asm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ __MUL16NOADD:
136136

137137
#line 20 "array.asm"
138138

139-
#line 24 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
139+
#line 24 "/src/zxb/trunk/library-asm/array.asm"
140140

141141
__ARRAY:
142142
PROC
@@ -159,10 +159,10 @@ __ARRAY:
159159
ld hl, 0 ; BC = Offset "accumulator"
160160

161161
LOOP:
162-
#line 49 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
162+
#line 49 "/src/zxb/trunk/library-asm/array.asm"
163163
pop bc ; Get next index (Ai) from the stack
164164

165-
#line 59 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
165+
#line 59 "/src/zxb/trunk/library-asm/array.asm"
166166

167167
add hl, bc ; Adds current index
168168

@@ -192,7 +192,7 @@ ARRAY_END:
192192
push de
193193
exx
194194

195-
#line 92 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
195+
#line 92 "/src/zxb/trunk/library-asm/array.asm"
196196
LOCAL ARRAY_SIZE_LOOP
197197

198198
ex de, hl
@@ -223,7 +223,7 @@ ARRAY_SIZE_LOOP:
223223

224224
;add hl, de
225225
;__ARRAY_FIN:
226-
#line 123 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
226+
#line 123 "/src/zxb/trunk/library-asm/array.asm"
227227

228228
pop de
229229
add hl, de ; Adds element start
@@ -562,9 +562,9 @@ __MEM_START:
562562
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
563563
ld a, h ; HL = NULL (No memory available?)
564564
or l
565-
#line 111 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/alloc.asm"
565+
#line 111 "/src/zxb/trunk/library-asm/alloc.asm"
566566
ret z ; NULL
567-
#line 113 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/alloc.asm"
567+
#line 113 "/src/zxb/trunk/library-asm/alloc.asm"
568568
; HL = Pointer to Free block
569569
ld e, (hl)
570570
inc hl

tests/functional/arrcheck.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ __STOP:
173173
ld (ERR_NR), a
174174
ret
175175
#line 23 "array.asm"
176-
#line 24 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
176+
#line 24 "/src/zxb/trunk/library-asm/array.asm"
177177

178178
__ARRAY:
179179
PROC
@@ -198,7 +198,7 @@ __ARRAY:
198198
LOOP:
199199

200200
pop de
201-
#line 49 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
201+
#line 49 "/src/zxb/trunk/library-asm/array.asm"
202202
pop bc ; Get next index (Ai) from the stack
203203

204204

@@ -208,7 +208,7 @@ LOOP:
208208
ld a, ERROR_SubscriptWrong
209209
jp c, __ERROR
210210
ex de, hl
211-
#line 59 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
211+
#line 59 "/src/zxb/trunk/library-asm/array.asm"
212212

213213
add hl, bc ; Adds current index
214214

@@ -238,7 +238,7 @@ ARRAY_END:
238238
push de
239239
exx
240240

241-
#line 92 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
241+
#line 92 "/src/zxb/trunk/library-asm/array.asm"
242242
LOCAL ARRAY_SIZE_LOOP
243243

244244
ex de, hl
@@ -269,7 +269,7 @@ ARRAY_SIZE_LOOP:
269269

270270
;add hl, de
271271
;__ARRAY_FIN:
272-
#line 123 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
272+
#line 123 "/src/zxb/trunk/library-asm/array.asm"
273273

274274
pop de
275275
add hl, de ; Adds element start

0 commit comments

Comments
 (0)