From 73dff5ae409e4b996d8a99dee0c430e99181aad7 Mon Sep 17 00:00:00 2001 From: 4am Date: Sat, 31 Mar 2018 10:22:09 -0400 Subject: [PATCH] . --- src/path.a | 34 ++++++++++++++++++++++++++++++++++ src/prodos.a | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/ui.main.a | 34 ++++++++++++---------------------- 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/src/path.a b/src/path.a index c2d04a8..8166558 100644 --- a/src/path.a +++ b/src/path.a @@ -71,3 +71,37 @@ SetStartupPath bpl - rts } + +;------------------------------------------------------------------------------ +; CreateNullTerminatedString +; Copy a length-prefixed string to kNullTerminatedBuffer and null-terminate it. +; Destination string is left-padded with a single space because reasons. +; Maximum length is 127 bytes. +; +; in: A/Y contains address of length-prefixed string to copy +; X contains length of null-terminated string -- if > length of source, +; remaining buffer will be padded with spaces (#$A0) +; out: all registers and flags clobbered +; $00/$01 clobbered +;------------------------------------------------------------------------------ +!zone { +CreateNullTerminatedString + +STAY $00 + + phx + lda #$A0 +- dex + sta kNullTerminatedBuffer,x + bpl - + plx + lda #$00 + sta kNullTerminatedBuffer,x + + lda ($00) + tay +- lda ($00),y + sta kNullTerminatedBuffer,y + dey + bne - + rts +} diff --git a/src/prodos.a b/src/prodos.a index 3221ec8..20ea0dd 100644 --- a/src/prodos.a +++ b/src/prodos.a @@ -15,6 +15,7 @@ CMD_QUIT = $65 ; quit to ProDOS CMD_CREATE = $C0 ; create new file CMD_DESTROY = $C1 ; delete a file +CMD_GETFILEINFO = $C4 ; get file (or volume) info CMD_SETPREFIX= $C6 ; change default pathname prefix CMD_OPEN = $C8 ; open a file CMD_READ = $CA ; read an open file @@ -25,6 +26,7 @@ CMD_CLOSE = $CC ; close an open file PC_QUIT = $04 PC_CREATE = $07 PC_DESTROY = $01 +PC_GETFILEINFO = $0A PC_SETPREFIX = $01 PC_OPEN = $03 PC_READ = $04 @@ -265,6 +267,34 @@ SetPrefix jmp _setprefix } +;------------------------------- +; GetFileInfo +; just what it says on the tin +; +; in: stack contains 2 bytes of parameters: +; +1 address of pathname +; out: if C set, MLI call failed and A contains error code +; from open or read +; if C clear, MLI call succeeded and mliparam contains +; all the info +; all other flags clobbered +; all registers clobbered +; stack set to next instruction after parameters +;------------------------------- +!zone { +GetFileInfo + +PARAMS_ON_STACK 2 + + ldy #$01 + lda (PARAM),y ; lo byte of pathname + sta mliparam+1 + iny + lda (PARAM),y ; hi byte of pathname + sta mliparam+2 + + jmp _getfileinfo +} + ;------------------------------- ; open file via ProDOS MLI ; @@ -391,6 +421,20 @@ _setprefix jsr mli rts +;------------------------------- +; get file info via ProDOS MLI +; +; in: caller has filled @mliparam with address of +; pathname +; out: if C set, open failed and A contains error code +; if C clear, open succeeded and A contains +; file reference number +;------------------------------- +_getfileinfo + lda #CMD_GETFILEINFO ; MLI command + ldy #CMD_GETFILEINFO ; number of parameters for 'getfileinfo' command + jmp mli + ;------------------------------- QuitToProDOS lda #CMD_QUIT @@ -420,7 +464,7 @@ filetype !byte $FE ; file type (set by MLI get_file_info) auxtype ; auxiliary file type (2 bytes, set by MLI get_file_info) refnum !byte $FE ; file refnum (set by MLI open) mlilen !byte $FE,$FE ; file length (set by MLI read) -blocks !byte $FE,$FE ; blocks used (set by getvolumeinfo) +blocks !byte $FE,$FE ; blocks used (set by getvolumeinfo/getfileinfo) ; member is also used by createfile !byte $FE,$FE,$FE,$FE,$FE,$FE,$FE,$FE ; used by get_file_info diff --git a/src/ui.main.a b/src/ui.main.a index e87ce96..1653358 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -144,44 +144,34 @@ paintInfoView jsr WeeGUI +LDAY addrInfo ldx #kInfoPaintWidth - phx jsr multiPrint - plx - lda #$A0 -- sta kNullTerminatedBuffer,x - dex - bpl - - lda #$00 - sta kNullTerminatedBuffer+kInfoPaintWidth jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore !word kLastPlayed - +STAY + + +STAY + ; A/Y contains address + jsr okvs_get ; get selected version of this game !word gGlobalPrefsStore + !word $FDFD ; SMC - +STAY + + +STAY + ; A/Y contains address + jsr okvs_get ; get long description of this version !word gVersionsStore + !word $FDFD ; SMC - +STAY SRC - lda (SRC) - tay -- lda (SRC),y - sta $3F00,y - dey - bne - - stz $00 - lda #$3F - sta $01 - jmp .printLoop + ; A/Y contains address + ldx #kInfoPaintWidth + jsr CreateNullTerminatedString + + +LDADDR kNullTerminatedBuffer + bra multiPrintWhereYouAre multiPrint - +STAY $00 stx .printLineLength+1 stz .htab+1 stz .vtab+1 +multiPrintWhereYouAre + +STAY $00 .printLoop lda ($00) beq .printDone