From 4b061a76ff895bc538c88b38c5efffba72efaed2 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Tue, 13 Feb 2024 23:39:00 +0100 Subject: [PATCH] Help info with F1 --- README.md | 18 ----------------- frontend/a2sdl/main.go | 38 +++++++++++++++++++++++++++++++---- frontend/a2sdl/sdlKeyboard.go | 6 +++++- screen/snapshotsDebug.go | 26 +++++++++++++++++++++++- 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a4c0ce5..eea9b45 100644 --- a/README.md +++ b/README.md @@ -168,24 +168,6 @@ Line: ``` -### Keys - -- Ctrl-F1: Reset button -- F5: Toggle speed between real and fastest -- Ctrl-F5: Show current speed in Mhz -- F6: Toggle between NTSC color TV and green phosphor monochrome monitor -- F7: Show the video mode and a split screen with the views for NTSC color TV, page 1, page 2 and extra info. -- F10: Cycle character generator code pages. Only if the character generator ROM has more than one 2Kb page. -- Ctrl-F10: Show the charater map for the current character generator page. -- Shift-F10: When showing the character map, use altText. -- F11: Toggle on and off the trace to console of the CPU execution -- F12: Save a screen snapshot to a file `snapshot.png` -- Pause: Pause the emulation - -Drag and drop a diskette file on the left side of the window to change Drive 1; to the right side to change the disk on Drive 2. - -Only valid on SDL mode - ### Command line options diff --git a/frontend/a2sdl/main.go b/frontend/a2sdl/main.go index 2dbe43c..19d2c5b 100644 --- a/frontend/a2sdl/main.go +++ b/frontend/a2sdl/main.go @@ -39,7 +39,9 @@ func sdlRun(a *izapple2.Apple2) { defer window.Destroy() defer renderer.Destroy() - window.SetTitle("iz-" + a.Name) + + title := "iz-" + a.Name + " (F1 for help)" + window.SetTitle(title) sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "best") @@ -96,16 +98,18 @@ func sdlRun(a *izapple2.Apple2) { if paused != a.IsPaused() { if a.IsPaused() { - window.SetTitle("iz-" + a.Name + " - PAUSED!") + window.SetTitle(title + " - PAUSED!") } else { - window.SetTitle("iz-" + a.Name) + window.SetTitle(title) } paused = a.IsPaused() } if !a.IsPaused() { var img *image.RGBA - if kp.showCharGen { + if kp.showHelp { + img = screen.SnapshotMessageGenerator(a, helpMessage) + } else if kp.showCharGen { img = screen.SnapshotCharacterGenerator(a, kp.showAltText) window.SetTitle(fmt.Sprintf("%v character map", a.Name)) } else if kp.showPages { @@ -142,3 +146,29 @@ func sdlRun(a *izapple2.Apple2) { } } + +var helpMessage = ` + + F1: Show/Hide help + Ctrl-F2: Reset + F5: Fast/Normal speed + Ctrl-F5: Show speed + F6: Next screen mode + F7: Show/Hide pages + F10: Next character set + Ctrl-F10: Show/Hide character set + Shift-F10: Show/Hide alternate text + F11: Show/Hide CPU trace + F12: Save screen snapshot + Pause: Pause the emulation + + Drop a file on the left or right + side of the window to load a disk + + Run izapple2 -h for more options + + More info at + https://github.com/ivanizag/izapple2 +` + +/////////////////////////////////////// diff --git a/frontend/a2sdl/sdlKeyboard.go b/frontend/a2sdl/sdlKeyboard.go index 486dfd4..6d70a3b 100644 --- a/frontend/a2sdl/sdlKeyboard.go +++ b/frontend/a2sdl/sdlKeyboard.go @@ -12,6 +12,7 @@ type sdlKeyboard struct { a *izapple2.Apple2 keyChannel *izapple2.KeyboardChannel + showHelp bool showPages bool showCharGen bool showAltText bool @@ -40,6 +41,7 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) { 20 PRINT A, A - 128 30 GOTO 10 */ + if keyEvent.Type != sdl.KEYDOWN { // Process only key pushes return @@ -87,11 +89,13 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) { result = 127 // 24 in the Base64A // Base64A clone particularities - case sdl.K_F2: + case sdl.K_F3: result = 127 // Base64A // Control of the emulator case sdl.K_F1: + k.showHelp = !k.showHelp + case sdl.K_F2: if ctrl { k.a.SendCommand(izapple2.CommandReset) } diff --git a/screen/snapshotsDebug.go b/screen/snapshotsDebug.go index 03249d2..0162520 100644 --- a/screen/snapshotsDebug.go +++ b/screen/snapshotsDebug.go @@ -3,6 +3,7 @@ package screen import ( "image" "image/color" + "strings" ) // SnapshotParts the currently visible screen @@ -154,5 +155,28 @@ func SnapshotCharacterGenerator(vs VideoSource, isAltText bool) *image.RGBA { } } - return renderText(vs, text, isAltText, nil, color.White) + snap := renderText(vs, text, isAltText, nil, color.White) + snap = linesSeparatedFilter(snap) + return snap +} + +// SnapshotMessageGenerator shows a message on the screen +func SnapshotMessageGenerator(vs VideoSource, message string) *image.RGBA { + lines := strings.Split(message, "\n") + text := make([]uint8, textLines*text40Columns) + for i := range text { + text[i] = 0x20 + 0x80 // Space + } + + for l, line := range lines { + for c, char := range line { + if c < text40Columns && l < textLines { + text[text40Columns*l+c] = uint8(char) + 0x80 + } + } + } + + snap := renderText(vs, text, false, nil, color.White) + snap = linesSeparatedFilter(snap) + return snap }