simplifying_20arithmetic_20using_20strings
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
simplifying_20arithmetic_20using_20strings [2018/03/31 13:19] – external edit 127.0.0.1 | simplifying_20arithmetic_20using_20strings [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 9: | Line 9: | ||
| 11\\ | text top line\\ | 32\\ | text top line\\ | | | 11\\ | text top line\\ | 32\\ | text top line\\ | | ||
\\ I didn't want to go through the whole program changing every reference, it was easier and safer to build a veneer function to convert Acorn VDU offsets into BBFW VDU offsets.\\ \\ If you subtract two from the Acorn offset and then multiply by four you get the same range of BBFW offsets, but in a different order. The difficulty was trying to build a formula to get them in the right order.\\ \\ Looking at the bottom two bits, it needs to convert 0, 1, 2, 3 to 0, 3, 1, 2. I found the easiest way to do that was as follows: | \\ I didn't want to go through the whole program changing every reference, it was easier and safer to build a veneer function to convert Acorn VDU offsets into BBFW VDU offsets.\\ \\ If you subtract two from the Acorn offset and then multiply by four you get the same range of BBFW offsets, but in a different order. The difficulty was trying to build a formula to get them in the right order.\\ \\ Looking at the bottom two bits, it needs to convert 0, 1, 2, 3 to 0, 3, 1, 2. I found the easiest way to do that was as follows: | ||
+ | <code bb4w> | ||
m=24+4*VALMID$(" | m=24+4*VALMID$(" | ||
+ | </ | ||
This changes 8, 9, 10, 11 to 24, 36, 28, 32. Taking account of @vdu% values being in pixels, not characters, this allowed me to write the following veneer function: | This changes 8, 9, 10, 11 to 24, 36, 28, 32. Taking account of @vdu% values being in pixels, not characters, this allowed me to write the following veneer function: | ||
+ | <code bb4w> | ||
DEF FNvdu(n) | DEF FNvdu(n) | ||
IF (bbfw) THEN | IF (bbfw) THEN | ||
Line 16: | Line 19: | ||
ENDIF | ENDIF | ||
=VDU n | =VDU n | ||
+ | </ | ||
where bbfw is a variable in the program that indicates that it is running on BBC BASIC for Windows.\\ \\ //Richard Russell, May 2009// | where bbfw is a variable in the program that indicates that it is running on BBC BASIC for Windows.\\ \\ //Richard Russell, May 2009// | ||
+ | <code bb4w> | ||
DEF FNvdu(n) | DEF FNvdu(n) | ||
CASE bbfw AND n OF | CASE bbfw AND n OF | ||
Line 25: | Line 30: | ||
ENDCASE | ENDCASE | ||
= VDU n | = VDU n | ||
+ | </ | ||
This code relies on **bbfw** being a Boolean (i.e. having the value 0 or -1).\\ \\ | This code relies on **bbfw** being a Boolean (i.e. having the value 0 or -1).\\ \\ | ||
===== See also ===== | ===== See also ===== | ||
[[/ | [[/ |
simplifying_20arithmetic_20using_20strings.1522502382.txt.gz · Last modified: 2024/01/05 00:16 (external edit)