It is currently Mon Oct 20, 2014 4:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: SWR storage
PostPosted: Fri Jan 01, 2010 4:25 pm 
Offline
 Profile

Joined: Mon Jul 07, 2008 6:58 pm
Posts: 64
Hi all,

Happy New Year!
Hope you all still have your fingers and hands after the fire work ;)

At the moment I'm busy with an ADFS disc catalogue system. (to browse, copy, move files etc.), all written in Basic.
With a Beebug util, I can convert the Basic application to a SWR image so that it can be run using a * command and no disc is needed to load it.
This all works fine, but to make the program totally in depended from a disk system I would like to use the SWR also to store some application settings as well.

I have discovered that I can use the *SRDATA command to make one SWR ROM available to store data. But then I need 2 SWR sockets. One for the application and one for the the data that can be used by the application.
Is it possible to combine these 2 into to one SWR socket?
So that I load the application into one SWR socket. And use the remaining space of the same socket to store some settings? (like txt strings etc)

Cheers

Koen


Top
 
 Post subject: Re: SWR storage
PostPosted: Sat Jan 02, 2010 6:47 pm 
Offline
User avatar
 Profile

Joined: Sun Jun 28, 2009 11:37 pm
Posts: 55
Happy New Year to you too!

Is it the RomIt utility that you're using?

My understanding is that it stores programs in the ROM Filing System format. If you only need to read some settings from the ROM, you could create a data file from BASIC, add the file to the ROM using RomIt, and then simply read it in from your program with the usual commands: OPENIN, BGET etc.

If you want to read and write data in a sideways RAM that's possible, but more difficult. You would need a small assembly language routine to switch out the BASIC ROM to get access to the RAM (it can be done with the *SRREAD and *SRWRITE commands but they are only available as standard on Master machines). I would recommend copying sections of the data between SWRAM and main memory, then using BASIC's indirection operators (? ! and $) to access the data there.

Hope this helps. If you need more details just ask.


Top
 
 Post subject: Re: SWR storage
PostPosted: Sat Jan 02, 2010 10:28 pm 
Offline
 Profile

Joined: Mon Jul 07, 2008 6:58 pm
Posts: 64
Evening,

Indeed RomIt does, in a way, the same as the util I found in a Beebug magazine. (and RomIt does more)

Indeed I have to read and write into SWR. In Beebug Vol.6 nr.6 I found a util that gives the possibility to read and write in a ROM. But when I have a program in ROM 1 then the method of Beebug needs a 2nd ROM to read and write data.
And what I hope for is a way to keep it to 1 ROM.

Cheers

Koen


Top
 
 Post subject: Re: SWR storage
PostPosted: Sat Jan 02, 2010 11:49 pm 
Offline
User avatar
 Profile

Joined: Sun Jun 28, 2009 11:37 pm
Posts: 55
Okay, here's how it can be done.

Assuming the following to make it easier to explain:
- You are using a BBC Master
- The program is loaded into SW RAM bank 4
- The program only uses the first half of the ROM (&8000-&8FFF)
- leaving the second half of the ROM (&9000-&9FFF) free for data

Lets say you have some data, two numbers and a string up to 20 characters. Each number uses 4 bytes so that makes a total size of 28 bytes. First, we create the data in a buffer in main memory (I'm using the tape buffer at &A00 here as an example):

Code:
buffer=&A00
buffer!0=123
buffer!4=456
$(buffer+8)="Example"

Next, to store it away, we copy this memory to SW RAM bank 4 at a free location. The command to do this is

*SRWRITE <start> +<length> <sram-start> <sram-bank>

which can be done in a program like this:

Code:
SWRbank=4
SWRdata=&9000
size=28
OSCLI "SRWRITE "+STR$~buffer+" +"+STR$~size+" "+STR$~SWRdata+" "+STR$SWRbank

This will write 'size' bytes of data from the buffer to the SW RAM data area.

To read the information back, just reverse the process. First copy the data from SW RAM to the buffer:

Code:
size=28
OSCLI "SRREAD "+STR$~buffer+" +"+STR$~size+" "+STR$~SWRdata+" "+STR$SWRbank

Then you can access the data from the buffer with the indirection operators:

Code:
PRINT buffer!0
PRINT buffer!4
PRINT $(buffer+8)

To make things easier you could create procedures to do the memory transfer:

Code:
DEFPROCSWRaccess(mode$,buffer,size,SWRaddr)
OSCLI "SR"+mode$+" "+STR$~buffer+" +"+STR$~size+" "+STR$~SWRaddr+" "+STR$SWRbank
ENDPROC
DEFPROCSWRwrite(buffer,size,SWRaddr)
PROCSWRaccess("WRITE",buffer,size,SWRaddr)
ENDPROC
DEFPROCSWRread(buffer,size,SWRaddr)
PROCSWRaccess("READ",buffer,size,SWRaddr)
ENDPROC

Then you can just do something like:

Code:
PROCSWRread(buffer,50,SWRdata+100)

to read 50 bytes from the 100th position in the SW RAM data. A similar PROCSWRwrite call would write it back again.

Using the tape buffer allows you to work on up to 256 bytes at a time. If you need a larger buffer it will have to be allocated from BASIC memory, e.g:

DIM buffer 1000


Top
 
 Post subject: Re: SWR storage
PostPosted: Sun Jan 03, 2010 7:54 pm 
Offline
 Profile

Joined: Mon Jul 07, 2008 6:58 pm
Posts: 64
This is really helpful!
And sounds even for a simple mind for me understandable :)

I'll have a look and try. This may take a view days, but I'll manage :) (or bother you :D )

Thanks a lot

Cheers

Koen


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron