2017-10-12 03:45:58 +00:00
|
|
|
.setcpu "6502"
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-06 05:19:45 +00:00
|
|
|
.include "apple2.inc"
|
2018-02-27 04:13:18 +00:00
|
|
|
.include "../inc/apple2.inc"
|
2017-09-04 19:56:41 +00:00
|
|
|
.include "../inc/prodos.inc"
|
2018-01-29 05:18:00 +00:00
|
|
|
.include "../mgtk.inc"
|
2018-05-03 03:04:56 +00:00
|
|
|
.include "../desktop.inc"
|
2018-02-07 02:42:00 +00:00
|
|
|
.include "../macros.inc"
|
2017-10-12 03:45:58 +00:00
|
|
|
|
2018-05-03 03:04:56 +00:00
|
|
|
;;; ============================================================
|
|
|
|
|
2017-10-12 03:45:58 +00:00
|
|
|
.org $800
|
2017-08-29 15:07:02 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
dummy1000 := $1000
|
|
|
|
|
|
|
|
|
2017-08-29 03:58:09 +00:00
|
|
|
start: jmp copy2aux
|
|
|
|
|
2017-09-01 05:53:07 +00:00
|
|
|
save_stack:.byte 0
|
|
|
|
|
|
|
|
;;; Copy $800 through $13FF (the DA) to aux
|
2017-08-30 02:07:44 +00:00
|
|
|
.proc copy2aux
|
2017-08-29 03:58:09 +00:00
|
|
|
tsx
|
2017-09-01 05:53:07 +00:00
|
|
|
stx save_stack
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTON
|
2017-09-01 05:53:07 +00:00
|
|
|
ldy #0
|
|
|
|
src: lda start,y ; self-modified
|
|
|
|
dst: sta start,y ; self-modified
|
2017-08-29 03:58:09 +00:00
|
|
|
dey
|
2017-09-01 05:53:07 +00:00
|
|
|
bne src
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTOFF
|
2017-09-01 05:53:07 +00:00
|
|
|
inc src+2
|
|
|
|
inc dst+2
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTON
|
2017-09-01 05:53:07 +00:00
|
|
|
lda dst+2
|
2017-08-29 03:58:09 +00:00
|
|
|
cmp #$14
|
2017-09-01 05:53:07 +00:00
|
|
|
bne src
|
2017-08-30 02:07:44 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-02 02:35:50 +00:00
|
|
|
call_main_trampoline := $20 ; installed on ZP, turns off auxmem and calls...
|
|
|
|
call_main_addr := call_main_trampoline+7 ; address patched in here
|
|
|
|
|
2017-09-02 02:06:14 +00:00
|
|
|
;;; Copy the following "call_main_template" routine to $20
|
2017-09-01 05:53:07 +00:00
|
|
|
.scope
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTON
|
|
|
|
sta RAMRDON
|
2018-12-08 17:56:47 +00:00
|
|
|
COPY_BYTES sizeof_call_main_template+1, call_main_template, call_main_trampoline
|
2017-09-01 05:53:07 +00:00
|
|
|
jmp call_init
|
|
|
|
.endscope
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 02:06:14 +00:00
|
|
|
.proc call_main_template
|
2017-08-30 02:07:44 +00:00
|
|
|
sta RAMRDOFF
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTOFF
|
2018-04-29 03:00:18 +00:00
|
|
|
jsr dummy1000 ; overwritten (in zp version)
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMRDON
|
|
|
|
sta RAMWRTON
|
|
|
|
rts
|
2017-08-30 02:07:44 +00:00
|
|
|
.endproc
|
2018-12-28 23:46:09 +00:00
|
|
|
sizeof_call_main_template = * - call_main_template
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-01 05:53:07 +00:00
|
|
|
.proc call_init
|
|
|
|
;; run the DA
|
|
|
|
jsr init
|
|
|
|
|
|
|
|
;; tear down/exit
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
|
|
|
sta RAMRDOFF
|
|
|
|
sta RAMWRTOFF
|
2017-09-01 05:53:07 +00:00
|
|
|
ldx save_stack
|
2017-08-29 03:58:09 +00:00
|
|
|
txs
|
2017-09-01 05:53:07 +00:00
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-01 05:53:07 +00:00
|
|
|
;;; ProDOS MLI calls
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc open_file
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr copy_params_aux_to_main
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPOFF
|
2017-08-29 15:40:35 +00:00
|
|
|
MLI_CALL OPEN, open_params
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 16:08:46 +00:00
|
|
|
jsr copy_params_main_to_aux
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 01:47:15 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc read_file
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr copy_params_aux_to_main
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPOFF
|
2017-08-29 15:40:35 +00:00
|
|
|
MLI_CALL READ, read_params
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 16:08:46 +00:00
|
|
|
jsr copy_params_main_to_aux
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 01:47:15 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc get_file_eof
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr copy_params_aux_to_main
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPOFF
|
2017-08-29 15:45:32 +00:00
|
|
|
MLI_CALL GET_EOF, get_eof_params
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 16:08:46 +00:00
|
|
|
jsr copy_params_main_to_aux
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 01:47:15 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-30 01:47:15 +00:00
|
|
|
.proc set_file_mark
|
|
|
|
jsr copy_params_aux_to_main
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPOFF
|
2017-08-29 15:47:42 +00:00
|
|
|
MLI_CALL SET_MARK, set_mark_params
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 16:08:46 +00:00
|
|
|
jsr copy_params_main_to_aux
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 01:47:15 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-30 01:47:15 +00:00
|
|
|
.proc close_file
|
|
|
|
jsr copy_params_aux_to_main
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPOFF
|
2017-08-29 15:45:32 +00:00
|
|
|
MLI_CALL CLOSE, close_params
|
2017-08-29 03:58:09 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 16:08:46 +00:00
|
|
|
jsr copy_params_main_to_aux
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 01:47:15 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-01 05:53:07 +00:00
|
|
|
|
2017-08-29 16:08:46 +00:00
|
|
|
;;; Copies param blocks from Aux to Main
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc copy_params_aux_to_main
|
2017-08-29 16:08:46 +00:00
|
|
|
ldy #(params_end - params_start + 1)
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTOFF
|
2017-08-29 16:08:46 +00:00
|
|
|
loop: lda params_start - 1,y
|
|
|
|
sta params_start - 1,y
|
2017-08-29 03:58:09 +00:00
|
|
|
dey
|
2017-08-29 16:08:46 +00:00
|
|
|
bne loop
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMRDOFF
|
|
|
|
rts
|
2017-08-29 16:08:46 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-29 16:08:46 +00:00
|
|
|
;;; Copies param blocks from Main to Aux
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc copy_params_main_to_aux
|
2017-08-29 16:08:46 +00:00
|
|
|
pha
|
2017-08-29 03:58:09 +00:00
|
|
|
php
|
|
|
|
sta RAMWRTON
|
2017-08-29 16:08:46 +00:00
|
|
|
ldy #(params_end - params_start + 1)
|
|
|
|
loop: lda params_start - 1,y
|
|
|
|
sta params_start - 1,y
|
2017-08-29 03:58:09 +00:00
|
|
|
dey
|
2017-08-29 16:08:46 +00:00
|
|
|
bne loop
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMRDON
|
|
|
|
plp
|
|
|
|
pla
|
2017-08-29 16:08:46 +00:00
|
|
|
rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-29 16:08:46 +00:00
|
|
|
;;; ----------------------------------------
|
|
|
|
|
|
|
|
params_start:
|
|
|
|
;;; This block gets copied between main/aux
|
2017-08-29 15:40:35 +00:00
|
|
|
|
2017-09-01 05:53:07 +00:00
|
|
|
;;; ProDOS MLI param blocks
|
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
io_buf := $0C00
|
|
|
|
default_buffer := $1200
|
2018-12-28 23:46:09 +00:00
|
|
|
read_length = $0100
|
2017-09-01 05:39:06 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
DEFINE_OPEN_PARAMS open_params, pathbuf, io_buf
|
|
|
|
DEFINE_READ_PARAMS read_params, default_buffer, read_length
|
2018-02-27 04:51:23 +00:00
|
|
|
DEFINE_GET_EOF_PARAMS get_eof_params
|
|
|
|
DEFINE_SET_MARK_PARAMS set_mark_params, 0
|
|
|
|
DEFINE_CLOSE_PARAMS close_params
|
2017-08-29 16:08:46 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
pathbuf: .res 65, 0
|
2017-09-01 01:38:49 +00:00
|
|
|
|
2017-08-29 03:58:09 +00:00
|
|
|
L0945: .byte $00
|
|
|
|
L0946: .byte $00
|
|
|
|
L0947: .byte $00
|
|
|
|
L0948: .byte $00
|
|
|
|
L0949: .byte $00
|
2017-09-02 03:10:21 +00:00
|
|
|
|
2017-09-03 03:23:14 +00:00
|
|
|
params_end := * + 4 ; bug in original? (harmless as this is static)
|
2017-08-29 16:08:46 +00:00
|
|
|
;;; ----------------------------------------
|
|
|
|
|
2017-09-03 03:23:14 +00:00
|
|
|
black_pattern:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res 8, $00
|
2017-09-02 04:24:35 +00:00
|
|
|
|
2017-09-03 03:23:14 +00:00
|
|
|
white_pattern:
|
2017-09-14 04:01:30 +00:00
|
|
|
.res $8, $FF
|
2017-09-03 03:23:14 +00:00
|
|
|
|
2018-12-28 23:46:09 +00:00
|
|
|
da_window_id = 100
|
2017-09-01 15:15:05 +00:00
|
|
|
|
2018-12-28 23:46:09 +00:00
|
|
|
line_spacing = 10
|
|
|
|
right_const = 506
|
2018-04-29 03:00:18 +00:00
|
|
|
|
2017-08-29 03:58:09 +00:00
|
|
|
L095A: .byte $00
|
2018-04-29 03:00:18 +00:00
|
|
|
L095B: .word right_const
|
2017-09-01 15:15:05 +00:00
|
|
|
|
|
|
|
.proc line_pos
|
|
|
|
left: .word 0
|
|
|
|
base: .word 0
|
|
|
|
.endproc
|
|
|
|
|
2017-09-01 15:48:46 +00:00
|
|
|
window_width: .word 0
|
|
|
|
window_height: .word 0
|
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
y_remaining: .word 0
|
|
|
|
line_count: .word 0
|
2018-02-07 02:42:00 +00:00
|
|
|
L096A: .word 0
|
|
|
|
L096C: .word 0
|
2017-08-31 04:13:25 +00:00
|
|
|
|
|
|
|
track_scroll_delta:
|
|
|
|
.byte $00
|
2017-08-30 05:10:33 +00:00
|
|
|
|
|
|
|
fixed_mode_flag:
|
2017-09-02 03:30:55 +00:00
|
|
|
.byte $00 ; 0 = proportional, otherwise = fixed
|
2017-08-30 05:10:33 +00:00
|
|
|
|
2018-01-30 04:14:34 +00:00
|
|
|
.proc event_params
|
2018-01-30 05:11:32 +00:00
|
|
|
kind: .byte 0
|
2018-11-17 06:48:16 +00:00
|
|
|
|
2018-11-18 04:37:19 +00:00
|
|
|
;;; if state is MGTK::EventKind::key_down
|
2018-11-17 06:48:16 +00:00
|
|
|
key := *
|
|
|
|
modifiers := *+1
|
|
|
|
|
|
|
|
;;; otherwise
|
|
|
|
coords := *
|
|
|
|
mousex := * ; spills into target query
|
|
|
|
mousey := *+2
|
|
|
|
|
|
|
|
.res 4 ; space for both
|
2017-09-09 03:45:11 +00:00
|
|
|
.endproc
|
2018-01-31 08:05:54 +00:00
|
|
|
|
2018-01-30 04:14:34 +00:00
|
|
|
.proc findwindow_params
|
2018-01-31 08:05:54 +00:00
|
|
|
which_area: .byte 0
|
|
|
|
window_id: .byte 0
|
2017-08-31 02:42:31 +00:00
|
|
|
.endproc
|
2017-08-30 05:10:33 +00:00
|
|
|
|
2018-01-30 04:14:34 +00:00
|
|
|
.proc growwindow_params
|
2018-01-31 08:05:54 +00:00
|
|
|
window_id: .byte da_window_id
|
|
|
|
mousex: .word 0
|
|
|
|
mousey: .word 0
|
|
|
|
it_grew: .byte 0
|
2017-09-02 02:54:04 +00:00
|
|
|
.endproc
|
2017-08-31 03:30:46 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
.proc trackgoaway_params ; queried after close clicked to see if aborted/finished
|
|
|
|
goaway: .byte 0 ; 0 = aborted, 1 = clicked
|
2017-08-31 03:30:46 +00:00
|
|
|
.endproc
|
|
|
|
|
2018-01-31 08:05:54 +00:00
|
|
|
.byte 0,0 ; ???
|
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
.proc findcontrol_params ; queried after a client click to identify target
|
2018-01-31 08:05:54 +00:00
|
|
|
mousex: .word 0
|
|
|
|
mousey: .word 0
|
2018-04-29 03:00:18 +00:00
|
|
|
which_ctl: .byte 0 ; 0 = client, 1 = vscroll, 2 = hscroll
|
|
|
|
which_part: .byte 0 ; 1 = up, 2 = down, 3 = above, 4 = below, 5 = thumb
|
2017-08-31 03:30:46 +00:00
|
|
|
.endproc
|
|
|
|
|
2018-01-30 04:14:34 +00:00
|
|
|
.proc updatethumb_params ; called to update scroll bar position
|
2018-01-31 08:05:54 +00:00
|
|
|
which_ctl: .byte 0 ; 1 = vscroll, 2 = hscroll
|
|
|
|
thumbpos: .byte 0 ; new position
|
2017-08-31 15:10:51 +00:00
|
|
|
.endproc
|
2017-08-31 05:13:41 +00:00
|
|
|
|
|
|
|
;;; Used when dragging vscroll thumb
|
2018-01-31 08:05:54 +00:00
|
|
|
.proc trackthumb_params
|
|
|
|
which_ctl: .byte 0 ; 1 = vscroll, 2 = hscroll
|
|
|
|
mousex: .word 0
|
|
|
|
mousey: .word 0
|
|
|
|
thumbpos: .byte 0 ; position
|
|
|
|
thumbmoved: .byte 0 ; 0 if not moved, 1 if moved
|
2017-08-31 05:13:41 +00:00
|
|
|
.endproc
|
2017-08-30 01:52:56 +00:00
|
|
|
|
2018-01-31 08:05:54 +00:00
|
|
|
.proc drawtext_params
|
2018-04-29 03:00:18 +00:00
|
|
|
textptr: .addr 0 ; address
|
|
|
|
textlen: .byte 0 ; length
|
2017-09-01 05:12:02 +00:00
|
|
|
.endproc
|
2017-08-30 01:52:56 +00:00
|
|
|
|
2018-12-28 23:46:09 +00:00
|
|
|
default_width = 512
|
|
|
|
default_height = 150
|
|
|
|
default_left = 10
|
|
|
|
default_top = 28
|
2017-09-03 01:51:03 +00:00
|
|
|
|
2018-01-30 05:11:32 +00:00
|
|
|
.proc winfo
|
2018-04-29 03:00:18 +00:00
|
|
|
window_id: .byte da_window_id ; window identifier
|
2018-11-18 04:34:17 +00:00
|
|
|
options: .byte MGTK::Option::go_away_box ; window flags (2=include close port)
|
2018-04-29 03:00:18 +00:00
|
|
|
title: .addr dummy1000 ; overwritten to point at filename
|
2018-11-18 04:34:17 +00:00
|
|
|
hscroll: .byte MGTK::Scroll::option_none
|
|
|
|
vscroll: .byte MGTK::Scroll::option_normal
|
2018-04-29 03:00:18 +00:00
|
|
|
hthumbmax: .byte 32
|
|
|
|
hthumbpos: .byte 0
|
|
|
|
vthumbmax: .byte 255
|
|
|
|
vthumbpos: .byte 0
|
|
|
|
status: .byte 0
|
2018-01-30 05:11:32 +00:00
|
|
|
reserved: .byte 0
|
2018-04-29 03:00:18 +00:00
|
|
|
mincontwidth: .word 200
|
|
|
|
mincontlength: .word 51
|
|
|
|
maxcontwidth: .word default_width
|
|
|
|
maxcontlength: .word default_height
|
2018-01-31 08:05:54 +00:00
|
|
|
port:
|
2018-04-29 03:00:18 +00:00
|
|
|
viewloc: DEFINE_POINT default_left, default_top, viewloc
|
|
|
|
mapbits: .addr MGTK::screen_mapbits
|
|
|
|
mapwidth: .word MGTK::screen_mapwidth
|
|
|
|
maprect: DEFINE_RECT 0, 0, default_width, default_height, maprect
|
|
|
|
pattern: .res 8, $00
|
|
|
|
colormasks: .byte MGTK::colormask_and, MGTK::colormask_or
|
|
|
|
penloc: DEFINE_POINT 0, 0
|
|
|
|
penwidth: .byte 1
|
|
|
|
penheight: .byte 1
|
|
|
|
penmode: .byte 0
|
|
|
|
textback: .byte $7F
|
|
|
|
textfont: .addr DEFAULT_FONT
|
|
|
|
nextwinfo: .addr 0
|
2017-09-14 03:09:36 +00:00
|
|
|
.endproc
|
2017-09-01 15:15:05 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
|
2018-01-30 05:11:32 +00:00
|
|
|
;; gets copied over winfo::port after mode is drawn
|
2018-01-31 08:05:54 +00:00
|
|
|
.proc default_port
|
2018-04-29 03:00:18 +00:00
|
|
|
viewloc: DEFINE_POINT default_left, default_top
|
|
|
|
mapbits: .word MGTK::screen_mapbits
|
|
|
|
mapwidth: .word MGTK::screen_mapwidth
|
2018-01-31 08:05:54 +00:00
|
|
|
maprect: DEFINE_RECT 0, 0, default_width, default_height
|
2017-09-01 15:32:29 +00:00
|
|
|
.endproc
|
2017-08-29 16:08:46 +00:00
|
|
|
|
2017-09-01 05:53:07 +00:00
|
|
|
.proc init
|
2017-09-02 03:30:55 +00:00
|
|
|
sta ALTZPON
|
2017-08-29 03:58:09 +00:00
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
2017-09-02 01:43:53 +00:00
|
|
|
|
2017-09-04 04:47:45 +00:00
|
|
|
;; Get filename by checking DeskTop selected window/icon
|
2017-09-02 01:43:53 +00:00
|
|
|
|
2017-09-04 04:47:45 +00:00
|
|
|
;; Check that an icon is selected
|
2017-09-02 01:32:37 +00:00
|
|
|
lda #0
|
2018-04-29 03:00:18 +00:00
|
|
|
sta pathbuf
|
2018-02-19 19:33:13 +00:00
|
|
|
lda selected_file_count
|
2017-09-02 01:32:37 +00:00
|
|
|
beq abort ; some file properties?
|
2017-09-02 01:43:53 +00:00
|
|
|
lda path_index ; prefix index in table
|
2017-09-02 02:39:29 +00:00
|
|
|
bne :+
|
2017-09-02 01:32:37 +00:00
|
|
|
abort: rts
|
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
;; Copy path (prefix) into pathbuf.
|
2017-09-02 02:39:29 +00:00
|
|
|
: src := $06
|
2017-09-02 01:32:37 +00:00
|
|
|
dst := $08
|
2017-09-02 01:43:53 +00:00
|
|
|
|
|
|
|
asl a ; (since address table is 2 bytes wide)
|
2017-08-29 03:58:09 +00:00
|
|
|
tax
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 path_table,x, src
|
2017-09-02 01:32:37 +00:00
|
|
|
ldy #0
|
|
|
|
lda (src),y
|
2017-08-29 03:58:09 +00:00
|
|
|
tax
|
2017-09-02 01:32:37 +00:00
|
|
|
inc src
|
|
|
|
bne :+
|
|
|
|
inc src+1
|
2018-04-29 03:00:18 +00:00
|
|
|
: copy16 #pathbuf+1, dst
|
|
|
|
jsr copy_pathbuf ; copy x bytes (src) to (dst)
|
2017-09-02 01:32:37 +00:00
|
|
|
|
2017-09-02 01:58:36 +00:00
|
|
|
;; Append separator.
|
|
|
|
lda #'/'
|
2017-09-02 01:32:37 +00:00
|
|
|
ldy #0
|
|
|
|
sta (dst),y
|
2018-04-29 03:00:18 +00:00
|
|
|
inc pathbuf
|
2017-09-02 01:32:37 +00:00
|
|
|
inc dst
|
|
|
|
bne :+
|
|
|
|
inc dst+1
|
2017-09-02 01:43:53 +00:00
|
|
|
|
2017-09-02 05:08:43 +00:00
|
|
|
;; Get file entry.
|
2018-02-19 19:33:13 +00:00
|
|
|
: lda selected_file_list ; file index in table
|
2017-09-02 01:43:53 +00:00
|
|
|
asl a ; (since table is 2 bytes wide)
|
2017-08-29 03:58:09 +00:00
|
|
|
tax
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 file_table,x, src
|
2017-09-02 01:58:36 +00:00
|
|
|
|
2017-09-02 05:08:43 +00:00
|
|
|
;; Exit if a directory.
|
|
|
|
ldy #2 ; 2nd byte of entry
|
2017-09-02 01:32:37 +00:00
|
|
|
lda (src),y
|
2018-12-25 00:00:55 +00:00
|
|
|
and #icon_entry_type_mask
|
2017-09-02 01:32:37 +00:00
|
|
|
bne :+
|
2018-12-25 00:00:55 +00:00
|
|
|
rts ; 000 = directory
|
2017-09-02 01:58:36 +00:00
|
|
|
|
2017-09-02 05:08:43 +00:00
|
|
|
;; Set window title to point at filename (9th byte of entry)
|
|
|
|
;; (title includes the spaces before/after from the icon)
|
2017-09-02 01:32:37 +00:00
|
|
|
: clc
|
2018-12-25 00:00:55 +00:00
|
|
|
lda src
|
|
|
|
adc #IconEntry::len
|
2018-01-30 05:11:32 +00:00
|
|
|
sta winfo::title
|
2017-09-02 01:32:37 +00:00
|
|
|
lda src+1
|
2017-09-02 01:58:36 +00:00
|
|
|
adc #0
|
2018-01-30 05:11:32 +00:00
|
|
|
sta winfo::title+1
|
2017-09-02 01:58:36 +00:00
|
|
|
|
2017-09-02 05:08:43 +00:00
|
|
|
;; Append filename to path.
|
2018-12-25 00:00:55 +00:00
|
|
|
ldy #IconEntry::len
|
2017-09-02 05:08:43 +00:00
|
|
|
lda (src),y ; grab length
|
|
|
|
tax ; name has spaces before/after
|
|
|
|
dex ; so subtract 2 to get actual length
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
|
|
|
clc
|
2017-09-02 01:32:37 +00:00
|
|
|
lda src
|
2017-09-02 05:08:43 +00:00
|
|
|
adc #11 ; 9 = length, 10 = space, 11 = name
|
2017-09-02 01:32:37 +00:00
|
|
|
sta src
|
2017-09-02 01:58:36 +00:00
|
|
|
bcc :+
|
2017-09-02 01:32:37 +00:00
|
|
|
inc src+1
|
2018-04-29 03:00:18 +00:00
|
|
|
: jsr copy_pathbuf ; copy x bytes (src) to (dst)
|
2017-09-02 01:58:36 +00:00
|
|
|
|
2017-09-04 03:07:05 +00:00
|
|
|
;; Clear selection (why???)
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 #JUMP_TABLE_CLEAR_SEL, call_main_addr
|
2017-09-02 02:06:14 +00:00
|
|
|
jsr call_main_trampoline
|
2017-09-02 01:58:36 +00:00
|
|
|
|
2017-09-01 05:12:02 +00:00
|
|
|
jmp open_file_and_init_window
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
.proc copy_pathbuf ; copy x bytes from src to dst
|
2017-09-02 01:32:37 +00:00
|
|
|
ldy #0 ; incrementing path length and dst
|
|
|
|
loop: lda (src),y
|
|
|
|
sta (dst),y
|
2017-08-29 03:58:09 +00:00
|
|
|
iny
|
2018-04-29 03:00:18 +00:00
|
|
|
inc pathbuf
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
2017-09-01 05:12:02 +00:00
|
|
|
bne loop
|
2017-08-29 03:58:09 +00:00
|
|
|
tya
|
|
|
|
clc
|
2017-09-02 01:32:37 +00:00
|
|
|
adc dst
|
|
|
|
sta dst
|
2017-09-01 05:12:02 +00:00
|
|
|
bcc end
|
2017-09-02 01:32:37 +00:00
|
|
|
inc dst+1
|
2017-09-01 05:12:02 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 01:32:37 +00:00
|
|
|
.endproc
|
|
|
|
|
2017-09-16 03:04:56 +00:00
|
|
|
font_width_backup := $1100
|
|
|
|
|
2017-09-01 05:12:02 +00:00
|
|
|
.proc open_file_and_init_window
|
|
|
|
lda #0
|
2017-08-30 05:10:33 +00:00
|
|
|
sta fixed_mode_flag
|
2017-09-01 05:12:02 +00:00
|
|
|
|
2017-09-16 03:04:56 +00:00
|
|
|
;; make backup of font width table; overwritten if fixed
|
2018-06-02 02:00:00 +00:00
|
|
|
ldx DEFAULT_FONT + MGTK::Font::lastchar
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTOFF
|
2018-06-02 02:00:00 +00:00
|
|
|
loop: lda DEFAULT_FONT + MGTK::Font::charwidth - 1,x
|
2017-09-18 15:10:19 +00:00
|
|
|
sta font_width_backup - 1,x
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
2017-09-01 05:12:02 +00:00
|
|
|
bne loop
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTON
|
2017-09-01 05:12:02 +00:00
|
|
|
|
|
|
|
;; open file, get length
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr open_file
|
2017-08-31 02:42:31 +00:00
|
|
|
lda open_params::ref_num
|
|
|
|
sta read_params::ref_num
|
|
|
|
sta set_mark_params::ref_num
|
|
|
|
sta get_eof_params::ref_num
|
|
|
|
sta close_params::ref_num
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr get_file_eof
|
2017-09-01 05:12:02 +00:00
|
|
|
|
|
|
|
;; create window
|
2018-01-30 05:11:32 +00:00
|
|
|
MGTK_CALL MGTK::OpenWindow, winfo
|
|
|
|
MGTK_CALL MGTK::SetPort, winfo::port
|
2017-09-02 16:44:33 +00:00
|
|
|
jsr calc_window_size
|
2017-08-31 02:42:31 +00:00
|
|
|
jsr calc_and_draw_mode
|
2017-09-01 01:38:49 +00:00
|
|
|
jsr draw_content
|
2018-01-29 16:38:23 +00:00
|
|
|
MGTK_CALL MGTK::FlushEvents
|
2017-09-02 03:10:21 +00:00
|
|
|
;; fall through
|
2017-09-01 05:12:02 +00:00
|
|
|
.endproc
|
2017-08-30 05:10:33 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Main Input Loop
|
|
|
|
|
2017-08-30 05:10:33 +00:00
|
|
|
input_loop:
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::GetEvent, event_params
|
|
|
|
lda event_params
|
2018-11-18 04:37:19 +00:00
|
|
|
cmp #MGTK::EventKind::key_down ; key?
|
2018-11-17 06:48:16 +00:00
|
|
|
beq on_key_down
|
2018-11-18 04:37:19 +00:00
|
|
|
cmp #MGTK::EventKind::button_down ; was clicked?
|
2017-08-30 05:10:33 +00:00
|
|
|
bne input_loop ; nope, keep waiting
|
|
|
|
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::FindWindow, event_params::coords
|
2018-01-31 08:05:54 +00:00
|
|
|
lda findwindow_params::window_id ; in our window?
|
|
|
|
cmp #da_window_id
|
2017-08-30 05:10:33 +00:00
|
|
|
bne input_loop
|
2017-09-01 05:39:06 +00:00
|
|
|
|
|
|
|
;; which part of the window?
|
2018-01-31 08:05:54 +00:00
|
|
|
lda findwindow_params::which_area
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Area::close_box
|
2017-09-02 04:24:35 +00:00
|
|
|
beq on_close_click
|
2017-09-01 05:39:06 +00:00
|
|
|
|
2017-09-02 04:24:35 +00:00
|
|
|
;; title and resize clicks need mouse location
|
2018-01-31 08:05:54 +00:00
|
|
|
ldx event_params::mousex
|
|
|
|
stx growwindow_params::mousex
|
|
|
|
stx findcontrol_params::mousex
|
|
|
|
ldx event_params::mousex+1
|
|
|
|
stx growwindow_params::mousex+1
|
|
|
|
stx findcontrol_params::mousex+1
|
|
|
|
ldx event_params::mousey
|
|
|
|
stx growwindow_params::mousey
|
|
|
|
stx findcontrol_params::mousey
|
2017-09-01 05:39:06 +00:00
|
|
|
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Area::dragbar
|
2017-09-01 05:39:06 +00:00
|
|
|
beq title
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Area::grow_box ; not enabled, so this will never match
|
2017-08-30 05:10:33 +00:00
|
|
|
beq input_loop
|
2017-08-31 03:30:46 +00:00
|
|
|
jsr on_client_click
|
2017-08-30 05:10:33 +00:00
|
|
|
jmp input_loop
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-01 05:39:06 +00:00
|
|
|
title: jsr on_title_bar_click
|
2017-08-30 05:10:33 +00:00
|
|
|
jmp input_loop
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-11-17 06:48:16 +00:00
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
;;; Key
|
|
|
|
|
|
|
|
.proc on_key_down
|
2018-12-25 02:24:11 +00:00
|
|
|
lda event_params::modifiers
|
2018-11-17 06:48:16 +00:00
|
|
|
beq no_mod
|
|
|
|
|
|
|
|
;; Modifiers
|
|
|
|
lda event_params::key
|
|
|
|
|
2018-11-25 01:41:31 +00:00
|
|
|
cmp #CHAR_DOWN ; Apple-Down = Page Down
|
2018-11-17 06:48:16 +00:00
|
|
|
bne :+
|
|
|
|
jsr page_down
|
|
|
|
jmp input_loop
|
|
|
|
|
2018-11-25 01:41:31 +00:00
|
|
|
: cmp #CHAR_UP ; Apple-Up = Page Up
|
2018-11-17 06:48:16 +00:00
|
|
|
bne :+
|
|
|
|
jsr page_up
|
2018-11-25 01:41:31 +00:00
|
|
|
jmp input_loop
|
|
|
|
|
|
|
|
: cmp #CHAR_LEFT ; Apple-Left = Home
|
|
|
|
bne :+
|
|
|
|
jsr scroll_top
|
|
|
|
jmp input_loop
|
|
|
|
|
|
|
|
: cmp #CHAR_RIGHT ; Apple-Right = End
|
|
|
|
bne :+
|
|
|
|
jsr scroll_bottom
|
2018-11-17 06:48:16 +00:00
|
|
|
|
|
|
|
: jmp input_loop
|
|
|
|
|
|
|
|
;; No modifiers
|
|
|
|
no_mod:
|
|
|
|
lda event_params::key
|
|
|
|
|
|
|
|
cmp #CHAR_ESCAPE
|
|
|
|
bne :+
|
|
|
|
jmp do_close
|
|
|
|
|
|
|
|
: cmp #CHAR_DOWN
|
|
|
|
bne :+
|
|
|
|
jsr scroll_down
|
|
|
|
jmp input_loop
|
|
|
|
|
|
|
|
: cmp #CHAR_UP
|
|
|
|
bne :+
|
|
|
|
jsr scroll_up
|
|
|
|
|
|
|
|
: jmp input_loop
|
|
|
|
.endproc
|
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Close Button
|
|
|
|
|
|
|
|
.proc on_close_click
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::TrackGoAway, trackgoaway_params
|
2018-01-30 05:11:32 +00:00
|
|
|
lda trackgoaway_params::goaway ; did click complete?
|
2018-11-17 06:48:16 +00:00
|
|
|
bne do_close ; yes
|
|
|
|
jmp input_loop ; no
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc do_close
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr close_file
|
2018-01-30 05:11:32 +00:00
|
|
|
MGTK_CALL MGTK::CloseWindow, winfo
|
2018-02-05 03:13:21 +00:00
|
|
|
DESKTOP_CALL DT_REDRAW_ICONS
|
2017-08-30 06:47:18 +00:00
|
|
|
rts ; exits input loop
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Client Area
|
|
|
|
|
2017-08-31 04:04:16 +00:00
|
|
|
;;; Non-title (client) area clicked
|
2017-08-31 03:30:46 +00:00
|
|
|
.proc on_client_click
|
2017-09-02 04:24:35 +00:00
|
|
|
;; On one of the scroll bars?
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::FindControl, findcontrol_params
|
2018-01-31 08:05:54 +00:00
|
|
|
lda findcontrol_params::which_ctl
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Ctl::vertical_scroll_bar
|
2017-08-31 03:41:54 +00:00
|
|
|
beq on_vscroll_click
|
|
|
|
end: rts
|
2017-08-31 03:30:46 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Vertical Scroll Bar
|
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_click
|
2018-11-18 04:34:17 +00:00
|
|
|
lda #MGTK::Ctl::vertical_scroll_bar
|
2018-01-31 08:05:54 +00:00
|
|
|
sta trackthumb_params::which_ctl
|
|
|
|
sta updatethumb_params::which_ctl
|
|
|
|
lda findcontrol_params::which_part
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Part::thumb
|
2017-08-31 03:41:54 +00:00
|
|
|
beq on_vscroll_thumb_click
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Part::page_down
|
2017-08-31 03:41:54 +00:00
|
|
|
beq on_vscroll_below_click
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Part::page_up
|
2017-08-31 03:41:54 +00:00
|
|
|
beq on_vscroll_above_click
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Part::up_arrow
|
2017-08-31 03:41:54 +00:00
|
|
|
beq on_vscroll_up_click
|
2018-11-18 04:34:17 +00:00
|
|
|
cmp #MGTK::Part::down_arrow
|
2017-08-31 03:30:46 +00:00
|
|
|
bne end
|
2017-08-31 03:41:54 +00:00
|
|
|
jmp on_vscroll_down_click
|
|
|
|
end: rts
|
2017-08-31 03:30:46 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_thumb_click
|
2018-01-31 08:05:54 +00:00
|
|
|
jsr do_trackthumb
|
|
|
|
lda trackthumb_params::thumbmoved
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2018-01-31 08:05:54 +00:00
|
|
|
lda trackthumb_params::thumbpos
|
|
|
|
sta updatethumb_params::thumbpos
|
2017-09-02 16:44:33 +00:00
|
|
|
jsr update_voffset
|
2017-08-31 15:17:06 +00:00
|
|
|
jsr update_vscroll
|
2017-09-01 01:38:49 +00:00
|
|
|
jsr draw_content
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L0947
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L0949
|
2017-08-31 03:41:54 +00:00
|
|
|
bne end
|
2017-09-16 03:04:56 +00:00
|
|
|
jsr clear_window
|
2017-08-31 03:41:54 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_above_click
|
2018-11-17 06:48:16 +00:00
|
|
|
loop: jsr page_up
|
|
|
|
jsr check_button_release
|
|
|
|
bcc loop ; repeat while button down
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc page_up
|
|
|
|
lda winfo::vthumbpos
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2017-08-31 04:13:25 +00:00
|
|
|
jsr calc_track_scroll_delta
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2018-01-30 05:11:32 +00:00
|
|
|
lda winfo::vthumbpos
|
2017-08-31 04:13:25 +00:00
|
|
|
sbc track_scroll_delta
|
2017-08-31 15:17:06 +00:00
|
|
|
bcs store
|
2017-09-02 02:54:04 +00:00
|
|
|
lda #0 ; underflow
|
2018-01-31 08:05:54 +00:00
|
|
|
store: sta updatethumb_params::thumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
jsr update_scroll_pos
|
2017-08-31 03:41:54 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_up_click
|
2018-11-17 06:48:16 +00:00
|
|
|
loop: jsr scroll_up
|
|
|
|
jsr check_button_release
|
|
|
|
bcc loop ; repeat while button down
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc scroll_up
|
|
|
|
lda winfo::vthumbpos
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2017-08-31 04:04:16 +00:00
|
|
|
sbc #1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::thumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
jsr update_scroll_pos
|
2017-08-31 03:41:54 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-11-25 01:41:31 +00:00
|
|
|
.proc scroll_top
|
|
|
|
lda winfo::vthumbpos
|
|
|
|
beq end
|
|
|
|
copy #0, updatethumb_params::thumbpos
|
|
|
|
jsr update_scroll_pos
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
2018-12-28 23:46:09 +00:00
|
|
|
vscroll_max = $FA
|
2017-08-31 04:04:16 +00:00
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_below_click
|
2018-11-17 06:48:16 +00:00
|
|
|
loop: jsr page_down
|
|
|
|
jsr check_button_release
|
|
|
|
bcc loop ; repeat while button down
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc page_down
|
|
|
|
lda winfo::vthumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
cmp #vscroll_max ; pos == max ?
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2017-08-31 04:13:25 +00:00
|
|
|
jsr calc_track_scroll_delta
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2018-01-30 05:11:32 +00:00
|
|
|
lda winfo::vthumbpos
|
2017-08-31 04:13:25 +00:00
|
|
|
adc track_scroll_delta ; pos + delta
|
2017-08-31 04:04:16 +00:00
|
|
|
bcs overflow
|
|
|
|
cmp #vscroll_max+1 ; > max ?
|
|
|
|
bcc store ; nope, it's good
|
|
|
|
overflow:
|
|
|
|
lda #vscroll_max ; set to max
|
2018-01-31 08:05:54 +00:00
|
|
|
store: sta updatethumb_params::thumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
jsr update_scroll_pos
|
2017-08-31 03:41:54 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 03:41:54 +00:00
|
|
|
.proc on_vscroll_down_click
|
2018-11-17 06:48:16 +00:00
|
|
|
loop: jsr scroll_down
|
|
|
|
jsr check_button_release
|
|
|
|
bcc loop ; repeat while button down
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc scroll_down
|
|
|
|
lda winfo::vthumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
cmp #vscroll_max
|
2017-08-31 03:41:54 +00:00
|
|
|
beq end
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2017-08-31 04:04:16 +00:00
|
|
|
adc #1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::thumbpos
|
2017-08-31 04:04:16 +00:00
|
|
|
jsr update_scroll_pos
|
2017-08-31 03:41:54 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-11-25 01:41:31 +00:00
|
|
|
.proc scroll_bottom
|
|
|
|
lda winfo::vthumbpos
|
|
|
|
cmp #vscroll_max
|
|
|
|
beq end
|
|
|
|
copy #vscroll_max, updatethumb_params::thumbpos
|
|
|
|
jsr update_scroll_pos
|
|
|
|
end: rts
|
|
|
|
.endproc
|
|
|
|
|
2017-08-31 04:13:25 +00:00
|
|
|
.proc update_scroll_pos ; Returns with carry set if mouse released
|
2017-09-02 16:44:33 +00:00
|
|
|
jsr update_voffset
|
2017-08-31 15:17:06 +00:00
|
|
|
jsr update_vscroll
|
2017-09-01 01:38:49 +00:00
|
|
|
jsr draw_content
|
2018-11-17 06:48:16 +00:00
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc check_button_release
|
2017-08-31 04:04:16 +00:00
|
|
|
jsr was_button_released
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2017-08-31 04:04:16 +00:00
|
|
|
bne end
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2017-08-31 04:04:16 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-31 04:13:25 +00:00
|
|
|
.proc calc_track_scroll_delta
|
2018-04-29 03:00:18 +00:00
|
|
|
lda window_height ; ceil(height / 50)
|
2017-08-31 04:13:25 +00:00
|
|
|
ldx #0
|
|
|
|
loop: inx
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2017-08-31 04:13:25 +00:00
|
|
|
sbc #50
|
|
|
|
cmp #50
|
|
|
|
bcs loop
|
|
|
|
stx track_scroll_delta
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-31 04:13:25 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; UI Helpers
|
|
|
|
|
2018-11-18 04:34:17 +00:00
|
|
|
;; Used at start of thumb EventKind::drag
|
2018-01-31 08:05:54 +00:00
|
|
|
.proc do_trackthumb
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 event_params::mousex, trackthumb_params::mousex
|
2018-01-31 08:05:54 +00:00
|
|
|
lda event_params::mousey
|
|
|
|
sta trackthumb_params::mousey
|
|
|
|
MGTK_CALL MGTK::TrackThumb, trackthumb_params
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-31 05:22:04 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-01 02:05:41 +00:00
|
|
|
;;; Checks button state; z clear if button was released, set otherwise
|
2017-08-31 04:04:16 +00:00
|
|
|
.proc was_button_released
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::GetEvent, event_params
|
|
|
|
lda event_params
|
2017-08-31 04:04:16 +00:00
|
|
|
cmp #2
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-31 04:04:16 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-01 05:12:02 +00:00
|
|
|
;;; only used from hscroll code?
|
2017-09-16 21:20:41 +00:00
|
|
|
.proc adjust_box_width
|
2018-04-29 03:00:18 +00:00
|
|
|
|
|
|
|
res := $06
|
2018-01-30 05:11:32 +00:00
|
|
|
lda winfo::hthumbpos
|
2017-09-03 05:52:38 +00:00
|
|
|
jsr mul_by_16
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2018-04-29 03:00:18 +00:00
|
|
|
lda res
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::x1
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_width
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::x2
|
2018-04-29 03:00:18 +00:00
|
|
|
lda res+1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::x1+1
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_width+1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::x2+1
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-01 05:12:02 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 16:44:33 +00:00
|
|
|
.proc update_voffset
|
2017-09-01 05:39:06 +00:00
|
|
|
lda #0
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::y1
|
|
|
|
sta winfo::maprect::y1+1
|
|
|
|
ldx updatethumb_params::thumbpos
|
2017-09-16 04:44:41 +00:00
|
|
|
loop: beq adjust_box_height
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::maprect::y1
|
2017-08-31 15:17:06 +00:00
|
|
|
adc #50
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::y1
|
2017-09-02 02:39:29 +00:00
|
|
|
bcc :+
|
2018-01-31 08:05:54 +00:00
|
|
|
inc winfo::maprect::y1+1
|
2017-09-02 02:39:29 +00:00
|
|
|
: dex
|
2017-09-01 05:39:06 +00:00
|
|
|
jmp loop
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-16 04:44:41 +00:00
|
|
|
.proc adjust_box_height
|
2017-09-01 05:39:06 +00:00
|
|
|
clc
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::maprect::y1
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_height
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::y2
|
|
|
|
lda winfo::maprect::y1+1
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_height+1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta winfo::maprect::y2+1
|
2017-09-16 21:20:41 +00:00
|
|
|
jsr calc_line_position
|
2017-08-31 15:17:06 +00:00
|
|
|
lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L096A
|
2018-02-07 02:42:00 +00:00
|
|
|
sta L096A+1
|
2018-01-31 08:05:54 +00:00
|
|
|
ldx updatethumb_params::thumbpos
|
2017-09-01 05:39:06 +00:00
|
|
|
loop: beq end
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
|
|
|
lda L096A
|
2017-08-31 15:17:06 +00:00
|
|
|
adc #5
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L096A
|
2017-09-02 02:39:29 +00:00
|
|
|
bcc :+
|
2018-02-07 02:42:00 +00:00
|
|
|
inc L096A+1
|
2017-09-02 02:39:29 +00:00
|
|
|
: dex
|
2017-09-01 05:39:06 +00:00
|
|
|
jmp loop
|
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 03:30:55 +00:00
|
|
|
.proc update_hscroll
|
|
|
|
lda #2
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::which_ctl
|
2018-04-29 03:00:18 +00:00
|
|
|
|
|
|
|
val := $06
|
|
|
|
copy16 winfo::maprect::x1, val
|
2017-09-03 05:52:38 +00:00
|
|
|
jsr div_by_16
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::thumbpos
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::UpdateThumb, updatethumb_params
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-02 03:30:55 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-01-31 08:05:54 +00:00
|
|
|
.proc update_vscroll ; updatethumb_params::thumbpos set by caller
|
2017-08-31 15:17:06 +00:00
|
|
|
lda #1
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::which_ctl
|
2018-01-30 04:14:34 +00:00
|
|
|
MGTK_CALL MGTK::UpdateThumb, updatethumb_params
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-31 15:17:06 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 03:30:55 +00:00
|
|
|
.proc finish_resize ; only called from dead code
|
2018-02-05 03:13:21 +00:00
|
|
|
DESKTOP_CALL DT_REDRAW_ICONS
|
2018-01-30 05:11:32 +00:00
|
|
|
MGTK_CALL MGTK::SetPort, winfo::port
|
|
|
|
lda winfo::hscroll
|
2017-09-03 03:49:28 +00:00
|
|
|
ror a ; check if low bit (track enabled) is set
|
2017-09-02 02:39:29 +00:00
|
|
|
bcc :+
|
2017-09-02 03:30:55 +00:00
|
|
|
jsr update_hscroll
|
2018-01-30 05:11:32 +00:00
|
|
|
: lda winfo::vthumbpos
|
2018-01-31 08:05:54 +00:00
|
|
|
sta updatethumb_params::thumbpos
|
2017-08-31 15:17:06 +00:00
|
|
|
jsr update_vscroll
|
2017-09-01 01:38:49 +00:00
|
|
|
jsr draw_content
|
2017-08-30 05:10:33 +00:00
|
|
|
jmp input_loop
|
2017-09-01 05:39:06 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-16 03:04:56 +00:00
|
|
|
.proc clear_window
|
2018-01-29 05:18:00 +00:00
|
|
|
MGTK_CALL MGTK::SetPattern, white_pattern
|
2018-01-31 08:05:54 +00:00
|
|
|
MGTK_CALL MGTK::PaintRect, winfo::maprect::x1
|
2018-01-29 05:18:00 +00:00
|
|
|
MGTK_CALL MGTK::SetPattern, black_pattern
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-16 03:04:56 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Content Rendering
|
|
|
|
|
2017-09-01 01:38:49 +00:00
|
|
|
.proc draw_content
|
2018-04-29 03:00:18 +00:00
|
|
|
ptr := $06
|
|
|
|
|
2017-09-01 05:39:06 +00:00
|
|
|
lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0949
|
2017-09-16 04:44:41 +00:00
|
|
|
jsr assign_fixed_font_width_table_if_needed
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr set_file_mark
|
2017-09-01 05:39:06 +00:00
|
|
|
lda #<default_buffer
|
2018-02-27 04:51:23 +00:00
|
|
|
sta read_params::data_buffer
|
2018-04-29 03:00:18 +00:00
|
|
|
sta ptr
|
2017-09-01 05:39:06 +00:00
|
|
|
lda #>default_buffer
|
2018-02-27 04:51:23 +00:00
|
|
|
sta read_params::data_buffer+1
|
2018-04-29 03:00:18 +00:00
|
|
|
sta ptr+1
|
2017-09-16 21:20:41 +00:00
|
|
|
lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0945
|
|
|
|
sta L0946
|
|
|
|
sta L0947
|
2017-09-01 15:15:05 +00:00
|
|
|
sta line_pos::base+1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L096C
|
2018-02-07 02:42:00 +00:00
|
|
|
sta L096C+1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0948
|
2018-04-29 03:00:18 +00:00
|
|
|
lda #line_spacing
|
2017-09-01 15:15:05 +00:00
|
|
|
sta line_pos::base
|
2018-04-29 03:00:18 +00:00
|
|
|
jsr reset_line
|
2017-09-16 04:44:41 +00:00
|
|
|
|
|
|
|
do_line:
|
2018-02-07 02:42:00 +00:00
|
|
|
lda L096C+1
|
|
|
|
cmp L096A+1
|
2017-09-16 04:44:41 +00:00
|
|
|
bne :+
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L096C
|
|
|
|
cmp L096A
|
2017-09-16 04:44:41 +00:00
|
|
|
bne :+
|
2017-09-16 03:04:56 +00:00
|
|
|
jsr clear_window
|
2017-08-29 03:58:09 +00:00
|
|
|
inc L0948
|
2018-01-29 05:18:00 +00:00
|
|
|
: MGTK_CALL MGTK::MoveTo, line_pos
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2017-09-02 03:10:21 +00:00
|
|
|
lda #250
|
2017-09-01 15:15:05 +00:00
|
|
|
sbc line_pos::left
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095B
|
2017-09-02 03:10:21 +00:00
|
|
|
lda #1
|
2017-09-01 15:15:05 +00:00
|
|
|
sbc line_pos::left+1
|
2018-02-07 02:42:00 +00:00
|
|
|
sta L095B+1
|
2017-09-16 16:31:05 +00:00
|
|
|
jsr find_text_run
|
2018-04-29 03:00:18 +00:00
|
|
|
bcs done
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2018-01-31 08:05:54 +00:00
|
|
|
lda drawtext_params::textlen
|
2018-04-29 03:00:18 +00:00
|
|
|
adc ptr
|
|
|
|
sta ptr
|
2017-09-15 08:09:42 +00:00
|
|
|
bcc :+
|
2018-04-29 03:00:18 +00:00
|
|
|
inc ptr+1
|
2017-09-15 08:09:42 +00:00
|
|
|
: lda L095A
|
2017-09-16 04:44:41 +00:00
|
|
|
bne do_line
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2017-09-01 15:15:05 +00:00
|
|
|
lda line_pos::base
|
2018-04-29 03:00:18 +00:00
|
|
|
adc #line_spacing
|
2017-09-01 15:15:05 +00:00
|
|
|
sta line_pos::base
|
2017-09-15 08:09:42 +00:00
|
|
|
bcc :+
|
2017-09-01 15:15:05 +00:00
|
|
|
inc line_pos::base+1
|
2018-04-29 03:00:18 +00:00
|
|
|
: jsr reset_line
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L096C
|
2018-04-29 03:00:18 +00:00
|
|
|
cmp line_count
|
2017-09-15 08:09:42 +00:00
|
|
|
bne :+
|
2018-02-07 02:42:00 +00:00
|
|
|
lda L096C+1
|
2018-04-29 03:00:18 +00:00
|
|
|
cmp line_count+1
|
|
|
|
beq done
|
2017-09-15 08:09:42 +00:00
|
|
|
: inc L096C
|
2017-09-16 02:08:20 +00:00
|
|
|
bne :+
|
2018-02-07 02:42:00 +00:00
|
|
|
inc L096C+1
|
2017-09-16 04:44:41 +00:00
|
|
|
: jmp do_line
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
done: jsr restore_proportional_font_table_if_needed
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-01 01:38:49 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
.proc reset_line
|
|
|
|
copy16 #right_const, L095B
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 #3, line_pos::left
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095A
|
|
|
|
rts
|
2017-09-01 01:38:49 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-09-16 16:31:05 +00:00
|
|
|
.proc find_text_run
|
2018-04-29 03:00:18 +00:00
|
|
|
ptr := $06
|
|
|
|
|
2017-09-16 16:31:05 +00:00
|
|
|
lda #$FF
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0F9B
|
2017-09-16 05:05:41 +00:00
|
|
|
lda #0
|
|
|
|
sta run_width
|
|
|
|
sta run_width+1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095A
|
2018-01-31 08:05:54 +00:00
|
|
|
sta drawtext_params::textlen
|
2018-04-29 03:00:18 +00:00
|
|
|
copy16 ptr, drawtext_params::textptr
|
2017-09-16 16:31:05 +00:00
|
|
|
|
|
|
|
loop: lda L0945
|
|
|
|
bne more
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L0947
|
2017-09-16 16:31:05 +00:00
|
|
|
beq :+
|
2017-09-16 05:05:41 +00:00
|
|
|
jsr draw_text_run
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2017-09-16 16:31:05 +00:00
|
|
|
: jsr ensure_page_buffered
|
2018-01-31 08:05:54 +00:00
|
|
|
more: ldy drawtext_params::textlen
|
2018-04-29 03:00:18 +00:00
|
|
|
lda (ptr),y
|
2018-06-02 01:52:26 +00:00
|
|
|
and #CHAR_MASK
|
2018-04-29 03:00:18 +00:00
|
|
|
sta (ptr),y
|
2017-08-29 03:58:09 +00:00
|
|
|
inc L0945
|
2018-02-27 04:13:18 +00:00
|
|
|
cmp #CHAR_RETURN
|
2017-09-16 16:31:05 +00:00
|
|
|
beq finish_text_run
|
2018-06-02 01:52:26 +00:00
|
|
|
cmp #' '
|
2017-09-15 08:09:42 +00:00
|
|
|
bne :+
|
2017-08-29 03:58:09 +00:00
|
|
|
sty L0F9B
|
|
|
|
pha
|
|
|
|
lda L0945
|
|
|
|
sta L0946
|
|
|
|
pla
|
2018-02-27 04:13:18 +00:00
|
|
|
: cmp #CHAR_TAB
|
2017-09-16 05:05:41 +00:00
|
|
|
bne :+
|
|
|
|
jmp handle_tab
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-16 05:05:41 +00:00
|
|
|
: tay
|
2018-06-02 02:00:00 +00:00
|
|
|
lda DEFAULT_FONT + MGTK::Font::charwidth,y
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2017-09-16 05:05:41 +00:00
|
|
|
adc run_width
|
|
|
|
sta run_width
|
2017-09-15 08:09:42 +00:00
|
|
|
bcc :+
|
2017-09-16 05:05:41 +00:00
|
|
|
inc run_width+1
|
2018-02-07 02:42:00 +00:00
|
|
|
: lda L095B+1
|
2017-09-16 05:05:41 +00:00
|
|
|
cmp run_width+1
|
2017-09-15 08:09:42 +00:00
|
|
|
bne :+
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L095B
|
2017-09-16 05:05:41 +00:00
|
|
|
cmp run_width
|
|
|
|
: bcc :+
|
2018-01-31 08:05:54 +00:00
|
|
|
inc drawtext_params::textlen
|
2017-09-16 16:31:05 +00:00
|
|
|
jmp loop
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-16 05:05:41 +00:00
|
|
|
: lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095A
|
|
|
|
lda L0F9B
|
|
|
|
cmp #$FF
|
2017-09-15 08:09:42 +00:00
|
|
|
beq :+
|
2018-01-31 08:05:54 +00:00
|
|
|
sta drawtext_params::textlen
|
2017-08-29 03:58:09 +00:00
|
|
|
lda L0946
|
|
|
|
sta L0945
|
2018-01-31 08:05:54 +00:00
|
|
|
: inc drawtext_params::textlen
|
2017-09-16 16:31:05 +00:00
|
|
|
;; fall through
|
|
|
|
.endproc
|
2017-09-16 05:05:41 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
.proc finish_text_run
|
|
|
|
ptr := $06
|
|
|
|
|
|
|
|
jsr draw_text_run
|
2018-01-31 08:05:54 +00:00
|
|
|
ldy drawtext_params::textlen
|
2018-04-29 03:00:18 +00:00
|
|
|
lda (ptr),y
|
2018-02-27 04:13:18 +00:00
|
|
|
cmp #CHAR_TAB
|
2017-09-16 05:05:41 +00:00
|
|
|
beq tab
|
2018-02-27 04:13:18 +00:00
|
|
|
cmp #CHAR_RETURN
|
2017-09-16 05:05:41 +00:00
|
|
|
bne :+
|
2018-01-31 08:05:54 +00:00
|
|
|
tab: inc drawtext_params::textlen
|
2017-09-16 05:05:41 +00:00
|
|
|
: clc
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2018-04-29 03:00:18 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-08-29 16:08:46 +00:00
|
|
|
L0F9B: .byte 0
|
2017-09-16 05:05:41 +00:00
|
|
|
run_width: .word 0
|
|
|
|
|
|
|
|
.proc handle_tab
|
2017-09-01 02:05:41 +00:00
|
|
|
lda #1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095A
|
|
|
|
clc
|
2017-09-16 05:05:41 +00:00
|
|
|
lda run_width
|
2017-09-01 15:15:05 +00:00
|
|
|
adc line_pos::left
|
|
|
|
sta line_pos::left
|
2017-09-16 05:05:41 +00:00
|
|
|
lda run_width+1
|
2017-09-01 15:15:05 +00:00
|
|
|
adc line_pos::left+1
|
|
|
|
sta line_pos::left+1
|
2017-09-01 02:05:41 +00:00
|
|
|
ldx #0
|
|
|
|
loop: lda times70+1,x
|
2017-09-01 15:15:05 +00:00
|
|
|
cmp line_pos::left+1
|
2017-09-15 08:09:42 +00:00
|
|
|
bne :+
|
2017-09-01 02:05:41 +00:00
|
|
|
lda times70,x
|
2017-09-01 15:15:05 +00:00
|
|
|
cmp line_pos::left
|
2017-09-15 08:09:42 +00:00
|
|
|
: bcs :+
|
2017-08-29 03:58:09 +00:00
|
|
|
inx
|
|
|
|
inx
|
2017-09-01 02:05:41 +00:00
|
|
|
cpx #14
|
|
|
|
beq done
|
|
|
|
jmp loop
|
2018-02-07 02:42:00 +00:00
|
|
|
: copy16 times70,x, line_pos::left
|
2017-09-16 16:31:05 +00:00
|
|
|
jmp finish_text_run
|
2017-09-01 02:05:41 +00:00
|
|
|
done: lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L095A
|
2017-09-16 16:31:05 +00:00
|
|
|
jmp finish_text_run
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-01 02:05:41 +00:00
|
|
|
times70:.word 70
|
|
|
|
.word 140
|
|
|
|
.word 210
|
|
|
|
.word 280
|
|
|
|
.word 350
|
|
|
|
.word 420
|
|
|
|
.word 490
|
|
|
|
.endproc
|
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
;;; Draw a line of content
|
|
|
|
|
2017-09-16 05:05:41 +00:00
|
|
|
.proc draw_text_run
|
2017-09-16 03:04:56 +00:00
|
|
|
lda L0948
|
|
|
|
beq end
|
2018-01-31 08:05:54 +00:00
|
|
|
lda drawtext_params::textlen
|
2017-09-16 03:04:56 +00:00
|
|
|
beq end
|
2018-01-31 08:05:54 +00:00
|
|
|
MGTK_CALL MGTK::DrawText, drawtext_params
|
2017-09-01 05:53:07 +00:00
|
|
|
lda #1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0949
|
2017-09-16 03:04:56 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-09-16 16:31:05 +00:00
|
|
|
.proc ensure_page_buffered
|
2018-04-29 03:00:18 +00:00
|
|
|
ptr := $06
|
|
|
|
|
2018-01-31 08:05:54 +00:00
|
|
|
lda drawtext_params::textptr+1
|
2017-09-16 21:20:41 +00:00
|
|
|
cmp #>default_buffer
|
|
|
|
beq read
|
2017-09-02 03:10:21 +00:00
|
|
|
|
2018-04-29 03:00:18 +00:00
|
|
|
;; TODO: Where does $1300 come from ???
|
2017-09-02 03:10:21 +00:00
|
|
|
;; copy a page of characters from $1300 to the buffer
|
|
|
|
ldy #0
|
|
|
|
loop: lda $1300,y
|
2017-09-01 05:39:06 +00:00
|
|
|
sta default_buffer,y
|
2017-08-29 03:58:09 +00:00
|
|
|
iny
|
2017-09-02 03:10:21 +00:00
|
|
|
bne loop
|
|
|
|
|
2018-01-31 08:05:54 +00:00
|
|
|
dec drawtext_params::textptr+1
|
2018-04-29 03:00:18 +00:00
|
|
|
copy16 drawtext_params::textptr, ptr
|
2017-09-16 21:20:41 +00:00
|
|
|
|
|
|
|
read: lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0945
|
2017-09-16 16:31:05 +00:00
|
|
|
jsr read_file_page
|
2018-02-27 04:51:23 +00:00
|
|
|
lda read_params::data_buffer+1
|
2017-09-16 16:31:05 +00:00
|
|
|
cmp #>default_buffer
|
|
|
|
bne :+
|
2018-02-27 04:51:23 +00:00
|
|
|
inc read_params::data_buffer+1
|
2017-09-16 16:31:05 +00:00
|
|
|
: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-09-16 16:31:05 +00:00
|
|
|
.proc read_file_page
|
2018-11-24 19:17:46 +00:00
|
|
|
copy16 read_params::data_buffer, @store_addr
|
2017-09-16 16:31:05 +00:00
|
|
|
|
|
|
|
lda #' ' ; fill buffer with spaces
|
|
|
|
ldx #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta RAMWRTOFF
|
2018-04-29 03:00:18 +00:00
|
|
|
|
2018-11-24 19:17:46 +00:00
|
|
|
@store_addr := *+1
|
2017-09-01 05:39:06 +00:00
|
|
|
store: sta default_buffer,x ; self-modified
|
2017-08-29 03:58:09 +00:00
|
|
|
inx
|
2017-08-30 02:07:44 +00:00
|
|
|
bne store
|
2017-09-16 16:31:05 +00:00
|
|
|
|
|
|
|
sta RAMWRTON ; read file chunk
|
2018-04-29 03:00:18 +00:00
|
|
|
lda #0
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0947
|
2017-08-30 01:47:15 +00:00
|
|
|
jsr read_file
|
2017-09-16 16:31:05 +00:00
|
|
|
|
|
|
|
pha ; copy read buffer main>aux
|
2017-08-29 03:58:09 +00:00
|
|
|
lda #$00
|
2017-09-01 01:20:36 +00:00
|
|
|
sta STARTLO
|
|
|
|
sta DESTINATIONLO
|
2017-08-29 03:58:09 +00:00
|
|
|
lda #$FF
|
2017-09-01 01:20:36 +00:00
|
|
|
sta ENDLO
|
2018-02-27 04:51:23 +00:00
|
|
|
lda read_params::data_buffer+1
|
2017-09-01 01:20:36 +00:00
|
|
|
sta DESTINATIONHI
|
|
|
|
sta STARTHI
|
|
|
|
sta ENDHI
|
|
|
|
sec ; main>aux
|
2017-08-29 03:58:09 +00:00
|
|
|
jsr AUXMOVE
|
|
|
|
pla
|
2017-09-16 16:31:05 +00:00
|
|
|
|
2017-08-30 02:07:44 +00:00
|
|
|
beq end
|
2018-04-29 03:00:18 +00:00
|
|
|
cmp #ERR_END_OF_FILE
|
2017-08-30 02:07:44 +00:00
|
|
|
beq done
|
2018-04-29 03:00:18 +00:00
|
|
|
brk ; crash on other error
|
|
|
|
done: lda #1
|
2017-08-29 03:58:09 +00:00
|
|
|
sta L0947
|
2017-08-30 02:07:44 +00:00
|
|
|
end: rts
|
2017-09-02 03:10:21 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-02 16:44:33 +00:00
|
|
|
.proc calc_window_size
|
|
|
|
sec
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::maprect::x2
|
|
|
|
sbc winfo::maprect::x1
|
2017-09-01 15:48:46 +00:00
|
|
|
sta window_width
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::maprect::x2+1
|
|
|
|
sbc winfo::maprect::x1+1
|
2017-09-01 15:48:46 +00:00
|
|
|
sta window_width+1
|
2017-09-02 04:24:35 +00:00
|
|
|
|
2017-08-29 03:58:09 +00:00
|
|
|
sec
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::maprect::y2
|
|
|
|
sbc winfo::maprect::y1
|
2017-09-01 15:48:46 +00:00
|
|
|
sta window_height
|
2017-09-02 16:44:33 +00:00
|
|
|
;; fall through
|
|
|
|
.endproc
|
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-09-16 21:20:41 +00:00
|
|
|
.proc calc_line_position
|
2018-04-29 03:00:18 +00:00
|
|
|
copy16 winfo::maprect::y2, y_remaining
|
2017-09-02 04:24:35 +00:00
|
|
|
|
2017-09-02 16:44:33 +00:00
|
|
|
lda #0
|
2018-04-29 03:00:18 +00:00
|
|
|
sta line_count
|
|
|
|
sta line_count+1
|
|
|
|
|
|
|
|
loop: lda y_remaining+1
|
2017-09-02 16:44:33 +00:00
|
|
|
bne :+
|
2018-04-29 03:00:18 +00:00
|
|
|
lda y_remaining
|
|
|
|
cmp #line_spacing
|
2017-09-02 16:44:33 +00:00
|
|
|
bcc end
|
2018-04-29 03:00:18 +00:00
|
|
|
|
2017-09-02 16:44:33 +00:00
|
|
|
: sec
|
2018-04-29 03:00:18 +00:00
|
|
|
lda y_remaining
|
|
|
|
sbc #line_spacing
|
|
|
|
sta y_remaining
|
2017-09-02 16:44:33 +00:00
|
|
|
bcs :+
|
2018-04-29 03:00:18 +00:00
|
|
|
dec y_remaining+1
|
|
|
|
: inc line_count
|
2017-09-02 16:44:33 +00:00
|
|
|
bne loop
|
2018-04-29 03:00:18 +00:00
|
|
|
inc line_count+1
|
2017-09-02 16:44:33 +00:00
|
|
|
jmp loop
|
2018-04-29 03:00:18 +00:00
|
|
|
|
2017-09-02 16:44:33 +00:00
|
|
|
end: rts
|
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
|
2017-09-03 05:52:38 +00:00
|
|
|
.proc div_by_16 ; input in $06/$07, output in a
|
2018-04-29 03:00:18 +00:00
|
|
|
val := $06
|
|
|
|
|
2017-09-03 05:52:38 +00:00
|
|
|
ldx #4
|
2017-09-02 03:10:21 +00:00
|
|
|
loop: clc
|
2018-04-29 03:00:18 +00:00
|
|
|
ror val+1
|
|
|
|
ror val
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
2017-09-02 03:10:21 +00:00
|
|
|
bne loop
|
2018-04-29 03:00:18 +00:00
|
|
|
lda val
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-02 03:10:21 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-03 05:52:38 +00:00
|
|
|
.proc mul_by_16 ; input in a, output in $06/$07
|
2018-04-29 03:00:18 +00:00
|
|
|
res := $06
|
|
|
|
|
|
|
|
sta res
|
2017-09-03 05:52:38 +00:00
|
|
|
lda #0
|
2018-04-29 03:00:18 +00:00
|
|
|
sta res+1
|
2017-09-03 05:52:38 +00:00
|
|
|
ldx #4
|
2017-09-02 03:10:21 +00:00
|
|
|
loop: clc
|
2018-04-29 03:00:18 +00:00
|
|
|
rol res
|
|
|
|
rol res+1
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
2017-09-02 03:10:21 +00:00
|
|
|
bne loop
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-02 03:10:21 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-09-18 15:10:19 +00:00
|
|
|
.proc redraw_screen
|
2018-02-07 02:42:00 +00:00
|
|
|
copy16 #JUMP_TABLE_REDRAW_ALL, call_main_addr
|
2017-09-02 02:06:14 +00:00
|
|
|
jsr call_main_trampoline
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-09-02 02:06:14 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
;;; Restore the font glyph width table when switching
|
|
|
|
;;; back to proportional mode.
|
|
|
|
|
|
|
|
.proc restore_proportional_font_table_if_needed
|
2017-09-01 01:38:49 +00:00
|
|
|
lda fixed_mode_flag ; if not fixed (i.e. proportional)
|
2017-09-16 02:08:20 +00:00
|
|
|
beq done ; then exit
|
|
|
|
|
2017-09-16 03:04:56 +00:00
|
|
|
start := font_width_backup
|
|
|
|
end := font_width_backup + $7E
|
2018-06-02 02:00:00 +00:00
|
|
|
dest := DEFAULT_FONT + MGTK::Font::charwidth
|
2017-09-01 01:38:49 +00:00
|
|
|
|
2017-09-16 02:08:20 +00:00
|
|
|
lda #<start
|
2017-09-01 01:20:36 +00:00
|
|
|
sta STARTLO
|
2017-09-16 02:08:20 +00:00
|
|
|
lda #<end
|
|
|
|
sta ENDLO
|
|
|
|
lda #>start
|
2017-09-01 01:20:36 +00:00
|
|
|
sta STARTHI
|
|
|
|
sta ENDHI
|
2017-09-01 01:38:49 +00:00
|
|
|
|
|
|
|
lda #>dest
|
2017-09-01 01:20:36 +00:00
|
|
|
sta DESTINATIONHI
|
2017-09-01 01:38:49 +00:00
|
|
|
lda #<dest
|
2017-09-01 01:20:36 +00:00
|
|
|
sta DESTINATIONLO
|
|
|
|
sec ; main>aux
|
2017-08-29 03:58:09 +00:00
|
|
|
jsr AUXMOVE
|
2017-09-16 02:08:20 +00:00
|
|
|
done: rts
|
2017-09-01 01:38:49 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-16 04:44:41 +00:00
|
|
|
;;; Overwrite the font glyph width table (with 7s)
|
|
|
|
;;; when switching to fixed width mode.
|
|
|
|
|
|
|
|
.proc assign_fixed_font_width_table_if_needed
|
2017-09-01 02:05:41 +00:00
|
|
|
lda fixed_mode_flag ; if not fixed (i.e. proportional)
|
|
|
|
beq end ; then exit
|
2018-06-02 02:00:00 +00:00
|
|
|
ldx DEFAULT_FONT + MGTK::Font::lastchar
|
2017-09-02 02:35:50 +00:00
|
|
|
lda #7 ; 7 pixels/character
|
2018-06-02 02:00:00 +00:00
|
|
|
loop: sta DEFAULT_FONT + MGTK::Font::charwidth - 1,x
|
2017-08-29 03:58:09 +00:00
|
|
|
dex
|
2017-09-01 01:38:49 +00:00
|
|
|
bne loop
|
2017-09-01 02:05:41 +00:00
|
|
|
end: rts
|
2017-09-01 01:38:49 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-03-05 05:36:00 +00:00
|
|
|
;;; ============================================================
|
2017-09-02 04:24:35 +00:00
|
|
|
;;; Title Bar (Proportional/Fixed mode button)
|
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc on_title_bar_click
|
2018-01-31 08:05:54 +00:00
|
|
|
lda event_params::mousex+1 ; mouse x high byte?
|
2018-04-29 03:00:18 +00:00
|
|
|
cmp mode_mapinfo_viewloc_xcoord+1
|
2017-08-30 05:10:33 +00:00
|
|
|
bne :+
|
2018-01-31 08:05:54 +00:00
|
|
|
lda event_params::mousex
|
2018-04-29 03:00:18 +00:00
|
|
|
cmp mode_mapinfo_viewloc_xcoord
|
2017-08-30 05:10:33 +00:00
|
|
|
: bcc ignore
|
2017-09-02 04:24:35 +00:00
|
|
|
|
|
|
|
;; Toggle the state and redraw
|
2017-08-30 05:10:33 +00:00
|
|
|
lda fixed_mode_flag
|
|
|
|
beq set_flag
|
|
|
|
dec fixed_mode_flag ; clear flag (mode = proportional)
|
2017-09-16 04:44:41 +00:00
|
|
|
jsr restore_proportional_font_table_if_needed
|
2017-08-30 05:10:33 +00:00
|
|
|
jmp redraw
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2017-08-30 05:10:33 +00:00
|
|
|
set_flag:
|
|
|
|
inc fixed_mode_flag ; set flag (mode = fixed)
|
2017-08-31 02:42:31 +00:00
|
|
|
redraw: jsr draw_mode
|
2017-09-01 01:38:49 +00:00
|
|
|
jsr draw_content
|
2017-08-30 05:10:33 +00:00
|
|
|
sec ; Click consumed
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
|
|
|
|
2017-08-30 05:10:33 +00:00
|
|
|
ignore: clc ; Click ignored
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 05:10:33 +00:00
|
|
|
.endproc
|
2017-08-29 03:58:09 +00:00
|
|
|
|
2018-01-29 05:18:00 +00:00
|
|
|
fixed_str: DEFINE_STRING "Fixed "
|
|
|
|
prop_str: DEFINE_STRING "Proportional"
|
2018-12-28 23:46:09 +00:00
|
|
|
label_width = 50
|
|
|
|
title_bar_height = 12
|
2018-04-29 03:00:18 +00:00
|
|
|
|
|
|
|
.proc mode_mapinfo ; bounding port for mode label
|
|
|
|
viewloc: DEFINE_POINT 0, 0, viewloc
|
|
|
|
mapbits: .word MGTK::screen_mapbits
|
|
|
|
mapwidth: .byte MGTK::screen_mapwidth
|
|
|
|
reserved: .byte 0
|
|
|
|
maprect: DEFINE_RECT 0, 0, 80, 10, maprect
|
2017-09-01 15:15:05 +00:00
|
|
|
.endproc
|
2018-04-29 03:00:18 +00:00
|
|
|
mode_mapinfo_viewloc_xcoord := mode_mapinfo::viewloc::xcoord
|
2017-09-01 15:15:05 +00:00
|
|
|
|
|
|
|
.proc mode_pos
|
|
|
|
left: .word 0 ; horizontal text offset
|
|
|
|
base: .word 10 ; vertical text offset (to baseline)
|
|
|
|
.endproc
|
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc calc_and_draw_mode
|
2017-08-30 05:10:33 +00:00
|
|
|
sec
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::viewloc::ycoord
|
2017-09-01 15:48:46 +00:00
|
|
|
sbc #title_bar_height
|
2018-04-29 03:00:18 +00:00
|
|
|
sta mode_mapinfo::viewloc::ycoord
|
2017-08-29 03:58:09 +00:00
|
|
|
clc
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::viewloc::xcoord
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_width
|
2017-08-29 03:58:09 +00:00
|
|
|
pha
|
2018-01-31 08:05:54 +00:00
|
|
|
lda winfo::viewloc::xcoord+1
|
2017-09-01 15:48:46 +00:00
|
|
|
adc window_width+1
|
2017-08-29 03:58:09 +00:00
|
|
|
tax
|
|
|
|
sec
|
|
|
|
pla
|
2017-09-01 15:48:46 +00:00
|
|
|
sbc #<label_width
|
2018-04-29 03:00:18 +00:00
|
|
|
sta mode_mapinfo::viewloc::xcoord
|
2017-08-29 03:58:09 +00:00
|
|
|
txa
|
2017-09-01 15:48:46 +00:00
|
|
|
sbc #>label_width
|
2018-04-29 03:00:18 +00:00
|
|
|
sta mode_mapinfo::viewloc::xcoord+1
|
2017-09-01 02:05:41 +00:00
|
|
|
;; fall through...
|
2017-08-30 05:10:33 +00:00
|
|
|
.endproc
|
2017-09-01 02:05:41 +00:00
|
|
|
|
2017-08-31 02:42:31 +00:00
|
|
|
.proc draw_mode
|
2018-04-29 03:00:18 +00:00
|
|
|
MGTK_CALL MGTK::SetPortBits, mode_mapinfo
|
2018-01-29 05:18:00 +00:00
|
|
|
MGTK_CALL MGTK::MoveTo, mode_pos
|
2017-08-30 05:10:33 +00:00
|
|
|
lda fixed_mode_flag
|
|
|
|
beq else ; is proportional?
|
2018-01-29 05:18:00 +00:00
|
|
|
MGTK_CALL MGTK::DrawText, fixed_str
|
2017-08-30 05:10:33 +00:00
|
|
|
jmp endif
|
2018-01-29 05:18:00 +00:00
|
|
|
else: MGTK_CALL MGTK::DrawText, prop_str
|
2017-09-01 15:15:05 +00:00
|
|
|
|
2018-12-08 17:56:47 +00:00
|
|
|
endif: COPY_STRUCT MGTK::MapInfo, default_port, winfo::port
|
2018-01-30 05:11:32 +00:00
|
|
|
MGTK_CALL MGTK::SetPortBits, winfo::port
|
2017-08-29 03:58:09 +00:00
|
|
|
rts
|
2017-08-30 05:10:33 +00:00
|
|
|
.endproc
|
2019-01-06 22:34:51 +00:00
|
|
|
|
|
|
|
.assert * <= default_buffer, error, "DA overlaps with read buffer"
|