pointless fiddling

This commit is contained in:
4am 2018-04-18 15:28:55 -04:00
parent df86e8cf36
commit 43e54ae029
13 changed files with 227 additions and 230 deletions

View File

@ -12,14 +12,11 @@
; 3F00..3FFF - gPathname
; kNullTerminatedBuffer
; gKey/gVal
; 4000.~5BFF - WeeGUI (approximate end)
;~5C00.~71FF - program code (approximate start and end)
;~7200.~7FFF - program data (approximate start and end)
; 4000.~5BFF - WeeGUI (approximate)
;~5C00.~73FF - program code (approximate)
;~7400...... - program data (approximate)
;
kInfoPaintWidth = 65 ; used by paintInfoView
kDescriptionPaintWidth = 78 ; used by paintDescriptionView
kGameInfoBuffer = $0800 ; used by LoadGameInfo
kProDOSFileBuffer = $1C00 ; 1K buffer for ProDOS MLI calls
kSystemAddress = $2000 ; used by LaunchInterpreter
@ -34,6 +31,7 @@ WGInit = $4000 ; WeeGUI file load address and initializati
MAGICRTS = $FF58 ; used to set overflow bit
; zero page
PARAM = $00 ; used by PARAMS_ON_STACK macro, so basically everywhere
PTR = $02
SRC = $04
DEST = $06

View File

@ -90,7 +90,7 @@ reloc cld
jsr $bf00
!byte $cc
!word cc_parms
jmp $3FFD
jmp $3FE3
c7_parms
c6_parms
@ -106,7 +106,7 @@ c8_parms
ca_parms
!byte 4
!byte $d1
!word $3FFD
!word $3FE3
!word $ffff
!word $34d1

View File

@ -4,8 +4,6 @@
; common assembler macros
;
PARAM = $00
; for functions that take parameters on the stack
; set (PARAM) to point to the parameters and
; move the stack pointer to the first byte after the parameters

View File

@ -8,8 +8,8 @@
; - CheckForSavedGames
;
; Public variables
; - gHasSavedGames 0=false, 1=true (set in CheckForSavedGames)
; - gLastSavedGameSlot 0-7 (only valid if gHasSavedGames=1)
; - gHasSavedGames byte 0=false, nonzero=true (set in CheckForSavedGames)
; - gLastSavedGameSlot byte 0-7 (only valid if gHasSavedGames=1)
;
; Public constants (keys in gOptionsStore)
; - kHasArtwork

View File

@ -8,7 +8,8 @@
; - SaveGlobalPreferences
;
; Public variables
; - gGlobalPrefsDirty byte 0=false, 1=true
; - gGlobalPrefsStore word address of prefs okvs (set in LoadGameList)
; - gGlobalPrefsDirty byte 0=false, nonzero=true
; set to 1 if prefs have changed. SaveGlobalPreferences won't write to disk if this is 0.
;
; Public constants (all length-prefixed strings)

View File

@ -3,7 +3,7 @@
;
; It is Pitch Dark. You are likely to be eaten by a GUI.
;
; Public entry points
; Public functions
; - MainScreen
;
; Public variables
@ -13,10 +13,22 @@
!cpu 65c02
!ct "src/lcase.ct"
!to "build/PITCH.DARK",plain
*=$3FFD
*=$3FE3
jmp Start
jsr QuitUnless128KAnd65C02; check minimum hardware requirements
jsr DisconnectRAM32 ; disconnect /RAM in S3,D2
jsr ClearInterpreterOptions ; clear options struct at $300
jsr WGInit ; initialize WeeGUI
jsr LoadGameList ; get master list of games
jsr LoadGlobalPreferences ; get global options, including current game
jsr LoadGameInfo ; get current game description and game-specific options
ldx #WGEnableMouse ; enable mouse support
jsr WeeGUI
jmp MainScreen
!if * != $4000 {
!serious "WeeGUI library must start at $4000"
}
!bin "res/WEEGUI"
!source "src/macros.a"
@ -43,23 +55,6 @@
!source "src/ui.versions.a"
!source "src/ui.artwork.a"
Start
lda MACHID
and #$30
cmp #$30 ; 128K?
beq + ; yes, continue
- jmp QuitToProDOS
+ inc ; 65C02-only INC instruction will clear Z flag
beq - ; if Z flag is still set, this is not a 65C02
jsr DisconnectRAM32 ; disconnect /RAM in S3,D2
jsr ClearInterpreterOptions ; clear options struct at $300
jsr WGInit ; initialize WeeGUI
jsr LoadGameList ; get master list of games
jsr LoadGlobalPreferences ; get global options, including current game
jsr LoadGameInfo ; get current game description and game-specific options
ldx #WGEnableMouse ; enable mouse support
jsr WeeGUI
MainScreen
ldx #$FF
txs

View File

@ -13,28 +13,30 @@
;
; MLI command codes
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
CMD_WRITE = $CB ; write to an open file
CMD_CLOSE = $CC ; close an open file
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
CMD_WRITE = $CB ; write to an open file
CMD_CLOSE = $CC ; close an open file
; MLI parameter counts
PC_QUIT = $04
PC_CREATE = $07
PC_DESTROY = $01
PC_QUIT = $04
PC_CREATE = $07
PC_DESTROY = $01
PC_GETFILEINFO = $0A
PC_SETPREFIX = $01
PC_OPEN = $03
PC_READ = $04
PC_WRITE = $04
PC_CLOSE = $01
PC_SETPREFIX = $01
PC_OPEN = $03
PC_READ = $04
PC_WRITE = $04
PC_CLOSE = $01
PRODOSMLI = $BF00 ; [callable] MLI entry point
; ROM addresses
PRODOSMLI = $BF00 ; [callable] MLI entry point
MACHID = $BF98 ; machine identification byte
;-------------------------------
; LoadFile
@ -249,8 +251,6 @@ GetFileInfo
jmp _getfileinfo
}
;------------------------------------------------------------------------------
;-------------------------------
; open file via ProDOS MLI
;
@ -363,20 +363,6 @@ _deletefile
jsr mli
rts
;-------------------------------
; change current directory (set prefix)
; using ProDOS MLI
; in: caller has filled @mliparam
; with address of pathname
; out: if error, C set and A contains error code
; if success, C clear
;-------------------------------
_setprefix
lda #CMD_SETPREFIX
ldy #PC_SETPREFIX
jsr mli
rts
;-------------------------------
; get file info via ProDOS MLI
;
@ -392,11 +378,30 @@ _getfileinfo
jmp mli
;-------------------------------
; change current directory (set prefix)
; using ProDOS MLI
; in: caller has filled @mliparam
; with address of pathname
; out: if error, C set and A contains error code
; if success, C clear
;-------------------------------
_setprefix
lda #CMD_SETPREFIX
ldy #PC_SETPREFIX
jmp mli
QuitUnless128KAnd65C02
lda MACHID
and #$30
cmp #$30 ; 128K?
bne QuitToProDOS
+ inc ; 65C02-only INC instruction will clear Z flag
bne mliexit ; if Z flag is clear, this is a 65C02 (good)
; if Z flag is set, this is not a 65C02 (bad) and execution falls through here
QuitToProDOS
lda #CMD_QUIT
ldy #PC_QUIT
; execution falls through here
; execution falls through here
;-------------------------------
; low-level MLI wrapper
; in: A = MLI command code
@ -414,7 +419,7 @@ mli sta mlicmd ; store command code
jsr PRODOSMLI ; call ProDOS
mlicmd !byte 00 ; command number
!word mliparam ; address of parameter table
rts
mliexit rts
mliparam !byte $FE,$FE,$FE,$FE
filetype !byte $FE ; file type (set by MLI get_file_info)
auxtype ; auxiliary file type (2 bytes, set by MLI get_file_info)

View File

@ -10,12 +10,10 @@
;
; does not reconnect /RAM on exit, which is rude
;
MLI = $BF00 ; ProDOS MLI entry point
NODEV = $BF10 ; means 'no device connected'
RAM32 = $BF26 ; S3,D2 /RAM device
DEVCNT = $BF31 ; ProDOS device count
DEVLST = $BF32 ; ProDOS device list
MACHID = $BF98 ; machine identification byte
;------------------------------------------------------------------------------
; DisconnectRAM32

View File

@ -8,8 +8,8 @@
; - RepaintMainIfDirty
;
; Public variables
; - gMainScreenPaintDirty
; - gViewInUse
; - gMainScreenPaintDirty byte 0=false, nonzero=true
; - gViewInUse array of byte (each 0=false, nonzero=true)
;
; View IDs (application-specific, acceptable range 0..15, no duplicates)
@ -24,10 +24,13 @@ ID_INFO = 8
ID_DESCRIPTION = 9
gMainScreenPaintDirty
!byte 0 ; 0=false, 1=true
!byte 0
gViewInUse
!byte 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0
kInfoPaintWidth = 65
kDescriptionPaintWidth = 78
;------------------------------------------------------------------------------
; PaintMain/RepaintMainIfDirty
; call WeeGUI to create all application views and paint them
@ -149,6 +152,9 @@ RepaintMainIfDirty
jmp PaintDescriptionView ; paint contents of description box
}
;------------------------------------------------------------------------------
; internal functions
;------------------------------------------------------------------------------
; CreateOrDestroyButton
; create or destroy a WeeGUI Button view, based on per-game options
@ -284,6 +290,7 @@ MultiPrint
}
;------------------------------------------------------------------------------
; WeeGUI view configuration records
kViewPrevious
!byte ID_PREVIOUS ; view ID
@ -292,10 +299,6 @@ kViewPrevious
!byte 13 ; width
!word callback_previous ; callback
!word kStringPrevious ; caption
kStringPrevious
!text "< "
!byte $10 ; 'P' inverse
!text "revious",0
kViewNext
!byte ID_NEXT ; view ID
@ -304,79 +307,54 @@ kViewNext
!byte 13 ; width
!word callback_next ; callback
!word kStringNext ; caption
kStringNext
!byte $0E ; 'N' inverse
!text "ext game >",0
kViewOptions
!byte ID_OPTIONS ; view ID
!byte 34 ; left
!byte 2 ; top
!byte 12 ; width
!word callback_options ; callback
!word OptionsDialog ; callback
!word kStringOptions
kStringOptions
!byte $13 ; 'S' inverse
!text "ettings",0
kViewPlay
!byte ID_PLAY ; view ID
!byte 66 ; left
!byte 6 ; top
!byte 13 ; width
!word callback_play ; callback
!word LaunchInterpreterWithNewGame ; callback
!word kStringPlay ; caption
kStringPlay
!byte 144
!text "lay "
!byte $67 ; 'g' inverse
!text "ame",0
kViewResume
!byte ID_PLAY ; view ID
!byte 66 ; left
!byte 6 ; top
!byte 13 ; width
!word callback_resume ; callback
!word ResumeDialog ; callback
!word kStringResume ; caption
kStringResume
!byte 146
!text "esume "
!byte $67 ; 'g' inverse
!text "ame",0
kViewBoxArt
!byte ID_BOXART ; view ID
!byte 66 ; left
!byte 8 ; top
!byte 13 ; width
!word callback_boxart ; callback
!word DisplayArtwork ; callback
!word kStringBoxArt ; caption
kStringBoxArt
!byte $01 ; 'A' inverse
!text "rtwork",0
kViewHints
!byte ID_HINTS ; view ID
!byte 66 ; left
!byte 10 ; top
!byte 13 ; width
!word callback_hints ; callback
!word LaunchInterpreterWithHints ; callback
!word kStringHints ; caption
kStringHints
!byte $08 ; 'H' inverse
!text "ints",0
kViewVersions
!byte ID_VERSIONS ; view ID
!byte 66 ; left
!byte 12 ; top
!byte 13 ; width
!word callback_versions ; callback
!word VersionsDialog ; callback
!word kStringVersions ; caption
kStringVersions
!byte $16 ; 'V' inverse
!text "ersion",0
kViewInfo
!byte ID_INFO ; view ID
@ -397,3 +375,34 @@ kViewDescription
!byte 8 ; visible height
!byte 77 ; width
!byte 39 ; height
kStringPrevious
!text "< "
!byte $10 ; 'P' inverse
!text "revious",0
kStringNext
!byte $0E ; 'N' inverse
!text "ext game >",0
kStringOptions
!byte $13 ; 'S' inverse
!text "ettings",0
kStringPlay
!byte 144
!text "lay "
!byte $67 ; 'g' inverse
!text "ame",0
kStringResume
!byte 146
!text "esume "
!byte $67 ; 'g' inverse
!text "ame",0
kStringBoxArt
!byte $01 ; 'A' inverse
!text "rtwork",0
kStringHints
!byte $08 ; 'H' inverse
!text "ints",0
kStringVersions
!byte $16 ; 'V' inverse
!text "ersion",0

View File

@ -19,7 +19,7 @@ ID_Y = $84
ID_Z = $85
; action keys for main screen (should correspond to button titles)
.keys
kMainKeys
!byte $C7,ID_PLAY ; G
!byte $E7,ID_PLAY ; g
!byte $8D,ID_PLAY ; Return
@ -45,18 +45,18 @@ ID_Z = $85
!byte $F9,ID_Y ; y
!byte $DA,ID_Z ; Z
!byte $FA,ID_Z ; z
.endkeys
_endMainKeys
;------------------------------------------------------------------------------
; HandleKey
; handle keypress to activate various UI elements
; handle keypresses in main screen
;
; in: A contains key pressed
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
HandleKey
ldx #.endkeys-.keys
- cmp .keys,x
ldx #_endMainKeys-kMainKeys
- cmp kMainKeys,x
beq .foundKey
dex
dex
@ -64,7 +64,7 @@ HandleKey
.notFound
jmp SoftBell ; unknown key, beep softly
.foundKey
lda .keys+1,x ; get ID associated with this key
lda kMainKeys+1,x ; get ID associated with this key
bpl .activateView ; ID < #$80 is a WeeGUI view, so activate it
cmp #ID_X ; X, Y, and Z keys are part of
beq .x ; an undocumented feature
@ -99,38 +99,32 @@ HandleKey
;------------------------------------------------------------------------------
; XYZZY handler
;------------------------------------------------------------------------------
.y
lda .xyzzy
.y lda .xyzzyCounter
cmp #1
beq .y1
cmp #4
bne .xyzzyReset
beq .xyzzyGo
.z
lda .xyzzy
.z lda .xyzzyCounter
cmp #2
beq .z1
cmp #3
beq .z2
bra .xyzzyReset
.x
lda #1
.x lda #1
+HIDE_NEXT_2_BYTES
.y1
lda #2
.y1 lda #2
+HIDE_NEXT_2_BYTES
.z1
lda #3
.z1 lda #3
+HIDE_NEXT_2_BYTES
.z2
lda #4
.z2 lda #4
+HIDE_NEXT_2_BYTES
.xyzzyReset
lda #0
.xyzzyStoreAndExit
sta .xyzzy
sta .xyzzyCounter
.xyzzyError
jmp SoftBell
.xyzzy
.xyzzyCounter
!byte 0
.xyzzyGo
jsr SaveGlobalPreferences
@ -209,10 +203,3 @@ callback_next
sta gMainScreenPaintDirty ; will trigger a repaint later, in main run loop
jmp LoadGameInfo ; load new game info first
}
callback_options = OptionsDialog
callback_play = LaunchInterpreterWithNewGame
callback_resume = ResumeDialog
callback_boxart = DisplayArtwork
callback_hints = LaunchInterpreterWithHints
callback_versions = VersionsDialog

View File

@ -7,7 +7,6 @@
; - OptionsDialog
;
!zone {
; View IDs (application-specific, acceptable range 0..15, no duplicates)
ID_OPTIONS_FRAME = 1
ID_OPTIONS_FORCE40 = 2
@ -18,7 +17,7 @@ ID_OPTIONS_OK = 6
ID_OPTIONS_CANCEL = 7
; action keys for options screen
.keys
kOptionsKeys
!byte $CF,ID_OPTIONS_OK ; O
!byte $EF,ID_OPTIONS_OK ; o
!byte $8D,ID_OPTIONS_OK ; Return
@ -32,7 +31,7 @@ ID_OPTIONS_CANCEL = 7
!byte $E6,ID_OPTIONS_SCRIPTTOFILE ; f
!byte $D3,ID_OPTIONS_AUTOSCRIPT ; S
!byte $F3,ID_OPTIONS_AUTOSCRIPT ; s
.endkeys
_endOptionsKeys
;------------------------------------------------------------------------------
; OptionsDialog
@ -118,15 +117,15 @@ OptionsDialog
; internal functions
HandleOptionsKey
ldx #.endkeys-.keys
- cmp .keys,x
ldx #_endOptionsKeys-kOptionsKeys
- cmp kOptionsKeys,x
beq .foundKey
dex
dex
bpl -
jmp SoftBell
.foundKey
lda .keys+1,x
lda kOptionsKeys+1,x
ldx #WGSelectView
jsr WeeGUI
jmp SimulateClick
@ -210,6 +209,9 @@ SetPrefByCheckbox
!byte $FD ; SMC
}
;------------------------------------------------------------------------------
; WeeGUI view configuration records
kViewOptionsFrame
!byte ID_OPTIONS_FRAME ; view ID
!byte 2 ; style (decorated frame)
@ -219,8 +221,6 @@ kViewOptionsFrame
!byte 19 ; visible height
!byte 56 ; width
!byte 19 ; height
kStringOptionsFrame
!text "Settings",0
kViewOptionsOK
!byte ID_OPTIONS_OK ; view ID
@ -243,46 +243,48 @@ kViewForce40
!byte 14 ; left
!byte 4 ; top
!word kStringForce40 ; caption
kStringForce40
!text "Force "
!byte $34 ; '4' inverse
!text "0 column",0
kStringForce40Description
!text "Some games may be glitchy",0
kViewForceUpper
!byte ID_OPTIONS_FORCEUPPER ; view ID
!byte 14 ; left
!byte 9 ; top
!word kStringForceUpper ; caption
kStringForceUpper
!text "Force "
!byte $75 ; 'u' inverse
!text "ppercase",0
kStringForceUpperDescription
!text "A MATTER OF PREFERENCE, I SUPPOSE",0
kViewScriptToFile
!byte ID_OPTIONS_SCRIPTTOFILE ; view ID
!byte 14 ; left
!byte 14 ; top
!word kStringScriptToFile ; caption
kStringScriptToFile
!text "SCRIPT to "
!byte $66 ; 'f' inverse
!text "ile",0
kStringScriptToFileDescription
!text "Save transcripts to a file instead of printer",0
kViewAutoScript
!byte ID_OPTIONS_AUTOSCRIPT ; view ID
!byte 14 ; left
!byte 19 ; top
!word kStringAutoScript ; caption
kStringOptionsFrame
!text "Settings",0
kStringForce40
!text "Force "
!byte $34 ; '4' inverse
!text "0 column",0
kStringForce40Description
!text "Some games may be glitchy",0
kStringForceUpper
!text "Force "
!byte $75 ; 'u' inverse
!text "ppercase",0
kStringForceUpperDescription
!text "A MATTER OF PREFERENCE, I SUPPOSE",0
kStringScriptToFile
!text "SCRIPT to "
!byte $66 ; 'f' inverse
!text "ile",0
kStringScriptToFileDescription
!text "Save transcripts to a file instead of printer",0
kStringAutoScript
!text "Always "
!byte $13 ; 'S' inverse
!text "CRIPT",0
kStringAutoScriptDescription
!text "Turn on SCRIPT mode automatically",0
}

View File

@ -7,7 +7,6 @@
; - ResumeGameDialog
;
!zone {
; View IDs (application-specific, acceptable range 0..15, no duplicates)
ID_RESUME_FRAME = 0
ID_RESUME_SLOT0 = 1
@ -26,7 +25,7 @@ gResumeViewInUse
!byte 1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0
; action keys for options screen
.keys
kResumeKeys
!byte $CF,ID_RESUME_OK ; O
!byte $EF,ID_RESUME_OK ; o
!byte $8D,ID_RESUME_OK ; Return
@ -47,7 +46,7 @@ gResumeViewInUse
!byte $95,ID_RESUME_NEXT ; right arrow
!byte $8B,ID_RESUME_PREVIOUS; up arrow
!byte $8A,ID_RESUME_NEXT ; down arrow
.endkeys
_endResumeKeys
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
ID_RESUME_PREVIOUS = $81
@ -60,6 +59,7 @@ ID_RESUME_NEXT = $82
; in: WeeGUI initialized
; out: exits via MainScreen, LaunchInterpreterWithSavedGame, or LaunchInterpreterWithNewGame
;------------------------------------------------------------------------------
!zone {
ResumeDialog
ldx #$FF
txs
@ -145,10 +145,31 @@ ResumeDialog
bit $c010
jsr HandleResumeKey
bra .runLoop
}
;------------------------------------------------------------------------------
; internal functions
!zone {
HandleResumeKey
; A = key pressed
; out: all registers and flags clobbered
ldx #_endResumeKeys-kResumeKeys
- cmp kResumeKeys,x
beq .foundKey
dex
dex
bpl -
jmp SoftBell
.foundKey
; TODO need to handle up and down arrow keys like versions dialog
lda kResumeKeys+1,x
ldx #WGSelectView
jsr WeeGUI
jmp SimulateClick
}
!zone {
CreateResumeRadioCallback
; called via okvs_iter
; X = index (0-based) into gSavedGamesStore, which is also the slot number
@ -176,7 +197,9 @@ CreateResumeRadioCallback
inc iResumeVTAB
.createResumeRadioDone
rts
}
!zone {
PrintResumeLabelCallback
; called via okvs_iter_values
; X = index (0-based) into gSavedGamesStore, which is also the slot number
@ -202,23 +225,10 @@ iResumeVTAB
inc iResumeVTAB
.printResumeLabelDone
rts
}
HandleResumeKey
ldx #.endkeys-.keys
- cmp .keys,x
beq .foundKey
dex
dex
bpl -
jmp SoftBell
.foundKey
; TODO need to handle up and down arrow keys like versions dialog
lda .keys+1,x
ldx #WGSelectView
jsr WeeGUI
jmp SimulateClick
callback_resume_ok
!zone {
ResumeOKCallback
lda #ID_RESUME_SLOT0
ldy #ID_RESUME_NEWGAME+1
jsr GetCheckedRadioButton ; returns A = WeeGUI view ID
@ -227,8 +237,10 @@ callback_resume_ok
lda #0
+ dec ; A = saved game slot (which is WeeGUI view ID - 1) or #$FF
jmp LaunchInterpreterWithGame
}
callback_resume_cancel = MainScreen
;------------------------------------------------------------------------------
; WeeGUI view configuration records
kViewResumeFrame
!byte ID_RESUME_FRAME ; view ID
@ -239,15 +251,13 @@ kViewResumeFrame
!byte $FD ; visible height
!byte 70 ; width
!byte $FD ; height
kStringResumeFrame
!text "Resume Game",0
kViewResumeOK
!byte ID_RESUME_OK ; view ID
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_resume_ok ; callback
!word ResumeOKCallback ; callback
!word kStringOK ; caption
kViewResumeCancel
@ -255,7 +265,7 @@ kViewResumeCancel
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_resume_cancel ; callback
!word MainScreen ; callback
!word kStringCancel ; caption
kViewResumeRadio ; reused for each slot
@ -274,6 +284,7 @@ kViewResumeNewGameTop
!byte $FD ; top (SMC)
!word kStringNewGame ; caption
kStringResumeFrame
!text "Resume Game",0
kStringNewGame
!text " Start ",110,"ew game",0
}

View File

@ -26,7 +26,7 @@ gVersionsViewInUse
!byte 1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0
; action keys for versions screen
.keys
kVersionsKeys
!byte $CF,ID_VERSIONS_OK ; O
!byte $EF,ID_VERSIONS_OK ; o
!byte $8D,ID_VERSIONS_OK ; Return
@ -46,7 +46,7 @@ gVersionsViewInUse
!byte $95,ID_VERSIONS_NEXT ; right arrow
!byte $8B,ID_VERSIONS_PREVIOUS ; up arrow
!byte $8A,ID_VERSIONS_NEXT ; down arrow
.endkeys
_endVersionsKeys
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
ID_VERSIONS_PREVIOUS = $81
@ -175,25 +175,11 @@ iNumVersions=*+1
;------------------------------------------------------------------------------
; internal functions
PrintVersionLabelCallback
; called via okvs_iter_values
; X = index (0-based) into gVersionsStore
; A/Y points to okvs record value, which we use to create a printable label
ldx #50
jsr CreateNullTerminatedString
jsr PrintAt
!byte 7 ; htab (constant)
iVersionsVTAB
!byte $FD ; SMC
!word kNullTerminatedBuffer
inc iVersionsVTAB
inc iVersionsVTAB
rts
HandleVersionsKey
; A = key code from $C000
ldx #.endkeys-.keys
- cmp .keys,x
; A = key pressed
; out: all registers and flags clobbered
ldx #_endVersionsKeys-kVersionsKeys
- cmp kVersionsKeys,x
beq .foundKey
dex
dex
@ -201,7 +187,7 @@ HandleVersionsKey
.notFound
jmp SoftBell
.foundKey
lda .keys+1,x ; get ID associated with this key
lda kVersionsKeys+1,x ; get ID associated with this key
bpl .activateView ; ID < #$80 is a WeeGUI view, so activate it
sta .keyID ; ID >= #$80 is a screen-specific action, so stash it for now
@ -240,7 +226,6 @@ HandleVersionsKey
jsr WeeGUI
ldx #WGPaintView
jmp WeeGUI
.activateView
tax
ldy gVersionsViewInUse,x
@ -249,16 +234,31 @@ HandleVersionsKey
jsr WeeGUI
jmp SimulateClick
PrintVersionLabelCallback
; called via okvs_iter_values
; X = index (0-based) into gVersionsStore
; A/Y points to okvs record value, which we use to create a printable label
ldx #50
jsr CreateNullTerminatedString
jsr PrintAt
!byte 7 ; htab (constant)
iVersionsVTAB
!byte $FD ; SMC
!word kNullTerminatedBuffer
inc iVersionsVTAB
inc iVersionsVTAB
rts
GetCheckedVersion
lda #ID_VERSIONS_1
pha
clc
adc iNumVersions ; iNumVersions was populated during VersionsDialog and hasn't changed since
adc iNumVersions ; iNumVersions was populated in VersionsDialog and hasn't changed since
tay
pla
jmp GetCheckedRadioButton
callback_versions_ok
VersionsOKCallback
jsr GetCheckedVersion
dec
sta .n
@ -278,10 +278,11 @@ callback_versions_ok
lda #1
sta gGlobalPrefsDirty ; must set, otherwise SaveGlobalPreferences does nothing
jsr SaveGlobalPreferences ; immediately write new preferences to disk
jsr CheckForSavedGames ; recheck whether the (newly selected) version has saved games (affects painting in main screen)
; execution falls through here
callback_versions_cancel
jmp MainScreen
jsr CheckForSavedGames ; recheck whether the newly selected version has saved games (affects painting in main screen)
jmp MainScreen ; exit via main screen
;------------------------------------------------------------------------------
; WeeGUI view configuration records
kViewVersionsFrame
!byte ID_VERSIONS_FRAME ; view ID
@ -292,15 +293,13 @@ kViewVersionsFrame
!byte $FD ; visible height
!byte 70 ; width
!byte $FD ; height
kStringVersionsFrame
!text "Select Version",0
kViewVersionsOK
!byte ID_VERSIONS_OK ; view ID
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_versions_ok ; callback
!word VersionsOKCallback ; callback
!word kStringOK ; caption
kViewVersionsCancel
@ -308,7 +307,7 @@ kViewVersionsCancel
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_versions_cancel ; callback
!word MainScreen ; callback
!word kStringCancel ; caption
kViewVersionsArray
@ -376,30 +375,24 @@ kViewVersions9
!byte 20 ; top
!word kString9 ; caption
kStringVersionsFrame
!text "Select Version",0
kString1
!text " ",$31,0
kString2
!text " ",$32,0
kString3
!text " ",$33,0
kString4
!text " ",$34,0
kString5
!text " ",$35,0
kString6
!text " ",$36,0
kString7
!text " ",$37,0
kString8
!text " ",$38,0
kString9
!text " ",$39,0
}