Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Drivecode framework
2021-07-14 12:08
Krill

Registered: Apr 2002
Posts: 2804
Drivecode framework

Quoting Count Zero
Learn 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....
 
2021-07-15 09:22
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.
2021-07-15 09:44
Krill

Registered: Apr 2002
Posts: 2804
Quoting Quiss
Also, 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. =)
2021-07-15 09:54
Krill

Registered: Apr 2002
Posts: 2804
Quoting ChristopherJam
It'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. =)
2021-07-15 10:16
Krill

Registered: Apr 2002
Posts: 2804
Quoting Quiss
Also, 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... =)
2021-07-15 10:20
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.)
2021-07-15 10:23
Krill

Registered: Apr 2002
Posts: 2804
Quoting Quiss
if 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.
2021-07-15 11:06
Rastah Bar

Registered: Oct 2012
Posts: 336
Quoting Krill
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... =)

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.
2021-07-15 11:17
Krill

Registered: Apr 2002
Posts: 2804
Quoting Rastah Bar
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.
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.
2021-07-15 12:18
Rastah Bar

Registered: Oct 2012
Posts: 336
Yeah, but what about that other byte then??? :-)
2021-07-15 13:53
Krill

Registered: Apr 2002
Posts: 2804
Quoting Rastah Bar
Yeah, 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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
mutetus/Ald ^ Ons
rambo/Therapy/ Resou..
Airwolf/F4CG
Guests online: 363
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.07 sec.