Skip to content

Commit 3593074

Browse files
authored
Merge pull request #277 from boriel/bugfix/scroll
Bugfix/scroll
2 parents 30a5e71 + 313c978 commit 3593074

58 files changed

Lines changed: 1999 additions & 2502 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/print.asm

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

@@ -50,7 +51,6 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
5051
LOCAL __PRINT_UDG
5152
LOCAL __PRGRAPH
5253
LOCAL __PRINT_START
53-
LOCAL __NO_SCROLL
5454
LOCAL __ROM_SCROLL_SCR
5555
LOCAL __TVFLAGS
5656

@@ -62,32 +62,40 @@ PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
6262
__PRINT_JUMP:
6363
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
6464

65+
#ifndef DISABLE_SCROLL
66+
LOCAL __SCROLL
67+
__SCROLL: ; Scroll?
68+
ld hl, __TVFLAGS
69+
bit 1, (hl)
70+
ret z
71+
call __ROM_SCROLL_SCR
72+
ld hl, __TVFLAGS
73+
res 1, (hl)
74+
ret
75+
#endif
76+
6577
__PRINT_START:
6678
cp ' '
6779
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
6880

6981
exx ; Switch to alternative registers
7082
ex af, af' ; Saves a value (char to print) for later
7183

72-
ld hl, __TVFLAGS
73-
bit 1, (hl)
74-
jp z, __NO_SCROLL
75-
call __ROM_SCROLL_SCR
76-
ld hl, __TVFLAGS
77-
res 1, (hl)
78-
__NO_SCROLL:
84+
#ifndef DISABLE_SCROLL
85+
call __SCROLL
86+
#endif
7987
call __LOAD_S_POSN
8088

8189
; At this point we have the new coord
8290
ld hl, (SCREEN_ADDR)
8391

8492
ld a, d
85-
ld c, a ; Saves it for later
93+
ld c, a ; Saves it for later
8694
8795
and 0F8h ; Masks 3 lower bit ; zy
8896
ld d, a
8997

90-
ld a, c ; Recovers it
98+
ld a, c ; Recovers it
9199
and 07h ; MOD 7 ; y1
92100
rrca
93101
rrca
@@ -125,9 +133,9 @@ __SRCADDR:
125133
ld bc, (CHARS)
126134

127135
__PRGRAPH0:
128-
add a, a ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
136+
add a, a ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
129137
ld l, a
130-
ld h, 0 ; HL = a * 2 (accumulator)
138+
ld h, 0 ; HL = a * 2 (accumulator)
131139
add hl, hl
132140
add hl, hl ; HL = a * 8
133141
add hl, bc ; HL = CHARS address
@@ -142,20 +150,20 @@ __PRGRAPH:
142150
__PRCHAR:
143151
ld a, (de) ; DE *must* be ALWAYS source, and HL destiny
144152

145-
PRINT_MODE: ; Which operation is used to write on the screen
153+
PRINT_MODE: ; Which operation is used to write on the screen
146154
; Set it with:
147155
; LD A, <OPERATION>
148156
; LD (PRINT_MODE), A
149157
;
150158
; Available opertions:
151-
; NORMAL: 0h --> NOP ; OVER 0
152-
; XOR : AEh --> XOR (HL) ; OVER 1
153-
; OR : B6h --> OR (HL) ; PUTSPRITE
154-
; AND : A6h --> AND (HL) ; PUTMASK
155-
nop ;
159+
; NORMAL : 0h --> NOP ; OVER 0
160+
; XOR : AEh --> XOR (HL) ; OVER 1
161+
; OR : B6h --> OR (HL) ; PUTSPRITE
162+
; AND : A6h --> AND (HL) ; PUTMASK
163+
nop ;
156164

157-
INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
158-
nop ; 2F -> CPL -> INVERSE 1
165+
INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
166+
nop ; 2F -> CPL -> INVERSE 1
159167

160168
ld (hl), a
161169

@@ -196,6 +204,9 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence
196204
exx
197205

198206
__PRINT_0Dh: ; Called WHEN printing CHR$(13)
207+
#ifndef DISABLE_SCROLL
208+
call __SCROLL
209+
#endif
199210
call __LOAD_S_POSN
200211

201212
__PRINT_EOL1: ; Another entry called from PRINT when next line required
@@ -209,9 +220,13 @@ __PRINT_AT1_END:
209220
ld hl, (MAXY)
210221
cp l
211222
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
223+
#ifndef DISABLE_SCROLL
212224
ld hl, __TVFLAGS
213225
set 1, (hl)
214226
ld a, d
227+
#else
228+
xor a
229+
#endif
215230

216231
__PRINT_EOL_END:
217232
ld d, a
@@ -449,7 +464,7 @@ LOOP:
449464
ret
450465
ENDP
451466

452-
PRINT_AT: ; CHanges cursor to ROW, COL
467+
PRINT_AT: ; Changes cursor to ROW, COL
453468
; COL in A register
454469
; ROW in stack
455470

@@ -460,7 +475,10 @@ PRINT_AT: ; CHanges cursor to ROW, COL
460475

461476
call __IN_SCREEN
462477
ret nc ; Return if out of screen
463-
478+
#ifndef DISABLE_SCROLL
479+
ld hl, __TVFLAGS
480+
res 1, (hl)
481+
#endif
464482
jp __SAVE_S_POSN
465483

466484
LOCAL __PRINT_COM
@@ -498,16 +516,16 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes
498516
DW __PRINT_NOP ; 11
499517
DW __PRINT_NOP ; 12
500518
DW __PRINT_0Dh ; 13
501-
DW __PRINT_BOLD ; 14
519+
DW __PRINT_BOLD ; 14
502520
DW __PRINT_ITA ; 15
503521
DW __PRINT_INK ; 16
504522
DW __PRINT_PAP ; 17
505523
DW __PRINT_FLA ; 18
506524
DW __PRINT_BRI ; 19
507525
DW __PRINT_INV ; 20
508526
DW __PRINT_OVR ; 21
509-
DW __PRINT_AT ; 22 AT
510-
DW __PRINT_TAB ; 23 TAB
527+
DW __PRINT_AT ; 22 AT
528+
DW __PRINT_TAB ; 23 TAB
511529

512530
ENDP
513531

tests/functional/astore16.asm

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -730,34 +730,38 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
730730
LOCAL __PRINT_UDG
731731
LOCAL __PRGRAPH
732732
LOCAL __PRINT_START
733-
LOCAL __NO_SCROLL
734733
LOCAL __ROM_SCROLL_SCR
735734
LOCAL __TVFLAGS
736735
__ROM_SCROLL_SCR EQU 0DFEh
737736
__TVFLAGS EQU 5C3Ch
738737
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
739738
__PRINT_JUMP:
740739
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
741-
__PRINT_START:
742-
cp ' '
743-
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
744-
exx ; Switch to alternative registers
745-
ex af, af' ; Saves a value (char to print) for later
740+
LOCAL __SCROLL
741+
__SCROLL: ; Scroll?
746742
ld hl, __TVFLAGS
747743
bit 1, (hl)
748-
jp z, __NO_SCROLL
744+
ret z
749745
call __ROM_SCROLL_SCR
750746
ld hl, __TVFLAGS
751747
res 1, (hl)
752-
__NO_SCROLL:
748+
ret
749+
#line 75 "/zxbasic/library-asm/print.asm"
750+
__PRINT_START:
751+
cp ' '
752+
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
753+
exx ; Switch to alternative registers
754+
ex af, af' ; Saves a value (char to print) for later
755+
call __SCROLL
756+
#line 86 "/zxbasic/library-asm/print.asm"
753757
call __LOAD_S_POSN
754758
; At this point we have the new coord
755759
ld hl, (SCREEN_ADDR)
756760
ld a, d
757-
ld c, a ; Saves it for later
761+
ld c, a ; Saves it for later
758762
and 0F8h ; Masks 3 lower bit ; zy
759763
ld d, a
760-
ld a, c ; Recovers it
764+
ld a, c ; Recovers it
761765
and 07h ; MOD 7 ; y1
762766
rrca
763767
rrca
@@ -785,9 +789,9 @@ __PRINT_UDG:
785789
__SRCADDR:
786790
ld bc, (CHARS)
787791
__PRGRAPH0:
788-
add a, a ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
792+
add a, a ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
789793
ld l, a
790-
ld h, 0 ; HL = a * 2 (accumulator)
794+
ld h, 0 ; HL = a * 2 (accumulator)
791795
add hl, hl
792796
add hl, hl ; HL = a * 8
793797
add hl, bc ; HL = CHARS address
@@ -800,19 +804,19 @@ __PRGRAPH:
800804
ld b, 8 ; 8 bytes per char
801805
__PRCHAR:
802806
ld a, (de) ; DE *must* be ALWAYS source, and HL destiny
803-
PRINT_MODE: ; Which operation is used to write on the screen
807+
PRINT_MODE: ; Which operation is used to write on the screen
804808
; Set it with:
805809
; LD A, <OPERATION>
806810
; LD (PRINT_MODE), A
807811
;
808812
; Available opertions:
809-
; NORMAL: 0h --> NOP ; OVER 0
810-
; XOR : AEh --> XOR (HL) ; OVER 1
811-
; OR : B6h --> OR (HL) ; PUTSPRITE
812-
; AND : A6h --> AND (HL) ; PUTMASK
813-
nop ;
814-
INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
815-
nop ; 2F -> CPL -> INVERSE 1
813+
; NORMAL : 0h --> NOP ; OVER 0
814+
; XOR : AEh --> XOR (HL) ; OVER 1
815+
; OR : B6h --> OR (HL) ; PUTSPRITE
816+
; AND : A6h --> AND (HL) ; PUTMASK
817+
nop ;
818+
INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
819+
nop ; 2F -> CPL -> INVERSE 1
816820
ld (hl), a
817821
inc de
818822
inc h ; Next line
@@ -843,6 +847,8 @@ __PRINT_SPECIAL: ; Jumps here if it is a special char
843847
PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence
844848
exx
845849
__PRINT_0Dh: ; Called WHEN printing CHR$(13)
850+
call __SCROLL
851+
#line 209 "/zxbasic/library-asm/print.asm"
846852
call __LOAD_S_POSN
847853
__PRINT_EOL1: ; Another entry called from PRINT when next line required
848854
ld e, 0
@@ -1057,7 +1063,7 @@ LOOP:
10571063
djnz LOOP
10581064
ret
10591065
ENDP
1060-
PRINT_AT: ; CHanges cursor to ROW, COL
1066+
PRINT_AT: ; Changes cursor to ROW, COL
10611067
; COL in A register
10621068
; ROW in stack
10631069
pop hl ; Ret address
@@ -1066,6 +1072,8 @@ PRINT_AT: ; CHanges cursor to ROW, COL
10661072
ex de, hl
10671073
call __IN_SCREEN
10681074
ret nc ; Return if out of screen
1075+
ld hl, __TVFLAGS
1076+
res 1, (hl)
10691077
jp __SAVE_S_POSN
10701078
LOCAL __PRINT_COM
10711079
LOCAL __BOLD
@@ -1100,16 +1108,16 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes
11001108
DW __PRINT_NOP ; 11
11011109
DW __PRINT_NOP ; 12
11021110
DW __PRINT_0Dh ; 13
1103-
DW __PRINT_BOLD ; 14
1111+
DW __PRINT_BOLD ; 14
11041112
DW __PRINT_ITA ; 15
11051113
DW __PRINT_INK ; 16
11061114
DW __PRINT_PAP ; 17
11071115
DW __PRINT_FLA ; 18
11081116
DW __PRINT_BRI ; 19
11091117
DW __PRINT_INV ; 20
11101118
DW __PRINT_OVR ; 21
1111-
DW __PRINT_AT ; 22 AT
1112-
DW __PRINT_TAB ; 23 TAB
1119+
DW __PRINT_AT ; 22 AT
1120+
DW __PRINT_TAB ; 23 TAB
11131121
ENDP
11141122
#line 53 "astore16.bas"
11151123
#line 1 "printu16.asm"

0 commit comments

Comments
 (0)