The place for codemasters or beginners to talk about programming any language for the Spectrum.
777
Manic Miner
Posts: 512 Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk
Quote
0
login to like this post
Post
by 777 » Sun Apr 24, 2022 2:12 pm
Code: Select all
org 40000
call 3503
ld a,0
start
inc a
rst 16
jp start
i have no idea...
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
PeterJ
Site Admin
Posts: 6873 Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK
Quote
0
login to like this post
Post
by PeterJ » Sun Apr 24, 2022 2:22 pm
RST is printing the Character code @777 . Look at page 135 onwards of the original Spectrum manual in the code column.
Try starting A at 48 which is a 0. After 9, you get the maths symbols then A-Z
777
Manic Miner
Posts: 512 Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk
Quote
1
login to like this post
Post
by 777 » Sun Apr 24, 2022 2:27 pm
sorry, i meant character.
nope, it still gets stuck on 9's...
Last edited by
777 on Sun Apr 24, 2022 2:28 pm, edited 1 time in total.
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
PeterJ
Site Admin
Posts: 6873 Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK
Quote
0
login to like this post
Post
by PeterJ » Sun Apr 24, 2022 2:27 pm
777 wrote: ↑ Sun Apr 24, 2022 2:27 pm
sorry, i meant character
Yes, so set A to 48
777
Manic Miner
Posts: 512 Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk
Quote
0
login to like this post
Post
by 777 » Sun Apr 24, 2022 2:28 pm
tried that, it still gets stuck on 9's...
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
PeterJ
Site Admin
Posts: 6873 Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK
Quote
0
login to like this post
Post
by PeterJ » Sun Apr 24, 2022 2:29 pm
777 wrote: ↑ Sun Apr 24, 2022 2:27 pm
nope, it still gets stuck on 9's...
It will because after 9 comes the maths characters and A-Z
Luzie
Manic Miner
Posts: 907 Joined: Fri May 01, 2020 2:07 pm
Quote
1
login to like this post
Post
by Luzie » Sun Apr 24, 2022 2:30 pm
777 wrote: ↑ Sun Apr 24, 2022 2:12 pm
Code: Select all
org 40000
call 3503
ld a,0
start
inc a
rst 16
jp start
i have no idea...
Fast idea: Try with PUSH before rst16 and POP after rst16:
Code: Select all
org 40000
call 3503
ld a,0
start
inc a
push af
rst 16
pop af
jp start
777
Manic Miner
Posts: 512 Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk
Quote
0
login to like this post
Post
by 777 » Sun Apr 24, 2022 2:31 pm
ok, i c. so i should use the calculator routine?
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
jimmy
Drutt
Posts: 31 Joined: Sun Nov 24, 2019 9:06 pm
Quote
1
login to like this post
Post
by jimmy » Sun Apr 24, 2022 2:33 pm
...because RST 16 does the same as PRINT CHR$(A) in BASIC. It also destroys the value of A when it has finished.
If you want to print a number (0-9999) you can use another ROM routine:
Code: Select all
org 40000
call 3503 ;ROM routine CLS
ld bc,0 ;start counting from 0
loop:
push bc ;preserve BC as routine below destroys value
call 6683 ;ROM routine OUT-NUM
pop bc ;restore BC
inc bc
jr loop
777
Manic Miner
Posts: 512 Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk
Quote
1
login to like this post
Post
by 777 » Sun Apr 24, 2022 2:35 pm
Luzie wrote: ↑ Sun Apr 24, 2022 2:30 pm
Fast idea: Try with PUSH before rst16 and POP after rst16:
yea that works, but that is weird cos i tried that before...
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
Dr beep
Manic Miner
Posts: 381 Joined: Mon Oct 01, 2018 8:53 pm
Quote
1
login to like this post
Post
by Dr beep » Mon Apr 25, 2022 8:05 am
The RST 16 effects A, so PUSH Iand POP is needed.