Skip to content

Commit da0c5e9

Browse files
committed
refact: use sysvars and SCREEN ptrs
1 parent ef8d786 commit da0c5e9

14 files changed

Lines changed: 50 additions & 60 deletions

File tree

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include once <sposn.asm>
55
#include once <error.asm>
66
#include once <in_screen.asm>
7-
#include once <const.asm>
8-
#include once <cls.asm>
7+
#include once <sysvars.asm>
98

109
push namespace core
1110

@@ -14,20 +13,18 @@ __ATTR_ADDR:
1413
; Contributed by Santiago Romero at http://www.speccy.org
1514
ld h, 0 ; 7 T-States
1615
ld a, d ; 4 T-States
16+
ld d, h
1717
add a, a ; a * 2 ; 4 T-States
1818
add a, a ; a * 4 ; 4 T-States
1919
ld l, a ; HL = A * 4 ; 4 T-States
2020

2121
add hl, hl ; HL = A * 8 ; 15 T-States
2222
add hl, hl ; HL = A * 16 ; 15 T-States
2323
add hl, hl ; HL = A * 32 ; 15 T-States
24-
25-
ld d, 18h ; DE = 6144 + E. Note: 6144 is the screen size (before attr zone)
2624
add hl, de
2725

28-
ld de, (SCREEN_ADDR) ; Adds the screen address
26+
ld de, (SCREEN_ATTR_ADDR) ; Adds the screen address
2927
add hl, de
30-
3128
; Return current screen address in HL
3229
ret
3330

@@ -74,9 +71,9 @@ SET_PIXEL_ADDR_ATTR:
7471
rrca
7572
rrca
7673
and 3
77-
or 18h
74+
7875
ld h, a
79-
ld de, (SCREEN_ADDR)
76+
ld de, (SCREEN_ATTR_ADDR)
8077
add hl, de ;; Final screen addr
8178
jp __SET_ATTR2
8279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Sets bright flag in ATTR_P permanently
22
; Parameter: Paper color in A register
33

4-
#include once <const.asm>
4+
#include once <sysvars.asm>
55

66
push namespace core
77

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
; JUMPS directly to spectrum CLS
2-
; This routine does not clear lower screen
3-
4-
;CLS EQU 0DAFh
5-
6-
; Our faster implementation
1+
;; Clears the user screen (24 rows)
72

83
#include once <sposn.asm>
4+
#include once <sysvars.asm>
95

106
push namespace core
117

128
CLS:
139
PROC
1410

15-
LOCAL COORDS
16-
LOCAL __CLS_SCR
17-
LOCAL ATTR_P
18-
LOCAL SCREEN
19-
2011
ld hl, 0
2112
ld (COORDS), hl
2213
ld hl, 1821h
2314
ld (S_POSN), hl
24-
__CLS_SCR:
25-
ld hl, SCREEN
15+
ld hl, (SCREEN_ADDR)
2616
ld (hl), 0
2717
ld d, h
2818
ld e, l
@@ -32,19 +22,16 @@ __CLS_SCR:
3222

3323
; Now clear attributes
3424

25+
ld hl, (SCREEN_ATTR_ADDR)
26+
ld d, h
27+
ld e, l
28+
inc de
3529
ld a, (ATTR_P)
3630
ld (hl), a
3731
ld bc, 767
3832
ldir
3933
ret
4034

41-
COORDS EQU 23677
42-
SCREEN EQU 16384 ; Default start of the screen (can be changed)
43-
ATTR_P EQU 23693
44-
;you can poke (SCREEN_SCRADDR) to change CLS, DRAW & PRINTing address
45-
46-
SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines
47-
; to get the start of the screen
4835
ENDP
4936

5037
pop namespace

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include once <print.asm>
33
#endif
44

5-
#include once <const.asm>
5+
#include once <sysvars.asm>
66

77
push namespace core
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Sets flash flag in ATTR_P permanently
22
; Parameter: Paper color in A register
33

4-
#include once <const.asm>
4+
#include once <sysvars.asm>
55

66
push namespace core
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Sets ink color in ATTR_P permanently
22
; Parameter: Paper color in A register
33

4-
#include once <const.asm>
4+
#include once <sysvars.asm>
55

66
push namespace core
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Sets OVER flag in P_FLAG permanently
22
; Parameter: OVER flag in bit 0 of A register
33
#include once <copy_attr.asm>
4-
#include once <const.asm>
4+
#include once <sysvars.asm>
55

66
push namespace core
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; Sets paper color in ATTR_P permanently
22
; Parameter: Paper color in A register
33

4-
#include once <const.asm>
4+
#include once <sysvars.asm>
55

66
push namespace core
77

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
; vim:ts=4:sw=4:et:
2-
; vim:ts=4:sw=4:et:
32
; PRINT command routine
43
; Does not print attribute. Use PRINT_STR or PRINT_NUM for that
54

65
#include once <sposn.asm>
7-
#include once <cls.asm>
86
#include once <in_screen.asm>
97
#include once <table_jump.asm>
108
#include once <ink.asm>
@@ -15,7 +13,7 @@
1513
#include once <inverse.asm>
1614
#include once <bold.asm>
1715
#include once <italic.asm>
18-
#include once <const.asm>
16+
#include once <sysvars.asm>
1917
#include once <attr.asm>
2018

2119
; Putting a comment starting with @INIT <address>
@@ -54,10 +52,8 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
5452
LOCAL __PRGRAPH
5553
LOCAL __PRINT_START
5654
LOCAL __ROM_SCROLL_SCR
57-
LOCAL __TVFLAGS
5855

5956
__ROM_SCROLL_SCR EQU 0DFEh
60-
__TVFLAGS EQU 5C3Ch
6157

6258
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
6359

@@ -67,11 +63,11 @@ __PRINT_JUMP:
6763
#ifndef DISABLE_SCROLL
6864
LOCAL __SCROLL
6965
__SCROLL: ; Scroll?
70-
ld hl, __TVFLAGS
66+
ld hl, TVFLAGS
7167
bit 1, (hl)
7268
ret z
7369
call __ROM_SCROLL_SCR
74-
ld hl, __TVFLAGS
70+
ld hl, TVFLAGS
7571
res 1, (hl)
7672
ret
7773
#endif
@@ -220,7 +216,7 @@ __PRINT_AT1_END:
220216
cp l
221217
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
222218
#ifndef DISABLE_SCROLL
223-
ld hl, __TVFLAGS
219+
ld hl, TVFLAGS
224220
set 1, (hl)
225221
dec a
226222
#else
@@ -479,7 +475,7 @@ PRINT_AT: ; Changes cursor to ROW, COL
479475
call __IN_SCREEN
480476
ret nc ; Return if out of screen
481477
#ifndef DISABLE_SCROLL
482-
ld hl, __TVFLAGS
478+
ld hl, TVFLAGS
483479
res 1, (hl)
484480
#endif
485481
jp __SAVE_S_POSN

0 commit comments

Comments
 (0)