Home » Personal collection » Acorn ADFS disks » Greaseweazled » adfs_EUG_55.adf » V/+BRR3

V/+BRR3

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Greaseweazled » adfs_EUG_55.adf
Filename: V/+BRR3
Read OK:
File size: 0925 bytes
Load address: 2B204556
Exec address: 33525242
Duplicates

There are 3 duplicate copies of this file in the archive:

File contents
             [ BASIC ROM ROUTINES ARTICLE - CONTINUATION ]

6.      Routine: Convert number in IWA to ASCII decimal or hexadecimal
        Basic 2: &9EFF
        Basic 4: &A138

        Entry: IWA should contain number to be converted
               location &15 = &FF for hexadecimal ASCII
               or       &15 = 0   for decimal ASCII

The previous routine only allowed 16-bit numbers (numbers in the range
0-65535) to be printed. This routine helps you print 32-bit numbers in
decimal or hex. When we speak of "hexadecimal" or "decimal ASCII", it
means that a string containing ASCII codes is made for the given number.
For example, the four ASCII decimal codes for &9EFF are 57, 69, 70, and
70 (ignoring the ampersand which Basic doesn't print anyway). Basic puts
these ASCII codes into the String Work Area, or SWA for short. We can 
then use another routine to print out the contents of the SWA:

7.      Routine: Print the SWA
        Basic 2: &8E12
        Basic 4: &921B

        Entry: location &30 must contain the length of the string
               the SWA must contain the string
               location &A must = 0.

        Ex.:    LDX #&50  \copy integer at &50-3
                JSR &AF56  \to SWA
                LDA #&FF:STA &15  \number to be in hex
                JSR &9EFF  \convert IWA to ASCII codes  
                LDA #0:STA &A
                JMP &8E12  \and print the number 

8.      Routine: Random number generator
        Basic 2: &AF51
        Basic 4: &AA7B
        
        No entry requirements. On exit, the IWA contains a 4-byte random
        integer.

        Ex.:    JSR &AF51
                LDA &2A
                JSR alien

I find this Rom routine extremely useful for getting random numbers in
games, and it's the only decent way of getting fairly unpredictable 
numbers in machine code.
 
Conclusion
IF you use any of the above routines, don't forget to use the correct
address for your version of Basic. Now that you've seen what the Basic
Rom can do, hopefully you'll want to start exploring other parts. If you
find anything useful, do write in and let us know!
                                                    Christopher Dewhurst
                                                      24 September, 2000
                                                                 EUG #55
00000000  20 20 20 20 20 20 20 20  20 20 20 20 20 5b 20 42  |             [ B|
00000010  41 53 49 43 20 52 4f 4d  20 52 4f 55 54 49 4e 45  |ASIC ROM ROUTINE|
00000020  53 20 41 52 54 49 43 4c  45 20 2d 20 43 4f 4e 54  |S ARTICLE - CONT|
00000030  49 4e 55 41 54 49 4f 4e  20 5d 0d 0d 36 2e 20 20  |INUATION ]..6.  |
00000040  20 20 20 20 52 6f 75 74  69 6e 65 3a 20 43 6f 6e  |    Routine: Con|
00000050  76 65 72 74 20 6e 75 6d  62 65 72 20 69 6e 20 49  |vert number in I|
00000060  57 41 20 74 6f 20 41 53  43 49 49 20 64 65 63 69  |WA to ASCII deci|
00000070  6d 61 6c 20 6f 72 20 68  65 78 61 64 65 63 69 6d  |mal or hexadecim|
00000080  61 6c 0d 20 20 20 20 20  20 20 20 42 61 73 69 63  |al.        Basic|
00000090  20 32 3a 20 26 39 45 46  46 0d 20 20 20 20 20 20  | 2: &9EFF.      |
000000a0  20 20 42 61 73 69 63 20  34 3a 20 26 41 31 33 38  |  Basic 4: &A138|
000000b0  0d 0d 20 20 20 20 20 20  20 20 45 6e 74 72 79 3a  |..        Entry:|
000000c0  20 49 57 41 20 73 68 6f  75 6c 64 20 63 6f 6e 74  | IWA should cont|
000000d0  61 69 6e 20 6e 75 6d 62  65 72 20 74 6f 20 62 65  |ain number to be|
000000e0  20 63 6f 6e 76 65 72 74  65 64 0d 20 20 20 20 20  | converted.     |
000000f0  20 20 20 20 20 20 20 20  20 20 6c 6f 63 61 74 69  |          locati|
00000100  6f 6e 20 26 31 35 20 3d  20 26 46 46 20 66 6f 72  |on &15 = &FF for|
00000110  20 68 65 78 61 64 65 63  69 6d 61 6c 20 41 53 43  | hexadecimal ASC|
00000120  49 49 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |II.             |
00000130  20 20 6f 72 20 20 20 20  20 20 20 26 31 35 20 3d  |  or       &15 =|
00000140  20 30 20 20 20 66 6f 72  20 64 65 63 69 6d 61 6c  | 0   for decimal|
00000150  20 41 53 43 49 49 0d 0d  54 68 65 20 70 72 65 76  | ASCII..The prev|
00000160  69 6f 75 73 20 72 6f 75  74 69 6e 65 20 6f 6e 6c  |ious routine onl|
00000170  79 20 61 6c 6c 6f 77 65  64 20 31 36 2d 62 69 74  |y allowed 16-bit|
00000180  20 6e 75 6d 62 65 72 73  20 28 6e 75 6d 62 65 72  | numbers (number|
00000190  73 20 69 6e 20 74 68 65  20 72 61 6e 67 65 0d 30  |s in the range.0|
000001a0  2d 36 35 35 33 35 29 20  74 6f 20 62 65 20 70 72  |-65535) to be pr|
000001b0  69 6e 74 65 64 2e 20 54  68 69 73 20 72 6f 75 74  |inted. This rout|
000001c0  69 6e 65 20 68 65 6c 70  73 20 79 6f 75 20 70 72  |ine helps you pr|
000001d0  69 6e 74 20 33 32 2d 62  69 74 20 6e 75 6d 62 65  |int 32-bit numbe|
000001e0  72 73 20 69 6e 0d 64 65  63 69 6d 61 6c 20 6f 72  |rs in.decimal or|
000001f0  20 68 65 78 2e 20 57 68  65 6e 20 77 65 20 73 70  | hex. When we sp|
00000200  65 61 6b 20 6f 66 20 22  68 65 78 61 64 65 63 69  |eak of "hexadeci|
00000210  6d 61 6c 22 20 6f 72 20  22 64 65 63 69 6d 61 6c  |mal" or "decimal|
00000220  20 41 53 43 49 49 22 2c  20 69 74 0d 6d 65 61 6e  | ASCII", it.mean|
00000230  73 20 74 68 61 74 20 61  20 73 74 72 69 6e 67 20  |s that a string |
00000240  63 6f 6e 74 61 69 6e 69  6e 67 20 41 53 43 49 49  |containing ASCII|
00000250  20 63 6f 64 65 73 20 69  73 20 6d 61 64 65 20 66  | codes is made f|
00000260  6f 72 20 74 68 65 20 67  69 76 65 6e 20 6e 75 6d  |or the given num|
00000270  62 65 72 2e 0d 46 6f 72  20 65 78 61 6d 70 6c 65  |ber..For example|
00000280  2c 20 74 68 65 20 66 6f  75 72 20 41 53 43 49 49  |, the four ASCII|
00000290  20 64 65 63 69 6d 61 6c  20 63 6f 64 65 73 20 66  | decimal codes f|
000002a0  6f 72 20 26 39 45 46 46  20 61 72 65 20 35 37 2c  |or &9EFF are 57,|
000002b0  20 36 39 2c 20 37 30 2c  20 61 6e 64 0d 37 30 20  | 69, 70, and.70 |
000002c0  28 69 67 6e 6f 72 69 6e  67 20 74 68 65 20 61 6d  |(ignoring the am|
000002d0  70 65 72 73 61 6e 64 20  77 68 69 63 68 20 42 61  |persand which Ba|
000002e0  73 69 63 20 64 6f 65 73  6e 27 74 20 70 72 69 6e  |sic doesn't prin|
000002f0  74 20 61 6e 79 77 61 79  29 2e 20 42 61 73 69 63  |t anyway). Basic|
00000300  20 70 75 74 73 0d 74 68  65 73 65 20 41 53 43 49  | puts.these ASCI|
00000310  49 20 63 6f 64 65 73 20  69 6e 74 6f 20 74 68 65  |I codes into the|
00000320  20 53 74 72 69 6e 67 20  57 6f 72 6b 20 41 72 65  | String Work Are|
00000330  61 2c 20 6f 72 20 53 57  41 20 66 6f 72 20 73 68  |a, or SWA for sh|
00000340  6f 72 74 2e 20 57 65 20  63 61 6e 20 0d 74 68 65  |ort. We can .the|
00000350  6e 20 75 73 65 20 61 6e  6f 74 68 65 72 20 72 6f  |n use another ro|
00000360  75 74 69 6e 65 20 74 6f  20 70 72 69 6e 74 20 6f  |utine to print o|
00000370  75 74 20 74 68 65 20 63  6f 6e 74 65 6e 74 73 20  |ut the contents |
00000380  6f 66 20 74 68 65 20 53  57 41 3a 0d 0d 37 2e 20  |of the SWA:..7. |
00000390  20 20 20 20 20 52 6f 75  74 69 6e 65 3a 20 50 72  |     Routine: Pr|
000003a0  69 6e 74 20 74 68 65 20  53 57 41 0d 20 20 20 20  |int the SWA.    |
000003b0  20 20 20 20 42 61 73 69  63 20 32 3a 20 26 38 45  |    Basic 2: &8E|
000003c0  31 32 0d 20 20 20 20 20  20 20 20 42 61 73 69 63  |12.        Basic|
000003d0  20 34 3a 20 26 39 32 31  42 0d 0d 20 20 20 20 20  | 4: &921B..     |
000003e0  20 20 20 45 6e 74 72 79  3a 20 6c 6f 63 61 74 69  |   Entry: locati|
000003f0  6f 6e 20 26 33 30 20 6d  75 73 74 20 63 6f 6e 74  |on &30 must cont|
00000400  61 69 6e 20 74 68 65 20  6c 65 6e 67 74 68 20 6f  |ain the length o|
00000410  66 20 74 68 65 20 73 74  72 69 6e 67 0d 20 20 20  |f the string.   |
00000420  20 20 20 20 20 20 20 20  20 20 20 20 74 68 65 20  |            the |
00000430  53 57 41 20 6d 75 73 74  20 63 6f 6e 74 61 69 6e  |SWA must contain|
00000440  20 74 68 65 20 73 74 72  69 6e 67 0d 20 20 20 20  | the string.    |
00000450  20 20 20 20 20 20 20 20  20 20 20 6c 6f 63 61 74  |           locat|
00000460  69 6f 6e 20 26 41 20 6d  75 73 74 20 3d 20 30 2e  |ion &A must = 0.|
00000470  0d 0d 20 20 20 20 20 20  20 20 45 78 2e 3a 20 20  |..        Ex.:  |
00000480  20 20 4c 44 58 20 23 26  35 30 20 20 5c 63 6f 70  |  LDX #&50  \cop|
00000490  79 20 69 6e 74 65 67 65  72 20 61 74 20 26 35 30  |y integer at &50|
000004a0  2d 33 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |-3.             |
000004b0  20 20 20 4a 53 52 20 26  41 46 35 36 20 20 5c 74  |   JSR &AF56  \t|
000004c0  6f 20 53 57 41 0d 20 20  20 20 20 20 20 20 20 20  |o SWA.          |
000004d0  20 20 20 20 20 20 4c 44  41 20 23 26 46 46 3a 53  |      LDA #&FF:S|
000004e0  54 41 20 26 31 35 20 20  5c 6e 75 6d 62 65 72 20  |TA &15  \number |
000004f0  74 6f 20 62 65 20 69 6e  20 68 65 78 0d 20 20 20  |to be in hex.   |
00000500  20 20 20 20 20 20 20 20  20 20 20 20 20 4a 53 52  |             JSR|
00000510  20 26 39 45 46 46 20 20  5c 63 6f 6e 76 65 72 74  | &9EFF  \convert|
00000520  20 49 57 41 20 74 6f 20  41 53 43 49 49 20 63 6f  | IWA to ASCII co|
00000530  64 65 73 20 20 0d 20 20  20 20 20 20 20 20 20 20  |des  .          |
00000540  20 20 20 20 20 20 4c 44  41 20 23 30 3a 53 54 41  |      LDA #0:STA|
00000550  20 26 41 0d 20 20 20 20  20 20 20 20 20 20 20 20  | &A.            |
00000560  20 20 20 20 4a 4d 50 20  26 38 45 31 32 20 20 5c  |    JMP &8E12  \|
00000570  61 6e 64 20 70 72 69 6e  74 20 74 68 65 20 6e 75  |and print the nu|
00000580  6d 62 65 72 20 0d 0d 38  2e 20 20 20 20 20 20 52  |mber ..8.      R|
00000590  6f 75 74 69 6e 65 3a 20  52 61 6e 64 6f 6d 20 6e  |outine: Random n|
000005a0  75 6d 62 65 72 20 67 65  6e 65 72 61 74 6f 72 0d  |umber generator.|
000005b0  20 20 20 20 20 20 20 20  42 61 73 69 63 20 32 3a  |        Basic 2:|
000005c0  20 26 41 46 35 31 0d 20  20 20 20 20 20 20 20 42  | &AF51.        B|
000005d0  61 73 69 63 20 34 3a 20  26 41 41 37 42 0d 20 20  |asic 4: &AA7B.  |
000005e0  20 20 20 20 20 20 0d 20  20 20 20 20 20 20 20 4e  |      .        N|
000005f0  6f 20 65 6e 74 72 79 20  72 65 71 75 69 72 65 6d  |o entry requirem|
00000600  65 6e 74 73 2e 20 4f 6e  20 65 78 69 74 2c 20 74  |ents. On exit, t|
00000610  68 65 20 49 57 41 20 63  6f 6e 74 61 69 6e 73 20  |he IWA contains |
00000620  61 20 34 2d 62 79 74 65  20 72 61 6e 64 6f 6d 0d  |a 4-byte random.|
00000630  20 20 20 20 20 20 20 20  69 6e 74 65 67 65 72 2e  |        integer.|
00000640  0d 0d 20 20 20 20 20 20  20 20 45 78 2e 3a 20 20  |..        Ex.:  |
00000650  20 20 4a 53 52 20 26 41  46 35 31 0d 20 20 20 20  |  JSR &AF51.    |
00000660  20 20 20 20 20 20 20 20  20 20 20 20 4c 44 41 20  |            LDA |
00000670  26 32 41 0d 20 20 20 20  20 20 20 20 20 20 20 20  |&2A.            |
00000680  20 20 20 20 4a 53 52 20  61 6c 69 65 6e 0d 0d 49  |    JSR alien..I|
00000690  20 66 69 6e 64 20 74 68  69 73 20 52 6f 6d 20 72  | find this Rom r|
000006a0  6f 75 74 69 6e 65 20 65  78 74 72 65 6d 65 6c 79  |outine extremely|
000006b0  20 75 73 65 66 75 6c 20  66 6f 72 20 67 65 74 74  | useful for gett|
000006c0  69 6e 67 20 72 61 6e 64  6f 6d 20 6e 75 6d 62 65  |ing random numbe|
000006d0  72 73 20 69 6e 0d 67 61  6d 65 73 2c 20 61 6e 64  |rs in.games, and|
000006e0  20 69 74 27 73 20 74 68  65 20 6f 6e 6c 79 20 64  | it's the only d|
000006f0  65 63 65 6e 74 20 77 61  79 20 6f 66 20 67 65 74  |ecent way of get|
00000700  74 69 6e 67 20 66 61 69  72 6c 79 20 75 6e 70 72  |ting fairly unpr|
00000710  65 64 69 63 74 61 62 6c  65 20 0d 6e 75 6d 62 65  |edictable .numbe|
00000720  72 73 20 69 6e 20 6d 61  63 68 69 6e 65 20 63 6f  |rs in machine co|
00000730  64 65 2e 0d 20 0d 43 6f  6e 63 6c 75 73 69 6f 6e  |de.. .Conclusion|
00000740  0d 49 46 20 79 6f 75 20  75 73 65 20 61 6e 79 20  |.IF you use any |
00000750  6f 66 20 74 68 65 20 61  62 6f 76 65 20 72 6f 75  |of the above rou|
00000760  74 69 6e 65 73 2c 20 64  6f 6e 27 74 20 66 6f 72  |tines, don't for|
00000770  67 65 74 20 74 6f 20 75  73 65 20 74 68 65 20 63  |get to use the c|
00000780  6f 72 72 65 63 74 0d 61  64 64 72 65 73 73 20 66  |orrect.address f|
00000790  6f 72 20 79 6f 75 72 20  76 65 72 73 69 6f 6e 20  |or your version |
000007a0  6f 66 20 42 61 73 69 63  2e 20 4e 6f 77 20 74 68  |of Basic. Now th|
000007b0  61 74 20 79 6f 75 27 76  65 20 73 65 65 6e 20 77  |at you've seen w|
000007c0  68 61 74 20 74 68 65 20  42 61 73 69 63 0d 52 6f  |hat the Basic.Ro|
000007d0  6d 20 63 61 6e 20 64 6f  2c 20 68 6f 70 65 66 75  |m can do, hopefu|
000007e0  6c 6c 79 20 79 6f 75 27  6c 6c 20 77 61 6e 74 20  |lly you'll want |
000007f0  74 6f 20 73 74 61 72 74  20 65 78 70 6c 6f 72 69  |to start explori|
00000800  6e 67 20 6f 74 68 65 72  20 70 61 72 74 73 2e 20  |ng other parts. |
00000810  49 66 20 79 6f 75 0d 66  69 6e 64 20 61 6e 79 74  |If you.find anyt|
00000820  68 69 6e 67 20 75 73 65  66 75 6c 2c 20 64 6f 20  |hing useful, do |
00000830  77 72 69 74 65 20 69 6e  20 61 6e 64 20 6c 65 74  |write in and let|
00000840  20 75 73 20 6b 6e 6f 77  21 0d 20 20 20 20 20 20  | us know!.      |
00000850  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000870  20 20 20 20 20 20 20 20  20 20 20 20 20 20 43 68  |              Ch|
00000880  72 69 73 74 6f 70 68 65  72 20 44 65 77 68 75 72  |ristopher Dewhur|
00000890  73 74 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |st.             |
000008a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000008c0  20 20 20 20 20 20 20 20  20 32 34 20 53 65 70 74  |         24 Sept|
000008d0  65 6d 62 65 72 2c 20 32  30 30 30 0d 20 20 20 20  |ember, 2000.    |
000008e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000910  20 20 20 20 20 20 20 20  20 20 20 20 20 45 55 47  |             EUG|
00000920  20 23 35 35 0d                                    | #55.|
00000925
V/+BRR3.m0
V/+BRR3.m1
V/+BRR3.m2
V/+BRR3.m4
V/+BRR3.m5