diff --git a/desk.acc/calculator.s b/desk.acc/calculator.s index 0658676..b2aa023 100644 --- a/desk.acc/calculator.s +++ b/desk.acc/calculator.s @@ -74,11 +74,8 @@ call_init: zp_stash := $20 lda LCBANK1 lda LCBANK1 - ldx #sizeof_routine -: lda routine,x - sta zp_stash,x - dex - bpl :- + + COPY_BYTES sizeof_routine+1, routine, zp_stash jsr zp_stash ;; Redraw window after event_kind_drag @@ -869,11 +866,7 @@ exit: lda LCBANK1 ;; Copy following routine to ZP and invoke it zp_stash := $20 - ldx #sizeof_routine -loop: lda routine,x - sta zp_stash,x - dex - bpl loop + COPY_BYTES sizeof_routine+1, routine, zp_stash jmp zp_stash .proc routine diff --git a/desk.acc/date.s b/desk.acc/date.s index 4f1583f..0c1d6ed 100644 --- a/desk.acc/date.s +++ b/desk.acc/date.s @@ -616,11 +616,7 @@ dialog_result: .byte 0 ;; Copy the relay routine to the zero page dest := $20 - ldx #sizeof_routine -loop: lda routine,x - sta dest,x - dex - bpl loop + COPY_BYTES sizeof_routine+1, routine, dest lda dialog_result beq skip diff --git a/desk.acc/puzzle.s b/desk.acc/puzzle.s index 97ae7fc..fe0c589 100644 --- a/desk.acc/puzzle.s +++ b/desk.acc/puzzle.s @@ -74,11 +74,7 @@ stash_stack: .byte 0 dest := $20 ;; copy following routine to $20 and call it - ldx #sizeof_routine -loop: lda routine,x - sta dest,x - dex - bpl loop + COPY_BYTES sizeof_routine+1, routine, dest jsr dest ;; now check the window pos @@ -739,11 +735,7 @@ destroy: DESKTOP_CALL DT_REDRAW_ICONS target = $20 ; copy following to ZP and run it - ldx #sizeof_routine -loop: lda routine,x - sta target,x - dex - bpl loop + COPY_BYTES sizeof_routine+1, routine, target jmp target .proc routine diff --git a/desk.acc/show.image.file.s b/desk.acc/show.image.file.s index 37acecb..895548f 100644 --- a/desk.acc/show.image.file.s +++ b/desk.acc/show.image.file.s @@ -41,11 +41,7 @@ call_main_addr := call_main_trampoline+7 ; address patched in here .scope sta RAMWRTON sta RAMRDON - ldx #sizeof_routine -loop: lda routine,x - sta call_main_trampoline,x - dex - bpl loop + COPY_BYTES sizeof_routine+1, routine, call_main_trampoline jmp call_init .endscope diff --git a/desk.acc/show.text.file.s b/desk.acc/show.text.file.s index 1bcd93e..aedf208 100644 --- a/desk.acc/show.text.file.s +++ b/desk.acc/show.text.file.s @@ -44,11 +44,7 @@ call_main_addr := call_main_trampoline+7 ; address patched in her .scope sta RAMWRTON sta RAMRDON - ldx #sizeof_call_main_template -loop: lda call_main_template,x - sta call_main_trampoline,x - dex - bpl loop + COPY_BYTES sizeof_call_main_template+1, call_main_template, call_main_trampoline jmp call_init .endscope @@ -1425,11 +1421,7 @@ base: .word 10 ; vertical text offset (to baseline) jmp endif else: MGTK_CALL MGTK::DrawText, prop_str -endif: ldx #.sizeof(MGTK::MapInfo) - 1 -loop: lda default_port,x - sta winfo::port,x - dex - bpl loop +endif: COPY_STRUCT MGTK::MapInfo, default_port, winfo::port MGTK_CALL MGTK::SetPortBits, winfo::port rts .endproc diff --git a/desktop.system/desktop.system.s b/desktop.system/desktop.system.s index be86032..de693dd 100644 --- a/desktop.system/desktop.system.s +++ b/desktop.system/desktop.system.s @@ -1391,11 +1391,7 @@ is_dir: lda #$FF jmp show_no_space_prompt ;; copy dates -: ldx #3 -: lda get_file_info_params2::create_date,x - sta create_params::create_date,x - dex - bpl :- +: COPY_STRUCT DateTime, get_file_info_params2::create_date, create_params::create_date ;; create the file lda create_params::storage_type @@ -1592,11 +1588,7 @@ finish: MLI_CALL CLOSE, close_dstdir_params sta create_dir_params::access ;; Copy dates - ldx #3 -: lda get_file_info_params2::create_date,x - sta create_dir_params::create_date,x - dex - bpl :- + COPY_STRUCT DateTime, get_file_info_params2::create_date, create_dir_params::create_date ;; Create it lda create_dir_params::storage_type @@ -1741,11 +1733,7 @@ loop2: lda L320A,y .proc get_file_info_and_copy MLI_CALL GET_FILE_INFO, get_file_info_params2 bne fail - ldx #$0A -: lda get_file_info_params2::access,x - sta get_file_info_params3::access,x - dex - bpl :- + COPY_BYTES $B, get_file_info_params2::access, get_file_info_params3::access rts fail: pla diff --git a/desktop/desktop_aux.s b/desktop/desktop_aux.s index 917e87f..c1ff660 100644 --- a/desktop/desktop_aux.s +++ b/desktop/desktop_aux.s @@ -878,7 +878,7 @@ L97F6: .byte 0 cpy #0 bne :- - jsr push_zp_addrs + jsr push_pointers lda icon_id jsr L9EB4 stax $06 @@ -972,11 +972,9 @@ is_drag: and #icon_entry_winid_mask sta L9832 MGTK_CALL MGTK::InitPort, grafport - ldx #.sizeof(MGTK::Rect)-1 -L98E3: lda grafport::cliprect,x - sta L9835,x - dex - bpl L98E3 + + COPY_STRUCT MGTK::Rect, grafport::cliprect, L9835 + ldx highlight_count stx L9C74 L98F2: lda highlight_count,x @@ -995,7 +993,7 @@ L9909: sta L9834 lda L9C74 cmp highlight_count beq L9936 - jsr push_zp_addrs + jsr push_pointers lda $08 sec @@ -1007,7 +1005,7 @@ L9909: sta L9834 L992D: ldy #IconEntry::state lda #$80 ; Highlighted sta ($08),y - jsr pop_zp_addrs + jsr pop_pointers L9936: ldx #icon_poly_size-1 ldy #icon_poly_size-1 @@ -1031,11 +1029,7 @@ L9954: dec L9C74 ldx L9C74 jmp L98F2 -L995F: ldx #7 -: lda drag_outline_buffer+2,x - sta L9C76,x - dex - bpl :- +L995F: COPY_BYTES 8, drag_outline_buffer+2, L9C76 copy16 #drag_outline_buffer, $08 L9972: ldy #2 @@ -1127,11 +1121,8 @@ L9A20: lda findwindow_params2,x jsr L9E14 jmp L9A0E -L9A31: ldx #3 -L9A33: lda findwindow_params2,x - sta L9C92,x - dex - bpl L9A33 +L9A31: COPY_BYTES 4, findwindow_params2, L9C92 + lda highlight_icon_id beq L9A84 lda L9831 @@ -1245,7 +1236,7 @@ L9BD4: ora #$80 L9BDC: lda L9832 beq L9BD1 -L9BE1: jsr push_zp_addrs +L9BE1: jsr push_pointers MGTK_CALL MGTK::InitPort, grafport MGTK_CALL MGTK::SetPort, grafport ldx highlight_count @@ -1264,7 +1255,7 @@ L9BF3: dex tax jmp L9BF3 -L9C18: jsr pop_zp_addrs +L9C18: jsr pop_pointers ldx highlight_count dex txa @@ -1305,7 +1296,7 @@ L9C63: lda #0 just_select: ; ??? tay - jsr pop_zp_addrs + jsr pop_pointers tya tax ldy #0 @@ -1338,11 +1329,7 @@ L9C96: .word 0 L9C98: .word 0 .byte $00,$00,$00,$00 -L9C9E: ldx #.sizeof(MGTK::Rect)-1 -: lda L9C76,x - sta L9C86,x - dex - bpl :- +L9C9E: COPY_STRUCT MGTK::Rect, L9C76, L9C86 rts L9CAA: lda L9C76 @@ -1425,7 +1412,7 @@ L9E14: bit L9833 bpl L9E1A rts -L9E1A: jsr push_zp_addrs +L9E1A: jsr push_pointers MGTK_CALL MGTK::FindWindow, findwindow_params2 lda findwindow_params2::which_area bne L9E2B @@ -1467,7 +1454,7 @@ L9E97: MGTK_CALL MGTK::InitPort, grafport MGTK_CALL MGTK::SetPort, grafport MGTK_CALL MGTK::SetPattern, checkerboard_pattern2 MGTK_CALL MGTK::SetPenMode, penXOR_2 - jsr pop_zp_addrs + jsr pop_pointers rts L9EB3: .byte 0 @@ -1610,7 +1597,7 @@ L9F9F: lda #$80 cpy #IconEntry::iconx + 6 ; x/y/bits bne :- - jsr push_zp_addrs + jsr push_pointers copy16 paintbits_params2::mapbits, $08 ldy #11 : lda ($08),y @@ -1621,7 +1608,7 @@ L9F9F: lda #$80 bit L9F92 bpl :+ jsr LA12C -: jsr pop_zp_addrs +: jsr pop_pointers ldy #9 : lda ($06),y @@ -1655,11 +1642,9 @@ L9F9F: lda #$80 add16_8 paintbits_params2::viewloc::ycoord, paintbits_params2::maprect::y2, moveto_params2::ycoord add16 moveto_params2::ycoord, #1, moveto_params2::ycoord add16_8 moveto_params2::ycoord, font_height, moveto_params2::ycoord - ldx #3 -: lda moveto_params2,x - sta L9F94,x - dex - bpl :- + + COPY_STRUCT MGTK::Point, moveto_params2, L9F94 + bit L9F92 bvc LA097 MGTK_CALL MGTK::InitPort, grafport @@ -1696,11 +1681,7 @@ LA0C2: MGTK_CALL MGTK::PaintBits, paintbits_params2 LA0E6: MGTK_CALL MGTK::SetPenMode, penOR_2 LA0EC: MGTK_CALL MGTK::PaintRect, paintrect_params6 -LA0F2: ldx #3 -: lda L9F94,x - sta moveto_params2,x - dex - bpl :- +LA0F2: COPY_STRUCT MGTK::Point, L9F94, moveto_params2 MGTK_CALL MGTK::MoveTo, moveto_params2 bit L9F92 @@ -1717,11 +1698,7 @@ setbg: sta settextbg_params MGTK_CALL MGTK::ShowCursor rts -LA12C: ldx #.sizeof(paintbits_params)-1 -: lda paintbits_params2,x - sta paintbits_params,x - dex - bpl :- +LA12C: COPY_BLOCK paintbits_params2, paintbits_params ldy paintbits_params::maprect::y2 LA13A: lda paintbits_params::mapwidth @@ -1770,7 +1747,7 @@ icon_poly_size = (8 * .sizeof(MGTK::Point)) + 2 entry_ptr := $6 bitmap_ptr := $8 - jsr push_zp_addrs + jsr push_pointers ;; v0 - copy from icon entry ldy #IconEntry::iconx+3 @@ -1889,7 +1866,7 @@ got_width: adc #0 sta poly::v3::xcoord+1 sta poly::v4::xcoord+1 - jsr pop_zp_addrs + jsr pop_pointers rts icon_width: .byte 0 @@ -1906,10 +1883,10 @@ text_width: .byte 0 ;; DT_REDAW_ICON params LA2A9: .byte 0 -LA2AA: jsr pop_zp_addrs +LA2AA: jsr pop_pointers rts -LA2AE: jsr push_zp_addrs +LA2AE: jsr push_pointers ldx num_icons dex LA2B5: bmi LA2AA @@ -2023,7 +2000,7 @@ icon_num: .byte 0 ;;; ============================================================ -.proc push_zp_addrs +.proc push_pointers ;; save return addr pla sta stash @@ -2050,7 +2027,7 @@ stash: .word 0 ;;; ============================================================ -.proc pop_zp_addrs +.proc pop_pointers ;; save return addr pla sta stash @@ -2148,18 +2125,14 @@ volume: .proc erase_icon copy16 poly::v0::ycoord, LA3B1 copy16 poly::v6::xcoord, LA3AF - ldx #3 -: lda poly::v4::xcoord,x - sta LA3B3,x - dex - bpl :- + COPY_BLOCK poly::v4, LA3B3 MGTK_CALL MGTK::PaintPoly, poly rts .endproc ;;; ============================================================ -LA446: jsr push_zp_addrs +LA446: jsr push_pointers ldx num_icons dex ; any icons to draw? @@ -2172,7 +2145,7 @@ LA446: jsr push_zp_addrs bpl :+ MGTK_CALL MGTK::InitPort, grafport MGTK_CALL MGTK::SetPort, grafport4 -: jsr pop_zp_addrs +: jsr pop_pointers rts LA466: txa @@ -2281,7 +2254,7 @@ LA56D: .word 0 LA56F: pla tay - jsr push_zp_addrs + jsr push_pointers tya asl a tax @@ -2294,12 +2267,12 @@ LA56F: pla sub16in ($06),y, LA56B, ($06),y iny sub16in ($06),y, LA56D, ($06),y - jsr pop_zp_addrs + jsr pop_pointers rts LA5CB: pla tay - jsr push_zp_addrs + jsr push_pointers tya asl a tax @@ -2312,7 +2285,7 @@ LA5CB: pla add16in ($06),y, LA56B, ($06),y iny add16in ($06),y, LA56D, ($06),y - jsr pop_zp_addrs + jsr pop_pointers rts ;;; ============================================================ @@ -2415,11 +2388,9 @@ LA6C7: lda L9F93 adc #0 sta setportbits_params2::cliprect::x1+1 sta setportbits_params2::viewloc::xcoord+1 - ldx #5 -LA6E5: lda LA629,x - sta setportbits_params2::cliprect::y1,x - dex - bpl LA6E5 + + COPY_BYTES 6, LA629, setportbits_params2::cliprect::y1 + lda setportbits_params2::cliprect::y1 sta setportbits_params2::viewloc::ycoord lda setportbits_params2::cliprect::y1+1 @@ -2488,7 +2459,7 @@ LA77D: lda LA6B3,x lda findwindow_params::window_id sta getwinport_params MGTK_CALL MGTK::GetWinPort, getwinport_params - jsr push_zp_addrs + jsr push_pointers MGTK_CALL MGTK::GetWinPtr, findwindow_params::window_id copy16 LA6AE, $06 ldy #1 @@ -2541,7 +2512,7 @@ LA833: bit LA6B1 sta grafport4::cliprect::x2 bcc LA846 inc grafport4::cliprect::x2+1 -LA846: jsr pop_zp_addrs +LA846: jsr pop_pointers sub16 grafport4::cliprect::x2, grafport4::cliprect::x1, LA6C3 sub16 grafport4::cliprect::y2, grafport4::cliprect::y1, LA6C5 lda LA6C3 diff --git a/desktop/desktop_lc.s b/desktop/desktop_lc.s index e3bc05c..5385d3c 100644 --- a/desktop/desktop_lc.s +++ b/desktop/desktop_lc.s @@ -128,7 +128,7 @@ to: lda #$00 : sta flag - jsr desktop_main_push_zp_addrs + jsr desktop_main_push_pointers lda cached_window_id asl a ; * 2 @@ -178,7 +178,7 @@ copy_from: done: sta RAMRDOFF sta RAMWRTOFF - jsr desktop_main_pop_zp_addrs + jsr desktop_main_pop_pointers rts flag: .byte 0 diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index e69fbfa..01230de 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -261,10 +261,7 @@ L41E2: copy cached_window_id, getwinport_params2::window_id jsr get_set_port2 jsr cached_icons_window_to_screen - ldx #.sizeof(MGTK::Rect)-1 -: copy grafport2::cliprect,x, rect_E230,x - dex - bpl :- + COPY_BLOCK grafport2::cliprect, rect_E230 copy #0, L4241 L41FE: lda L4241 @@ -308,10 +305,7 @@ bail: rts jsr get_port2 jsr offset_grafport2_and_set - ldx #.sizeof(MGTK::Rect)-1 -: copy grafport2::cliprect,x, rect_E230,x - dex - bpl :- + COPY_BLOCK grafport2::cliprect, rect_E230 L4270: lda L42C3 cmp selected_icon_count @@ -1993,11 +1987,7 @@ L4FD4: lda #$80 bpl :- ;; Create with current date - ldx #3 -: lda DATELO,x - sta create_params::create_date,x - dex - bpl :- + COPY_STRUCT DateTime, DATELO, create_params::create_date ;; Create folder MLI_RELAY_CALL CREATE, create_params @@ -2071,10 +2061,11 @@ L5098: .byte $00 .proc cmd_quit_impl -stack_data: +.proc stack_data .addr $DEAF,$DEAD ; ??? +.endproc -quit_code: +.proc quit_code ;;; note that GS/OS GQUIT is called by ProDOS at $E0D000 ;;; to quit back to GS/OS. ;;; since DeskTop pre-dates GS/OS, it's likely that this does @@ -2087,25 +2078,19 @@ quit_code: xce ; enter native mode jmp $E0D004 ; ProDOS 8->16 QUIT, presumably .popcpu +.endproc DEFINE_QUIT_PARAMS quit_params start: - ldx #3 -: lda stack_data,x - sta $0102,x ; Populate stack ??? - dex - bpl :- + COPY_BLOCK stack_data, $0102 ; Populate stack ??? ;; Install new quit routine sta ALTZPOFF lda LCBANK2 lda LCBANK2 - ldx #5 -: lda quit_code,x - sta SELECTOR,x - dex - bpl :- + + COPY_BLOCK quit_code, SELECTOR ;; Restore machine to text state sta ALTZPOFF @@ -2176,6 +2161,7 @@ L5162: sta ($06),y dey cpy #$1B bne L5162 + ldy #$23 ldx #$03 L516D: lda L51EB,x @@ -2183,8 +2169,9 @@ L516D: lda L51EB,x dey dex bpl L516D + lda active_window_id - jsr L763A + jsr create_file_icon_ep2 lda active_window_id sta getwinport_params2::window_id jsr get_set_port2 @@ -2261,6 +2248,7 @@ L523B: sta ($06),y dey cpy #$1B bne L523B + ldy #$23 ldx #$03 L5246: lda L5263,x @@ -2268,6 +2256,7 @@ L5246: lda L5263,x dey dex bpl L5246 + lda #$80 sta L4152 jsr reset_grafport3 @@ -3436,11 +3425,7 @@ L5B1B: .byte 0 sta L5B1B ;; Restore event coords (following detect_double_click) - ldx #3 -: lda saved_event_coords,x - sta event_coords,x - dex - bpl :- + COPY_STRUCT MGTK::Point, saved_event_coords, event_coords MGTK_RELAY_CALL MGTK::FindControl, event_coords lda findcontrol_which_ctl @@ -3897,12 +3882,14 @@ L5F0F: .byte 0 start: copy16 #notpenXOR, $06 jsr L60D5 + ldx #$03 L5F20: lda event_coords,x sta L5F0B,x sta L5F0F,x dex bpl L5F20 + jsr peek_event lda event_kind cmp #MGTK::EventKind::drag @@ -3981,11 +3968,9 @@ L600E: lda L60CB jmp L5F6B L601F: MGTK_RELAY_CALL MGTK::FrameRect, rect_E230 - ldx #$03 -L602A: lda event_coords,x - sta L60CF,x - dex - bpl L602A + + COPY_STRUCT MGTK::Point, event_coords, L60CF + cmp16 event_xcoord, rect_E230::x2 bpl L6068 cmp16 event_xcoord, rect_E230::x1 @@ -4026,7 +4011,7 @@ L60D1: .word 0 L60D3: .byte 0 L60D4: .byte 0 -L60D5: jsr push_zp_addrs +L60D5: jsr push_pointers jmp icon_ptr_window_to_screen .endproc L5F13 := L5F13_impl::start @@ -4849,11 +4834,9 @@ L6978: lda L6A35 jmp L68E4 L6989: MGTK_RELAY_CALL MGTK::FrameRect, rect_E230 - ldx #$03 -L6994: lda event_coords,x - sta L6A39,x - dex - bpl L6994 + + COPY_STRUCT MGTK::Point, event_coords, L6A39 + cmp16 event_xcoord, rect_E230::x2 bpl L69D2 cmp16 event_xcoord, rect_E230::x1 @@ -5108,7 +5091,7 @@ L6C0E: .byte 0 bmi L6C25 jmp L6CCD -L6C25: jsr push_zp_addrs +L6C25: jsr push_pointers lda cached_window_id sta getwinport_params2::window_id jsr get_set_port2 @@ -5178,7 +5161,7 @@ rloop: lda rows_done jmp rloop done: jsr reset_grafport3 - jsr pop_zp_addrs + jsr pop_pointers rts rows_done: @@ -5193,11 +5176,9 @@ L6CCD: lda cached_window_id jsr draw_window_header L6CDE: jsr cached_icons_window_to_screen jsr offset_grafport2_and_set - ldx #$07 -L6CE6: lda grafport2::cliprect,x - sta rect_E230,x - dex - bpl L6CE6 + + COPY_BLOCK grafport2::cliprect, rect_E230 + ldx #$00 txa pha @@ -5664,12 +5645,10 @@ L70C4: .byte $00 .proc start sta L72A7 - jsr push_zp_addrs - ldx #$40 -L70CD: lda LE1B0,x - sta vol_info_path_buf,x - dex - bpl L70CD + jsr push_pointers + + COPY_BYTES $41, LE1B0, vol_info_path_buf + jsr do_open lda open_params::ref_num sta read_params::ref_num @@ -5870,7 +5849,7 @@ L7293: jmp do_entry L7296: copy16 record_ptr, L485F jsr do_close - jsr pop_zp_addrs + jsr pop_pointers rts L72A7: .byte 0 L72A8: .word 0 @@ -5973,7 +5952,7 @@ L734A: lda LE1F1+1,x inx copy16 LE202,x, $08 ldy #$00 - jsr push_zp_addrs + jsr push_pointers L73A5: lda LCBANK2 lda LCBANK2 lda ($08),y @@ -5988,7 +5967,7 @@ L73A5: lda LCBANK2 lda $08 cmp L485F bne L73A5 - jsr pop_zp_addrs + jsr pop_pointers lda LE1F1 asl a tax @@ -6031,7 +6010,7 @@ L7449: .word 0 ldy #$09 lda ($06),y tay - jsr push_zp_addrs + jsr push_pointers lda $06 clc adc #$09 @@ -6052,12 +6031,12 @@ L7471: lda ($06),y lda ($08),y and #%11011111 ; ??? sta ($08),y - jsr pop_zp_addrs + jsr pop_pointers ldy #IconEntry::win_type lda ($06),y and #icon_entry_winid_mask bne L74D3 - jsr push_zp_addrs + jsr push_pointers lda cached_window_id jsr window_address_lookup stax $08 @@ -6094,7 +6073,7 @@ L74C8: lda ($08),y L74D3: tay lda #$00 sta L7620 - jsr push_zp_addrs + jsr push_pointers tya pha jsr window_address_lookup @@ -6202,7 +6181,7 @@ L75A3: sta ($06),y sta ($06),y ldy #$09 sta ($06),y - jsr pop_zp_addrs + jsr pop_pointers lda icon_params2 jsr open_directory @@ -6229,20 +6208,24 @@ L75FA: ldx cached_window_id copy16 vol_kb_used, window_k_used_table,x copy16 vol_kb_free, window_k_free_table,x lda cached_window_id - jsr L7635 + jsr create_file_icon_ep1 rts L7620: .byte $00 .endproc ;;; ============================================================ -;;; Icon entry construction +;;; File Icon Entry Construction + +.proc create_file_icon L7621: .byte $00 ; window_id ? L7622: .addr 0 ; iconbits L7624: .byte $00 ; icon type L7625: .byte $00 -L7626: .word $34,$10 + +initial_coords: DEFINE_POINT 52,16 + L762A: .word 0 L762C: .word 0 L762E: .byte $05 @@ -6251,25 +6234,25 @@ L7630: .word 0 L7632: .word 0 L7634: .byte $00 -.proc L7635 +.proc ep1 ; entry point #1 ??? pha - lda #$00 + lda #0 beq L7647 -L763A: pha + +ep2: pha ; entry point #2 ??? ldx cached_window_id dex lda LEC26,x sta icon_params2 lda #$80 + L7647: sta L7634 pla sta L7621 - jsr push_zp_addrs - ldx #$03 -L7653: lda L7626,x - sta L762A,x - dex - bpl L7653 + jsr push_pointers + + COPY_STRUCT MGTK::Point, initial_coords, L762A + lda #$00 sta L762F sta L7625 @@ -6312,7 +6295,7 @@ L76AA: lda L7625 L76BB: bit L7634 bpl :+ - jsr pop_zp_addrs + jsr pop_pointers rts : jsr L7B6B @@ -6365,14 +6348,13 @@ L7744: ldy #$22 lda icon_params2 ldx L7621 jsr animate_window_open - jsr pop_zp_addrs + jsr pop_pointers rts L7764: .byte $00,$00,$00 L7767: .byte $14 .endproc - L763A := L7635::L763A ;;; ============================================================ ;;; Create icon @@ -6487,7 +6469,7 @@ L7826: copy16 L762C, L7632 cmp L762E bne L7862 add16 L762C, #32, L762C - copy16 L7626, L762A + copy16 initial_coords, L762A lda #$00 sta L762F jmp L7870 @@ -6521,7 +6503,7 @@ L7870: lda cached_window_id ptr := $6 sta file_type - jsr push_zp_addrs + jsr push_pointers ;; Find index of file type copy16 type_table_addr, ptr @@ -6548,13 +6530,17 @@ found: ;; Look up icon definition copy16 type_icons_addr, ptr copy16in (ptr),y, L7622 - jsr pop_zp_addrs + jsr pop_pointers rts file_type: .byte 0 .endproc +.endproc + create_file_icon_ep2 := create_file_icon::ep1::ep2 + create_file_icon_ep1 := create_file_icon::ep1 + ;;; ============================================================ ;;; Draw header (items/k in disk/k available/lines) @@ -7660,11 +7646,9 @@ loop: lda LEC43,x .proc prepare_col_type lda LEC53 jsr L8707 - ldx #4 -loop: lda LDFC5,x - sta text_buffer2::data-1,x - dex - bpl loop + + COPY_BYTES 5, LDFC5, text_buffer2::data-1 + rts .endproc @@ -7949,7 +7933,7 @@ L84D0: .byte 0 ;;; ============================================================ .proc L84D1 - jsr push_zp_addrs + jsr push_pointers bit L5B1B bmi L84DC jsr cached_icons_window_to_screen @@ -8028,7 +8012,7 @@ L85E4: lda grafport2::cliprect::x1,x dey dex bpl L85E4 - jsr pop_zp_addrs + jsr pop_pointers rts L85F1: .byte 0 @@ -8389,7 +8373,7 @@ check_alpha: ;;; ============================================================ ;;; Pushes two words from $6/$8 to stack -.proc push_zp_addrs +.proc push_pointers ptr := $6 pla ; stash return address @@ -8416,7 +8400,7 @@ addr: .addr 0 ;;; ============================================================ ;;; Pops two words from stack to $6/$8 -.proc pop_zp_addrs +.proc pop_pointers ptr := $6 pla ; stash return address @@ -8449,7 +8433,7 @@ port_copy: ptr := $6 tay - jsr push_zp_addrs + jsr push_pointers tya jsr window_lookup stax ptr @@ -8461,7 +8445,7 @@ port_copy: inx cpx #.sizeof(MGTK::GrafPort) bne :- - jsr pop_zp_addrs + jsr pop_pointers rts .endproc @@ -8469,7 +8453,7 @@ port_copy: ptr := $6 tay - jsr push_zp_addrs + jsr push_pointers tya jsr window_lookup stax ptr @@ -8481,7 +8465,7 @@ port_copy: inx cpx #.sizeof(MGTK::GrafPort) bne :- - jsr pop_zp_addrs + jsr pop_pointers rts .endproc @@ -8494,7 +8478,7 @@ port_copy: winfo_ptr := $8 tay - jsr push_zp_addrs + jsr push_pointers tya jsr icon_entry_lookup stax entry_ptr @@ -8537,7 +8521,7 @@ port_copy: ;; icony sub16in (entry_ptr),y, pos_win+2, (entry_ptr),y - jsr pop_zp_addrs + jsr pop_pointers rts pos_screen: .word 0, 0 @@ -8551,7 +8535,7 @@ pos_win: .word 0, 0 .proc icon_window_to_screen tay - jsr push_zp_addrs + jsr push_pointers tya jsr icon_entry_lookup stax $06 @@ -8600,7 +8584,7 @@ pos_win: .word 0, 0 ;; icony add16in (entry_ptr),y, pos_win+2, (entry_ptr),y - jsr pop_zp_addrs + jsr pop_pointers rts pos_screen: .word 0, 0 @@ -8656,7 +8640,7 @@ success: create_icon: icon_ptr := $6 - jsr push_zp_addrs + jsr push_pointers jsr DESKTOP_ALLOC_ICON ldy device_num sta device_to_icon_map,y @@ -8772,7 +8756,7 @@ selected_device_icon: ldy #IconEntry::id lda (icon_ptr),y sta cached_window_icon_list,x - jsr pop_zp_addrs + jsr pop_pointers return #0 .endproc @@ -8821,14 +8805,14 @@ remove: lda cached_window_icon_list+1,x ;;; ============================================================ -L8B19: jsr push_zp_addrs +L8B19: jsr push_pointers jmp L8B2E L8B1F: lda icon_params2 bne L8B25 rts -L8B25: jsr push_zp_addrs +L8B25: jsr push_pointers lda icon_params2 jsr L7345 ;; fall through @@ -8854,7 +8838,7 @@ skip: lda icon_params2 and #(~icon_entry_open_mask)&$FF ; clear open_flag sta ($06),y jsr L4244 - jsr pop_zp_addrs + jsr pop_pointers rts .endproc @@ -8882,6 +8866,7 @@ open: ldy #$00 clc adc #$23 tay + ldx #$23 : lda (ptr),y sta grafport2,x @@ -11620,11 +11605,7 @@ LA46C: rts .endproc .proc LA46D - ldx #10 -loop: lda file_info_params2::access,x - sta file_info_params3::access,x - dex - bpl loop + COPY_BYTES 11, file_info_params2::access, file_info_params3::access rts .endproc @@ -11642,6 +11623,9 @@ done: rts .endproc ;;; ============================================================ +;;; Show Alert Dialog +;;; A=error. If ERR_VOL_NOT_FOUND or ERR_FILE_NOT_FOUND, will +;;; show "please insert source disk" (or destination, if flag set) .proc show_error_alert_impl @@ -11985,19 +11969,19 @@ LA777: jmp format_erase_overlay::L0CF9 LA77A: bit LD8E7 bvc LA79B cmp #'Y' - beq LA7E8 + beq do_yes cmp #'y' - beq LA7E8 + beq do_yes cmp #'N' - beq LA7F7 + beq do_no cmp #'n' - beq LA7F7 + beq do_no cmp #'A' - beq LA806 + beq do_all cmp #'a' - beq LA806 + beq do_all cmp #CHAR_RETURN - beq LA7E8 + beq do_yes LA79B: bit LD8F5 bmi LA7C8 @@ -12027,7 +12011,7 @@ LA7C8: cmp #' ' bcs LA7CF jmp LA717 -LA7CF: cmp #$7E +LA7CF: cmp #'~' beq LA7DD bcc LA7DD jmp LA717 @@ -12038,17 +12022,16 @@ LA7DD: ldx has_input_field_flag beq LA7E5 jsr LBB0B LA7E5: return #$FF -.endproc -LA7E8: jsr set_penmode_xor2 +do_yes: jsr set_penmode_xor2 MGTK_RELAY_CALL MGTK::PaintRect, desktop_aux::yes_button_rect return #prompt_button_yes -LA7F7: jsr set_penmode_xor2 +do_no: jsr set_penmode_xor2 MGTK_RELAY_CALL MGTK::PaintRect, desktop_aux::no_button_rect return #prompt_button_no -LA806: jsr set_penmode_xor2 +do_all: jsr set_penmode_xor2 MGTK_RELAY_CALL MGTK::PaintRect, desktop_aux::all_button_rect return #prompt_button_all @@ -12098,10 +12081,13 @@ LA88D: lda has_input_field_flag beq LA895 jsr LBB63 LA895: return #$FF +.endproc rts1: rts +;;; ============================================================ + jump_relay: .assert * = $A899, error, "Entry point used by overlay" jmp dummy0000 @@ -12560,7 +12546,7 @@ LAE42: cmp #$40 LAE49: copy #$80, has_input_field_flag jsr clear_path_buf2 lda #$00 - jsr LB509 + jsr open_prompt_window lda winfo_alert_dialog jsr set_port_from_window_id addr_call draw_dialog_title, desktop_aux::str_new_folder_title @@ -12647,7 +12633,7 @@ LAF34: copy #0, has_input_field_flag lsr a ror a eor #$80 - jsr LB509 + jsr open_prompt_window lda winfo_alert_dialog jsr set_port_from_window_id addr_call draw_dialog_title, desktop_aux::str_info_title @@ -12913,7 +12899,7 @@ LB27D: jsr clear_path_buf1 copy #$80, has_input_field_flag jsr clear_path_buf2 lda #$00 - jsr LB509 + jsr open_prompt_window lda winfo_alert_dialog jsr set_port_from_window_id addr_call draw_dialog_title, desktop_aux::str_rename_title @@ -13109,10 +13095,7 @@ set_penmode_xor2: double_click_deltax := 5 double_click_deltay := 4 - ldx #3 -: copy event_coords,x, coords,x - dex - bpl :- + COPY_STRUCT MGTK::Point, event_coords, coords lda #0 sta counter+1 @@ -13219,22 +13202,25 @@ unused: .byte 0 ; unused ;;; ============================================================ -LB509: +.proc open_prompt_window .assert * = $B509, error, "Entry point used by overlay" sta LD8E7 jsr open_dialog_window bit LD8E7 - bvc LB51A + bvc :+ jsr draw_yes_no_all_cancel_buttons - jmp LB526 + jmp no_ok -LB51A: MGTK_RELAY_CALL MGTK::FrameRect, desktop_aux::ok_button_rect +: MGTK_RELAY_CALL MGTK::FrameRect, desktop_aux::ok_button_rect jsr draw_ok_label -LB526: bit LD8E7 - bmi LB537 +no_ok: bit LD8E7 + bmi done MGTK_RELAY_CALL MGTK::FrameRect, desktop_aux::cancel_button_rect jsr draw_cancel_label -LB537: jmp reset_grafport3a +done: jmp reset_grafport3a +.endproc + +;;; ============================================================ .proc open_dialog_window MGTK_RELAY_CALL MGTK::OpenWindow, winfo_alert_dialog @@ -13246,6 +13232,8 @@ LB537: jmp reset_grafport3a rts .endproc +;;; ============================================================ + .proc open_alert_window MGTK_RELAY_CALL MGTK::OpenWindow, winfo_alert_dialog lda winfo_alert_dialog @@ -14122,11 +14110,7 @@ LBD33: rts target := $20 ;; Backup copy of $20 - ldx #proc_len -: lda target,x - sta saved_proc_buf,x - dex - bpl :- + COPY_BYTES proc_len+1, target, saved_proc_buf ;; Overwrite with proc ldx #proc_len @@ -14140,11 +14124,7 @@ LBD33: rts pha ;; Restore copy - ldx #proc_len -: lda saved_proc_buf,x - sta target,x - dex - bpl :- + COPY_BYTES proc_len+1, saved_proc_buf, target pla rts @@ -14312,8 +14292,8 @@ reset_grafport3a: PAD_TO $BF00 .endproc ; desktop_main - desktop_main_pop_zp_addrs := desktop_main::pop_zp_addrs - desktop_main_push_zp_addrs := desktop_main::push_zp_addrs + desktop_main_pop_pointers := desktop_main::pop_pointers + desktop_main_push_pointers := desktop_main::push_pointers ;;; ============================================================ ;;; Segment loaded into MAIN $800-$FFF @@ -14449,12 +14429,12 @@ found_ram: .proc populate_icon_entries_table ptr := $6 - jsr desktop_main::push_zp_addrs + jsr desktop_main::push_pointers copy16 #icon_entries, ptr ldx #1 loop: cpx #max_icon_count bne :+ - jsr desktop_main::pop_zp_addrs + jsr desktop_main::pop_pointers jmp end : txa pha diff --git a/desktop/mgtk.s b/desktop/mgtk.s index 33107ab..574be52 100644 --- a/desktop/mgtk.s +++ b/desktop/mgtk.s @@ -101,16 +101,8 @@ bpl adjust_stack ;; Save $80...$FF, swap in what MGTK needs at $F4...$FF - ldx #$7F -: lda $80,x - sta zp_saved,x - dex - bpl :- - ldx #$0B -: lda active_saved,x - sta active_port,x - dex - bpl :- + COPY_BYTES $80, $80, zp_saved + COPY_BYTES $C, active_saved, active_port jsr apply_active_port_to_port adjust_stack: ; Adjust stack to account for params @@ -195,16 +187,9 @@ cleanup: : bit preserve_zp_flag bpl exit_with_0 jsr apply_port_to_active_port - ldx #$0B -: lda active_port,x - sta active_saved,x - dex - bpl :- - ldx #$7F -: lda zp_saved,x - sta $80,x - dex - bpl :- + + COPY_BYTES $C, active_port, active_saved + COPY_BYTES $80, zp_saved, $80 ;; default is to return with A=0 exit_with_0: @@ -1690,11 +1675,7 @@ frect_ctr: .byte 0 bottom := $A5 ldy #3 -rloop: ldx #7 -: lda left,x - sta left_masks_table,x - dex - bpl :- +rloop: COPY_BYTES 8, left, left_masks_table ldx rect_sides,y lda left,x pha @@ -1708,11 +1689,7 @@ rloop: ldx #7 ldy frect_ctr dey bpl rloop - ldx #3 -: lda left,x - sta current_penloc,x - dex - bpl :- + COPY_BYTES 4, left, current_penloc .endproc prts: rts @@ -3646,11 +3623,7 @@ next_byte: text_ndbm: inc $A0 : - ldx #15 -: lda text_bits_buf+16,x - sta text_bits_buf,x - dex - bpl :- + COPY_BYTES 16, text_bits_buf+16, text_bits_buf jmp L5BFF @@ -3914,12 +3887,7 @@ maybe_stash: bpl end ;; Copy buffer to ZP $00-$43 -stash: - ldx #$43 -: lda low_zp_stash_buffer,x - sta $00,x - dex - bpl :- +stash: COPY_BYTES $44, low_zp_stash_buffer, $00 end: rts @@ -3929,11 +3897,7 @@ maybe_unstash: ;; Copy ZP $00-$43 to buffer unstash: - ldx #$43 -: lda $00,x - sta low_zp_stash_buffer,x - dex - bpl :- + COPY_BYTES $44, $00, low_zp_stash_buffer rts .endproc maybe_stash_low_zp := SetZP2Impl::maybe_stash @@ -4309,11 +4273,7 @@ active_cursor_mask := draw_cursor::active_cursor_mask bit cursor_flag bmi drts - ldx #3 -: lda cursor_data,x - sta cursor_bytes,x - dex - bpl :- + COPY_BYTES 4, cursor_data, cursor_bytes ldx #$23 ldy cursor_y2 @@ -4600,11 +4560,7 @@ savesize: .res 2 pla sta save_p_reg - ldx #4 -: lda params::machine,x - sta machid,x - dex - bpl :- + COPY_BYTES 5, params::machine, machid lda #$7F sta standard_port::textback @@ -5227,11 +5183,7 @@ up: lda #MGTK::EventKind::button_up set_state: sta input::state - ldx #2 -: lda set_pos_params,x - sta input::key,x - dex - bpl :- + COPY_BYTES 3, set_pos_params, input::key put_key_event: jsr put_event @@ -5269,11 +5221,7 @@ body: ; returned by GetIntHandler lda LOWSCR sta SET80COL - ldx #8 ; preserve 9 bytes of ZP -sloop: lda $82,x - sta int_stash_zp,x - dex - bpl sloop + COPY_BYTES 9, $82, int_stash_zp ; preserve 9 bytes of ZP ldy #SERVEMOUSE jsr call_mouse @@ -5284,11 +5232,7 @@ sloop: lda $82,x bpl :+ clc ; carry clear if interrupt handled -: ldx #8 ; restore ZP -rloop: lda int_stash_zp,x - sta $82,x - dex - bpl rloop +: COPY_BYTES 9, int_stash_zp, $82 ; restore ZP lda LOWSCR ; restore soft switches sta CLR80COL @@ -6611,11 +6555,7 @@ check_char: .res 1 control_char: .res 1 END_PARAM_BLOCK - ldx #3 -loop: lda params,x - sta menu_glyphs,x - dex - bpl loop + COPY_BYTES 4, params, menu_glyphs copy16 standard_port::textfont, params ldy #0 @@ -6967,11 +6907,7 @@ in_winrect: ;; and height of the maprect of the window's port. ;; .proc get_winrect - ldx #3 -: lda current_winport::viewloc,x ; copy viewloc to left/top of winrect - sta winrect,x - dex - bpl :- + COPY_BLOCK current_winport::viewloc, winrect ; copy viewloc to left/top of winrect ldx #2 : lda current_winport::maprect::x2,x ; x2/y2 @@ -7786,11 +7722,8 @@ win_port: .addr 0 jsr window_by_id_or_exit copy16 params::win_port, params_addr - ldx #7 -: lda fill_rect_params,x - sta current_maprect_x1,x - dex - bpl :- + COPY_STRUCT MGTK::Rect, fill_rect_params, current_maprect_x1 + jsr prepare_winport bcc err_obscured @@ -8243,11 +8176,7 @@ DragWindowImpl_drag_or_grow := DragWindowImpl::drag_or_grow jsr set_desktop_port jsr get_winframerect - ldx #7 -: lda winrect,x - sta left,x - dex - bpl :- + COPY_BLOCK winrect, left jsr clip_rect ldx #3 @@ -9237,21 +9166,13 @@ movement_cancel: .byte $00 kbd_mouse_status: .byte $00 .proc kbd_mouse_save_zp - ldx #$7F -: lda $80,x - sta kbd_mouse_zp_stash,x - dex - bpl :- + COPY_BYTES $80, $80, kbd_mouse_zp_stash rts .endproc .proc kbd_mouse_restore_zp - ldx #$7F -: lda kbd_mouse_zp_stash,x - sta $80,x - dex - bpl :- + COPY_BYTES $80, kbd_mouse_zp_stash,$80 rts .endproc @@ -9346,11 +9267,7 @@ scale_y: .proc kbd_mouse_to_mouse - ldx #2 -: lda kbd_mouse_x,x - sta mouse_x,x - dex - bpl :- + COPY_BYTES 3, kbd_mouse_x, mouse_x rts .endproc @@ -9362,11 +9279,7 @@ scale_y: .proc save_mouse_pos jsr read_mouse_pos - ldx #2 -: lda mouse_x,x - sta saved_mouse_pos,x - dex - bpl :- + COPY_BYTES 3, mouse_x, saved_mouse_pos rts .endproc @@ -9506,11 +9419,7 @@ waitloop: lda #0 sta kbd_mouse_status ; reset mouse button status - ldx #2 -: lda set_pos_params,x - sta kbd_mouse_x,x - dex - bpl :- + COPY_BYTES 3, set_pos_params, kbd_mouse_x ret: rts in_kbd_mouse: @@ -9545,11 +9454,7 @@ pla_ret: and #$20 beq kbd_mouse_to_mouse_jmp - ldx #2 -: lda mouse_x,x - sta kbd_mouse_x,x - dex - bpl :- + COPY_BYTES 3, mouse_x, kbd_mouse_x stx kbd_menu_select_flag ; =$ff rts @@ -10047,21 +9952,13 @@ out_of_boundsl: not_left: sta set_input_key - ldx #.sizeof(MGTK::GrafPort)-1 -: lda $A7,x - sta $0600,x - dex - bpl :- + COPY_STRUCT MGTK::GrafPort, $A7, $0600 lda set_input_key jsr kbd_menu_by_shortcut php - ldx #.sizeof(MGTK::GrafPort)-1 -: lda $0600,x - sta $A7,x - dex - bpl :- + COPY_STRUCT MGTK::GrafPort, $0600, $A7 plp bcc :+ diff --git a/desktop/ovl1.s b/desktop/ovl1.s index a4647d1..be87012 100644 --- a/desktop/ovl1.s +++ b/desktop/ovl1.s @@ -48,11 +48,7 @@ start: lda #$80 MGTK_RELAY_CALL MGTK::SetZP1, ptr ;; Copy menu bar up to language card, and use it. - ldx #.sizeof(menu_bar) -: lda menu_bar,x - sta $D400,x - dex - bpl :- + COPY_BYTES .sizeof(menu_bar)+1, menu_bar, $D400 MGTK_RELAY_CALL MGTK::SetMenu, menu_target ;; Clear most of the system bitmap diff --git a/desktop/ovl2.s b/desktop/ovl2.s index 0e39e41..52ad7f9 100644 --- a/desktop/ovl2.s +++ b/desktop/ovl2.s @@ -18,7 +18,7 @@ L0800: pha ;;; Format Disk L080C: copy #$00, has_input_field_flag - jsr desktop_main::LB509 + jsr desktop_main::open_prompt_window lda winfo_alert_dialog jsr desktop_main::set_port_from_window_id addr_call desktop_main::draw_dialog_title, desktop_aux::str_format_disk @@ -154,7 +154,7 @@ L09D8: .byte 0 L09D9: lda #$00 sta has_input_field_flag - jsr desktop_main::LB509 + jsr desktop_main::open_prompt_window lda winfo_alert_dialog jsr desktop_main::set_port_from_window_id addr_call desktop_main::draw_dialog_title, desktop_aux::str_erase_disk diff --git a/desktop/ovl4.s b/desktop/ovl4.s index 9a0825f..9f5b0dc 100644 --- a/desktop/ovl4.s +++ b/desktop/ovl4.s @@ -1179,11 +1179,7 @@ L5C27: ldx $177F ;;; ============================================================ .proc L5C4F - ldx #3 -: lda screentowindow_screenx,x - sta L5CF0,x - dex - bpl :- + COPY_STRUCT MGTK::Point, screentowindow_screenx, L5CF0 lda machine_type ; Timer for insertion point blink sta ip_blink_counter @@ -1885,7 +1881,7 @@ L631A: iny L6322: lda L63BE sta L63C0 ldx #$0F - lda #$20 + lda #' ' L632C: sta L63C2,x dex bpl L632C diff --git a/inc/prodos.inc b/inc/prodos.inc index d497bd4..8c27e99 100644 --- a/inc/prodos.inc +++ b/inc/prodos.inc @@ -129,6 +129,17 @@ ERR_END_OF_FILE := $4C ERR_ACCESS_ERROR := $4E ERR_DUPLICATE_VOLUME := $57 +;;; ============================================================ +;;; Misc Structures +;;; ============================================================ + +.struct DateTime + datelo .byte + datehi .byte + timelo .byte + timehi .byte +.endstruct + ;;; ============================================================ ;;; Directory Structures ;;; ============================================================ diff --git a/macros.inc b/macros.inc index f929886..a9736dc 100644 --- a/macros.inc +++ b/macros.inc @@ -641,3 +641,25 @@ skip: dec arg .org saved_org .endscope .endmacro + +;;; ============================================================ +;;; Structure Helpers +;;; ============================================================ + +.macro COPY_BYTES size, src, dst +.scope + ldx #size - 1 +loop: lda src,x + sta dst,x + dex + bpl loop +.endscope +.endmacro + +.macro COPY_STRUCT type, src, dst + COPY_BYTES .sizeof(type), src, dst +.endmacro + +.macro COPY_BLOCK block, dst + COPY_BYTES .sizeof(block), block, dst +.endmacro