MEGA65 / mega65-user-guide

MEGA65 User Guide
75 stars 51 forks source link

BASIC: DISK: Fix change unit example #609

Closed johnwayner closed 2 months ago

johnwayner commented 2 months ago

Hmmm I wonder if this petscii numeric version was once supported? There's this snippet mentioned here: https://discord.com/channels/719326990221574164/791383472853614593/877489126113411093

 8632               ; CHANGE DEVICE ADDRESS
 8633 
 8634 ab71 a0 03    30$ ldy #3
 8635 ab73 20 7b a9     jsr aschex_1     ;Convert it
 8636 ab76 c9 1f        cmp #31          ;Only device numbers 0 thru 30 are allowed by the dos,
 8637 ab78 b0 31        bcs utlbad       ;But only 4 thru 30 are allowed by BASIC
 8638 ab7a ae c9 01 35$ ldx drivenumber
 8639 ab7d 9d 13 01     sta cbdosaddress,x
 8640 ab80 60           rts

that looks like it converts "9" -> $09. But none of this code is currently in dos.src.

johnwayner commented 2 months ago

Ahhh it was removed in the big merge of stuff: https://github.com/MEGA65/mega65-rom/commit/8a3d24a9dc278cb6fd4413f4285d94376852088f

I found at least one other bug in that one (https://github.com/MEGA65/mega65-rom/pull/52). So maybe the docs aren't the bug, but the removed functionality in the ROM is the bug, @dansanderson ?

EDIT: This is strangely documented as such in the code (and the C64DX SYSTEM SPECIFICATION), but the code itself only works with "U0>"+CHR$(n):

* "U0>?"+chr$(n) ? = set device number          1571,1581,CBDOS *

I'm not really sure what the original intention was, but it does seem that the old way was implemented even by the original code -- even if they were trying to introduce a couple of new ways:

dansanderson commented 2 months ago

The DOS change was slightly before my time, so I don't have context on what was intended. Certainly that change's description does not imply that a feature would be removed. I'm also surprised by the "9" vs CHR$(9) thing, seems like most DOS commands accept drive and unit numbers as PETSCII.

The docs here are just trying to give an example of a disk command that isn't an explicit BASIC command, so perhaps the best fix for now is to either come up with another example or just remove this one. Separately we can figure out if CBDOS should be doing something differently. We recently noticed that when the Freezer changes the unit number assigned to a virtual drive, it's actually just poking a CBDOS variable, so a DOS command to do this should be feasible—and we should try to nail down that variable location in code so it doesn't accidentally move and break the Freezer feature (and/or get the Freezer to issue the DOS command instead of just poke a variable).

johnwayner commented 2 months ago

That discord link I provided is to a discussion about the freezer and locking down the variable location to $10113. That location is locked down already. Are you suggesting an explicit command (or maybe an option to an existing command) to change the device number? I'd like that. Perhaps part of MOUNT?

I'll close this PR as well.

dansanderson commented 2 months ago

I hadn't looked at the code yet to see whether poking the location is a robust enough API for the purposes of supporting the Freezer. If it looks good to you, then I'm satisfied. It sounds like, separately, there's potential and precedent for a CBDOS command that could perform this function, which isn't otherwise available to programs as far as I know. Sounds like a good feature request for the ROM!