Тёмный

Adding Command Line-esque Parameters to C64 and C128 Programs 

8-Bit Show And Tell
Подписаться 56 тыс.
Просмотров 17 тыс.
50% 1

It's actually pretty easy to add support for command-line-style parameters to Commodore 64 and Commodore 128 programs by reading the line input buffer with some PEEKs. We examine how to do this, why this might be beneficial, and give some example code in BASIC and Assembly. We also learn a bit about how BASIC parses and interprets our code, and the internal structure of these commands and programs. And we look at the Commodore 128 feature to RUN a file from disk that further enhances the use of parameters.
Download the D64 of today's code: 8bitshowandtell.com/downloads...
To support 8-Bit Show And Tell:
Become a patron: / 8bitshowandtell
One-time donation: paypal.me/8BitShowAndTell
2nd channel: / @8-bitshowandtell247
Previous videos referenced:
"About Commodore 64 BASIC Abbreviations": • About Commodore 64 BAS...
"Cracking a Commodore 64 Game From Cassette: Livingstone, I Presume?": • Cracking a Commodore 6...
"4-Byte Commodore 64 Demo and Follow-up on 10 PRINT Orthogonal [32 bytes]": • 4-Byte Commodore 64 De...
"Using Commodore 64 BASIC SYS Parameters in Machine Language": • Using Commodore 64 BAS...
Index:
0:00 Can parameters be added to a Commodore BASIC program?
1:57 How EXAMPLE 1 works
5:42 What's the point?
7:15 Some problems
9:12 EXAMPLE 2: More Robust
10:55 BORDER: A slightly more useful example
14:28 Rhymes with Orange: a tokenization problem
16:02 Commodore 128 Mode: RUN "FILENAME"
18:30 Turbo Macro Pro: Assembly example
19:52 BASIC Header / Stub
21:13 TXTPTR / rest of code walkthrough
24:35 Modifying for border colour version
25:36 Thanks!

Наука

Опубликовано:

 

3 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 106   
@hueyiroquois3839
@hueyiroquois3839 6 месяцев назад
20:00 This probably hasn't been important for several decades, but "STA $FA" corrupts the RS-232 output buffer pointer.
@8_Bit
@8_Bit 6 месяцев назад
And now I have no idea why I used $FA/$FB instead of $FB/$FC !! Weird mistake for me to make. Good catch.
@m7hacke
@m7hacke 7 месяцев назад
The line of the day, "It's still fairly useless." I love it. After all, retro computing is for the nostalgia, not the productivity. That's what makes it fun.
@noland65
@noland65 7 месяцев назад
If we modified the RUN command in V.2.0 BASIC (C64, etc.) to behave like it does on the C128, it would be quite useful, actually. That meant, of course, making a custom ROM with resident code for the improved RUN command to load programs from disk. BTW, I had no idea of the improved RUN of the C128 (BASIC V.7.0), at all. So, thank you, Robin!
@doomtints
@doomtints 7 месяцев назад
I don't think it's useless! This opens up a lot of options, it's just way too late!
@Starchface
@Starchface 7 месяцев назад
Absolutely. Computers of today may be much faster, but they're also a lot more boring. No personality.
@m7hacke
@m7hacke 7 месяцев назад
@@Starchface Agreed. 8 and 16 bit computers had character.
@Starchface
@Starchface 7 месяцев назад
They all had their own personalities, on ROM (usually). I remember being so excited to try a new machine and learn its idiosyncrasies back in the day that my hands were shaking. If that ever happens again it will be if I've got Parkinson's!
@theuglycamel8122
@theuglycamel8122 7 месяцев назад
I've learned more from following your videos than I have in all the 35 years I've spent fooling with these things! I'm sure you've heard it before, but you could teach an entire course on 8-bit programming. Great video as always!
@joecincotta5805
@joecincotta5805 7 месяцев назад
Inspired. Nice video... Was flicking through the Loadstar disks last night and found an article by you about game development. Then here you are this morning!
@IanM-id8or
@IanM-id8or 7 месяцев назад
I love it that you had a pic of Arnie when you mentioned the Terminator. It's doubly appropriate as the Terminator runs 6502 code
@silkwesir1444
@silkwesir1444 5 месяцев назад
I'm not sure he runs that code, seems more like he's daydreaming about it...
@logiciananimal
@logiciananimal 7 месяцев назад
Neat. Works in Applesoft too, at least in the initial example's case. It occurred to me that it would work because the input buffer is in the same memory location, even!
@tedthrasher9433
@tedthrasher9433 7 месяцев назад
I was just about to try that!
@AlexEvans1
@AlexEvans1 6 месяцев назад
On the CoCo it is at address 732 (the input buffer actually starts at 733, but is tokenized starting at 732 overwriting the untokenized string).
@johnrickard8512
@johnrickard8512 7 месяцев назад
Tricks like this must be why the C64 was so loved
@DavidYoud
@DavidYoud 7 месяцев назад
A perfect way to kick off New Year's morning, thanks!
@SellamAbraham
@SellamAbraham 7 месяцев назад
That was yesterday.
@LordmonkeyTRM
@LordmonkeyTRM 7 месяцев назад
​@@SellamAbrahamit was but so was the comment
@SellamAbraham
@SellamAbraham 7 месяцев назад
Weird. This video was just posted 15 minutes ago for me. Happy new year.
@DavidYoud
@DavidYoud 7 месяцев назад
@@SellamAbraham Those that support the channel on patreon get videos just a little bit earlier (and without ads).
@ChopsticksDIYGarden
@ChopsticksDIYGarden 19 дней назад
4:57 Wow, I did not know this can be done this way. Thank you for sharing.
@klif_n
@klif_n 7 месяцев назад
Happy New Year! Thanks in advance for another year of great videos.
@weedmanwestvancouverbc9266
@weedmanwestvancouverbc9266 7 месяцев назад
GREP. Now that's a name I have not heard in a long time, a long time.
@jack002tuber
@jack002tuber 7 месяцев назад
I worked with the c64 for lots of years, and the 128 some. I NEVER knew you could load and run with RUN "program name" like that on the 128! Wow.
@p_mouse8676
@p_mouse8676 7 месяцев назад
I am kinda confused why people don't find this useful? For something simple and small, obviously, but that's not the point here. If you make any programs that are much bigger and more complex, it's just so much easier and more intuitive, when you also want to troubleshoot things for example. Especially for those who go back from years of DOS/Linux commands to these things. Great video! :)
@michaelstoliker971
@michaelstoliker971 7 месяцев назад
I could see games written to read level codes so it could jump to the level associated with the code. Many MSDOS programmers use this trick to pull multiple command line options from the command line. You could use a control character to terminate strings so that multiple options could be separated by spaces.
@scottfromderby
@scottfromderby 7 месяцев назад
Really enjoyed that :) happy new year!
@2rleif1
@2rleif1 7 месяцев назад
In the late 80's I created fake command input written in Basic to emulate MSDOS! It was to prank a work mate!
@RetroRobotRadio
@RetroRobotRadio 7 месяцев назад
I had never heard of this feature but it is very interesting and might be useful.
@jsmythib
@jsmythib 7 месяцев назад
Thats just fun :) 'Heres something neat! Lets play! lol' Cool share. All sorts of neat things we never knew.
@LeftoverBeefcake
@LeftoverBeefcake 7 месяцев назад
I like your BASIC stub since it's easier to understand and modify, say if you need to point SYS to a different memory location in a program. The stub that CBM Prg Studio generates is smaller (if I'm remembering correctly) but a little trickier to decipher in order to modify it. #HappyCommodoreNewYear
@8_Bit
@8_Bit 7 месяцев назад
I think this is my "latest generation" of BASIC stub and yeah, the aim was to make it easier to modify within the limits of Turbo Macro Pro's pseudo-ops. I think some fancier cross-assemblers have the potential to make it even more clear what each byte does.
@75slaine
@75slaine 7 месяцев назад
Oh I really enjoyed this Robin, great video. This feels like it could be useful to me at least. I find I often write little BASIC utilities to automate stuff I do regularly on my C64. I'll keep this video in mind for the next time I need to scratch an itch. Thanks Robin 👍
@NeilRoy
@NeilRoy 7 месяцев назад
Fascinating stuff. Happy New Year to you and yours. Thanks.
@fragram1976
@fragram1976 7 месяцев назад
Great first video of the year Robin! In c128 mode there's no need of any wedge software to use sd2iec. Just enter built-in monitor and type: @,cddirname to change current dir, @cd
@8_Bit
@8_Bit 7 месяцев назад
Aha, I didn't realize the C128 monitor allows @ commands. That's great, thanks. I should see if that also works in the Plus/4 monitor.
@fragram1976
@fragram1976 7 месяцев назад
I remember your video on the monitor of plus4... Very interesting! also for c128 users like me. But there are little differences. Probably you could do a video ad-hoc, mentioning sd2iec and other related stuff! ;)
@HelloKittyFanMan
@HelloKittyFanMan 7 месяцев назад
Wow, this is pretty interesting. But of course in 128 mode you'd save that feature for something more complicated, since changing the border color in direct mode is simply just a matter of using the color command.
@da5idnz
@da5idnz 7 месяцев назад
I didn't really know how to write a BASIC stub back in the day, so I'd write the first line in BASIC, then go into the MC monitor and write code after the program in memory and change the SYS code to where it should go later.
@melkiorwiseman5234
@melkiorwiseman5234 7 месяцев назад
Despite its bad reputation, the TRS-80 had one big advantage which was that the BASIC interpreter already had "hooks" in memory which were designed to allow the language to be expanded (intended for disk BASIC commands) and so anyone with some knowledge of machine code and what each "hook" did could add their own commands to the language.
@tabachanker8716
@tabachanker8716 7 месяцев назад
In your last ML example, since you use the BASIC expression parser to get your parameter, I think you can potentially use arithmetic and variables in the parameter itself. So you could write something like, RUN:3+a*8 and it would potentially work (haven't tested it though).
@MrLondonGo
@MrLondonGo 7 месяцев назад
Never knew this, so thanks to you an the Channel creator. Obvs in Linux / Unix things are case sensitive.
@donnierussellii4659
@donnierussellii4659 7 месяцев назад
At the end of the program, I think you could also poke characters into the keyboard buffer to print "RUN:" again.
@fitfogey
@fitfogey 7 месяцев назад
Good stuff Robin. Had no idea this was possible.
@damiezequel
@damiezequel 7 месяцев назад
Happy New Year Robin i like much all videos
@user-qg6lv7ch8p
@user-qg6lv7ch8p 7 месяцев назад
Interesting C64 interpreter specialty. Love it!
@willyarma_uk
@willyarma_uk 7 месяцев назад
Great video, I enjoyed that. I was thinking in the basic border colour program about allowing abbreviations and just find first match so RUN:"O" would pick orange, and "LT B" would be light blue
@PaulHockerOnEarth
@PaulHockerOnEarth 7 месяцев назад
Really cool!
@berndeckenfels
@berndeckenfels 7 месяцев назад
There must be a kernal location to expand tokens to text (used for list)
@kranser
@kranser 7 месяцев назад
Each DATA statement with the valid colour parameters could be doubled, so that 2 values are read per loop the first being the parameter in text and the second being the tokenised value - or blank if the same as the first. So that tokenised text would be recognized!
@Lion_McLionhead
@Lion_McLionhead 7 месяцев назад
For someone using an emulator, the easiest way is going to be overwriting part of the disk image with command line data before every invocation.
@8BitNaptime
@8BitNaptime 7 месяцев назад
If you type GOTO 100 in immediate mode it's interesting, it adds a 0 every time. If you put a STOP on the next line, and copy the same routine to the following lines, you can also pass a parameter to the CONT command. You can also GOSUB from immediate mode but it adds zeroes to the start of the parameter.
@silkwesir1444
@silkwesir1444 5 месяцев назад
don't gosub and goto have two-byte tokens? Maybe that's the issue with the "added zeroes" you mention?
@jefferystone1
@jefferystone1 7 месяцев назад
Neat, Neat, Neat
@markjreed
@markjreed 7 месяцев назад
It's not 2022 anymore, Robin. Or 2023, for that matter. Your BASIC stub has missed a whole year! (Happy new year!) :)
@8_Bit
@8_Bit 7 месяцев назад
I think this video got stuck in a buffer for a couple years or something!
@revelationnow
@revelationnow 7 месяцев назад
Love to see some simons basic stuff in here. Also, do you plan on going back to the IDE-DOS cartridge?
@AppliedCryogenics
@AppliedCryogenics 7 месяцев назад
Enjoyable episode as always, Robin! Have you played with the VIC-2 Kawari or Commander X16 or have any interest in doing so? I did a cursory search of your chan but didn't find anything.
@8_Bit
@8_Bit 7 месяцев назад
Thanks very much! Both are interesting, as well as the Mega65, but I've got a lot of time and money already invested in many other 8-bit things (systems, software, accessories, etc.) that I'm equally interested in and already plan to make videos about without spending more money :) So yes, I'm interested, but they're a fairly low priority mostly due to limits of time and money.
@AiOinc1
@AiOinc1 7 месяцев назад
I've always hated the CLI and I will never be convinced that it's a good way to interact with a computer - Especially one that can easily display graphics or more comprehensive text.
@8_Bit
@8_Bit 7 месяцев назад
I found the Amiga's CLI very restrictive after being used to the C64's free-form screen editor approach, but I now appreciate the CLI approach for certain tasks that can be broken into precise steps, which often happens while doing software development.
@ian_b
@ian_b 7 месяцев назад
Hi Robin!
@Nelwyn
@Nelwyn 7 месяцев назад
I just had an idea for a video. I was watching gameplay of Caverns of Khafka and I remember playing it years ago as it was in the Cosmi top 20 collection. I was never a big fan of it though. This game has some of the glitchiest sounds I've ever heard on the 64 and I wanted to see if you could disassemble it to figure out why it sounds the way it does. For instance, the music gets interrupted by other sounds and sometimes makes a garbled noise which sounds the same every time. The elevator sound makes a few beeping noises after it stops moving and there's a green bug which changes pitch after it dies and your character moves around and many more. Just a video showcasing why it does all that would be neat, but if you could write some code to fix some of the issues that would be interesting as well.
@bradnelson3595
@bradnelson3595 7 месяцев назад
Could you implement a special case for your BASIC border color-changing program to account for that tokenized "OR"?
@globecyclist
@globecyclist 7 месяцев назад
Hello! Can't you test for the tokenised "orange" string and make it work? Like double the DATA entries with even numbers being string and odd tokenised. Or something.
@8_Bit
@8_Bit 7 месяцев назад
Yes, that's likely a good work-around, or perhaps the BASIC ROM routines could be leveraged to de-tokenise before the comparison is done.
@GreenAppelPie
@GreenAppelPie 7 месяцев назад
I used to flash the border red if you entered an incorrect response.
@HeyBirt
@HeyBirt 7 месяцев назад
Interesting that it tokenizes after the : Makes me wonder about having the 'parameter' be a ML program encoded in a REM statement.
@8_Bit
@8_Bit 7 месяцев назад
Yeah, the whole line is tokenized, no matter how many commands (and colons) are on it. The two things that prevent tokenization are a REM statement, or quote mode.
@HeyBirt
@HeyBirt 7 месяцев назад
@@8_Bit I picked up on the REM/Quote thing. What I'm curious about is executing code that is after the colon. If it is BASIC code it would be difficult as the BASIC pointers would need to be changed (and changed back). I'm not sure that it could be run as immediate mode code either, perhaps it can but I missed that part. If you encode ML code in the REM statement your BASIC program could SYS it. I don't know why you would want to do this, but it would be interesting.
@HelloKittyFanMan
@HelloKittyFanMan 7 месяцев назад
I'm curious about something else too: Wouldn't "lineesque" form as a real word just by the rule that standard suffixes can be added to just about anything? Like if I said "computerish," and even though not every conceivable word formation based on every conceivable prefix or suffix is in the dictionary (because that would make a physical one huge), it's still a real word because of the way those suffixes work and according to the word-formation rules concerning them? So why not still use the hyphen, but just move it between "command" and "linesque" to form the compound word "command-lineesque"? What made you rationalize that the hyphen needed to be there because you needed "line-esque" instead of just having the whole term with "command-" as "command-lineesque"?
@fumthings
@fumthings 7 месяцев назад
OR... if you named the colour "dark yellow" maybe "LT BROWN" it would all work
@OscarSommerbo
@OscarSommerbo 7 месяцев назад
Couldn't you copy the kernal in to ram, and change the tokenization code?
@alex_6874
@alex_6874 7 месяцев назад
Hi Robin! Sorry for asking, but in my country there are to few people who is pograming for Commodore. Are there any forums or groups or channels or something where can I publish my game (and development process).
@8_Bit
@8_Bit 7 месяцев назад
The website itch io seems to be a leading place for C64 developers to publish their game. Search there for Commodore 64 and you'll see quite a few.
@royalestel
@royalestel 6 месяцев назад
Can we simply add up arrows for histoey? Type the first two characters of a Basic command and right arrow to autocomplete? More like linux
@jjdigitalvideosolutionsllc5343
@jjdigitalvideosolutionsllc5343 7 месяцев назад
On a C64/128 note, but unrelated to the current video topic, perhaps something for a future video though, can the 1541/71/81 drives be used as co-processors for game or application performance gains? Each floppy drive has its own 6502 and you could add some memory. The 1571/81 drives run their 6502s at 2mhz. If you have 4 drives attached, you have the possibility of 5 6502s at your disposal.
@8_Bit
@8_Bit 7 месяцев назад
It's an interesting topic that I've thought about, but haven't come up with a good way of demonstrating it. The short answer is yes this will work in high computation, low-bandwidth cases. The problem is that it's very slow, relatively, for the CPUs to communicate with each other over the IEC bus. So there has to be the right balance for a net gain from the extra CPU computation, once you remove the CPU cycles burned in communication.
@JohnnyWednesday
@JohnnyWednesday 7 месяцев назад
@@8_Bit - There's a demo "freespin" that runs entirely on a 1541 - sound and video too :O (it doesn't address the bandwidth issue no - but an extra music channel if nothing else)
@magnustveten492
@magnustveten492 7 месяцев назад
I used to have 2 disk drives and a printer….i made a program that would program one disk drive to send the home work file to the printer while I used the 64 and other drive to play games…
@yellowrose0910
@yellowrose0910 6 месяцев назад
OK grew up with an Apple ][+, then PC, then Mac SE, then PCs again, so no Commodore experience, and definitely no Commodore hate, but I gotta admit this not leaving a space after LOAD or RUN or other commands really irks my OCD
@8_Bit
@8_Bit 6 месяцев назад
Just retrain your OCD to focus on optimizing away unnecessary whitespace. Works for me, anyway!
@rager1969
@rager1969 7 месяцев назад
Couldn't have accounted for the token for OR in your error checking?
@cheat_engine
@cheat_engine 7 месяцев назад
Just add a lookup table for when the character read from peek is outside of the ASCII range. Will make the code a lot larger though
@csbruce
@csbruce 7 месяцев назад
9:56 BASIC does seem to get rid of any spaces before the RUN command. Similarly, you can't indent BASIC lines without a leading ":". 14:57 Seems more like a brown than an orange. 15:26 You could add "┌ANGE" as an alias. You might want that for the British "GREY" spellings as well. 16:59 This is more like it - giving command-line arguments on the command that loads and runs the program. Various C64 wedges also have a loan-and-run command. 17:32 I assume this fails if the filename has a colon in it. 19:01 Cool - the C64 automatically changes «LIST» to «L╮»! 20:32 But it's 2024! 26:00 Yeah, you manually hacked my name to not break your credits program! I suppose «Craig'; DROP TABLE Students;» won't work here, either.
@greywizard2557
@greywizard2557 7 месяцев назад
Fun (useless) fact - orange and brown are one and the same. It's the brightness of the orange and the contrast between it and any surrounding colours that determine if your eyes perceive it as orange or brown (assuming one isn't colour blind).
@necronom
@necronom 7 месяцев назад
Yes, brown is dark orange, just like pink is light red.
@mikehaas543
@mikehaas543 6 месяцев назад
You know you could make RUN:ORANGE work without the rem or "...
@kcinplatinumgaming2598
@kcinplatinumgaming2598 7 месяцев назад
amazing how a value can be carried on P and also use a P$ can hold a string, a lot of programming languages dont allow that in basic i think6 anymore??
@8_Bit
@8_Bit 7 месяцев назад
Yes, and in fact P% is also available as a signed 16-bit integer, and then all 3 of those types can also be made into arrays with the same variable name. So we could have P, P%, P$, P(), P%(), and P$() all being valid independent variables :)
@gabrielsroka
@gabrielsroka 7 месяцев назад
​@@8_Biti think DEF FN P, too
@8_Bit
@8_Bit 7 месяцев назад
@@gabrielsroka Yes, true, even if it's a function and not a variable, it's still stored like one. FNP() or FN P() in that case.
@gabrielsroka
@gabrielsroka 7 месяцев назад
@@8_Bit i found the article, but i can't paste the link. search the web for "The Case of the Missing 4th Commodore BASIC Variable (and the 5th Byte)" by masswerk
@no1leader135
@no1leader135 7 месяцев назад
Great video, but using lower and upper case like "rU:TEST" it doesn't work. 😂 And what about GOTO? Like "GOTO:MENU"? If line zero is there.
@rathakeo3608
@rathakeo3608 6 месяцев назад
Hi Robin! I'm soo please to meet you. I'm San K. Rianna came a few times, very nice girl. Lately, I want my old computers (A500 and A3000) stand on their feet again. Both of them still running but A3000 HD death.
@8_Bit
@8_Bit 6 месяцев назад
Hello San! Thanks for subscribing, and for having Rianna as a guest. That's really cool you're into Amiga! My friend @10MARC is very knowledgeable about Amiga, I suggest watching his videos in particular. I like Amiga very much but have not got a lot of experience with repairing them.
@8_Bit
@8_Bit 6 месяцев назад
Try his channel here: youtube.com/@10MARC/
Далее
10x Faster Than C64 BASIC? Hare Basic
48:01
Просмотров 31 тыс.
RAM Scan 64 - Early 1980s Glitch Art Code?
28:52
Просмотров 20 тыс.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
🔴Ютуб закрывают... Пока?
00:39
Просмотров 1,5 млн
Water powered timers hidden in public restrooms
13:12
Просмотров 705 тыс.
38911 Bytes Free? Commodore 64's BASIC RAM
29:57
Просмотров 38 тыс.
iPhone 16 - 20+ КРУТЫХ ИЗМЕНЕНИЙ
5:20