Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions library-asm/attr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ __SET_ATTR:
PROC

call __ATTR_ADDR

__SET_ATTR2: ; Sets attr from ATTR_T to (HL) which points to the scr address
ld de, (ATTR_T) ; E = ATTR_T, D = MASK_T

ld a, d
Expand All @@ -61,3 +63,17 @@ __SET_ATTR:
ENDP


; Sets the attribute at a given screen pixel address in hl
; HL contains the address in RAM for a given pixel (not a coordinate)
SET_PIXEL_ADDR_ATTR:
;; gets ATTR position with offset given in SCREEN_ADDR
ld a, h
rrca
rrca
rrca
and 3
or 18h
ld h, a
ld de, (SCREEN_ADDR)
add hl, de ;; Final screen addr
jp __SET_ATTR2
24 changes: 20 additions & 4 deletions library-asm/bright.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,38 @@
BRIGHT:
ld de, ATTR_P

PROC
LOCAL IS_TR
LOCAL IS_ZERO

__SET_BRIGHT:
; Another entry. This will set the bright flag at location pointer by DE
and 1 ; # Convert to 0/1
cp 8
jr z, IS_TR

; # Convert to 0/1
or a
jr z, IS_ZERO
ld a, 0x40

rrca
rrca
IS_ZERO:
ld b, a ; Saves the color
ld a, (de)
and 0BFh ; Clears previous value
or b
ld (de), a
ret

IS_TR: ; transparent
inc de ; Points DE to MASK_T or MASK_P
ld a, (de)
or 0x40; Set bit 6 to enable transparency
ld (de), a
ret


; Sets the BRIGHT flag passed in A register in the ATTR_T variable
BRIGHT_TMP:
ld de, ATTR_T
jr __SET_BRIGHT

ENDP
23 changes: 5 additions & 18 deletions library-asm/draw.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include once <in_screen.asm>

#include once <cls.asm>
#include once <attr.asm>

#include once <SP/PixelDown.asm>
#include once <SP/PixelUp.asm>
Expand Down Expand Up @@ -36,7 +37,6 @@ __DRAW_ERROR:
DRAW:
;; ENTRY POINT

LOCAL PIXEL_ADDR
LOCAL COORDS
LOCAL __DRAW_SETUP1, __DRAW_START, __PLOTOVER, __PLOTINVERSE

Expand Down Expand Up @@ -208,7 +208,7 @@ __DRAW4:

DY1: ; y += yi
inc b
call __INCY ; This address will be dyncamically updated
call __INCY ; This address will be dynamically updated
ld a, e ; Restores A reg.
call __FASTPLOT

Expand Down Expand Up @@ -272,7 +272,6 @@ __DRAW6_LOOP:
ld (COORDS), bc
ret

PIXEL_ADDR EQU 22ACh
COORDS EQU 5C7Dh

__DRAW_END:
Expand Down Expand Up @@ -313,21 +312,9 @@ __PLOTOVER:

push hl
push de
;; gets ATTR position with offset given in SCREEN_ADDR
ld a, h
rrca
rrca
rrca
and 3
or 18h
ld h, a
ld de, (SCREEN_ADDR)
add hl, de ;; Final screen addr

LOCAL PO_ATTR_2
PO_ATTR_2 EQU 0BE4h ; Another entry to PO_ATTR
call PO_ATTR_2 ; This will update attr accordingly. Beware, uses IY

push bc
call SET_PIXEL_ADDR_ATTR
pop bc
pop de
pop hl

Expand Down
22 changes: 20 additions & 2 deletions library-asm/flash.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,39 @@

FLASH:
ld de, ATTR_P

PROC
LOCAL IS_TR
LOCAL IS_ZERO

__SET_FLASH:
; Another entry. This will set the flash flag at location pointer by DE
and 1 ; # Convert to 0/1
cp 8
jr z, IS_TR

; # Convert to 0/1
or a
jr z, IS_ZERO
ld a, 0x80

rrca
IS_ZERO:
ld b, a ; Saves the color
ld a, (de)
and 07Fh ; Clears previous value
or b
ld (de), a
ret

IS_TR: ; transparent
inc de ; Points DE to MASK_T or MASK_P
ld a, (de)
or 0x80; Set bit 7 to enable transparency
ld (de), a
ret

; Sets the FLASH flag passed in A register in the ATTR_T variable
FLASH_TMP:
ld de, ATTR_T
jr __SET_FLASH
ENDP

17 changes: 2 additions & 15 deletions library-asm/plot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include once <error.asm>
#include once <in_screen.asm>
#include once <cls.asm>
#include once <attr.asm>

PLOT:
PROC
Expand Down Expand Up @@ -64,21 +65,7 @@ __PLOT_OVER1:
LOCAL __PLOT_END
__PLOT_END:
ld (hl), a

;; gets ATTR position with offset given in SCREEN_ADDR
ld a, h
rrca
rrca
rrca
and 3
or 18h
ld h, a
ld de, (SCREEN_ADDR)
add hl, de ;; Final screen addr

LOCAL PO_ATTR_2
PO_ATTR_2 EQU 0BE4h ; Another entry to PO_ATTR
jp PO_ATTR_2 ; This will update attr accordingly. Beware, uses IY
jp SET_PIXEL_ADDR_ATTR

__PLOT_ERR:
jp __OUT_OF_SCREEN_ERR ; Spent 3 bytes, but saves 3 T-States at (#1)
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/arrbase1.asm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ __MUL16NOADD:

#line 20 "array.asm"

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

__ARRAY:
PROC
Expand All @@ -159,10 +159,10 @@ __ARRAY:
ld hl, 0 ; BC = Offset "accumulator"

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

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

add hl, bc ; Adds current index

Expand Down Expand Up @@ -192,7 +192,7 @@ ARRAY_END:
push de
exx

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

ex de, hl
Expand Down Expand Up @@ -223,7 +223,7 @@ ARRAY_SIZE_LOOP:

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

pop de
add hl, de ; Adds element start
Expand Down Expand Up @@ -562,9 +562,9 @@ __MEM_START:
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
ld a, h ; HL = NULL (No memory available?)
or l
#line 111 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/alloc.asm"
#line 111 "/src/zxb/trunk/library-asm/alloc.asm"
ret z ; NULL
#line 113 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/alloc.asm"
#line 113 "/src/zxb/trunk/library-asm/alloc.asm"
; HL = Pointer to Free block
ld e, (hl)
inc hl
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/arrcheck.asm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ __STOP:
ld (ERR_NR), a
ret
#line 23 "array.asm"
#line 24 "/Users/boriel/Documents/src/zxbasic/zxbasic/library-asm/array.asm"
#line 24 "/src/zxb/trunk/library-asm/array.asm"

__ARRAY:
PROC
Expand All @@ -198,7 +198,7 @@ __ARRAY:
LOOP:

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


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

add hl, bc ; Adds current index

Expand Down Expand Up @@ -238,7 +238,7 @@ ARRAY_END:
push de
exx

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

ex de, hl
Expand Down Expand Up @@ -269,7 +269,7 @@ ARRAY_SIZE_LOOP:

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

pop de
add hl, de ; Adds element start
Expand Down
Loading