Skip to content

Commit d9731a1

Browse files
committed
refact: update drawing primitives dependencies (zx48k)
1 parent 7b9f87e commit d9731a1

8 files changed

Lines changed: 46 additions & 40 deletions

File tree

src/arch/zx48k/library-asm/attr.asm

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,4 @@ __SET_ATTR2: ; Sets attr from ATTR_T to (HL) which points to the scr address
6161

6262
ENDP
6363

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

src/arch/zx48k/library-asm/draw.asm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include once <error.asm>
99
#include once <in_screen.asm>
1010

11-
#include once <cls.asm>
12-
#include once <attr.asm>
11+
#include once <sysvars.asm>
12+
#include once <set_pixel_addr_attr.asm>
1313

1414
#include once <SP/PixelDown.asm>
1515
#include once <SP/PixelUp.asm>
@@ -330,4 +330,3 @@ __FASTPLOTEND:
330330
ENDP
331331

332332
pop namespace
333-

src/arch/zx48k/library-asm/in_screen.asm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ __IN_SCREEN:
1818
ld a, d
1919
inc hl
2020
cp (hl)
21-
;; jr nc, __IN_SCREEN_ERR ; Do nothing and return if out of range
22-
;; ret
2321
ret c ; Return if carry (OK)
2422

2523
__IN_SCREEN_ERR:

src/arch/zx48k/library-asm/plot.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
#include once <error.asm>
88
#include once <in_screen.asm>
9-
#include once <cls.asm>
10-
#include once <attr.asm>
9+
#include once <sysvars.asm>
10+
#include once <set_pixel_addr_attr.asm>
1111

1212
push namespace core
1313

src/arch/zx48k/library-asm/print.asm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ __PRINT_INIT: ; To be called before program starts (initializes library)
3232
ld hl, 1821h
3333
ld (MAXX), hl ; Sets current maxX and maxY
3434

35+
call __LOAD_S_POSN
36+
call __ATTR_ADDR
37+
3538
xor a
3639
ld (FLAGS2), a
3740

3841
ret
3942

4043

44+
45+
4146
__PRINTCHAR: ; Print character store in accumulator (A register)
4247
; Modifies H'L', B'C', A'F', D'E', A
4348

@@ -74,7 +79,7 @@ __SCROLL: ; Scroll?
7479

7580
__PRINT_START:
7681
cp ' '
77-
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
82+
jr c, __PRINT_SPECIAL ; Characters below ' ' are special ones
7883

7984
exx ; Switch to alternative registers
8085
ex af, af' ; Saves a value (char to print) for later
@@ -107,10 +112,10 @@ __PRINT_START:
107112
ex af, af'
108113

109114
cp 80h ; Is it an UDG or a ?
110-
jp c, __SRCADDR
115+
jr c, __SRCADDR
111116

112117
cp 90h
113-
jp nc, __PRINT_UDG
118+
jr nc, __PRINT_UDG
114119

115120
; Print a 8 bit pattern (80h to 8Fh)
116121

@@ -529,5 +534,3 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes
529534
ENDP
530535

531536
pop namespace
532-
533-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include once <attr.asm>
2+
3+
push namespace core
4+
5+
; Sets the attribute at a given screen pixel address in hl
6+
; HL contains the address in RAM for a given pixel (not a coordinate)
7+
SET_PIXEL_ADDR_ATTR:
8+
;; gets ATTR position with offset given in SCREEN_ADDR
9+
ld a, h
10+
rrca
11+
rrca
12+
rrca
13+
and 3
14+
15+
ld h, a
16+
ld de, (SCREEN_ATTR_ADDR)
17+
add hl, de ;; Final screen addr
18+
jp __SET_ATTR2
19+
20+
pop namespace
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#include once <sysvars.asm>
2+
13
; Printing positioning library.
24
push namespace core
35

46
PROC
5-
LOCAL ECHO_E
67

78
__LOAD_S_POSN: ; Loads into DE current ROW, COL print position from S_POSN mem var.
89
ld de, (S_POSN)
@@ -20,16 +21,6 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var.
2021
ld (S_POSN), hl ; saves it again
2122
ret
2223

23-
24-
ECHO_E EQU 23682
25-
MAXX EQU ECHO_E ; Max X position + 1
26-
MAXY EQU MAXX + 1 ; Max Y position + 1
27-
28-
S_POSN EQU 23688
29-
POSX EQU S_POSN ; Current POS X
30-
POSY EQU S_POSN + 1 ; Current POS Y
31-
3224
ENDP
3325

3426
pop namespace
35-

src/arch/zx48k/library-asm/sysvars.asm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ TVFLAGS EQU 23612 ; TV Flags
1515
UDG EQU 23675 ; Pointer to UDG Charset
1616
COORDS EQU 23677 ; Last PLOT coordinates
1717
FLAGS2 EQU 23681 ;
18+
ECHO_E EQU 23682 ;
19+
DFCC EQU 23684 ; Next screen addr for PRINT
20+
DFCCL EQU 23686 ; Next screen attr for PRINT
21+
S_POSN EQU 23688
1822
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
1923
ATTR_T EQU 23695 ; temporary ATTRIBUTES
2024
P_FLAG EQU 23697 ;
25+
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars
2126

22-
MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars
27+
;; Screen MAX col (MAXX) and MAX row (MAXY)
28+
MAXX EQU ECHO_E ; Max X position + 1
29+
MAXY EQU MAXX + 1 ; Max Y position + 1
30+
31+
;; Screen current ROW, COL (POSX, POSY) position
32+
POSX EQU S_POSN ; Current POS X
33+
POSY EQU S_POSN + 1 ; Current POS Y
2334

2435
pop namespace

0 commit comments

Comments
 (0)