home *** CD-ROM | disk | FTP | other *** search
- RunDA
- PRG formatted GEOS file V1.0
- LA-50
- ICON EDITOR
- BLASTER'S CONVERTER V2.5
- Write Image V2.1
- geoWrite V2.1
- This source file was written by
- Joseph Buckley.
- Portions of this file were written
- by Eric E. Del Sesto and Tony Requist and
- available in the GEOPROGRAMMER users' manual.
- You are free to use this code in
- your own programs and to modify it to suit your
- programming needs.
- For more information contact:
- Joseph Buckley
- 464 Beale St.
- W. Quincy, MA 02169-1307
- Red Storm via Quantum Link
- 71570,2600 via CompuServe
- (GEOS Section Leader, CBMPRG forum)
- ; These routines should be used by
- ; programmers who wish to include access to
- ; GEOS desk accessories from within their
- ; custom applications.
- ; Also included here are routines to
- ; determine which graphic
- (40/80 column)
- ; GEOS is operating under.
- .if Pass1
- .noeqin
- .noglbl
- .include geosSym
- .include geosMac
- .glbl
- .eqin
- .endif
- NumDAs =8
- NumDfltEntries =2
- DATxtInSprite =TRUE
- ; Conditional assembly flag to determine
- ; placement of text buffering for the file
- ; names of usable desk accessories.
- .if DATxtInSprite=TRUE
- ; If sprites 2, 3, and 4 are not needed by
- ; your application, you may use that RAM as
- ; buffering for the DA filenames.
- DA0Text ==spr2pic
- DA1Text ==DA0Text+17
- DA2Text ==DA1Text+17
- DA3Text ==DA2Text+17
- DA4Text ==DA3Text+17
- DA5Text ==DA4Text+17
- DA6Text ==DA5Text+17
- DA7Text ==DA6Text+17
- .endif
- ; InitDA was written by Tony Requist and
- ; Eric Del Sesto and modified by Joe B
- ; InitDA was written by Tony Requist and
- ; Eric Del Sesto and modified by Joe Buckley.
- ; To use, simply call InitDA from you
- ; application's main initialization routine
- InitDA:
- MoveB curDrive,BootDrive ; store drive that DAs are on
- LoadW r6,DA0Text ; pointer to DA filename buffer
- LoadB r7L,DESK_ACC ; GEOS file type to search for
- LoadB r7H,NumDAs ; number of files to locate
- ClrW r10 ; no 'Permanent Name String'
- jsr FindFTypes ; get DA file names
- lda #NumDAs ; total searched for
- sub r7H ; minus number NOT found
- beq 1$ ; if zero, then no DAs found
- add #NumDfltEntries ; number of default entries
- ; under 'geos' main menu entry
- ; I use 'File' instead of 'geos'
- pha ; store it
- ora #VERTICAL ; submenu is vertically aligned
- sta FileMenu+$06 ; modify menu table
- ; The menu table in the deskTop would be the
- ; 'geos' menu with its Info and printer/input
- ; driver options that are always present.
- ; The 'FileMenu' label should be changed to
- ; reflect the submenu table in which the DAs are
- ; to appear.
- pla ; recall total # menu entries
- sta r0 ; store in work space
- asl a ; muliply by 2
- asl a ; by 4
- asl a ; by 8
- asl a ; by 16
- sub r0 ; subtract # entries (total=#*15)
- sub r0 ; subtract # entries (total=#*14)
- ; Now we have calculated the number of
- ; scanlines our submenu is in height.
- add #$0f ; add offset for top of submenu
- sta FileMenu+1 ; place bottom menu scanline in table
- ; See above for details on use of the label
- ; 'FileMenu'.
- 1$ rts
- ; RunDA was written by Tony Requist and
- ; Eric Del Sesto and modified by Joe Buckley.
- RunDA:
- sta MenuTemp ; upon entry, A contains item #
- jsr GotoFirstMenu ; recover to main menu
- jsr ImprintScreen ; I save
- ; RunDA was written by Tony Requist and
- ; Eric Del Sesto and modified by Joe Buckley.
- RunDA:
- sta MenuTemp ; upon entry, A contains item #
- jsr GotoFirstMenu ; recover to main menu
- jsr ImprintScreen ; I save the screen to background
- ; All VLIR files accessed by the main
- ; application must be closed now.
- MoveB curDrive,DeviceTemp ; save current device #
- lda BootDrive ; go to boot drive
- jsr GotoDrive
- ; GotoDrive is found in my 'Stage' file.
- ; At its simplest, GotoDrive is a
- ; lda #XX/jsr SetDevice/jsr OpenDisk fragment.
- RunDA1:
- ClrB r6H
- lda MenuTemp ; recover menu selection #
- sta r6 ; store in work space
- asl a ; multiply by 2
- asl a ; by 4
- asl a ; by 8
- asl a ; by 16
- add r6 ; add it again (total=#*17)
- add #<(DA0Text-(NumDfltEntries*17))
- sta r6L
- sta DANameAddress
- lda #$00
- adc #>(DA0Text-(NumDfltEntries*17))
- sta r6H
- sta DANameAddress+1
- ; This fragment calculates the offset to the
- ; DA file name string by creating a text
- ; pointer taking into account the nonexistent
- ; file names for the non-DA menu choices.
- ; Any custom application code may be placed
- ; here to run before DA execution.
- jsr i_MoveData ; buffer sprite definitions
- .word spr0pic
- .word SpriteBuffer
- .word 8*64
- ldx CPU_DATA
- LoadB CPU_DATA,IO_IN
- PushB moby2 ; preserve moby2 value
- ClrB moby2 ; default it to unexspanded
- sta r0 ; zero GetFile flags
- stx CPU_DATA ; recover GEOS memory map
- LoadB r10,$c0 ; I flag DAs to preserve screens
- jsr GetFile ; load and run the DA
- stx r10 ; preserve error status
- ldx CPU_DATA
- LoadB CPU_DATA,IO_IN
- PopB moby2 ; recover moby2
- stx CPU_DATA
- jsr i_MoveData ; recover sprite definitions
- .word SpriteBuffer
- .word spr0pic
- .word 8*64
- jsr WhichMode ; check g
- jsr WhichMode ; check graphic mode
- bra 1$
- jsr i_RecoverRectangle ; recover 40 column screen
- .byte 0,199
- .word 0,319
- bra 2$
- 1$ jsr i_RecoverRectangle ; recover 80 column screen
- .byte 0,199
- .word 0,639
- 2$ ldx r10 ; check DA error staus
- beq 4$
- cpx #$05 ; check if 'File Not Found'
- beq 3$
- jsr GeneralError ; otherwise use general routine
- bra 4$
- 3$ jsr SetDrString ; determine booting drive
- LoadW r0,MissingDA ; generate error message
- jsr DoDlgBox
- lda sysDBData
- cmp #CANCEL
- beq 4$
- jsr OpenDisk ; try it again
- jmp RunDA1
- ; All VLIR files accessed by the main
- ; application may be reopened now.
- lda DeviceTemp ; abort and return to working drive
- jmp GotoDrive
- ty options
- MissingDA:
- .byte DEF_DB_POS | $01
- .byte DB_USR_ROUT
- .word SetWindow
- .byte DBTXTSTR,$10,$10
- .word DA_Name1
- .byte DBVARSTR,$10,$1f,r5
- .byte DBVARSTR,$10,$2e,r6
- .byte OK,$02,$40
- .byte CANCEL,$10,$40,0
- DA_Name1:
- .byte BOLDON,"Please place disk with",0
- DA_A_Drive:
- .byte BOLDON,"into DRIVE A.",PLAINTEXT,0
- DA_B_Drive:
- .byte BOLDON,"into DRIVE B.",PLAINTEXT,0
- SetDrString:
- MoveW DANameAddress,r5 ; pointer to the DA file name
- LoadW r6,DA_A_Drive ; pointer to boot drive string
- CmpBI curDrive,$08
- beq 1$
- LoadW r6,DA_B_Drive
- ; pointer to boot drive string
- 1$ rts
- SetWindow:
- ; Used in Dialog Boxes to reset the text
- ; printing margins and simplify long stri
- SetWindow:
- ; Used in Dialog Boxes to reset the text
- ; printing margins and simplify long string
- ; printing.
- LoadB windowTop,35
- LoadB windowBottom,125
- LoadW leftMargin,70
- LoadW rightMargin,250
- jsr WhichMode
- bpl 1$
- ; Here we are in 80 column mode, so modify
- ; the
- left
- and right margins.
- asl leftMargin
- rol leftMargin+$01 ; leftMargin*2
- asl rightMargin
- roll rightMargin+$01 ; rightMargin*2
- 1$ rts
- WhichMode:
- ; Returns in STATUS reg N bit current
- ; screen width (0/1; 40/80 columns)
- lda version
- cmp #$13
- bpl 1$
- lda #$00 ; reset N bit in STATUS reg
- ; (may not be needed)
- 1$ lda c128Flag ; $C013 ($00/$80;GEOS 64/GEOS 128)
- bpl 2$
- lda $3f ; BSW: graphMode ($00/$80; 40/80 columns)
- 2$ rts ; graphMode properly sets N
- ImprintScreen:
- ; Simple call to imprint the entire screen to
- ; background in an arbitrary graphic mode
- jsr WhichMode
- bmi 1$
- jsr i_ImprintRectangle ; imprint 40 column screen
- .byte 0,199
- .word 0,319
- 1$ jsr i_ImprintRectangle ; imprint 80 column screen
- .byte 0,199
- .word 0,639
- GeneralError:
- ; Generic disk error handler.
- ; Pass error number in X.
- LoadW r0,GenErrDB ; DB definition address
- GeneralError:
- ; Generic disk error handler.
- ; Pass error number in X.
- LoadW r0,GenErrDB ; DB definition address
- stx ErrorNumber ; check error type
- cpx #$03 ; is it a 'Not Enough Room' error?
- bne 1$
- LoadW r0,FulDiskDB ; yes, use special case DB
- 1$ jmp DoDlgBox
- GenErrDB:
- .byte DEF_DB_POS | $01
- .byte DB_USR_ROUT
- .word SetWindow
- .byte DBTXTSTRING,$01,$01
- .word ErrorText
- .byte DB_USR_ROUT
- .word PrintError
- .byte OK,$11,$40,0
- ErrorText:
- .byte CR,CR,BOLDON," General disk error."
- .byte CR,CR," Error: ",0
- PrintError:
- lda #'$'
- jsr PutChar ; print '$'
- lda ErrorNumber ; generate two ASCII chars
- lsr a ; shift high nibble down
- lsr a
- lsr a
- lsr a
- add #$30 ; make ASCII
- cmp #$3a ; is it >9?
- bmi 1$
- adc #$06 ; yes, make it a letter
- 1$ jsr PutChar ; print HEX high nibble
- lda ErrorNumber
- and #$0f ; mask for low nibble
- add #$30 ; make ASCII
- cmp #$3a ; is it >9?
- bmi 2$
- adc #$06 ; yes, make it a letter
- 2$ jmp PutChar ; print HEX low nibble/return
- FulDiskDB:
- .byte DEF_DB_POS | $01
- .byte DB_USR_ROUT
- .word SetWindow
- .byte DBTXTSTRING,$01,01
- .word FullText
- .byte OK,$11,$40,0
- FullText:
- .byte CR,CR,BOLDON,"There is insufficient space on"
- .byte CR,CR,"this disk for this operation.",PLAINTEXT,0
- ProgEnd:
- ; I use ProgEnd in my file header definitions
- ; to mark the highest used address.
- ; I always place the 'RunDA' module at the
- ; end of my .lnk file to take advantage of
- ; ProgEnd.
- .ramsect
- ErrorNumber:
- .block 1
- BootDrive: .block 1
- DeviceTemp: .block 1
- MenuTemp: .block 1
- DANameAddress:
- .block 2
- SpriteBuffer:
- .block 8*65
- .if !DATxtInSprite
- ; If sprites 2, 3, and 4 ARE needed by
- ; your application, you must provide alternate
- ; buffering for the DA filenames.
- DA0Text: .block 17
- DA1Text: .block 17
- DA2Text: .block 17
- DA3Text: .block 17
- DA4Text: .block 17
- DA5Text: .block 17
- DA6Text: .block 17
- DA7Text: .block 17
- .endif
- ; End of conditional.
- ; End of file.
-