Help info with F1

This commit is contained in:
Ivan Izaguirre 2024-02-13 23:39:00 +01:00
parent 94c85a460a
commit 4b061a76ff
4 changed files with 64 additions and 24 deletions

View File

@ -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 ### Command line options
<!-- doc/usage.txt start --> <!-- doc/usage.txt start -->

View File

@ -39,7 +39,9 @@ func sdlRun(a *izapple2.Apple2) {
defer window.Destroy() defer window.Destroy()
defer renderer.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") sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "best")
@ -96,16 +98,18 @@ func sdlRun(a *izapple2.Apple2) {
if paused != a.IsPaused() { if paused != a.IsPaused() {
if a.IsPaused() { if a.IsPaused() {
window.SetTitle("iz-" + a.Name + " - PAUSED!") window.SetTitle(title + " - PAUSED!")
} else { } else {
window.SetTitle("iz-" + a.Name) window.SetTitle(title)
} }
paused = a.IsPaused() paused = a.IsPaused()
} }
if !a.IsPaused() { if !a.IsPaused() {
var img *image.RGBA 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) img = screen.SnapshotCharacterGenerator(a, kp.showAltText)
window.SetTitle(fmt.Sprintf("%v character map", a.Name)) window.SetTitle(fmt.Sprintf("%v character map", a.Name))
} else if kp.showPages { } 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
`
///////////////////////////////////////

View File

@ -12,6 +12,7 @@ type sdlKeyboard struct {
a *izapple2.Apple2 a *izapple2.Apple2
keyChannel *izapple2.KeyboardChannel keyChannel *izapple2.KeyboardChannel
showHelp bool
showPages bool showPages bool
showCharGen bool showCharGen bool
showAltText bool showAltText bool
@ -40,6 +41,7 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
20 PRINT A, A - 128 20 PRINT A, A - 128
30 GOTO 10 30 GOTO 10
*/ */
if keyEvent.Type != sdl.KEYDOWN { if keyEvent.Type != sdl.KEYDOWN {
// Process only key pushes // Process only key pushes
return return
@ -87,11 +89,13 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
result = 127 // 24 in the Base64A result = 127 // 24 in the Base64A
// Base64A clone particularities // Base64A clone particularities
case sdl.K_F2: case sdl.K_F3:
result = 127 // Base64A result = 127 // Base64A
// Control of the emulator // Control of the emulator
case sdl.K_F1: case sdl.K_F1:
k.showHelp = !k.showHelp
case sdl.K_F2:
if ctrl { if ctrl {
k.a.SendCommand(izapple2.CommandReset) k.a.SendCommand(izapple2.CommandReset)
} }

View File

@ -3,6 +3,7 @@ package screen
import ( import (
"image" "image"
"image/color" "image/color"
"strings"
) )
// SnapshotParts the currently visible screen // 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
} }