;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; cda.asm - HardPressed classic desk accessory ; Copyright (C) 1993 by Andy McFadden ; ; This is an example of communication with HardPressed. It illustrates ; getting and setting the INIT's status with SendRequest. The calls used ; here are the ONLY ones which are guaranteed to exist in future versions ; of HardPressed. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE ON OBJCASE ON ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Header START ; ; System-required header for the CDA. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dc I1'str_end-str_begin' str_begin anop dc C'HardPressed Control' str_end anop dc A4'Main' dc A4'ShutDown' dc C'Copyright (C) 1993 by Andy McFadden',H'00' END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Globals DATA ; ; Program-wide defs. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; DP defs ; ptr gequ $00 ;4b ptr2 gequ $04 ;4b ; ; Softswitches ; CLR80VID equ $e0c00c SETALTCHR equ $e0c00f ; ; Global variables ; global_mode ds 2 global_flags ds 2 ; CDA display status dMaxOpt equ 2 hilite_opt ds 2 stat_tab anop stat1 ds 2 stat2 ds 2 max_tab anop max1 dc I2'3' ;3 states for item 1 max2 dc I2'2' ;2 here ; ; reasons for failure ; failP8 gequ 1 failInactive gequ 2 failBusy gequ 3 ; ; Text screen line offsets ; texttab ANOP dc I2'$400,$480,$500,$580,$600,$680,$700,$780' dc I2'$428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8' dc I2'$450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0' END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main START ; ; Calling conventions: ; (called by control panel) ; ; Stack is on page 1, DP is on page 0. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; using MesgData using Globals phb phk plb ; see if GS/OS is active lda >$e100bc ;OS_KIND and #$00ff cmp #$0001 ;GS/OS beq is_gsos lda #failP8 jmp ErrorMain is_gsos anop ; see if HardPressed is active lda #dMping ldx #$0000 ;no data_in txy jsr SendMsg ;leaves version in data_out+$02 bcc hp_active ;if no error, HP is up ; cmp #$0120 ;reqNotAccepted ; beq nohear ;else probably $0122 (invalidReq) inactive anop lda #failInactive jmp ErrorMain hp_busy anop lda #failBusy jmp ErrorMain hp_active anop lda #dMgetStatus ldx #$0000 ;no data_in txy jsr SendMsg ;failure here probably means that bcs hp_busy ; HP is busy (must be _AlertWindow) ; ; From here on, assume HardPressed is active and functioning normally. ; lda data_out+2 ;split the mode and the flags into tax ; two parts and #$00ff sta global_mode txa and #$ff00 sta global_flags lda #$0000 jsr InitScreen ;set 40 cols, clear, draw border ; init menu stuff stz hilite_opt ldx #$0000 lda global_mode cmp #dVpolOn beq got_pol inx cmp #dVpolDecode beq got_pol inx got_pol anop stx stat1 ldx #$0000 lda global_flags bit #fGverify beq got_ver inx got_ver anop stx stat2 ; ; main loop ; redraw_loop ANOP jsr DrawScreen key_loop ANOP jsr GetKey cmp #$000d ;return? beq save_status cmp #$001b ;escape? bne not_esc brl escape_hit not_esc anop cmp #$000a ;Ctrl-J (down arrow)? beq dn cmp #$000b ;Ctrl-K (up arrow)? beq up cmp #$0008 ;Ctrl-H (left arrow)? beq left cmp #$0015 ;Ctrl-U (right arrow)? beq right pea $0008 ;sbBadKeypress ldx #$3803 ;_SysBeep2 jsl $e10000 bra key_loop dn anop lda hilite_opt inc A sta hilite_opt cmp #dMaxOpt blt redraw_loop stz hilite_opt bra redraw_loop up anop lda hilite_opt dec A bpl upstore lda #dMaxOpt-1 upstore anop sta hilite_opt bra redraw_loop right anop lda hilite_opt asl A tax lda stat_tab,x inc A cmp max_tab,x blt rightstore lda #$0000 rightstore anop sta stat_tab,x bra redraw_loop left anop lda hilite_opt asl A tax lda stat_tab,x dec A bpl leftstore lda max_tab,x dec A leftstore anop sta stat_tab,x bra redraw_loop ; ; If return was hit, send the new status to the INIT ; save_status ANOP ldx #dVpolOn ;translate the menu index into lda stat1 ; the HP state value beq got_opol ldx #dVpolDecode cmp #$0001 beq got_opol ldx #dVpolOff got_opol anop stx global_mode ; set/clear the "verify" flag without disturbing any of the others lda #fGverify ;verify flag ldx stat2 ;is verify on? beq v_off tsb global_flags ;enable verify bra v_set v_off anop trb global_flags ;disable verify v_set anop lda global_mode ;now put it together with the mode ora global_flags tay ;lo word is status ldx #$0000 ;hi word is zero lda #dMsetStatus jsr SendMsg bcc Done pea $000c ;sbOperationFailed ldx #$3803 ;_SysBeep2 jsl $e10000 bra Done ; if escape was hit, just exit escape_hit ANOP Done ANOP plb rtl END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ErrorMain START ; ; Calling conventions: ; JMP from Main with reason for failure in Acc ; ; Displays a screen which tells the user why he/she/it can't use the CDA at ; this time. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; using Globals sta fail_cause lda #$0001 jsr InitScreen ; ; Just draw the message from here ; phb pea $e0e0 ;write to text page in bank $e0 plb plb ldx #11*2 lda >texttab,x clc adc #3 ;start at column 4 sta fail_cause cmp #failP8 bne fail2 fail1 anop lda #fail_p8 bra fail_comm fail2 anop cmp #failInactive bne fail3 lda #fail_hp bra fail_comm fail3 anop lda #fail_busy fail_comm anop sta $e0c010 lp lda >$e0c000 bpl lp sta >$e0c010 rep #$20 LONGA ON and #$007f Done ANOP rts Fail ANOP lda #$0020 ;call it a space bar rts event_rec anop what ds 2 message ds 4 when ds 4 where ds 4 modifiers ds 2 END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; InitScreen START ; ; Calling conventions: ; JSR with 0 or 1 in acc (indicating normal or error start) ; ; Sets 40 columns and mousetext, then draws the title, border, and key ; instructions. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; using Globals sta err_flag phb pea $e0e0 ;write to text page in bank $e0 plb plb sep #$20 LONGA OFF sta |CLR80VID ;set 40 columns sta |SETALTCHR ;we want MouseText rep #$20 LONGA ON home ANOP ldx #23*2 loop anop lda >texttab,x sta texttab ;addr of line 0 ($400, duh) sta ptr ldx #2*2 lda >texttab,x sta ptr2 ldy #37 ;two at a time, starting from 37/38 tloop1 anop lda #$dfdf ;normal '_' sta (ptr),y lda #$4c4c ;flashing 'L' sta (ptr2),y dey dey bpl tloop1 ;should end at -1 ldx #1*2 lda >texttab,x sta ptr lda #$a05a ;'Z ' (right-bar, space) sta (ptr) ; lda #$a041 ;'A ' (apple symbol, space) ; ldy #$0002 ; sta (ptr),y sep #$20 LONGA OFF ldy #$0002 ldx #$0000 tloop2 anop lda >title_str,x beq tloop2_done sta (ptr),y inx iny bra tloop2 tloop2_done anop lda #$a0 sta (ptr),y iny lda #$20 tloop3 anop cpy #39 bge tloop3_done sta (ptr),y iny bra tloop3 tloop3_done anop lda #$5f ;left-bar sta (ptr),y rep #$20 LONGA ON box ANOP ldx #2*2 edge anop lda >texttab,x sta texttab,x sta ptr ldy #37 bloop anop lda #$4c4c ;flashing 'L' - upper line sta (ptr),y dey dey bpl bloop ;should end at -1 text ANOP ldx #22*2 lda >texttab,x sta ptr ldy #$0002 ldx #$0000 lda >err_flag beq noerr ldx #finstr_str-instr_str noerr anop sep #$20 LONGA OFF instr_loop anop lda >instr_str,x beq instr_done sta (ptr),y iny inx bra instr_loop instr_done anop rep #$20 LONGA ON Done ANOP plb rts err_flag ds 2 msg_tab anop MSB ON title_str dc C'HardPressed Control',H'00' instr_str dc C'Select: ',H'48a055a04aa04b' dc C' Cancel:Esc Save: ',H'4d00' finstr_str dc C' Exit: ',H'4d00' MSB OFF END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DrawScreen START ; ; Calling conventions: ; JSR ; ; Draws the menu items (selected one in inverse), the appropriate selection, ; and a check mark for defaults. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; using Globals ; ; Initialize counters ; lda #4 sta cur_line lda #0 sta cur_item lda #$00e0 sta $60, then it's inverse bge islorn ; lower case or normal text cmp #$40 ;if it's < $40, it's inverse blt islorn ; punctuation (e.g. ':') sec sbc csub islorn anop sta [