nneonneo 1 hour ago

Hmm, based on the (handwritten!) notes on Table F-2 in http://bitsavers.informatik.uni-stuttgart.de/pdf/exidy/DP500..., it looks like pressing Graphic+key would allow you to enter BASIC tokens from 0x80 to 0xBF, while pressing Graphic+Shift+key would allow you to access 0xC0 to 0xC6. By inference, it seems like Graphic+Shift+key should allow access to the entire 0xC0 to 0xFF space, but most of those keys are undocumented.

Based on this, I wonder if it's worth trying the following:

    10 REM [Graphic+Shift+=] [_] [(] [Graphic+Shift+NumpadPlus] [2] [Graphic+Shift+NumpadEquals] [Graphic+Shift+Numpad6] [Graphic+Shift+0]

Note that you'll probably need an emulator with accurate keyboard emulation - or a real device - in order to type these in. However, with the emulator from http://www.liaquay.co.uk/sorcerer, I was able to confirm that Graphic+Shift+0 produced 201 (rendered as F4), and Graphic+Shift+= produced 255 (rendered as S), so I think this approach will work.

  • nneonneo 1 hour ago

    Bonus: Here's what all of the tokens >= 0x80 render as, including the corrupt ones:

      128 0x80 b'END'
      129 0x81 b'FOR'
      130 0x82 b'NEXT'
      131 0x83 b'DATA'
      132 0x84 b'BYE'
      133 0x85 b'INPUT'
      134 0x86 b'DIM'
      135 0x87 b'READ'
      136 0x88 b'LET'
      137 0x89 b'GOTO'
      138 0x8a b'RUN'
      139 0x8b b'IF'
      140 0x8c b'RESTORE'
      141 0x8d b'GOSUB'
      142 0x8e b'RETURN'
      143 0x8f b'REM'
      144 0x90 b'STOP'
      145 0x91 b'OUT'
      146 0x92 b'ON'
      147 0x93 b'NULL'
      148 0x94 b'WAIT'
      149 0x95 b'DEF'
      150 0x96 b'POKE'
      151 0x97 b'PRINT'
      152 0x98 b'CONT'
      153 0x99 b'LIST'
      154 0x9a b'CLEAR'
      155 0x9b b'CLOAD'
      156 0x9c b'CSAVE'
      157 0x9d b'NEW'
      158 0x9e b'TAB('
      159 0x9f b'TO'
      160 0xa0 b'FN'
      161 0xa1 b'SPC('
      162 0xa2 b'THEN'
      163 0xa3 b'NOT'
      164 0xa4 b'STEP'
      165 0xa5 b'+'
      166 0xa6 b'-'
      167 0xa7 b'*'
      168 0xa8 b'/'
      169 0xa9 b'^'
      170 0xaa b'AND'
      171 0xab b'OR'
      172 0xac b'>'
      173 0xad b'='
      174 0xae b'<'
      175 0xaf b'SGN'
      176 0xb0 b'INT'
      177 0xb1 b'ABS'
      178 0xb2 b'USR'
      179 0xb3 b'FRE'
      180 0xb4 b'INP'
      181 0xb5 b'POS'
      182 0xb6 b'SQR'
      183 0xb7 b'RND'
      184 0xb8 b'LOG'
      185 0xb9 b'EXP'
      186 0xba b'COS'
      187 0xbb b'SIN'
      188 0xbc b'TAN'
      189 0xbd b'ATN'
      190 0xbe b'PEEK'
      191 0xbf b'LEN'
      192 0xc0 b'STR$'
      193 0xc1 b'VAL'
      194 0xc2 b'ASC'
      195 0xc3 b'CHR$'
      196 0xc4 b'LEFT$'
      197 0xc5 b'RIGHT$'
      198 0xc6 b'MID$'
      199 0xc7 b'\x00\t'
      200 0xc8 b'G.'
      201 0xc9 b'F4'
      202 0xca b'K'
      203 0xcb b'5'
      204 0xcc b'H\x03'
      205 0xcd b'`C'
      206 0xce b'JO'
      207 0xcf b'Mr'
      208 0xd0 b'J'
      209 0xd1 b'L'
      210 0xd2 b'Hr'
      211 0xd3 b'HU'
      212 0xd4 b'HD'
      213 0xd5 b'I'
      214 0xd6 b']'
      215 0xd7 b'Fa'
      216 0xd8 b'H'
      217 0xd9 b'\x10'
      218 0xda b'H'
      219 0xdb b'7'
      220 0xdc b'H\x07'
      221 0xdd b'GV'
      222 0xde b'R&'
      223 0xdf b'IH'
      224 0xe0 b'G\\'
      225 0xe1 b'R\x1f'
      226 0xe2 b'O\x05'
      227 0xe3 b'Wh'
      228 0xe4 b'I5'
      229 0xe5 b'G'
      230 0xe6 b'F'
      231 0xe7 b'E\x0f'
      232 0xe8 b'HA'
      233 0xe9 b'S'
      234 0xea b'I'
      235 0xeb b'R\x1a'
      236 0xec b'Dy'
      237 0xed b'"'
      238 0xee b'Wy'
      239 0xef b'*'
      240 0xf0 b'S|'
      241 0xf1 b'j'
      242 0xf2 b'T|K'
      243 0xf3 b'U\x7f'
      244 0xf4 b'C'
      245 0xf5 b'XP'
      246 0xf6 b'('
      247 0xf7 b'LF'
      248 0xf8 b"'"
      249 0xf9 b'LNFSNRGODFCOVOMULBSDD/0IDTMOSLSSTCNUFMO'
      250 0xfa b'Ck'
      251 0xfb b'@'
      252 0xfc b'C'
      253 0xfd b'e'
      254 0xfe b'G'
      255 0xff b'S\x00'
    

    This is based on a simple decoding of the token table starting at 0xf6 in the BASIC ROM; it matches the observed output for 201, 247, 252, and 255 so I expect that it is generally correct. Indeed, with `10 REMX; POKE 474, 249; LIST` in the emulator, I get `10 REMLNFSNRGODFCOVOMULBSDD/0IDTMOSLSSTCNUFMO` printed out, which further confirms this decoding.

urbandw311er 33 minutes ago

I remember that my ZX Spectrum 48k came with a big orange book of BASIC programs to type in.

One of which was some sort of mystical “reflect on the runes” program that printed ancient symbols to contemplate. It had a written comment in the docs that it would self destruct after three attempts “to guard against frivolous use”. And, sure enough, if you typed it in without understanding it - there was the BASIC command that soft reset your computer on the third iteration! I can’t remember that command now - RANDOMIZE USR 0 perhaps? Happy days.

JSR_FDED 1 hour ago

See this is why I never understood LISP people proudly proclaiming that “code is data and data is code”… we were doing this in BASIC for decades already!

  • skydhash 1 hour ago

    “code is data and data is code” is a fact of computing. What LISP does is to make it an official feature of the language and provide nice abstraction for it. A lot of languages want you to use some cumbersome reflection library, a dangerous eval function, or a crippled macro mechanism. With LISP, you just use the language mechanism in order to write code that process code.

    • advisedwang 31 minutes ago

      > “code is data and data is code” is a fact of computing

      The general purpose computers we have today all follow that principal, yes. However it's not a fundamental fact of computing. Turing machines, cellular automata provide other paradigms. And if those aren't practical enough for you, ASIC programming is Turing complete but cannot access its code as data.

  • eichin 1 hour ago

    BASIC is older than most people realize, but it's still half a decade younger than Lisp.

  • bitwize 59 minutes ago

    The thing is in Lisp, data with a nice structure that you can easily work with is evaluatable as code; and all the code that runs has a nice structure and is easy to work with! You cannot easily manipulate and transform BASIC programs from within BASIC, and you cannot easily do anything in machine code.

    But maybe this is part of what Gerald Sussman was talking about when he called Lisp a "low level language": like machine code, Lisp has the nice property that its default data representation is used for building directly executable programs.

summa_tech 2 hours ago

It always feels a bit like lost magic. But at the same time, it's also something that was only enabled by the very high determinism of these old home systems. The design relies on having fixed RAM locations, no multiprocessing, etc.

Incredible to find out that typing the paper program would not have worked, though. And in such a disappointing way no less.

  • reaperducer 2 hours ago

    It always feels a bit like lost magic.

    I sometimes wonder if there is still a lot of that magic in the tech world, but were so used to having everything abstracted away from us in multiple layers that we've lost the ability to look for it.

    I think about the TLA hackers who do seemingly impossible things. Surely they must operate on this level.

    • summa_tech 1 hour ago

      It certainly tarnishes the shine to have a per-OS-version table of offsets to patch ;(

    • NetMageSCW 1 hour ago

      Because I started in that era, I sometimes think that’s why I was motivated to learn synthetic programming for the HP 41, write the first disassembler for the HP 48SX’s ROM, why I wrote jailbreak software on the iPhone before the App Store existed. Tiny limited environments most resemble where I first coded.

NetMageSCW 1 hour ago

This makes me sad about the history that has been forgotten. I never used a Sorcerer but I knew what the code was for at a glance.

urbandw311er 40 minutes ago

This was fascinating and a most enjoyable read - thank you for writing it all down!

deater 1 hour ago

back when the Apple II / Applesoft BASIC twitter bot was a thing similar techniques were the best way to inject assembly language into a BASIC program, though we quickly learned there were more compact ways than REM to get a line ignored.

Some examples here, as sadly the apple2twitter bot shut down and deleted their account a while ago.

http://deater.net/weave/vmwprod/appleiibot/part7.html

aa-jv 3 hours ago

The Oric Atmos won the 10-line BASIC Programming Competition in 2022 with a 1000-room dungeon crawler named "SNAKE TEMPLE":

https://bunsen.itch.io/the-snake-temple-by-rax

IN 10 LINES OF BASIC!!

I thought it was cute that it used the RND() function to seed things necessary to generate each room .. so I used that technique in my own Oric game, which generates a large blob of graphics data using the RND() seed, meaning I don't have to ship that data in the program itself. I find the pseudo-ness of the RNG infinitely resourceful in that regard ..

Another cute trick on the Oric Atmos is to seed the 14 registers of its synth chip with ROM data .. meaning the Oric Atmos has literally THOUSANDS of onboard sound presets to choose from - once you find them, of course. So I wrote a program to find the most interesting ones and have been accruing a list of "synth presets" that come onboard with the Oric, for use in my game.

Its quite rewarding to go back to these machines and use such techniques to generate nearly-infinite levels/sounds/etc.

  • ErroneousBosh 2 hours ago

    > I find the pseudo-ness of the RNG infinitely resourceful in that regard

    I can't remember how the ORIC BASIC does it but a cool property of LFSRs as PRNGs is that if you pick the right taps and length they must cycle through every possible number from 1 to (2^length)-1 exactly once, excluding zero. That's how the Wolfenstein "Fizzle Fade" effect worked - set up an LFSR long enough that every possible pixel can be visited once, with a few left over, and then throw away any that don't fit.

ErroneousBosh 2 hours ago

This is exactly how we used to do machine code on the Sinclair ZX81, too, where there was no way to declare a block of memory as "off limits" to BASIC, and no DATA statements like in the later (and much bigger) ZX Spectrum BASIC.

Then you'd do "RANDOMISE USR 16514" to start it. Actually USR was interesting because it would pass back the contents of BC when your machine code routine returned to BASIC.

  • rwmj 2 hours ago

    I managed to get that easter egg into libvirt - it listens on ports 16509 and 16514 (https://libvirt.org/remote.html).

    • alfiedotwtf 1 hour ago

      Sorry, I’m lost after looking at that page. Can you explain your comment?

      • rwmj 55 minutes ago

        Libvirt listens on ports 16509 and 16514 out of the box, in reference to ZX81 BASIC where the program starts at (address) 16509 and the first byte in a REM statement (commonly used to store machine code) is 16514.

classified 2 hours ago

Those were the times when programming a computer was an adventure in and of itself, bastardizing BASIC with assembler. Doubtlessly the first Make Your Own Adventure setting!