| |
Krill
Registered: Apr 2002 Posts: 2804 |
Drivecode framework
Quoting Count ZeroLearn some drive code (from this rant https://csdb.dk/forums/?roomid=12&topicid=150373#150526 in Release id #205500 : Freespin)
Recently, i've been asked about the 1541's computing capabilities, which reminded me of an old somewhat low-priority item on my todo list:
a drivecode framework.
The upcoming new version of Krill's Loader, Repository Version 184 has a hiscore saver that is built on top of the loader's now-finished custom drivecode API with its swapdrvcod, restoreldr, sendbyte and receivbyte calls.
Now, adding a few handy subroutines and macros for serial transfers plus some templates in a future version doesn't seem like a lot of work any more.
Question is (apart from who'd actually use this, and for which drive-side computing tasks/demo effects) what else would be required or nice to have in such a framework. |
|
... 10 posts hidden. Click here to view all posts.... |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1359 |
It'd be nice if the framework could also optionally handle sending a packet of data and awaiting+receiving a response. |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting QuissAlso, can't wait to look at that 38 byte transfer loop. :) With X := 0 and Y := [$1800]:.8:0000 A9 80 LDA #$80
.8:0002 CC 00 18 CPY $1800
.8:0005 F0 FB BEQ $0002
.8:0007 AC 00 18 LDY $1800
.8:000a C0 94 CPY #$94
.8:000c 6A ROR A
.8:000d 90 F3 BCC $0002
.8:000f 81 22 STA ($22,X)
.8:0011 E6 22 INC $22
.8:0013 D0 02 BNE $0017
.8:0015 E6 23 INC $23
.8:0017 E6 24 INC $24
.8:0019 D0 E5 BNE $0000
.8:001b E6 25 INC $25
.8:001d D0 E1 BNE $0000
.8:001f 4C B5 05 JMP $05B5
.8:0022 AE 05 B4
.8:0025 FE The transfer parameters (entry, to, $10000 - length) are at $20..$25. =) |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting ChristopherJamIt'd be nice if the framework could also optionally handle sending a packet of data and awaiting+receiving a response. Yes, transferring chunks of data will be part of the routines.
The usual highly-optimised fastloader thing with halve-variance to sync both clocks, then re-sync with "BR? * + 2" every few bytes, transfer in border.
(And maybe something even more highly-optimised, likely using this trick i learned when working on Transwarp: https://csdb.dk/forums/?roomid=12&topicid=146327#146478)
Otherwise the 2-bytes-per-rasterline rule of thumb wouldn't hold.
Example: Panta Rhei 2nd part. =) |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting QuissAlso, can't wait to look at that 38 byte transfer loop. :) It's easy to spot optimisations to save at least 2 bytes. Having the transfer parameters in one piece comes in handy during the upload procedure, though, but that other byte... =) |
| |
Quiss
Registered: Nov 2016 Posts: 37 |
Neat! I like the CPY trick.
Swap X and Y, to save a byte? :) I guess other optimizations might be possible, depending on how configurable the memory bounds are. (E.g., if you know you'll always transfer the whole zeropage, you could write the memory in decreasing order and overwrite $1b/$1c/$1d with a JMP instruction that'll kick in after you've written $00.) |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting Quissif you know you'll always transfer the whole zeropage Well, i don't. =) Where code goes to, and how much, is arbitrary.
Bounds aren't checked, though, so the user could pull some dirty tricks with the receive routine overwriting itself. |
| |
Rastah Bar
Registered: Oct 2012 Posts: 336 |
Quoting KrillIt's easy to spot optimisations to save at least 2 bytes. Having the transfer parameters in one piece comes in handy during the upload procedure, though, but that other byte... =)
If X:=$80, you could start with a TXA and replace the STA ($22,X) with STA ($A2,X), making use of the zeropage page wrap quirk. |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting Rastah BarIf X:=$80, you could start with a TXA and replace the STA ($22,X) with STA ($A2,X), making use of the zeropage page wrap quirk. That's exactly the idea i had in mind when typing "but that other byte...".
But please let's not devolve this thread to just another one of those single-byte 1-up code golf pieces. |
| |
Rastah Bar
Registered: Oct 2012 Posts: 336 |
Yeah, but what about that other byte then??? :-) |
| |
Krill
Registered: Apr 2002 Posts: 2804 |
Quoting Rastah BarYeah, but what about that other byte then??? :-) Doesn't matter. :) I'll just leave it at $26 bytes, i guess. Seems good enough for almost all purposes.
Drive code typically needs some zeropage variables, and $26 of them can easily be initialised in a loop. |
Previous - 1 | 2 - Next |