| www.retrosoftware.co.uk http://www.retrosoftware.co.uk/forum/ |
|
| SWR storage http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=400 |
Page 1 of 1 |
| Author: | Yrrah2 [ Fri Jan 01, 2010 4:25 pm ] |
| Post subject: | SWR storage |
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 |
|
| Author: | PaulDv [ Sat Jan 02, 2010 6:47 pm ] |
| Post subject: | Re: SWR storage |
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. |
|
| Author: | Yrrah2 [ Sat Jan 02, 2010 10:28 pm ] |
| Post subject: | Re: SWR storage |
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 |
|
| Author: | PaulDv [ Sat Jan 02, 2010 11:49 pm ] |
| Post subject: | Re: SWR storage |
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 |
|
| Author: | Yrrah2 [ Sun Jan 03, 2010 7:54 pm ] |
| Post subject: | Re: SWR storage |
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 Thanks a lot Cheers Koen |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|