From ffb0e132177bc88052d5091d64941f5f2161cb1a Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Wed, 20 Jun 2018 15:58:05 -0700 Subject: [PATCH] scrolly credits thingy --- res/credits.txt | 120 ++++++++++++------------ src/pitchdark.a | 1 + src/ui.credits.a | 226 +++++++++++++++++++++++++++++++++++++++++++++ src/ui.main.a | 14 +++ src/ui.main.keys.a | 3 +- src/ui.options.a | 2 +- src/ui.resume.a | 2 +- src/ui.versions.a | 2 +- 8 files changed, 307 insertions(+), 63 deletions(-) create mode 100644 src/ui.credits.a diff --git a/res/credits.txt b/res/credits.txt index 2d494b8..883e5b1 100644 --- a/res/credits.txt +++ b/res/credits.txt @@ -1,88 +1,90 @@ -Games, descriptions, and artwork are -copyright 1979-1988 Infocom, Inc. -Invisiclues are copyright 1993, 1999 -Activision, Inc. + Games, descriptions, and artwork are + copyright 1979-1988 Infocom, Inc. -Zork and all other game names are -registered trademarks of Activision. + Invisiclues are copyright 1993, 1999 + Activision, Inc. - ~ + Zork and all other game names are + registered trademarks of Activision. -Pitch Dark is a frontend for exploring -and playing Infocom text adventures. + ~ -Copyright 2018 4am + Pitch Dark is a frontend for exploring + and playing Infocom text adventures. -https://github.com/a2-4am/pitch-dark + Copyright 2018 4am - ~ + https://github.com/a2-4am/pitch-dark -On Beyond Z-Machine! is a ProDOS port of -Infocom's Z-Machine interpreters. + ~ -Copyright 2018 qkumba + On Beyond Z-Machine! is a ProDOS port + of Infocom's Z-Machine interpreters. -based on code from six different games -copyright 1979-1988 Infocom, Inc. + Copyright 2018 qkumba - ~ + based on code from six different games + copyright 1979-1988 Infocom, Inc. -WeeGUI is a compact and easy to use GUI -library for 8-bit Apple ][ computers. + ~ -Copyright 2014-8 Quinn Dunki + WeeGUI is a compact and easy to use + GUI library for 8-bit Apple ][ + computers. -https://github.com/blondie7575/WeeGUI/ + Copyright 2014-8 Quinn Dunki - ~ + https://github.com/blondie7575/WeeGUI/ -Artwork was scanned from original retail -boxes and converted to Apple II native -formats with the help of + ~ -Bmp2DHR copyright 2014 Bill Buckels -A2FCBmp copyright 2012-5 Bill Buckels -buckshot copyright 2017 Dagen Brock + Artwork was scanned from original + retail boxes and converted to Apple II + native formats with the help of -http://www.appleoldies.ca/bmp2dhr/ -https://apple2.gs/buckshot/ + Bmp2DHR copyright 2014 Bill Buckels + A2FCBmp copyright 2012-5 Bill Buckels + buckshot copyright 2017 Dagen Brock - ~ + http://www.appleoldies.ca/bmp2dhr/ + https://apple2.gs/buckshot/ -The PRIZM Project (Pretty Reliable -Invisiclues for Z-Machine) are genuine -Infocom Invisiclues, accessible in your -favorite Z-Machine interpreter. + ~ -Copyright 1999 Digby McWiggle and -Steven Marsh + The PRIZM Project (Pretty Reliable + Invisiclues for Z-Machine) are genuine + Infocom Invisiclues, accessible in + your favorite Z-Machine interpreter. -Compiled, edited, and Z-coded by - Digby McWiggle - Steven Marsh + Copyright 1999 Digby McWiggle and + Steven Marsh -from material supplied by - Henrik Dittmann - Paul David Doherty - Volker Blasius - Mike Threepoint + Compiled, edited, and Z-coded by + Digby McWiggle + Steven Marsh -Thanks also to - Brian Hall - L. Ross Raszewski - Graham Nelson + from material supplied by + Henrik Dittmann + Paul David Doherty + Volker Blasius + Mike Threepoint -http://www.waitingforgo.com/ + Thanks also to + Brian Hall + L. Ross Raszewski + Graham Nelson - ~ + http://www.waitingforgo.com/ -The authors also wish to express their -gratitude to their wonderfully patient -beta testers, who will be named here: + ~ - - TODO1 - - TODO2 - - TODO3 + The authors also wish to express their + gratitude to their wonderfully patient + beta testers, who will be named here: - [EOF] + - TODO1 + - TODO2 + - TODO3 + + [EOF] diff --git a/src/pitchdark.a b/src/pitchdark.a index a98a12f..05425c1 100644 --- a/src/pitchdark.a +++ b/src/pitchdark.a @@ -40,6 +40,7 @@ !source "src/ui.resume.a" !source "src/ui.versions.a" !source "src/ui.artwork.a" + !source "src/ui.credits.a" gGamesListStore !word *+2 ; address of first okvs store diff --git a/src/ui.credits.a b/src/ui.credits.a new file mode 100644 index 0000000..1147b2f --- /dev/null +++ b/src/ui.credits.a @@ -0,0 +1,226 @@ +;license:MIT +;(c) 2018 by 4am +; +; User interface - views and paint routines for credits screen +; +; Public functions +; - CreditsDialog +; + +; View IDs (application-specific, acceptable range 0..15, no duplicates) +ID_CREDITS_FRAME = 1 +ID_CREDITS_OK = 2 + +; action keys for credits screen +kCreditsKeys + !byte $CF,ID_CREDITS_OK ; O + !byte $EF,ID_CREDITS_OK ; o + !byte $8D,ID_CREDITS_OK ; Return + !byte $9B,ID_CREDITS_OK ; Esc + !byte $8B,ID_SCROLLUP ; up arrow + !byte $8A,ID_SCROLLDOWN ; down arrow +_endCreditsKeys + +;------------------------------------------------------------------------------ +; CreditsDialog +; call WeeGUI to create and paint credits screen, and run to completion +; +; in: WeeGUI initialized +; out: exits via MainScreen +; all registers and flags clobbered +;------------------------------------------------------------------------------ +CreditsDialog + ldx #$FF + txs + jsr HardResetWeeGUI + + jsr CreateDialog ; create decorated frame + !word kViewCreditsFrame + !word kStringCreditsFrame + + ldx #WGViewSetAction ; set view action (called automatically after scrolling) + +LDADDR PaintCreditsView + +STAY PARAM0 + jsr WeeGUI + + jsr CreateButton ; create OK button + !word kViewCreditsOK + + ldx #WGDesktop ; paint background + jsr WeeGUI + + jsr PaintTitleBar ; paint top title bar + + ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons) + jsr WeeGUI + + jsr LoadCredits ; fetch contents for credits box + jsr PaintCreditsView ; paint contents of credits box + + jsr ClearPendingInput +- ldx #WGPendingViewAction + jsr WeeGUI ; handle mouse movement and clicks + lda $C000 + bpl - + jsr ClearPendingInput + jsr HandleCreditsKey ; handle keypresses + bra - + +LoadCredits + jsr LoadFile ; load credits file at $2800 + !word @kStringCreditsFilename + !word $2800 + !word kProDOSFileBuffer + bcs @NoCredits + ldy #$20 + lda #0 + +STAY PARAM2 + ldy #$28 ; doubles as 40-column width + +STAY PARAM0 + stz CreditsMaxLine+1 +-- lda (PARAM0) + inc PARAM0 + bne + + inc PARAM1 ++ cmp #$0A + beq ++ ; ignore LF entirely + ora #$80 ; set bit 7 + tax +- cpx #$8D ; watch for CR + php + bne + + lda #$A0 ; switch to spaces ++ dey + beq + + sta (PARAM2) + inc PARAM2 + bne + + inc PARAM3 ++ plp + bne ++ + tya + bne - ; pad line with spaces until width + inc CreditsMaxLine+1 + tya + ldy #$29 ; reload 40-column width, +1 to compensate for DEY + tax ; replace cached char with #$00 + beq - ; loop to store it and then resume +++ lda mliparam+6 + bne + + dec mliparam+7 ++ dec mliparam+6 + dec + ora mliparam+7 + bne -- +@NoCredits + rts + +@kStringCreditsFilename + !byte 11 + !raw "CREDITS.TXT" + +PaintCreditsView + ldx #WGSelectView + lda #ID_CREDITS_FRAME + jsr WeeGUI + lda #$20 + sta CreditsPosHi+1 + stz CreditsPosLo+1 + stz CreditsCurLine+1 + +-- +CreditsCurLine + lda #$FD ; SMC + stz PARAM0 + sta PARAM1 + ldx #WGSetCursor + jsr WeeGUI + +CreditsPosHi + ldy #$20 +CreditsPosLo + lda #0 + +STAY PARAM0 + ldx #WGPrint + jsr WeeGUI +- lda (PARAM0) + inc PARAM0 + bne + + inc PARAM1 ++ tax + bne - + lda PARAM0 + sta CreditsPosLo+1 + lda PARAM1 + sta CreditsPosHi+1 + inc CreditsCurLine+1 + lda CreditsCurLine+1 + +CreditsMaxLine + cmp #$FD ; SMC + bne -- + lda CreditsMaxLine+1 ; minimum content height + ldx #WGSetContentHeight ; set content height so we stop scrolling on the last line of text + jmp WeeGUI + +;------------------------------------------------------------------------------ +; internal functions + +;------------------------------------------------------------------------------ +; HandleCredits +; +; in: A = key pressed +; out: all registers and flags clobbered +;------------------------------------------------------------------------------ +HandleCreditsKey + ldy #(_endCreditsKeys-kCreditsKeys)-2 +- cmp kCreditsKeys,y + beq @found + dey + dey + bpl - + jmp SoftBell +@found ldx #WGSelectView + lda kCreditsKeys+1,y + bpl @activateView ; ID < #$80 is a WeeGUI view, so activate it + ldy #$FF + cmp #ID_SCROLLDOWN ; arrow keys scroll the description box + beq @scroll + ldy #$01 +@scroll phy + ldx #WGSelectView + lda #ID_CREDITS_FRAME + jsr WeeGUI + ldx #WGScrollYBy + pla + +@activateView + jsr WeeGUI + jmp SimulateClick + +callback_credits_ok + jmp MainScreen + +;------------------------------------------------------------------------------ +; WeeGUI view configuration records + +kViewCreditsFrame + !byte ID_CREDITS_FRAME ; view ID + !byte 2 ; style (decorated frame) + !byte 1 ; left + !byte 3 ; top + !byte 77 ; visible width + !byte 20 ; visible height + !byte 77 ; width + !byte 100 ; height + +kViewCreditsOK + !byte ID_CREDITS_OK ; view ID + !byte 67 ; left + !byte 4 ; top + !byte 10 ; width + !word callback_credits_ok ; callback + !word kStringOK ; caption + +kStringCreditsFrame + !text "Credits",0 diff --git a/src/ui.main.a b/src/ui.main.a index 1bfe353..3ceceaf 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -20,6 +20,7 @@ ID_HINTS = 6 ID_VERSIONS = 7 ID_INFO = 8 ID_DESCRIPTION = 9 +ID_ABOUT = 10 gMainScreenPaintDirty !byte 0 @@ -105,6 +106,9 @@ RepaintMainIfDirty !word kViewVersions !word kHasVersions + jsr CreateButton ; create '?' button + !word kViewAbout + pla ; clear screen before repainting? beq @nohome ; no -> repaint over existing screen, YOLO @@ -376,6 +380,14 @@ kViewDescription !byte 77 ; width !byte 39 ; height +kViewAbout + !byte ID_ABOUT ; view ID + !byte 79 ; left + !byte 0 ; top + !byte 1 ; width + !word CreditsDialog ; callback + !word kStringAbout + kStringPrevious !text "< " !byte $10 ; 'P' inverse @@ -406,3 +418,5 @@ kStringHints kStringVersions !byte $16 ; 'V' inverse !text "ersion",0 +kStringAbout + !byte $3F, 0 ; '?' inverse diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index 736d78f..3eb8e5c 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -44,6 +44,7 @@ kMainKeys !byte $F9,ID_Y ; y !byte $DA,ID_Z ; Z !byte $FA,ID_Z ; z + !byte $BF,ID_ABOUT ; ? _endMainKeys ;------------------------------------------------------------------------------ @@ -54,7 +55,7 @@ _endMainKeys ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ HandleKey - ldx #_endMainKeys-kMainKeys + ldx #(_endMainKeys-kMainKeys)-2 - cmp kMainKeys,x beq @found dex diff --git a/src/ui.options.a b/src/ui.options.a index 68fc575..155dafc 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -122,7 +122,7 @@ OptionsDialog ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ HandleOptionsKey - ldx #_endOptionsKeys-kOptionsKeys + ldx #(_endOptionsKeys-kOptionsKeys)-2 - cmp kOptionsKeys,x beq @found dex diff --git a/src/ui.resume.a b/src/ui.resume.a index db45570..d048213 100644 --- a/src/ui.resume.a +++ b/src/ui.resume.a @@ -143,7 +143,7 @@ ResumeDialog ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ HandleResumeKey - ldx #_endResumeKeys-kResumeKeys + ldx #(_endResumeKeys-kResumeKeys)-2 - cmp kResumeKeys,x beq @found dex diff --git a/src/ui.versions.a b/src/ui.versions.a index 0f54997..cb67c42 100644 --- a/src/ui.versions.a +++ b/src/ui.versions.a @@ -166,7 +166,7 @@ iNumVersions=*+1 ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ HandleVersionsKey - ldx #_endVersionsKeys-kVersionsKeys + ldx #(_endVersionsKeys-kVersionsKeys)-2 - cmp kVersionsKeys,x beq @found dex