home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 04 geoProgramming / RUNDA.BIN (.txt) < prev    next >
Encoding:
GEOS ConVerT  |  2019-04-13  |  10.5 KB  |  348 lines

  1. RunDA
  2. PRG formatted GEOS file V1.0
  3. LA-50
  4. ICON EDITOR
  5. BLASTER'S CONVERTER V2.5
  6. Write Image V2.1
  7. geoWrite    V2.1
  8.     This source file was written by
  9. Joseph Buckley.
  10.     Portions of this file were written
  11. by Eric E. Del Sesto and Tony Requist and
  12. available in the GEOPROGRAMMER users' manual.
  13.     You are free to use this code in
  14. your own programs and to modify it to suit your
  15. programming needs.
  16.     For more information contact:
  17.     Joseph Buckley
  18.     464 Beale St.
  19.     W. Quincy, MA 02169-1307
  20.     Red Storm via Quantum Link
  21.     71570,2600 via CompuServe
  22.     (GEOS Section Leader, CBMPRG forum)
  23. ;   These routines should be used by
  24. ; programmers who wish to include access to
  25. ; GEOS desk accessories from within their
  26. ; custom applications.
  27. ;   Also included here are routines to
  28. ; determine which graphic 
  29.  (40/80 column)
  30. ; GEOS is operating under.
  31. .if    Pass1
  32. .noeqin
  33. .noglbl
  34. .include    geosSym
  35. .include    geosMac
  36. .glbl
  37. .eqin
  38. .endif
  39. NumDAs        =8
  40. NumDfltEntries    =2
  41. DATxtInSprite    =TRUE
  42. ;   Conditional assembly flag to determine
  43. ; placement of text buffering for the file
  44. ; names of usable desk accessories.
  45. .if    DATxtInSprite=TRUE
  46. ;   If sprites 2, 3, and 4 are not needed by
  47. ; your application, you may use that RAM as
  48. ; buffering for the DA filenames.
  49. DA0Text    ==spr2pic
  50. DA1Text    ==DA0Text+17
  51. DA2Text    ==DA1Text+17
  52. DA3Text    ==DA2Text+17
  53. DA4Text    ==DA3Text+17
  54. DA5Text    ==DA4Text+17
  55. DA6Text    ==DA5Text+17
  56. DA7Text    ==DA6Text+17
  57. .endif
  58. ;   InitDA was written by Tony Requist and 
  59. ; Eric Del Sesto and modified by Joe B
  60. ;   InitDA was written by Tony Requist and 
  61. ; Eric Del Sesto and modified by Joe Buckley.
  62. ;   To use, simply call InitDA from you
  63. ; application's main initialization routine
  64. InitDA:
  65.     MoveB    curDrive,BootDrive    ; store drive that DAs are on
  66.     LoadW    r6,DA0Text    ; pointer to DA filename buffer
  67.     LoadB    r7L,DESK_ACC    ; GEOS file type to search for
  68.     LoadB    r7H,NumDAs    ; number of files to locate
  69.     ClrW    r10    ; no 'Permanent Name String'
  70.     jsr    FindFTypes    ; get DA file names
  71.     lda    #NumDAs    ; total searched for
  72.     sub    r7H    ; minus number NOT found
  73.     beq    1$    ; if zero, then no DAs found
  74.     add    #NumDfltEntries    ; number of default entries
  75. ;              under 'geos' main menu entry
  76. ;              I use 'File' instead of 'geos'
  77.     pha        ; store it
  78.     ora    #VERTICAL    ; submenu is vertically aligned
  79.     sta    FileMenu+$06    ; modify menu table
  80. ;   The menu table in the deskTop would be the
  81. ; 'geos' menu with its Info and printer/input
  82. ; driver options that are always present.
  83. ;   The 'FileMenu' label should be changed to
  84. ; reflect the submenu table in which the DAs are
  85. ; to appear.
  86.     pla        ; recall total # menu entries
  87.     sta    r0    ; store in work space
  88.     asl    a    ; muliply by 2
  89.     asl    a    ; by 4
  90.     asl    a    ; by 8
  91.     asl    a    ; by 16
  92.     sub    r0    ; subtract # entries (total=#*15)
  93.     sub    r0    ; subtract # entries (total=#*14)
  94. ;   Now we have calculated the number of
  95. ; scanlines our submenu is in height.
  96.     add    #$0f    ; add offset for top of submenu
  97.     sta    FileMenu+1    ; place bottom menu scanline in table 
  98. ;   See above for details on use of the label
  99. ; 'FileMenu'.
  100. 1$    rts
  101. ;   RunDA was written by Tony Requist and 
  102. ; Eric Del Sesto and modified by Joe Buckley.
  103. RunDA:
  104.     sta    MenuTemp    ; upon entry, A contains item #
  105.     jsr    GotoFirstMenu    ; recover to main menu
  106.     jsr    ImprintScreen    ; I save 
  107. ;   RunDA was written by Tony Requist and 
  108. ; Eric Del Sesto and modified by Joe Buckley.
  109. RunDA:
  110.     sta    MenuTemp    ; upon entry, A contains item #
  111.     jsr    GotoFirstMenu    ; recover to main menu
  112.     jsr    ImprintScreen    ; I save the screen to background
  113. ;   All VLIR files accessed by the main
  114. ; application must be closed now.
  115.     MoveB    curDrive,DeviceTemp    ; save current device #
  116.     lda    BootDrive    ; go to boot drive
  117.     jsr    GotoDrive
  118. ;   GotoDrive is found in my 'Stage' file.
  119. ;   At its simplest, GotoDrive is a
  120. ; lda #XX/jsr SetDevice/jsr OpenDisk fragment.
  121. RunDA1:
  122.     ClrB    r6H
  123.     lda    MenuTemp    ; recover menu selection #
  124.     sta    r6    ; store in work space
  125.     asl    a    ; multiply by 2
  126.     asl    a    ; by 4
  127.     asl    a    ; by 8
  128.     asl    a    ; by 16
  129.     add    r6    ; add it again (total=#*17)
  130.     add    #<(DA0Text-(NumDfltEntries*17))
  131.     sta    r6L
  132.     sta    DANameAddress
  133.     lda    #$00
  134.     adc    #>(DA0Text-(NumDfltEntries*17))
  135.     sta    r6H
  136.     sta    DANameAddress+1
  137. ;   This fragment calculates the offset to the
  138. ; DA file name string by creating a text
  139. ; pointer taking into account the nonexistent
  140. ; file names for the non-DA menu choices.
  141. ;   Any custom application code may be placed
  142. ; here to run before DA execution.
  143.     jsr    i_MoveData    ; buffer sprite definitions
  144. .word    spr0pic
  145. .word    SpriteBuffer
  146. .word    8*64
  147.     ldx    CPU_DATA
  148.     LoadB    CPU_DATA,IO_IN
  149.     PushB    moby2    ; preserve moby2 value
  150.     ClrB    moby2    ; default it to unexspanded
  151.     sta    r0    ; zero GetFile flags
  152.     stx    CPU_DATA    ; recover GEOS memory map
  153.     LoadB    r10,$c0    ; I flag DAs to preserve screens
  154.     jsr    GetFile    ; load and run the DA
  155.     stx    r10    ; preserve error status
  156.     ldx    CPU_DATA
  157.     LoadB    CPU_DATA,IO_IN
  158.     PopB    moby2    ; recover moby2
  159.     stx    CPU_DATA
  160.     jsr    i_MoveData    ; recover sprite definitions
  161. .word    SpriteBuffer
  162. .word    spr0pic
  163. .word    8*64
  164.     jsr    WhichMode    ; check g
  165.     jsr    WhichMode    ; check graphic mode
  166.     bra    1$
  167.     jsr    i_RecoverRectangle    ; recover 40 column screen
  168. .byte    0,199
  169. .word    0,319
  170.     bra    2$
  171. 1$    jsr    i_RecoverRectangle    ; recover 80 column screen
  172. .byte    0,199
  173. .word    0,639
  174. 2$    ldx    r10    ; check DA error staus
  175.     beq    4$
  176.     cpx    #$05    ; check if 'File Not Found'
  177.     beq    3$
  178.     jsr    GeneralError    ; otherwise use general routine
  179.     bra    4$
  180. 3$    jsr    SetDrString    ; determine booting drive
  181.     LoadW    r0,MissingDA    ; generate error message
  182.     jsr    DoDlgBox
  183.     lda    sysDBData
  184.     cmp    #CANCEL
  185.     beq    4$
  186.     jsr    OpenDisk    ; try it again
  187.     jmp    RunDA1
  188. ;   All VLIR files accessed by the main
  189. ; application may be reopened now.
  190.     lda    DeviceTemp    ; abort and return to working drive
  191.     jmp    GotoDrive
  192. ty options
  193. MissingDA:
  194. .byte    DEF_DB_POS | $01
  195. .byte    DB_USR_ROUT
  196. .word    SetWindow
  197. .byte    DBTXTSTR,$10,$10
  198. .word    DA_Name1
  199. .byte    DBVARSTR,$10,$1f,r5
  200. .byte    DBVARSTR,$10,$2e,r6
  201. .byte    OK,$02,$40
  202. .byte    CANCEL,$10,$40,0
  203. DA_Name1:
  204. .byte    BOLDON,"Please place disk with",0
  205. DA_A_Drive:
  206. .byte    BOLDON,"into DRIVE A.",PLAINTEXT,0
  207. DA_B_Drive:
  208. .byte    BOLDON,"into DRIVE B.",PLAINTEXT,0
  209. SetDrString:
  210.     MoveW    DANameAddress,r5    ; pointer to the DA file name
  211.     LoadW    r6,DA_A_Drive    ; pointer to boot drive string
  212.     CmpBI    curDrive,$08
  213.     beq    1$
  214.     LoadW    r6,DA_B_Drive
  215.     ; pointer to boot drive string
  216. 1$    rts
  217. SetWindow:
  218. ;   Used in Dialog Boxes to reset the text
  219. ; printing margins and simplify long stri
  220. SetWindow:
  221. ;   Used in Dialog Boxes to reset the text
  222. ; printing margins and simplify long string
  223. ; printing.
  224.     LoadB    windowTop,35
  225.     LoadB    windowBottom,125
  226.     LoadW    leftMargin,70
  227.     LoadW    rightMargin,250
  228.     jsr    WhichMode
  229.     bpl    1$
  230. ;   Here we are in 80 column mode, so modify
  231. ; the 
  232. left 
  233. and right margins.
  234.     asl    leftMargin
  235.     rol    leftMargin+$01    ; leftMargin*2
  236.     asl    rightMargin
  237.     roll    rightMargin+$01    ; rightMargin*2
  238. 1$    rts
  239. WhichMode:
  240. ;  Returns in STATUS reg N bit current
  241. ; screen width (0/1; 40/80 columns)
  242.     lda    version
  243.     cmp    #$13
  244.     bpl    1$
  245.     lda    #$00    ; reset N bit in STATUS reg
  246. ;              (may not be needed)
  247. 1$    lda    c128Flag    ; $C013 ($00/$80;GEOS 64/GEOS 128)
  248.     bpl    2$
  249.     lda    $3f    ; BSW: graphMode ($00/$80; 40/80 columns)
  250. 2$    rts        ; graphMode properly sets N
  251. ImprintScreen:
  252. ;   Simple call to imprint the entire screen to
  253. ; background in an arbitrary graphic mode
  254.     jsr    WhichMode
  255.     bmi    1$
  256.     jsr    i_ImprintRectangle    ; imprint 40 column screen
  257. .byte    0,199
  258. .word    0,319
  259. 1$    jsr    i_ImprintRectangle    ; imprint 80 column screen
  260. .byte    0,199
  261. .word    0,639
  262. GeneralError:
  263. ;   Generic disk error handler.
  264. ;   Pass error number in X.
  265.     LoadW    r0,GenErrDB    ; DB definition address
  266. GeneralError:
  267. ;   Generic disk error handler.
  268. ;   Pass error number in X.
  269.     LoadW    r0,GenErrDB    ; DB definition address
  270.     stx    ErrorNumber    ; check error type
  271.     cpx    #$03    ; is it a 'Not Enough Room' error?
  272.     bne    1$
  273.     LoadW    r0,FulDiskDB    ; yes, use special case DB
  274. 1$    jmp    DoDlgBox
  275. GenErrDB:
  276. .byte    DEF_DB_POS | $01
  277. .byte    DB_USR_ROUT
  278. .word    SetWindow
  279. .byte    DBTXTSTRING,$01,$01
  280. .word    ErrorText
  281. .byte    DB_USR_ROUT
  282. .word    PrintError
  283. .byte    OK,$11,$40,0
  284. ErrorText:
  285. .byte    CR,CR,BOLDON,"  General disk error."
  286. .byte    CR,CR,"  Error: ",0
  287. PrintError:
  288.     lda    #'$'
  289.     jsr    PutChar    ; print '$'
  290.     lda    ErrorNumber    ; generate two ASCII chars
  291.     lsr    a    ; shift high nibble down
  292.     lsr    a
  293.     lsr    a
  294.     lsr    a
  295.     add    #$30    ; make ASCII
  296.     cmp    #$3a    ; is it >9?
  297.     bmi    1$
  298.     adc    #$06    ; yes, make it a letter
  299. 1$    jsr    PutChar    ; print HEX high nibble
  300.     lda    ErrorNumber
  301.     and    #$0f    ; mask for low nibble
  302.     add    #$30    ; make ASCII
  303.     cmp    #$3a    ; is it >9?
  304.     bmi    2$
  305.     adc    #$06    ; yes, make it a letter
  306. 2$    jmp    PutChar    ; print HEX low nibble/return
  307. FulDiskDB:
  308. .byte    DEF_DB_POS | $01
  309. .byte    DB_USR_ROUT
  310. .word    SetWindow
  311. .byte    DBTXTSTRING,$01,01
  312. .word    FullText
  313. .byte    OK,$11,$40,0
  314. FullText:
  315. .byte    CR,CR,BOLDON,"There is insufficient space on"
  316. .byte    CR,CR,"this disk for this operation.",PLAINTEXT,0
  317. ProgEnd:
  318. ;   I use ProgEnd in my file header definitions
  319. ; to mark the highest used address.
  320. ;   I always place the 'RunDA' module at the
  321. ; end of my .lnk file to take advantage of
  322. ; ProgEnd.
  323. .ramsect
  324. ErrorNumber:
  325.     .block    1
  326. BootDrive:    .block    1
  327. DeviceTemp:    .block    1
  328. MenuTemp:    .block    1
  329. DANameAddress:
  330.     .block    2
  331. SpriteBuffer:
  332.     .block    8*65
  333. .if    !DATxtInSprite
  334. ;   If sprites 2, 3, and 4 ARE needed by
  335. ; your application, you must provide alternate
  336. ; buffering for the DA filenames.
  337. DA0Text:    .block    17
  338. DA1Text:    .block    17
  339. DA2Text:    .block    17
  340. DA3Text:    .block    17
  341. DA4Text:    .block    17
  342. DA5Text:    .block    17
  343. DA6Text:    .block    17
  344. DA7Text:    .block    17
  345. .endif
  346. ;   End of conditional.
  347. ;   End of file.
  348.