Skip to content

Commit ff7f5f9

Browse files
authored
Merge pull request #267 from eduardocasino/kim-1
[KIM-1] Some fixes and improvements to the IMU utility for the K‑1013 port
2 parents e84e793 + 2095b00 commit ff7f5f9

5 files changed

Lines changed: 34 additions & 13 deletions

File tree

src/arch/kim-1/cpmfs/imu.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Image Manipulation Utility
22
==========================
33

4-
Usage: imu [/L]
4+
Usage: imu [{/L | /S}]
55
imu /M <drive> <image> [/O]
66
imu /U <drive>
77
imu /N <image> [/P]
@@ -15,6 +15,8 @@ Options
1515

1616
/L - Lists the available disk images on the SD card.
1717

18+
/S - Saves the current mounts to the SD card config file.
19+
1820
/M <drive> <image> [/O]
1921
- Mounts <image> into <drive>. Option /O makes it read-only.
2022

src/arch/kim-1/k-1013.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ EXT_CMD_CPY = 0b00011000
3535
EXT_CMD_MOV = 0b00011100
3636
EXT_CMD_MNT = 0b00100000
3737
EXT_CMD_UMNT = 0b00100100
38+
EXT_CMD_SAV = 0b00101000
3839

3940
ST4_UNSUPPORTED = 0b10000000
4041
ST4_ABNORMAL_TERM = 0b01000000

src/arch/kim-1/utils/imu-k1013.S

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ zproc unmount_drive
291291

292292
; Dig further for errors
293293

294+
lda disk_status ; Check for success
294295
and #ST4_ABNORMAL_TERM
295296
zif ne
296297
lda disk_status+1
@@ -314,13 +315,29 @@ zproc unmount_drive
314315
jmp inf_done
315316
zendproc
316317

317-
; Update config to flash. Not yet supported
318+
; Update the SD config file with the latest mounted drives
319+
; situation. Issues warning if the file could not be
320+
; updated.
318321
;
319322
zproc save_config
320-
lda #<unknown_msg
321-
ldy #>unknown_msg
322-
jsr err_withchar
323-
jmp err_usage
323+
324+
ldy #EXT_CMD_SAV
325+
jsr fdc_exec_extended ; Exec SD mounts config save
326+
zif cs
327+
lda #<fdc_msg
328+
ldx #>fdc_msg
329+
jmp err_withmsg ; Controller error
330+
zendif
331+
332+
lda disk_status ; Check for success
333+
and #ST4_ABNORMAL_TERM
334+
zif ne
335+
lda #<config_msg
336+
ldx #>config_msg
337+
jmp err_withmsg
338+
zendif
339+
340+
jmp inf_done
324341
zendproc
325342

326343
; Create an empty image on the SD card.
@@ -376,7 +393,7 @@ zproc create_image
376393

377394
; Set buffer for sending mount info
378395

379-
lda #BUFFER_DMA
396+
lda #DMA_AREA
380397
sta ADMA
381398

382399
; Prepare the command data
@@ -425,7 +442,7 @@ zproc create_image
425442
zendif
426443
; If we are here, there was an unexpected error
427444
lda #<generic_msg
428-
ldy #>generic_msg
445+
ldx #>generic_msg
429446
jmp err_withmsg
430447
zendif
431448

@@ -493,7 +510,7 @@ zproc delete_file
493510
zendif
494511
; If we are here, there was an unexpected error
495512
lda #<generic_msg
496-
ldy #>generic_msg
513+
ldx #>generic_msg
497514
jmp err_withmsg
498515
zendif
499516

@@ -741,7 +758,7 @@ disk_status: .fill 8 ; Result phase readouts from NEC-765
741758

742759
.global usage_msg
743760

744-
usage_msg: .ascii "Usage: imu [/L]\r\n"
761+
usage_msg: .ascii "Usage: imu [{/L | /S}]\r\n"
745762
.ascii " imu /M <drive> [/O]\r\n"
746763
.ascii " imu /U <drive>\r\n"
747764
.ascii " imu /N <image> [/P]\r\n"

src/arch/kim-1/utils/imu-sdshield.S

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,5 @@ imagerr_msg: .ascii "Image name must be in 8.3 format.\r\n"
609609
disabled_msg: .ascii "Disabled by hardware. Please flip option switch 2.\r\n"
610610
.byte 0
611611

612-
config_msg: .ascii "Can't update the SD config file.\r\n"
613-
.byte 0
614-
615612
working_msg: .ascii "On it. May take a while...\r\n"
616613
.byte 0

src/arch/kim-1/utils/imu.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ zendproc
481481

482482
.global unknown_msg, invalid_msg, mounterr_msg, mountederr_msg
483483
.global unmnterr_msg, notmntederr_msg, generic_msg, exists_msg
484+
.global config_msg
484485

485486
error_msg: .ascii "Error: "
486487
.byte 0
@@ -531,6 +532,9 @@ imgmounted_msg: .ascii "Error: Image file '"
531532
imgmounted_msg2:.ascii "' already mounted.\r\n"
532533
.byte 0
533534

535+
config_msg: .ascii "Can't update the SD config file.\r\n"
536+
.byte 0
537+
534538
warning_msg: .ascii "Warning: About to delete file '"
535539
.byte 0
536540
warning_msg2: .ascii "'.\r\n"

0 commit comments

Comments
 (0)