scrolling text vertically in the opposite direction in basic

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

scrolling text vertically in the opposite direction in basic

Post by 777 »

ive been trying to write this in basic but havent got very far. any hints on how i would do this?
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
Bubu
Manic Miner
Posts: 542
Joined: Fri Apr 02, 2021 8:24 pm
Location: Spain

Re: scrolling text vertically in the opposite direction in basic

Post by Bubu »

Code: Select all

10 LET a$="Hello, world"
20 LET b$="            "
30 FOR r=15 to 5 STEP -1
40 PRINT AT r,4;a$
50 PRINT AT r+1,4;b$
60 PAUSE 10
70 NEXT r
If something works, don't touch it !!!! at all !!!
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

Bubu wrote: Thu Nov 25, 2021 5:07 pm

Code: Select all

10 LET a$="Hello, world"
20 LET b$="            "
30 FOR r=15 to 5 STEP -1
40 PRINT AT r,4;a$
50 PRINT AT r+1,4;b$
60 PAUSE 10
70 NEXT r
thank you but i did program something similar myself earlier. i need it to keep adding characters and looping, so it looks like a road for instance.
Last edited by 777 on Thu Nov 25, 2021 5:15 pm, edited 1 time in total.
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
Bubu
Manic Miner
Posts: 542
Joined: Fri Apr 02, 2021 8:24 pm
Location: Spain

Re: scrolling text vertically in the opposite direction in basic

Post by Bubu »

yw :D
If something works, don't touch it !!!! at all !!!
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

Bubu wrote: Thu Nov 25, 2021 5:15 pmyw :D
sorry, just edited that ^

thank you but i did program something similar myself earlier. i need it to keep adding characters and looping, so it looks like a road for instance.
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
Morkin
Bugaboo
Posts: 3277
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: scrolling text vertically in the opposite direction in basic

Post by Morkin »

My memory of BASIC fades by the year(!) but I'm not sure how you'd do an upwards movement/downwards scroll.

There were tons of early BASIC games and type ins of this sort, Race Track for example, but the player is always moving down the screen.

I guess this is because you can just keep using PRINT to print the the next row of track. Then POKE 23692,255 stops the "Scroll?" message appearing (for a while at least!), so the track will naturally scroll up the screen without you needing to do anything. I don't know how you'd do it if you wanted to go in the opposite direction.

The machine code program that you were looking at in the other thread has to copy 736 character squares up one line:

Code: Select all

ld hl,23263 ;scroll road
ld de,23295
ld bc,736
lddr
It's insanely fast in assembly, but I dread to think how insanely slow it'd be in BASIC..!
My Speccy site: thirdharmoniser.com
+3code

Re: scrolling text vertically in the opposite direction in basic

Post by +3code »

I think the best solution is to call a small mc routine from BASIC to scroll down, print the new line from BASIC, and so. They are a lot of short mc routines published in magazines handable from BASIC.
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

where?
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
FFoulkes
Microbot
Posts: 161
Joined: Thu Feb 07, 2019 2:42 pm

Re: scrolling text vertically in the opposite direction in basic

Post by FFoulkes »

777 wrote: Thu Nov 25, 2021 5:12 pmi need it to keep adding characters and looping, so it looks like a road for instance.
Maybe prepare the complete string (a$) first, and print it as shown, when it's ready?
(Or probably prepare a full string of 32 characters before printing.)
hikoki
Manic Miner
Posts: 576
Joined: Thu Nov 16, 2017 10:54 am

Re: scrolling text vertically in the opposite direction in basic

Post by hikoki »

Code: Select all

30 GO SUB 100
45 PRINT : POKE 23692,0
50 PRINT AT 21,0;b$'''''':
60 GO TO 30
100 LET r=INT (3*RND): LET a$=("O" AND r<1)+("X" AND r>1): LET r=INT (5*RND): LET b$=("   "+a$ AND r=1)+("                   "+a$ AND r=2): LET b$=b$+("         "+a$ AND r=3)+("                      "+a$ AND r=4): RETURN 
FFoulkes
Microbot
Posts: 161
Joined: Thu Feb 07, 2019 2:42 pm

Re: scrolling text vertically in the opposite direction in basic

Post by FFoulkes »

Morkin wrote: Thu Nov 25, 2021 6:37 pmI guess this is because you can just keep using PRINT to print the the next row of track. Then POKE 23692,255 stops the "Scroll?" message appearing (for a while at least!), so the track will naturally scroll up the screen without you needing to do anything.
So that would be like this:

Code: Select all

10 POKE 23692,255
20 LET a$="Hello, world"
30 PRINT AT 21,0;a$
40 FOR i=1 TO 50
50 PRINT
60 NEXT i
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

hikoki wrote: Thu Nov 25, 2021 7:39 pm

Code: Select all

30 GO SUB 100
45 PRINT : POKE 23692,0
50 PRINT AT 21,0;b$'''''':
60 GO TO 30
100 LET r=INT (3*RND): LET a$=("O" AND r<1)+("X" AND r>1): LET r=INT (5*RND): LET b$=("   "+a$ AND r=1)+("                   "+a$ AND r=2): LET b$=b$+("         "+a$ AND r=3)+("                      "+a$ AND r=4): RETURN 
thank you for that...

its still scrolling the wrong way...

and its not drawing me a road

Image

maybe its a typo. btw i didnt want to put all those statements in a single line
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
+3code

Re: scrolling text vertically in the opposite direction in basic

Post by +3code »

777 wrote: Thu Nov 25, 2021 7:09 pmwhere?
https://spectrumcomputing.co.uk/entry/8 ... -Supercode

And a lot of other similar packs of routines.
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

+3code wrote: Thu Nov 25, 2021 8:10 pm
777 wrote: Thu Nov 25, 2021 7:09 pmwhere?
https://spectrumcomputing.co.uk/entry/8 ... -Supercode

And a lot of other similar packs of routines.
thank you
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
+3code

Re: scrolling text vertically in the opposite direction in basic

Post by +3code »

Break this BASIC game and take a look:

https://spectrumcomputing.co.uk/entry/1 ... lling_Maze
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

+3code wrote: Thu Nov 25, 2021 8:14 pm Break this BASIC game and take a look:

https://spectrumcomputing.co.uk/entry/1 ... lling_Maze
ok
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

+3code wrote: Thu Nov 25, 2021 8:10 pm
777 wrote: Thu Nov 25, 2021 7:09 pmwhere?
https://spectrumcomputing.co.uk/entry/8 ... -Supercode

And a lot of other similar packs of routines.
unfortunately none of those routines seem to do what i want
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

ok, thank you, it works
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
FFoulkes
Microbot
Posts: 161
Joined: Thu Feb 07, 2019 2:42 pm

Re: scrolling text vertically in the opposite direction in basic

Post by FFoulkes »

777 wrote: Thu Nov 25, 2021 8:45 pmok, thank you, it works
May I ask, what code did the trick?
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

FFoulkes wrote: Thu Nov 25, 2021 11:06 pm
777 wrote: Thu Nov 25, 2021 8:45 pmok, thank you, it works
May I ask, what code did the trick?
hi res scroll down
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
FFoulkes
Microbot
Posts: 161
Joined: Thu Feb 07, 2019 2:42 pm

Re: scrolling text vertically in the opposite direction in basic

Post by FFoulkes »

777 wrote: Fri Nov 26, 2021 11:52 amhi res scroll down
Thank you! So you're using a machine code routine.
User avatar
Bubu
Manic Miner
Posts: 542
Joined: Fri Apr 02, 2021 8:24 pm
Location: Spain

Re: scrolling text vertically in the opposite direction in basic

Post by Bubu »

That's cheating! :idea:
If something works, don't touch it !!!! at all !!!
FFoulkes
Microbot
Posts: 161
Joined: Thu Feb 07, 2019 2:42 pm

Re: scrolling text vertically in the opposite direction in basic

Post by FFoulkes »

Well, I'm still not really into Spectrum assembler (still find it too difficult), but if I were, I'd probably extract and write down those 99 bytes and create a disassembly to really understand what it does.
Then I'd post the result here. ;)
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: scrolling text vertically in the opposite direction in basic

Post by 777 »

777 wrote: Fri Nov 26, 2021 11:52 am
FFoulkes wrote: Thu Nov 25, 2021 11:06 pm
May I ask, what code did the trick?
hi res scroll down
i was wondering it was possible to change this code so it jumps 8 pixels instead of 1? ive had a go myself to no avail.

Code: Select all

	org 64098
	ld hl, 22527		 ; 64098 33     255 87     10ts
	ld b, 3			 ; 64101 6     3	 7ts
l_fa67: push bc			 ; 64103 197 11ts
	ld b, 8			 ; 64104 6     8	 7ts
l_fa6a: push bc			 ; 64106 197 11ts
	ld b, 7			 ; 64107 6     7	 7ts
l_fa6d: push bc			 ; 64109 197 11ts
	ld b, 32		 ; 64110 6     32	 7ts
l_fa70: push hl			 ; 64112 229 11ts
	ld de, 256		 ; 64113 17     0	 1     10ts
	and a			 ; 64116 167 4ts
	sbc hl, de		 ; 64117 237 82	 15ts
	pop de			 ; 64119 209 10ts
	ld a, (hl)		 ; 64120 126 7ts
	ld (de), a		 ; 64121 18     7ts
	ex de, hl		 ; 64122 235 4ts
	dec hl			 ; 64123 43     6ts
	djnz l_fa70		 ; 64124 16     242 8/13ts
	ld de, 224		 ; 64126 17     224 0     10ts
	and a			 ; 64129 167 4ts
	sbc hl, de		 ; 64130 237 82	 15ts
	pop bc			 ; 64132 193 10ts
	djnz l_fa6d		 ; 64133 16     230 8/13ts
	pop bc			 ; 64135 193 10ts
	ld a, b			 ; 64136 120 4ts
	cp 1			 ; 64137 254 1	 7ts
	jr z, l_faa3		 ; 64139 40     22	 12/7ts
	push bc			 ; 64141 197 11ts
	ld b, 32		 ; 64142 6     32	 7ts
l_fa90: ld de, 1760		 ; 64144 17     224 6     10ts
	push hl			 ; 64147 229 11ts
	add hl, de		 ; 64148 25     11ts
	pop de			 ; 64149 209 10ts
	ld a, (hl)		 ; 64150 126 7ts
	ld (de), a		 ; 64151 18     7ts
	ex de, hl		 ; 64152 235 4ts
	dec hl			 ; 64153 43     6ts
	djnz l_fa90		 ; 64154 16     244 8/13ts
	ld de, 1792		 ; 64156 17     0	 7     10ts
	add hl, de		 ; 64159 25     11ts
	pop bc			 ; 64160 193 10ts
	djnz l_fa6a		 ; 64161 16     199 8/13ts
l_faa3: pop bc			 ; 64163 193 10ts
	ld a, b			 ; 64164 120 4ts
	cp 1			 ; 64165 254 1	 7ts
	jr z, 64188		 ; 64167 40     19	 12/7ts
	push bc			 ; 64169 197 11ts
	ld b, 32		 ; 64170 6     32	 7ts
l_faac: ld de, 32		 ; 64172 17     32	 0     10ts
	push hl			 ; 64175 229 11ts
	and a			 ; 64176 167 4ts
	sbc hl, de		 ; 64177 237 82	 15ts
	pop de			 ; 64179 209 10ts
	ld a, (hl)		 ; 64180 126 7ts
	ld (de), a		 ; 64181 18     7ts
	ex de, hl		 ; 64182 235 4ts
	dec hl			 ; 64183 43     6ts
	djnz l_faac		 ; 64184 16     242 8/13ts
	pop bc			 ; 64186 193 10ts
	djnz l_fa67		 ; 64187 16     170 8/13ts
	ld b, 32		 ; 64189 6     32	 7ts
l_fabf: ld (hl), 0		 ; 64191 54     0	 10ts
	dec hl			 ; 64193 43     6ts
	djnz l_fabf		 ; 64194 16     251 8/13ts
	ret			 ; 64196 201 10ts
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
Post Reply