Q40 - Making ROM images into LRESPR binaries

Nagging hardware related question? Post here!
User avatar
Nix
ROM Dongle
Posts: 14
Joined: Thu Oct 19, 2023 8:21 pm

Q40 - Making ROM images into LRESPR binaries

Post by Nix »

Hi guys,

I'm new to this forum and a complete noob at QL/SMS, so please bare with me.
I bought my Q40 about 20 something years ago, with a view to using it as a development machine for a software development system I was writing.
The project, despite getting to a demonstrable state and even having a meeting with Sir Clive himself, I failed to capture the interest of anyone willing to support me.

Just recently, I have decided to revive the project, this time targetting the growing microcontroller / robotics education sector. Though my intended goals include ESP32, RP2040 and RISC-V boards, I thought it might be fun (I must be mad) / useful to also include my Q40. The software system is being written to run on RTOS, so my first challenge is to get RTOS working on the bare metal of the Q40 hardware.
In order to do this, I need to create 68000 ROM images (which I have achieved). The next challenge is to create images that can be tested without having to burn EPROMS.
I know that new ROMs can be loaded into RAM and switched to LOWRAM mode, and that these images are loaded using the LRESPR function from BASIC.
From what I understand, LRESPR loads the file and then just calls the address at which is was loaded.
So, how does this work with ROM images that start with a vector table? There must be some additional code that:
1. turns off interrupts
2. copies the ROM image into the shadow RAM
3. switched the machine into LOWRAM mode
4. and finally calls a soft reset.

My question is: can I get this code anywhere? I have tried disassembling other SMS ROM images (most of which start with invalid op codes... how does that work), looking for a header block that I can strip off and attach to my ROM images.

Many thanks, Nick :-)

Oh.... and many thanks to Derek, who has already helped me a great deal via e-mail and pointed me to this forum.


User avatar
Peter
Font of All Knowledge
Posts: 2011
Joined: Sat Jan 22, 2011 8:47 am

Re: Q40 - Making ROM images into LRESPR binaries

Post by Peter »

Hi Nick!
Nix wrote: Tue Oct 31, 2023 10:03 pm The software system is being written to run on RTOS, so my first challenge is to get RTOS working on the bare metal of the Q40 hardware.
Just out of curiosity, which RTOS?
Nix wrote: Tue Oct 31, 2023 10:03 pm In order to do this, I need to create 68000 ROM images (which I have achieved).
You mean 68040 ROM images?
Nix wrote: Tue Oct 31, 2023 10:03 pm [...] My question is: can I get this code anywhere?
Look for SOFTROM on this page: https://dilwyn.qlforum.co.uk/qx0/index.html

Good luck! Peter


User avatar
Nix
ROM Dongle
Posts: 14
Joined: Thu Oct 19, 2023 8:21 pm

Re: Q40 - Making ROM images into LRESPR binaries

Post by Nix »

Peter wrote: Tue Oct 31, 2023 10:17 pm Just out of curiosity, which RTOS?
FreeRTOS
Peter wrote: Tue Oct 31, 2023 10:17 pm You mean 68040 ROM images?
Yes... trypo.
Peter wrote: Tue Oct 31, 2023 10:17 pm Look for SOFTROM on this page: https://dilwyn.qlforum.co.uk/qx0/index.html

Good luck! Peter
Thank you.


User avatar
Peter
Font of All Knowledge
Posts: 2011
Joined: Sat Jan 22, 2011 8:47 am

Re: Q40 - Making ROM images into LRESPR binaries

Post by Peter »

If you have little interest in SMSQ/E and merely want a loader, you may also want to look at this ROMable goody with FAT32 and TFTP support:
https://github.com/willsowerbutts/gogoboot

Amazing that people still code for the Q40 in 2023... even non QL stuff.


Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Q40 - Making ROM images into LRESPR binaries

Post by Derek_Stewart »

Hi,

There is no need to disassemble the SMSQ ROMS, the SMSQ/E source is freely available along with older versions of SMSQ/E.

See: https://www.wlenerz.com/smsqe/


Regards,

Derek
User avatar
Nix
ROM Dongle
Posts: 14
Joined: Thu Oct 19, 2023 8:21 pm

Re: Q40 - Making ROM images into LRESPR binaries

Post by Nix »

Derek_Stewart wrote: Tue Oct 31, 2023 11:29 pm Hi,

There is no need to disassemble the SMSQ ROMS, the SMSQ/E source is freely available along with older versions of SMSQ/E.

See: https://www.wlenerz.com/smsqe/
Yes, I know this. But, having the source does not necessarily give me immediate access to the block of code that is executed after LRESPR. The header code are not part of the ROM image, that performs the operations listed above. My thinking / hoping was that there was a few bytes of code that were prepended to the ROM image that could be simply 'cut' off the ROM files, altered for the number of bytes on the image and bolted on to the new ROM image. This, however, appears not to be the case.

I'm going to try Peter's solution of compiling this SOFTROM utility which would be much more convenient than messing around with floppies.

Cheers, Nick :-)


User avatar
Nix
ROM Dongle
Posts: 14
Joined: Thu Oct 19, 2023 8:21 pm

Re: Q40 - Making ROM images into LRESPR binaries

Post by Nix »

Peter wrote: Tue Oct 31, 2023 10:50 pm If you have little interest in SMSQ/E and merely want a loader, you may also want to look at this ROMable goody with FAT32 and TFTP support:
https://github.com/willsowerbutts/gogoboot

Amazing that people still code for the Q40 in 2023... even non QL stuff.
It's a very convenient board. The architecture is clean and simple... (ish... excluding the inherent complexities of having to be QL compatible).
680x0 has a nice instruction set and although it has been left in the dust by Intel, Intel chips are ridiculously complicated. It's only real contender is ARM and the Raspberry Pi, but bare metal coding on that platform is also complicated. You can't just poke a value into an address and have a pixel appear on the screen or have the LED turn on/off.

It's only downside, for this sort of development, is the age of the connectivity options, but for experimentation purposes, it's great.

Nick :-)


User avatar
Peter
Font of All Knowledge
Posts: 2011
Joined: Sat Jan 22, 2011 8:47 am

Re: Q40 - Making ROM images into LRESPR binaries

Post by Peter »

Nix wrote: Wed Nov 01, 2023 12:03 pm I'm going to try Peter's solution of compiling this SOFTROM utility which would be much more convenient than messing around with floppies.
No need to compile, it is ready to go.


User avatar
Peter
Font of All Knowledge
Posts: 2011
Joined: Sat Jan 22, 2011 8:47 am

Re: Q40 - Making ROM images into LRESPR binaries

Post by Peter »

Nix wrote: Wed Nov 01, 2023 12:24 pm It's only downside, for this sort of development, is the age of the connectivity options, but for experimentation purposes, it's great.
Even easier ist the Q68, with it's integrated loader. You could simply upload your 68K ROM via serial or place it as image file on a FAT32 formatted SDHC card. Quite nice to use bare metal. The keyboard, mouse, serial, ethernet and video interfaces are simple but more modern. But it's an FPGA CPU and a bit slower than 68040. And SDHC card initialization is more complicated than IDE harddisk.


User avatar
Nix
ROM Dongle
Posts: 14
Joined: Thu Oct 19, 2023 8:21 pm

Re: Q40 - Making ROM images into LRESPR binaries

Post by Nix »

Peter wrote: Wed Nov 01, 2023 4:45 pm
Nix wrote: Wed Nov 01, 2023 12:03 pm I'm going to try Peter's solution of compiling this SOFTROM utility which would be much more convenient than messing around with floppies.
No need to compile, it is ready to go.
Yes, I found the softrom_rext.
Not being familiar with the whole SMSQ/E thing, I didn't recognise the extension. It was only when I viewed the file in order to set about compiling, that I noticed it was a binary.

Aha! - LRESPR successful! Now I have to write a program to send from Linux.


Post Reply