Simple USR call no longer working.

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
ch0maru
Berk
Posts: 2
Joined: Thu Sep 19, 2019 8:45 pm

Simple USR call no longer working.

Post by ch0maru » Thu Sep 19, 2019 9:19 pm

I've been trying to learn how to do some machine code programming on the Spectrum.

So I am following this tutorial - Machine code game in 30 minutes.
https://chuntey.wordpress.com/2010/01/1 ... 0-minutes/

It's just the perfect level of detail for my current level of learning. And! Amazingly, the things it said to do all worked... until...

I'm using fuse emulator, version 1.5.1, on Kubuntu 18.04. After installing and running for the first time, I was getting a warning on startup saying that it couldn't find 48.rom and that it was defaulting to opense.rom? I think. That default rom worked fine though - just as the tutorial said. I loaded the 4 byte machine code program into 33000 and was able to call it through BASIC using:

Code: Select all

PRINT "Return value is "; USR 33000
However. Working through the code in the tutorial, I got to a point where I was worried things would stop working with the screen colours of the default rom - it boots up with a black screen instead of the off-white of the 48.rom. So I installed the spectrum-roms package. After that the Spectrum48K machine booted. So I amn't getting the warning at startup any more...

But. The code doesn't work now.
I have, like, the simplest 4 byte program:
1,0,0,201
(That's:

Code: Select all

    ld bc,0
    ret
I have loaded it into memory two ways:
- Using File -> Load binary data... in fuse.
- Using a BASIC READ, POKE loop.

I'm looking in the memory in fuse using Machine -> Memory Browser... and I can actually see the bytes are in there, where they're supposed to be!
But when I do:

Code: Select all

PRINT USR 33000
all I get now is..

Code: Select all

2 Variable not found, 0:1
Have restarted fuse, of course - still same thing.

Has anyone seen anything like this before?
Am I missing some simple difference in the way these two ROMs deal with USR calls?
Could I have a dodgy version of the ROM?
Maybe I should revert to the opense version of the rom again?

Really don't know. Any and all help appreciated.
0 x

User avatar
Einar Saukas
Manic Miner
Posts: 937
Joined: Wed Nov 15, 2017 2:48 pm

Re: Simple USR call no longer working.

Post by Einar Saukas » Thu Sep 19, 2019 9:30 pm

i'm guessing you forgot to CLEAR 32999
0 x

User avatar
Seven.FFF
Manic Miner
Posts: 338
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Simple USR call no longer working.

Post by Seven.FFF » Thu Sep 19, 2019 9:36 pm

That’s a mystery. It works here with the standard 48K ROM in Fuse. I poke those four bytes starting at 33000; the debugger shows me ld bc, 0000 : ret at $80E8; I type PRINT USR 33000 from the BASIC prompt; 0 is displayed on the upper screen.

You should do Einar’s CLEAR 32999 always anyway, but unless you have a very large BASIC program or variable declarations resident, 33000 is quite out of the way for a simple test like this from power on.
0 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Alessandro
Manic Miner
Posts: 490
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Simple USR call no longer working.

Post by Alessandro » Thu Sep 19, 2019 11:05 pm

I tried doing the same just by entering the four POKE instructions one by one, and as Seven wrote, 33000 is high enough in the RAM to avoid trouble with such a small code. CLEAR 32999 can be safely omitted in this case, then.

However, my test was made under Windows 10, with the Fuse 1.5.7 Windows port, which includes the ROM files in a "roms" subdirectory. I'd suggest you, first of all, to download the most recent version of Fuse from http://fuse-emulator.sourceforge.net because the version you are using is way outdated. Then, if nothing changes, download the Windows port (the ZIP archive, not the installing executable) and substitute your ROM files with those present there, and see what happens.
1 x

User avatar
1024MAK
Manic Miner
Posts: 511
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Simple USR call no longer working.

Post by 1024MAK » Thu Sep 19, 2019 11:47 pm

Are you entering USR as individual letters, or as a ‘keyword’ by going to extended entry mode and pressing the L key?

Mark
3 x

ch0maru
Berk
Posts: 2
Joined: Thu Sep 19, 2019 8:45 pm

Re: Simple USR call no longer working.

Post by ch0maru » Fri Sep 20, 2019 11:51 am

1024MAK wrote:
Thu Sep 19, 2019 11:47 pm
Are you entering USR as individual letters, or as a ‘keyword’ by going to extended entry mode and pressing the L key?
Yes!

That's what it was. The previous rom I'd been using didn't have a keyword mode, so I was just typing away as usual... :?

Thanks.


ch0m
1 x

User avatar
1024MAK
Manic Miner
Posts: 511
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Simple USR call no longer working.

Post by 1024MAK » Fri Sep 20, 2019 12:03 pm

ch0maru wrote:
Fri Sep 20, 2019 11:51 am
1024MAK wrote:
Thu Sep 19, 2019 11:47 pm
Are you entering USR as individual letters, or as a ‘keyword’ by going to extended entry mode and pressing the L key?
Yes!

That's what it was. The previous rom I'd been using didn't have a keyword mode, so I was just typing away as usual... :?

Thanks.


ch0m
Being able to type individual characters is a feature of a number of ‘third party’ ZX Spectrum replacement BASIC ROMs, like opense. This ROM is supplied with Fuse because of its copyright status.

Have fun :D

Mark
0 x

Post Reply