mirror of
https://github.com/mi57730/a2d.git
synced 2024-11-01 10:05:56 +00:00
347 lines
7.6 KiB
ArmAsm
347 lines
7.6 KiB
ArmAsm
;;; ============================================================
|
|
;;; DeskTop - "Language Card" Segment
|
|
;;;
|
|
;;; Compiled as part of desktop.s
|
|
;;; ============================================================
|
|
|
|
;;; ============================================================
|
|
;;; Segment loaded into AUX $D000-$D1FF
|
|
;;; ============================================================
|
|
|
|
.org $D000
|
|
|
|
;;; Constants needed in both main and aux
|
|
|
|
menu_id_apple = 1
|
|
menu_id_file = 2
|
|
menu_id_view = 4
|
|
menu_id_special = 5
|
|
menu_id_startup = 8
|
|
menu_id_selector = 3
|
|
|
|
;;; Various routines callable from MAIN
|
|
|
|
;;; ============================================================
|
|
;;; MGTK call from main>aux, call in Y, params at (X,A)
|
|
|
|
.proc MGTKRelayImpl
|
|
.assert * = MGTK_RELAY, error, "Entry point mismatch"
|
|
sty addr-1
|
|
stax addr
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
MGTK_CALL 0, 0, addr
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; SET_POS with params at (X,A) followed by DRAW_TEXT call
|
|
|
|
.proc SetPosDrawText
|
|
stax addr
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
MGTK_CALL MGTK::MoveTo, 0, addr
|
|
MGTK_RELAY_CALL MGTK::DrawText, text_buffer2
|
|
tay
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
tya
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; DESKTOP call from main>aux, call in Y params at (X,A)
|
|
|
|
.proc DTRelayImpl
|
|
.assert * = DESKTOP_RELAY, error, "Entry point mismatch"
|
|
sty addr-1
|
|
stax addr
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
DESKTOP_CALL 0, 0, addr
|
|
tay
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
tya
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; Used/Free icon map (Aux $1F80 - $1FFF)
|
|
|
|
free_icon_map := $1F80
|
|
|
|
;;; Find first available free icon in the map; if
|
|
;;; available, mark it and return index+1.
|
|
|
|
.proc AllocateIcon
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
ldx #0
|
|
loop: lda free_icon_map,x
|
|
beq :+
|
|
inx
|
|
cpx #$7F
|
|
bne loop
|
|
rts
|
|
|
|
: inx
|
|
txa
|
|
dex
|
|
tay
|
|
lda #1
|
|
sta free_icon_map,x
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
tya
|
|
rts
|
|
.endproc
|
|
|
|
;;; Mark the specified icon as free
|
|
|
|
.proc FreeIcon
|
|
tay
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
dey
|
|
lda #0
|
|
sta free_icon_map,y
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; Copy data to/from buffers (see cached_window_id / cached_window_icon_list / window_icon_count_table/2) ???
|
|
|
|
.proc XferWindowIconTable
|
|
ptr := $6
|
|
|
|
from:
|
|
lda #$80
|
|
bne :+ ; always
|
|
|
|
to:
|
|
lda #$00
|
|
|
|
: sta flag
|
|
jsr desktop_main_push_pointers
|
|
|
|
lda cached_window_id
|
|
asl a ; * 2
|
|
tax
|
|
copy16 window_icon_count_table,x, ptr
|
|
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
bit flag
|
|
bpl set_length
|
|
|
|
;; assign length from cached_window_icon_list
|
|
lda cached_window_icon_count
|
|
ldy #0
|
|
sta (ptr),y
|
|
jmp set_copy_ptr
|
|
|
|
;; assign length to cached_window_icon_list
|
|
set_length:
|
|
ldy #0
|
|
lda (ptr),y
|
|
sta cached_window_icon_count
|
|
|
|
set_copy_ptr:
|
|
copy16 window_icon_list_table,x, ptr
|
|
bit flag
|
|
bmi copy_from
|
|
|
|
;; copy into cached_window_icon_list
|
|
ldy #0 ; flag clear...
|
|
: cpy cached_window_icon_count
|
|
beq done
|
|
lda (ptr),y
|
|
sta cached_window_icon_list,y
|
|
iny
|
|
jmp :-
|
|
|
|
;; copy from cached_window_icon_list
|
|
copy_from:
|
|
ldy #0
|
|
: cpy cached_window_icon_count
|
|
beq done
|
|
lda cached_window_icon_list,y
|
|
sta (ptr),y
|
|
iny
|
|
jmp :-
|
|
|
|
done: sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
jsr desktop_main_pop_pointers
|
|
rts
|
|
|
|
flag: .byte 0
|
|
rts ; ???
|
|
.endproc
|
|
StoreWindowIconTable := XferWindowIconTable::from
|
|
LoadWindowIconTable := XferWindowIconTable::to
|
|
|
|
.proc LoadActiveWindowIconTable
|
|
copy active_window_id, cached_window_id
|
|
jmp LoadWindowIconTable
|
|
.endproc
|
|
|
|
.proc LoadDesktopIconTable
|
|
copy #0, cached_window_id
|
|
jmp LoadWindowIconTable
|
|
.endproc
|
|
|
|
|
|
;;; ============================================================
|
|
;;; Assign active state to active_window_id window
|
|
|
|
.proc OverwriteWindowPort
|
|
src := $6
|
|
dst := $8
|
|
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
MGTK_CALL MGTK::GetPort, src ; grab window state
|
|
|
|
lda active_window_id ; which desktop window?
|
|
asl a
|
|
tax
|
|
copy16 win_table,x, dst
|
|
lda dst
|
|
clc
|
|
adc #MGTK::Winfo::port
|
|
sta dst
|
|
bcc :+
|
|
inc dst+1
|
|
|
|
: ldy #.sizeof(MGTK::GrafPort)-1
|
|
loop: lda (src),y
|
|
sta (dst),y
|
|
dey
|
|
bpl loop
|
|
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; From MAIN, load AUX (A,X) into A
|
|
|
|
.proc AuxLoad
|
|
stx op+2
|
|
sta op+1
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
op: lda dummy1234
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; From MAIN, show alert
|
|
|
|
;;; ...with prompt #0
|
|
.proc ShowAlert
|
|
ldx #$00
|
|
;; fall through
|
|
.endproc
|
|
|
|
;;; ... with prompt # in X
|
|
.proc ShowAlertOption
|
|
sta RAMRDON
|
|
sta RAMWRTON
|
|
jsr desktop_aux::show_alert_indirection
|
|
sta RAMRDOFF
|
|
sta RAMWRTOFF
|
|
rts
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; Input: numbers in A,X, Y (all unsigned)
|
|
;;; Output: number in A,X (unsigned)
|
|
|
|
.proc Multiply_16_8_16
|
|
stax num1
|
|
sty num2
|
|
|
|
;; Accumulate directly into A,X
|
|
lda #0
|
|
tax
|
|
beq test
|
|
|
|
add: clc
|
|
adc num1
|
|
tay
|
|
|
|
txa
|
|
adc num1+1
|
|
tax
|
|
tya
|
|
|
|
loop: asl num1
|
|
rol num1+1
|
|
test: lsr num2
|
|
bcs add
|
|
bne loop
|
|
|
|
rts
|
|
|
|
num1: .word 0
|
|
num2: .byte 0
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
;;; Input: dividend in A,X, divisor in Y (all unsigned)
|
|
;;; Output: quotient in A,X (unsigned)
|
|
|
|
.proc Divide_16_8_16
|
|
result := dividend
|
|
|
|
stax dividend
|
|
sty divisor
|
|
lda #0
|
|
sta divisor+1
|
|
sta remainder
|
|
sta remainder+1
|
|
ldx #16
|
|
|
|
loop: asl dividend
|
|
rol dividend+1
|
|
rol remainder
|
|
rol remainder+1
|
|
lda remainder
|
|
sec
|
|
sbc divisor
|
|
tay
|
|
lda remainder+1
|
|
sbc divisor+1
|
|
bcc skip
|
|
sta remainder+1
|
|
sty remainder
|
|
inc result
|
|
|
|
skip: dex
|
|
bne loop
|
|
ldax dividend
|
|
rts
|
|
|
|
dividend:
|
|
.word 0
|
|
divisor:
|
|
.word 0
|
|
remainder:
|
|
.word 0
|
|
.endproc
|
|
|
|
;;; ============================================================
|
|
|
|
PAD_TO $D200
|