Skip to content

Commit

Permalink
Add 'Screen Saver' DA, issue #27. Also adds DrawMenu to MGTK, fixes #136
Browse files Browse the repository at this point in the history
.
  • Loading branch information
inexorabletash committed Mar 12, 2019
1 parent 088ee11 commit a79eba0
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 118 deletions.
10 changes: 10 additions & 0 deletions MGTK.md
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,16 @@ Parameters:
.res 8 pattern 8x8 pixel pattern
```

#### DrawMenu ($51)
Redraws the current menu bar. Useful after full-screen operations.
Note that hilite state of menu bar items is not restored; this must
be done by manual calls to `HiliteMenu`

Parameters:
```
.res 8 pattern 8x8 pixel pattern
```


# Creating Applications and DeskTop Desk Accessories

Expand Down
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ https://github.com/inexorabletash/a2d/issues
* Shows an on-screen keyboard map and indicates which key is pressed.
* Run Basic Here
* Launch BASIC.SYSTEM with PREFIX set to the current window's pathname. (#42)
* Screen Saver
* Homage to Jack Eastman's classic. More to come. (#27)

Note that several of the new Desk Accessories will not work with older versions
of Apple II DeskTop/MouseDesk, due to dependence on new APIs.
Expand Down
2 changes: 2 additions & 0 deletions desk.acc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ New desk accessories:
* Shows an on-screen keyboard map, and indicates which key is pressed.
* [Run Basic Here](run.basic.here.s)
* Launches BASIC.SYSTEM with PREFIX set to current window's directory.
* [Screen Saver](screen.saver.s)
* Visual distractions.

See [API.md](API.md) for programming details

Expand Down
1 change: 1 addition & 0 deletions desk.acc/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ eyes
screen.dump
run.basic.here
key.caps
screen.saver
382 changes: 382 additions & 0 deletions desk.acc/screen.saver.s

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion desktop/mgtk.s
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ jump_table:
.addr SetMenuSelectionImpl; $4E SetMenuSelection
.addr GetDeskPatImpl ; $4F GetDeskPat
.addr SetDeskPatImpl ; $50 SetDeskPat
.addr DrawMenuImpl ; $51 DrawMenu

;; Entry point param lengths
;; (length, ZP destination, hide cursor flag)
Expand Down Expand Up @@ -497,6 +498,7 @@ param_lengths:
PARAM_DEFN 2, $82, 0 ; $4E SetMenuSelection
PARAM_DEFN 0, $00, 0 ; $4F GetDeskPat
PARAM_DEFN 0, $00, 0 ; $50 SetDeskPat
PARAM_DEFN 0, $00, 0 ; $51 DrawMenu

;;; ============================================================
;;; Pre-Shift Tables
Expand Down Expand Up @@ -5640,6 +5642,7 @@ need_savebehind:
sta savebehind_usage+1
copy16 params_addr, active_menu

draw_menu_impl:
jsr get_menu_count ; into menu_count
jsr hide_cursor_save_params
jsr set_standard_port
Expand Down Expand Up @@ -5776,7 +5779,7 @@ filler: ldx menu_item_index

: rts
.endproc

DrawMenuImpl := SetMenuImpl::draw_menu_impl

.proc get_menu_and_menu_item
ldx menu_index
Expand Down
3 changes: 3 additions & 0 deletions mgtk.inc
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ GetDeskPat = $4F
SetDeskPat = $50
;;; .res 8 pattern 8x8 pixel pattern to use for desktop

DrawMenu = $51 ; Redraw menu bar
;;; (no parameters)


;;; ============================================================
;;; Graphics Primitives Constants
Expand Down
139 changes: 22 additions & 117 deletions preview/show.image.file.s
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
;;; | MP Dst | | MP Dst |
;;; $1580 +-----------+ +-----------+
;;; | | | |
;;; | MP Src | | Menu Save |
;;; | MP Src | | |
;;; $1100 +-----------+ +-----------+
;;; | | | |
;;; | DA | | DA (Copy) |
Expand All @@ -34,20 +34,13 @@
hires := $2000 ; HR/DHR images are loaded directly into screen buffer
hires_size = $2000

;; Menu bits saved/restored
menu_rows = 13
menu_cols = 40
menu_save_area := $1100 ; Past DA code (need $410 bytes)
menu_save_size = menu_cols * 2 * menu_rows ; 5 pages

;; Minipix/Print Shop images are loaded/converted
minipix_src_buf = $1200 ; Load address
minipix_src_size = 576
minipix_dst_buf = $1580 ; Convert address
minipix_dst_size = 26*52

.assert (minipix_src_buf + minipix_src_size) < minipix_dst_buf, error, "Not enough room for Minipix load buffer"
.assert (menu_save_area + menu_save_size) < minipix_dst_buf, error, "Not enough room for menu save area"
.assert (minipix_dst_buf + minipix_dst_size) < WINDOW_ICON_TABLES, error, "Not enough room for Minipix convert buffer"

;;; ============================================================
Expand Down Expand Up @@ -81,9 +74,6 @@ save_stack:.byte 0
jsr init

;; tear down/exit
sta ALTZPON
lda LCBANK1
lda LCBANK1
sta RAMRDOFF
sta RAMWRTOFF

Expand Down Expand Up @@ -215,24 +205,7 @@ base: .word 0
.endproc


.proc event_params ; queried to track mouse-up
kind: .byte $00

;;; if state is MGTK::EventKind::key_down
key := *
modifiers := *+1

;;; otherwise
xcoord := *
ycoord := *+2

.res 4 ; space for both
.endproc

default_width = 560
default_height = 192
default_left = 0
default_top = 0
event_params: .tag MGTK::Event

.proc window_title
.byte 0 ; length
Expand All @@ -250,16 +223,16 @@ vthumbmax: .byte 32
vthumbpos: .byte 0
status: .byte 0
reserved: .byte 0
mincontwidth: .word default_width
mincontlength: .word default_height
maxcontwidth: .word default_width
maxcontlength: .word default_height
mincontwidth: .word screen_width
mincontlength: .word screen_height
maxcontwidth: .word screen_width
maxcontlength: .word screen_height

.proc port
viewloc: DEFINE_POINT default_left, default_top
viewloc: DEFINE_POINT 0, 0
mapbits: .addr MGTK::screen_mapbits
mapwidth: .word MGTK::screen_mapwidth
maprect: DEFINE_RECT 0, 0, default_width, default_height
maprect: DEFINE_RECT 0, 0, screen_width, screen_height
.endproc

pattern:.res 8, 0
Expand All @@ -275,10 +248,6 @@ nextwinfo: .addr 0


.proc init
sta ALTZPON
lda LCBANK1
lda LCBANK1

copy #0, mode

;; Get filename by checking DeskTop selected window/icon
Expand Down Expand Up @@ -376,7 +345,6 @@ end: rts
sta close_params::ref_num

MGTK_CALL MGTK::HideCursor
jsr stash_menu
MGTK_CALL MGTK::OpenWindow, winfo
MGTK_CALL MGTK::SetPort, winfo::port
jsr set_color_mode
Expand All @@ -394,17 +362,17 @@ end: rts

.proc input_loop
MGTK_CALL MGTK::GetEvent, event_params
lda event_params::kind
lda event_params + MGTK::Event::kind
cmp #MGTK::EventKind::button_down ; was clicked?
beq exit
cmp #MGTK::EventKind::key_down ; any key?
beq on_key
bne input_loop

on_key:
lda event_params::modifiers
lda event_params + MGTK::Event::modifiers
bne input_loop
lda event_params::key
lda event_params + MGTK::Event::key
cmp #CHAR_ESCAPE
beq exit
cmp #' '
Expand All @@ -415,11 +383,20 @@ on_key:
exit:
jsr set_bw_mode
MGTK_CALL MGTK::HideCursor

;; Restore menu
MGTK_CALL MGTK::DrawMenu
sta RAMWRTOFF
sta RAMRDOFF
yax_call JUMP_TABLE_MGTK_RELAY, MGTK::HiliteMenu, last_menu_click_params
sta RAMWRTON
sta RAMRDON

;; Force desktop redraw
MGTK_CALL MGTK::CloseWindow, winfo
DESKTOP_CALL DT_REDRAW_ICONS
jsr unstash_menu
MGTK_CALL MGTK::ShowCursor

MGTK_CALL MGTK::ShowCursor
rts ; exits input loop
.endproc

Expand Down Expand Up @@ -611,76 +588,6 @@ done: sta PAGE2OFF
rts
.endproc

;;; ============================================================
;;; Stash/Unstash Menu Bar

;;; Have not yet figured out how to force the menu to
;;; redraw, so instead we save the top 13 rows of the
;;; screen to a scratch buffer and restore after
;;; destroying the window.

.proc stash_menu
src := $08
dst := $06
copy16 #menu_save_area, dst

sta PAGE2ON
jsr inner
sta PAGE2OFF

inner:

lda #0 ; row #
rloop: pha
tax
copy hires_table_lo,x, src
copy hires_table_hi,x, src+1
ldy #menu_cols-1
cloop: lda (src),y
sta (dst),y
dey
bpl cloop

add16 dst, #menu_cols, dst

pla
inc
cmp #menu_rows
bcc rloop
rts
.endproc

.proc unstash_menu
src := $08
dst := $06
copy16 #menu_save_area, src

sta PAGE2ON
jsr inner
sta PAGE2OFF

inner:

lda #0 ; row #
rloop: pha
tax
copy hires_table_lo,x, dst
copy hires_table_hi,x, dst+1
ldy #menu_cols-1
cloop: lda (src),y
sta (dst),y
dey
bpl cloop

add16 src, #menu_cols, src

pla
inc
cmp #menu_rows
bcc rloop
rts
.endproc

;;; ============================================================
;;; Minipix images

Expand Down Expand Up @@ -814,5 +721,3 @@ done: rts
;;; ============================================================

da_end:

.assert * <= menu_save_area, error, "DA overlapping menu save area"

0 comments on commit a79eba0

Please sign in to comment.