home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_27_1988_Transactor_Publishing.d64 / loadermaker.sda / LOADERMAKER.SRC (.txt) next >
Commodore BASIC  |  2023-02-26  |  10KB  |  357 lines

  1. 100 sys 49152
  2. 110 ;"[204][207][193][196][197][210][205][193][203][197][210].[211][210][195] -- program to create a ml loader program on [199][197][207][211] disk"
  3. 120 ;"[206]ick [214]rtis    -- [202]anuary 1988"
  4. 130 ;
  5. 140 ; work registers as in geos programmers reference
  6. 150 r0  = $02
  7. 160 r1  = $04
  8. 170 r4  = $0a
  9. 180 r6  = $0e
  10. 190 r9  = $14
  11. 200 r10 = $16
  12. 210 a0  = $fb
  13. 220 a1  = $fd
  14. 230 ;
  15. 240 .tasc       ;assemble true ascii literals
  16. 250 ;
  17. 260 * = $5000-252 ;allow for geos info sector ($4f04)
  18. 270 .byte $bf
  19. 280 .byte $00,$00,$00,$7f,$ff,$fe,$40,$1f
  20. 290 .byte $fe,$5f,$80,$7e,$6f,$ff,$7e,$77
  21. 300 .byte $fe,$7e,$77,$05,$fe,$76,$03,$fe
  22. 310 .byte $74,$ff,$fe,$75,$80,$7e,$75,$ff
  23. 320 .byte $fe,$75,$80,$7e,$74,$ff,$e6,$76
  24. 330 .byte $03,$1a,$77,$07,$fc,$77,$ff,$fc
  25. 340 .byte $77,$a3,$fc,$77,$b8,$fa,$70,$3f
  26. 350 .byte $06,$7f,$ff,$fe,$00,$00,$00
  27. 360 .byte $83,$06,$00
  28. 370 .word begin       ;starting load address
  29. 380 .word ldrend      ;ending load address
  30. 390 .word begin       ;starting execution address
  31. 400 .asc "[204]oader[205]aker[214]1.0"
  32. 410 .byte 0,0,0,0,0
  33. 420 .asc "[206]ick [214]rtis -- 1988"
  34. 430 .byte 0,0
  35. 440 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  36. 450 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  37. 460 .asc "[195]reate a loader program on [199][197][207][211] disk to load [205][204] files "
  38. 470 .asc "created by a non-[199][197][207][211] assembler"
  39. 480 .byte 0
  40. 490 ;
  41. 500 * = $5000
  42. 510 moveto =$7f40 ;where boot code will execute from
  43. 520 begin lda #<title
  44. 530 sta r0
  45. 540 lda #>title
  46. 550 sta r0+1
  47. 560 jsr grphic  ;do the opening credits
  48. 570 ;
  49. 580 doagain = * ;restart point
  50. 590 lda #<mainmenu
  51. 600 sta r0
  52. 610 lda #>mainmenu
  53. 620 sta r0+1
  54. 630 lda #1      ;cursor on option #2
  55. 640 jmp menu
  56. 650 ;
  57. 660 doquit = *  ;handle the quit option
  58. 670 jmp restrt  ;back to desktop
  59. 680 ;
  60. 690 dohelp  = *  ;handle the help option
  61. 700 ldx #<helpw
  62. 710 ldy #>helpw
  63. 720 jsr xywindow
  64. 730 jmp drwmnu  ;redraw the menu
  65. 740 ;
  66. 750 domake  = *  ;handle the make option
  67. 760 jsr cmenus  ;close all menus
  68. 770 lda #<pgmname
  69. 780 sta r10
  70. 790 lda #>pgmname
  71. 800 sta r10+1
  72. 810 ldx #<loadnw
  73. 820 ldy #>loadnw
  74. 830 jsr xywindow
  75. 840 lda r0      ;check for cancel
  76. 850 cmp #2
  77. 860 beq doagain ;..yes-restart
  78. 870 ;
  79. 880 getln   = * ;get name for loader file
  80. 890 lda #<ldrname
  81. 900 sta r10
  82. 910 lda #>ldrname
  83. 920 sta r10+1
  84. 930 ldx #<ldrnw
  85. 940 ldy #>ldrnw
  86. 950 jsr xywindow
  87. 960 lda r0      ;check for cancel
  88. 970 cmp #2
  89. 980 beq doagain ;..yes-restart
  90. 990 lda #<ldrname
  91. 1000 sta r6
  92. 1010 lda #>ldrname
  93. 1020 sta r6+1
  94. 1030 lda drvsrch ;check only 'active' drive for new name
  95. 1040 pha         ;save current setting
  96. 1050 lda #0
  97. 1060 sta drvsrch
  98. 1070 jsr lookup  ;try to find loader name
  99. 1080 pla
  100. 1090 sta drvsrch ;reset drive search flag
  101. 1100 txa         ;check return from lookup
  102. 1110 bne fileok  ;..not found--(NULL)od
  103. 1120 ldx #<erafnw
  104. 1130 ldy #>erafnw
  105. 1140 jsr xywindow
  106. 1150 lda r0      ;see if ok to overlay
  107. 1160 cmp #4
  108. 1170 beq getln   ;..no-get a new loader name
  109. 1180 lda #<ldrname
  110. 1190 sta r0
  111. 1200 lda #>ldrname
  112. 1210 sta r0+1
  113. 1220 jsr delete  ;erase current version
  114. 1230 ;
  115. 1240 fileok = *   ;file setup is ok
  116. 1250 ldx #0      ;move loader code to where it will run from
  117. 1260 ldrmove = *
  118. 1270 lda ldrcode,x
  119. 1280 sta moveto,x
  120. 1290 inx
  121. 1300 cpx #<ldrend-ldrcode
  122. 1310 bne ldrmove
  123. 1320 clc          ;calc end address of save
  124. 1330 lda #<ldrend-ldrcode
  125. 1340 adc #<moveto
  126. 1350 sta savend
  127. 1360 lda #>ldrend-ldrcode
  128. 1370 adc #>moveto
  129. 1380 sta savend+1
  130. 1390 lda #0       ;try starting on 1st page of directory
  131. 1400 sta r10
  132. 1410 lda #<ldrinfo
  133. 1420 sta r9
  134. 1430 lda #>ldrinfo
  135. 1440 sta r9+1
  136. 1450 jsr save     ;save new file
  137. 1460 jmp doagain  ;redo menu/options
  138. 1470 ;
  139. 1480 xywindow = *  ;produce window pointed to by x/y regs
  140. 1490 stx r0
  141. 1500 sty r0+1
  142. 1510 jmp window   ;(NULL)t here via jsr/return directly
  143. 1520 ;
  144. 1530 mainmenu .byte 0 ;start @ top of screen
  145. 1540 .byte 14        ;to +14 down
  146. 1550 .word 0         ;left edge
  147. 1560 .word 92        ;right edge
  148. 1570 .byte 3         ;3 horizontal options
  149. 1580 .word done
  150. 1590 .byte $80       ;submenu option
  151. 1600 .word donemenu  ;submenu defination
  152. 1610 .word make
  153. 1620 .byte 0         ;flash & do option
  154. 1630 .word domake
  155. 1640 .word help
  156. 1650 .byte 0
  157. 1660 .word dohelp
  158. 1670 done .asc "[196]one" : .byte 0
  159. 1680 make .asc "[205]ake" : .byte 0
  160. 1690 help .asc "[200]elp" : .byte 0
  161. 1700 ;
  162. 1710 donemenu .byte 14  ;start below main
  163. 1720 .byte 14+14       ;still 14 pixels high
  164. 1730 .word 0           ;left edge
  165. 1740 .word 29          ;right edge
  166. 1750 .byte $80+1       ;one vertical entry
  167. 1760 .word quit
  168. 1770 .byte 0           ;flash & do
  169. 1780 .word doquit
  170. 1790 quit .asc "[209]uit" : .byte 0
  171. 1800 ;
  172. 1810 title .byte $05,28 ;fill pattern
  173. 1820 .byte $01,0,0,0   ;top/left corner
  174. 1830 .byte $03:.word 320:.byte 199 ;fill whole screen
  175. 1840 .byte $05,9       ;new fill pattern
  176. 1850 .byte $03:.word 320:.byte  20 ;fill top title line
  177. 1860 .byte $06:.word 8:.byte 190  ;output title
  178. 1870 .byte $18,$20,$1a   ; bold+outlined
  179. 1880 .asc "[204]oader[205]aker"
  180. 1890 .byte $1b,$18   ; just bold
  181. 1900 .asc " [214]1.0 [205]achine [204]anguage [204]oader [205]aker "
  182. 1910 .byte $16,8,0,142 ; new position for text
  183. 1920 .asc " [206]icholas [202]. [214]rtis "
  184. 1930 .byte $16,200,0,142
  185. 1940 .asc " [195]opyright 1988 "
  186. 1950 .byte $16,8,0,158
  187. 1960 .asc " 5863 [208]inetree [211].[197]. "
  188. 1970 .byte $16,8,0,174
  189. 1980 .asc " [203]entwood, [205][201] 49508 "
  190. 1990 .byte $1b,0       ;back to plaintext at end
  191. 2000 ;
  192. 2010 helpw .byte $01    ;non-standard sized window here
  193. 2020 .byte 22,178      ;top/bottom pixels
  194. 2030 .word 4           ;left edge
  195. 2040 .word 305         ;right edge
  196. 2050 .byte $0b,2,15
  197. 2060 .word helpmsg
  198. 2070 .byte $01,31,135,0 ;-cancel- box
  199. 2080 helpmsg .byte $18
  200. 2090 .asc "[212]his program is used to create a [199][197][207][211] program which"
  201. 2100 .byte $16,6,0,47  ;change here is window size adjusted
  202. 2110 .asc "can be run from the [196]esk[212]op.  [212]he [199][197][207][211] program will"
  203. 2120 .byte $16,6,0,57
  204. 2130 .asc "then load and run an assembler program created as a"
  205. 2140 .byte $16,6,0,67
  206. 2150 .asc "'normal' [195]ommodore program.  [212]his avoids having to"
  207. 2160 .byte $16,6,0,77
  208. 2170 .asc "run a seperate program to 'convert' your assembler"
  209. 2180 .byte $16,6,0,87
  210. 2190 .asc "program each time you reassemble it.  [193] 'normal'"
  211. 2200 .byte $16,6,0,97
  212. 2210 .asc "[195]ommodore program has the load address as the first"
  213. 2220 .byte $16,6,0,107
  214. 2230 .asc "two data bytes of the file, and starts execution at"
  215. 2240 .byte $16,6,0,117
  216. 2250 .asc "that address after being loaded."
  217. 2260 .byte $1b,0
  218. 2270 ;
  219. 2280 ldrnw .byte $81     ;standard size window
  220. 2290 .byte $0b,10,30
  221. 2300 .word lnmsg
  222. 2310 .byte $0b,10,40    ;two lines of text in this window
  223. 2320 .word lnmsg2
  224. 2330 .byte $0d,10,60    ;get input in window
  225. 2340 .byte <r10,16      ;r10 is buffer pointer/max 16 characters input
  226. 2350 .byte $02,17,78    ;-cancel- box
  227. 2360 .byte 0
  228. 2370 lnmsg .byte $18
  229. 2380 .asc "[197]nter name for [206][197][215] loader"
  230. 2390 .byte 0
  231. 2400 lnmsg2 .asc "program to be created."
  232. 2410 .byte $1b,0
  233. 2420 ;
  234. 2430 loadnw .byte $81    ;again a standard sized window
  235. 2440 .byte $0b,10,30
  236. 2450 .word plmsg
  237. 2460 .byte $0d,10,60
  238. 2470 .byte <r10,16
  239. 2480 .byte $02,17,78    ;cancel box
  240. 2490 .byte 0
  241. 2500 plmsg .byte $18
  242. 2510 .asc "[197]nter name of [208][210][207][199][210][193][205] to load."
  243. 2520 .byte $1b,0
  244. 2530 ;
  245. 2540 erafnw .byte $81
  246. 2550 .byte $0b,10,30
  247. 2560 .word errmsg
  248. 2570 .byte $0b,10,40
  249. 2580 .word errmsg2
  250. 2590 .byte $03,17,60    ;-yes- box
  251. 2600 .byte $04,17,78    ;-no-  box
  252. 2610 .byte 0
  253. 2620 errmsg .byte $18
  254. 2630 .asc "[212]hat file already exists."
  255. 2640 .byte 0
  256. 2650 errmsg2 .asc "[207][203] to overlay ?"
  257. 2660 .byte $1b,0
  258. 2670 ;
  259. 2680 ldrinfo .word ldrname
  260. 2690 .byte $03,$15,$bf
  261. 2700 .byte $ff,$ff,$ff,$80,$00,$01,$aa,$a0
  262. 2710 .byte $01,$a0,$55,$81,$90,$00,$01,$88
  263. 2720 .byte $01,$81,$80,$f8,$01,$89,$fc,$01
  264. 2730 .byte $83,$00,$01,$8a,$7f,$81,$82,$00
  265. 2740 .byte $01,$8a,$7f,$81,$83,$00,$09,$89
  266. 2750 .byte $fc,$a5,$80,$f8,$03,$88,$00,$01
  267. 2760 .byte $80,$54,$03,$88,$05,$05,$8d,$40
  268. 2770 .byte $a9,$80,$00,$01,$ff,$ff,$ff
  269. 2780 .byte $83,$06,$00
  270. 2790 .word moveto        ;begin address of save
  271. 2800 savend *=*+2        ;end address for save
  272. 2810 .word moveto+17     ;execution start address
  273. 2820 .asc "[204]oader[205]aker[214]1.0"
  274. 2830 .byte 0,0,0,0,0
  275. 2840 .asc "[206]ick [214]rtis -- 1988"
  276. 2850 .byte 0,0
  277. 2860 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  278. 2870 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  279. 2880 .asc "[204]oad and [210]un a [199][197][207][211] program created by a non-[199][197][207][211] assembler.  "
  280. 2890 .asc "[212]his program loads "
  281. 2900 ;
  282. 2910 ldrname .byte 0
  283. 2920 *=*+16         ;allow for full name + trailing null
  284. 2930 ;
  285. 2940 ldrcode = *     ;loader code starts here
  286. 2950 pgmname .byte 0
  287. 2960 *=*+16
  288. 2970 ;
  289. 2980 loadml lda #<moveto ;address of name of program to load
  290. 2990 sta r6
  291. 3000 lda #>moveto
  292. 3010 sta r6+1
  293. 3020 jsr lookup
  294. 3030 txa                  ;check return
  295. 3040 beq diskok           ;..found it ok
  296. 3050 jmp restrt           ;else abandon the load & (NULL) back to desktop
  297. 3060 ;
  298. 3070 diskok lda dentry+2   ;sector of file beginning
  299. 3080 sta r1+1
  300. 3090 lda dentry+1         ;track of file beginning
  301. 3100 sta r1
  302. 3110 lda #<buf0           ;set pointer to buffer for read
  303. 3120 sta r4
  304. 3130 lda #>buf0
  305. 3140 sta r4+1
  306. 3150 jsr read             ;read 1st buffer
  307. 3160 lda buf0+2           ;get program load adress
  308. 3170 sta a0
  309. 3180 sta a1               ;also store as starting address
  310. 3190 lda buf0+3
  311. 3200 sta a0+1
  312. 3210 sta a1+1
  313. 3220 ldx #3               ;skip t/s & address
  314. 3230 bne skipread         ;..unconditional-skip 1st read
  315. 3240 readpgm lda buf0      ;get track/sector of next block
  316. 3250 sta r1
  317. 3260 lda buf0+1
  318. 3270 sta r1+1
  319. 3280 jsr read
  320. 3290 ldx #1               ;skip t/s pointer for all other blocks
  321. 3300 skipread ldy #$ff     ;assume a full sector
  322. 3310 lda buf0             ;check next track pointer
  323. 3320 bne (NULL)odnxtt         ;..(NULL)od next track
  324. 3330 ldy buf0+1           ;else this is last sector/pick up # valid bytes
  325. 3340 (NULL)odnxtt sty r0      ;save # valid bytes (255 for full sector)
  326. 3350 ldy #0
  327. 3360 moveloop inx
  328. 3370 lda buf0,x           ;get input byte
  329. 3380 sta (a0),y           ;store it
  330. 3390 inc a0               ;bump pointer
  331. 3400 bne a0ok
  332. 3410 inc a0+1
  333. 3420 a0ok cpx r0          ;check if to end of buffer
  334. 3430 bne moveloop         ;..not yet/more to do
  335. 3440 lda buf0             ;check if more sectors to (NULL)
  336. 3450 bne readpgm          ;..yes (next track pointer is non-zero)
  337. 3460 jmp (a1)             ;now (NULL) start program
  338. 3470 ;
  339. 3480 ldrend = *            ;end of loader code to move
  340. 3490 ;
  341. 3500 buf0    = $8000       ;geos buffer 0
  342. 3510 dentry  = $8400       ;directory entry from lookup
  343. 3520 drvsrch = $886e       ;drive search flag
  344. 3530 ;
  345. 3540 grphic = $c136        ;graphic table processor
  346. 3550 menu   = $c151        ;menu processor
  347. 3560 drwmnu = $c193        ;redraw the menu
  348. 3570 cmenus = $c1bd        ;close all menus
  349. 3580 read   = $c1e4        ;read a sector
  350. 3590 save   = $c1ed        ;save a geos file
  351. 3600 lookup = $c20b        ;lookup file in directory
  352. 3610 restrt = $c22c        ;reload desktop & restart geos
  353. 3620 delete = $c238        ;delete geos file
  354. 3630 window = $c256        ;window processor routine
  355. 3640 ;
  356. 3650 .end
  357.