Skip to content

Commit 1a95314

Browse files
committed
Perform autoscroll as in original Sinclair BASIC
1 parent 20eab5a commit 1a95314

Some content is hidden

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

56 files changed

+865
-108
lines changed

library-asm/print.asm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
5050
LOCAL __PRINT_UDG
5151
LOCAL __PRGRAPH
5252
LOCAL __PRINT_START
53+
LOCAL __NO_SCROLL
54+
LOCAL __ROM_SCROLL_SCR
55+
LOCAL __TVFLAGS
56+
57+
__ROM_SCROLL_SCR EQU 0DFEh
58+
__TVFLAGS EQU 5C3Ch
5359

5460
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
5561

@@ -60,9 +66,16 @@ __PRINT_START:
6066
cp ' '
6167
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
6268

63-
exx ; Switch to alternative registers
69+
exx ; Switch to alternative registers
6470
ex af, af' ; Saves a value (char to print) for later
6571

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:
6679
call __LOAD_S_POSN
6780

6881
; At this point we have the new coord
@@ -196,7 +209,9 @@ __PRINT_AT1_END:
196209
ld hl, (MAXY)
197210
cp l
198211
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
199-
xor a
212+
ld hl, __TVFLAGS
213+
set 1, (hl)
214+
ld a, d
200215

201216
__PRINT_EOL_END:
202217
ld d, a

tests/functional/astore16.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
730730
LOCAL __PRINT_UDG
731731
LOCAL __PRGRAPH
732732
LOCAL __PRINT_START
733+
LOCAL __NO_SCROLL
734+
LOCAL __ROM_SCROLL_SCR
735+
LOCAL __TVFLAGS
736+
__ROM_SCROLL_SCR EQU 0DFEh
737+
__TVFLAGS EQU 5C3Ch
733738
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
734739
__PRINT_JUMP:
735740
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
736741
__PRINT_START:
737742
cp ' '
738743
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
739-
exx ; Switch to alternative registers
744+
exx ; Switch to alternative registers
740745
ex af, af' ; Saves a value (char to print) for later
746+
ld hl, __TVFLAGS
747+
bit 1, (hl)
748+
jp z, __NO_SCROLL
749+
call __ROM_SCROLL_SCR
750+
ld hl, __TVFLAGS
751+
res 1, (hl)
752+
__NO_SCROLL:
741753
call __LOAD_S_POSN
742754
; At this point we have the new coord
743755
ld hl, (SCREEN_ADDR)
@@ -841,7 +853,9 @@ __PRINT_AT1_END:
841853
ld hl, (MAXY)
842854
cp l
843855
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
844-
xor a
856+
ld hl, __TVFLAGS
857+
set 1, (hl)
858+
ld a, d
845859
__PRINT_EOL_END:
846860
ld d, a
847861
__PRINT_AT2_END:

tests/functional/code00.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
979979
LOCAL __PRINT_UDG
980980
LOCAL __PRGRAPH
981981
LOCAL __PRINT_START
982+
LOCAL __NO_SCROLL
983+
LOCAL __ROM_SCROLL_SCR
984+
LOCAL __TVFLAGS
985+
__ROM_SCROLL_SCR EQU 0DFEh
986+
__TVFLAGS EQU 5C3Ch
982987
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
983988
__PRINT_JUMP:
984989
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
985990
__PRINT_START:
986991
cp ' '
987992
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
988-
exx ; Switch to alternative registers
993+
exx ; Switch to alternative registers
989994
ex af, af' ; Saves a value (char to print) for later
995+
ld hl, __TVFLAGS
996+
bit 1, (hl)
997+
jp z, __NO_SCROLL
998+
call __ROM_SCROLL_SCR
999+
ld hl, __TVFLAGS
1000+
res 1, (hl)
1001+
__NO_SCROLL:
9901002
call __LOAD_S_POSN
9911003
; At this point we have the new coord
9921004
ld hl, (SCREEN_ADDR)
@@ -1090,7 +1102,9 @@ __PRINT_AT1_END:
10901102
ld hl, (MAXY)
10911103
cp l
10921104
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
1093-
xor a
1105+
ld hl, __TVFLAGS
1106+
set 1, (hl)
1107+
ld a, d
10941108
__PRINT_EOL_END:
10951109
ld d, a
10961110
__PRINT_AT2_END:

tests/functional/code01.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
979979
LOCAL __PRINT_UDG
980980
LOCAL __PRGRAPH
981981
LOCAL __PRINT_START
982+
LOCAL __NO_SCROLL
983+
LOCAL __ROM_SCROLL_SCR
984+
LOCAL __TVFLAGS
985+
__ROM_SCROLL_SCR EQU 0DFEh
986+
__TVFLAGS EQU 5C3Ch
982987
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
983988
__PRINT_JUMP:
984989
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
985990
__PRINT_START:
986991
cp ' '
987992
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
988-
exx ; Switch to alternative registers
993+
exx ; Switch to alternative registers
989994
ex af, af' ; Saves a value (char to print) for later
995+
ld hl, __TVFLAGS
996+
bit 1, (hl)
997+
jp z, __NO_SCROLL
998+
call __ROM_SCROLL_SCR
999+
ld hl, __TVFLAGS
1000+
res 1, (hl)
1001+
__NO_SCROLL:
9901002
call __LOAD_S_POSN
9911003
; At this point we have the new coord
9921004
ld hl, (SCREEN_ADDR)
@@ -1090,7 +1102,9 @@ __PRINT_AT1_END:
10901102
ld hl, (MAXY)
10911103
cp l
10921104
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
1093-
xor a
1105+
ld hl, __TVFLAGS
1106+
set 1, (hl)
1107+
ld a, d
10941108
__PRINT_EOL_END:
10951109
ld d, a
10961110
__PRINT_AT2_END:

tests/functional/code02.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
979979
LOCAL __PRINT_UDG
980980
LOCAL __PRGRAPH
981981
LOCAL __PRINT_START
982+
LOCAL __NO_SCROLL
983+
LOCAL __ROM_SCROLL_SCR
984+
LOCAL __TVFLAGS
985+
__ROM_SCROLL_SCR EQU 0DFEh
986+
__TVFLAGS EQU 5C3Ch
982987
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
983988
__PRINT_JUMP:
984989
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
985990
__PRINT_START:
986991
cp ' '
987992
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
988-
exx ; Switch to alternative registers
993+
exx ; Switch to alternative registers
989994
ex af, af' ; Saves a value (char to print) for later
995+
ld hl, __TVFLAGS
996+
bit 1, (hl)
997+
jp z, __NO_SCROLL
998+
call __ROM_SCROLL_SCR
999+
ld hl, __TVFLAGS
1000+
res 1, (hl)
1001+
__NO_SCROLL:
9901002
call __LOAD_S_POSN
9911003
; At this point we have the new coord
9921004
ld hl, (SCREEN_ADDR)
@@ -1090,7 +1102,9 @@ __PRINT_AT1_END:
10901102
ld hl, (MAXY)
10911103
cp l
10921104
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
1093-
xor a
1105+
ld hl, __TVFLAGS
1106+
set 1, (hl)
1107+
ld a, d
10941108
__PRINT_EOL_END:
10951109
ld d, a
10961110
__PRINT_AT2_END:

tests/functional/einarattr.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
545545
LOCAL __PRINT_UDG
546546
LOCAL __PRGRAPH
547547
LOCAL __PRINT_START
548+
LOCAL __NO_SCROLL
549+
LOCAL __ROM_SCROLL_SCR
550+
LOCAL __TVFLAGS
551+
__ROM_SCROLL_SCR EQU 0DFEh
552+
__TVFLAGS EQU 5C3Ch
548553
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
549554
__PRINT_JUMP:
550555
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
551556
__PRINT_START:
552557
cp ' '
553558
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
554-
exx ; Switch to alternative registers
559+
exx ; Switch to alternative registers
555560
ex af, af' ; Saves a value (char to print) for later
561+
ld hl, __TVFLAGS
562+
bit 1, (hl)
563+
jp z, __NO_SCROLL
564+
call __ROM_SCROLL_SCR
565+
ld hl, __TVFLAGS
566+
res 1, (hl)
567+
__NO_SCROLL:
556568
call __LOAD_S_POSN
557569
; At this point we have the new coord
558570
ld hl, (SCREEN_ADDR)
@@ -656,7 +668,9 @@ __PRINT_AT1_END:
656668
ld hl, (MAXY)
657669
cp l
658670
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
659-
xor a
671+
ld hl, __TVFLAGS
672+
set 1, (hl)
673+
ld a, d
660674
__PRINT_EOL_END:
661675
ld d, a
662676
__PRINT_AT2_END:

tests/functional/einarshift.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
581581
LOCAL __PRINT_UDG
582582
LOCAL __PRGRAPH
583583
LOCAL __PRINT_START
584+
LOCAL __NO_SCROLL
585+
LOCAL __ROM_SCROLL_SCR
586+
LOCAL __TVFLAGS
587+
__ROM_SCROLL_SCR EQU 0DFEh
588+
__TVFLAGS EQU 5C3Ch
584589
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
585590
__PRINT_JUMP:
586591
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
587592
__PRINT_START:
588593
cp ' '
589594
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
590-
exx ; Switch to alternative registers
595+
exx ; Switch to alternative registers
591596
ex af, af' ; Saves a value (char to print) for later
597+
ld hl, __TVFLAGS
598+
bit 1, (hl)
599+
jp z, __NO_SCROLL
600+
call __ROM_SCROLL_SCR
601+
ld hl, __TVFLAGS
602+
res 1, (hl)
603+
__NO_SCROLL:
592604
call __LOAD_S_POSN
593605
; At this point we have the new coord
594606
ld hl, (SCREEN_ADDR)
@@ -692,7 +704,9 @@ __PRINT_AT1_END:
692704
ld hl, (MAXY)
693705
cp l
694706
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
695-
xor a
707+
ld hl, __TVFLAGS
708+
set 1, (hl)
709+
ld a, d
696710
__PRINT_EOL_END:
697711
ld d, a
698712
__PRINT_AT2_END:

tests/functional/fact.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
738738
LOCAL __PRINT_UDG
739739
LOCAL __PRGRAPH
740740
LOCAL __PRINT_START
741+
LOCAL __NO_SCROLL
742+
LOCAL __ROM_SCROLL_SCR
743+
LOCAL __TVFLAGS
744+
__ROM_SCROLL_SCR EQU 0DFEh
745+
__TVFLAGS EQU 5C3Ch
741746
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
742747
__PRINT_JUMP:
743748
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
744749
__PRINT_START:
745750
cp ' '
746751
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
747-
exx ; Switch to alternative registers
752+
exx ; Switch to alternative registers
748753
ex af, af' ; Saves a value (char to print) for later
754+
ld hl, __TVFLAGS
755+
bit 1, (hl)
756+
jp z, __NO_SCROLL
757+
call __ROM_SCROLL_SCR
758+
ld hl, __TVFLAGS
759+
res 1, (hl)
760+
__NO_SCROLL:
749761
call __LOAD_S_POSN
750762
; At this point we have the new coord
751763
ld hl, (SCREEN_ADDR)
@@ -849,7 +861,9 @@ __PRINT_AT1_END:
849861
ld hl, (MAXY)
850862
cp l
851863
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
852-
xor a
864+
ld hl, __TVFLAGS
865+
set 1, (hl)
866+
ld a, d
853867
__PRINT_EOL_END:
854868
ld d, a
855869
__PRINT_AT2_END:

tests/functional/for0.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
618618
LOCAL __PRINT_UDG
619619
LOCAL __PRGRAPH
620620
LOCAL __PRINT_START
621+
LOCAL __NO_SCROLL
622+
LOCAL __ROM_SCROLL_SCR
623+
LOCAL __TVFLAGS
624+
__ROM_SCROLL_SCR EQU 0DFEh
625+
__TVFLAGS EQU 5C3Ch
621626
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
622627
__PRINT_JUMP:
623628
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
624629
__PRINT_START:
625630
cp ' '
626631
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
627-
exx ; Switch to alternative registers
632+
exx ; Switch to alternative registers
628633
ex af, af' ; Saves a value (char to print) for later
634+
ld hl, __TVFLAGS
635+
bit 1, (hl)
636+
jp z, __NO_SCROLL
637+
call __ROM_SCROLL_SCR
638+
ld hl, __TVFLAGS
639+
res 1, (hl)
640+
__NO_SCROLL:
629641
call __LOAD_S_POSN
630642
; At this point we have the new coord
631643
ld hl, (SCREEN_ADDR)
@@ -729,7 +741,9 @@ __PRINT_AT1_END:
729741
ld hl, (MAXY)
730742
cp l
731743
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
732-
xor a
744+
ld hl, __TVFLAGS
745+
set 1, (hl)
746+
ld a, d
733747
__PRINT_EOL_END:
734748
ld d, a
735749
__PRINT_AT2_END:

tests/functional/ifelse1.asm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,26 @@ __PRINTCHAR: ; Print character store in accumulator (A register)
594594
LOCAL __PRINT_UDG
595595
LOCAL __PRGRAPH
596596
LOCAL __PRINT_START
597+
LOCAL __NO_SCROLL
598+
LOCAL __ROM_SCROLL_SCR
599+
LOCAL __TVFLAGS
600+
__ROM_SCROLL_SCR EQU 0DFEh
601+
__TVFLAGS EQU 5C3Ch
597602
PRINT_JUMP_STATE EQU __PRINT_JUMP + 1
598603
__PRINT_JUMP:
599604
jp __PRINT_START ; Where to jump. If we print 22 (AT), next two calls jumps to AT1 and AT2 respectively
600605
__PRINT_START:
601606
cp ' '
602607
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
603-
exx ; Switch to alternative registers
608+
exx ; Switch to alternative registers
604609
ex af, af' ; Saves a value (char to print) for later
610+
ld hl, __TVFLAGS
611+
bit 1, (hl)
612+
jp z, __NO_SCROLL
613+
call __ROM_SCROLL_SCR
614+
ld hl, __TVFLAGS
615+
res 1, (hl)
616+
__NO_SCROLL:
605617
call __LOAD_S_POSN
606618
; At this point we have the new coord
607619
ld hl, (SCREEN_ADDR)
@@ -705,7 +717,9 @@ __PRINT_AT1_END:
705717
ld hl, (MAXY)
706718
cp l
707719
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
708-
xor a
720+
ld hl, __TVFLAGS
721+
set 1, (hl)
722+
ld a, d
709723
__PRINT_EOL_END:
710724
ld d, a
711725
__PRINT_AT2_END:

0 commit comments

Comments
 (0)