home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_27_1988_Transactor_Publishing.d64
/
loadermaker.sda
/
LOADERMAKER.SRC
(
.txt
)
next >
Wrap
Commodore BASIC
|
2023-02-26
|
10KB
|
357 lines
100 sys 49152
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"
120 ;"[206]ick [214]rtis -- [202]anuary 1988"
130 ;
140 ; work registers as in geos programmers reference
150 r0 = $02
160 r1 = $04
170 r4 = $0a
180 r6 = $0e
190 r9 = $14
200 r10 = $16
210 a0 = $fb
220 a1 = $fd
230 ;
240 .tasc ;assemble true ascii literals
250 ;
260 * = $5000-252 ;allow for geos info sector ($4f04)
270 .byte $bf
280 .byte $00,$00,$00,$7f,$ff,$fe,$40,$1f
290 .byte $fe,$5f,$80,$7e,$6f,$ff,$7e,$77
300 .byte $fe,$7e,$77,$05,$fe,$76,$03,$fe
310 .byte $74,$ff,$fe,$75,$80,$7e,$75,$ff
320 .byte $fe,$75,$80,$7e,$74,$ff,$e6,$76
330 .byte $03,$1a,$77,$07,$fc,$77,$ff,$fc
340 .byte $77,$a3,$fc,$77,$b8,$fa,$70,$3f
350 .byte $06,$7f,$ff,$fe,$00,$00,$00
360 .byte $83,$06,$00
370 .word begin ;starting load address
380 .word ldrend ;ending load address
390 .word begin ;starting execution address
400 .asc "[204]oader[205]aker[214]1.0"
410 .byte 0,0,0,0,0
420 .asc "[206]ick [214]rtis -- 1988"
430 .byte 0,0
440 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
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
460 .asc "[195]reate a loader program on [199][197][207][211] disk to load [205][204] files "
470 .asc "created by a non-[199][197][207][211] assembler"
480 .byte 0
490 ;
500 * = $5000
510 moveto =$7f40 ;where boot code will execute from
520 begin lda #<title
530 sta r0
540 lda #>title
550 sta r0+1
560 jsr grphic ;do the opening credits
570 ;
580 doagain = * ;restart point
590 lda #<mainmenu
600 sta r0
610 lda #>mainmenu
620 sta r0+1
630 lda #1 ;cursor on option #2
640 jmp menu
650 ;
660 doquit = * ;handle the quit option
670 jmp restrt ;back to desktop
680 ;
690 dohelp = * ;handle the help option
700 ldx #<helpw
710 ldy #>helpw
720 jsr xywindow
730 jmp drwmnu ;redraw the menu
740 ;
750 domake = * ;handle the make option
760 jsr cmenus ;close all menus
770 lda #<pgmname
780 sta r10
790 lda #>pgmname
800 sta r10+1
810 ldx #<loadnw
820 ldy #>loadnw
830 jsr xywindow
840 lda r0 ;check for cancel
850 cmp #2
860 beq doagain ;..yes-restart
870 ;
880 getln = * ;get name for loader file
890 lda #<ldrname
900 sta r10
910 lda #>ldrname
920 sta r10+1
930 ldx #<ldrnw
940 ldy #>ldrnw
950 jsr xywindow
960 lda r0 ;check for cancel
970 cmp #2
980 beq doagain ;..yes-restart
990 lda #<ldrname
1000 sta r6
1010 lda #>ldrname
1020 sta r6+1
1030 lda drvsrch ;check only 'active' drive for new name
1040 pha ;save current setting
1050 lda #0
1060 sta drvsrch
1070 jsr lookup ;try to find loader name
1080 pla
1090 sta drvsrch ;reset drive search flag
1100 txa ;check return from lookup
1110 bne fileok ;..not found--(NULL)od
1120 ldx #<erafnw
1130 ldy #>erafnw
1140 jsr xywindow
1150 lda r0 ;see if ok to overlay
1160 cmp #4
1170 beq getln ;..no-get a new loader name
1180 lda #<ldrname
1190 sta r0
1200 lda #>ldrname
1210 sta r0+1
1220 jsr delete ;erase current version
1230 ;
1240 fileok = * ;file setup is ok
1250 ldx #0 ;move loader code to where it will run from
1260 ldrmove = *
1270 lda ldrcode,x
1280 sta moveto,x
1290 inx
1300 cpx #<ldrend-ldrcode
1310 bne ldrmove
1320 clc ;calc end address of save
1330 lda #<ldrend-ldrcode
1340 adc #<moveto
1350 sta savend
1360 lda #>ldrend-ldrcode
1370 adc #>moveto
1380 sta savend+1
1390 lda #0 ;try starting on 1st page of directory
1400 sta r10
1410 lda #<ldrinfo
1420 sta r9
1430 lda #>ldrinfo
1440 sta r9+1
1450 jsr save ;save new file
1460 jmp doagain ;redo menu/options
1470 ;
1480 xywindow = * ;produce window pointed to by x/y regs
1490 stx r0
1500 sty r0+1
1510 jmp window ;(NULL)t here via jsr/return directly
1520 ;
1530 mainmenu .byte 0 ;start @ top of screen
1540 .byte 14 ;to +14 down
1550 .word 0 ;left edge
1560 .word 92 ;right edge
1570 .byte 3 ;3 horizontal options
1580 .word done
1590 .byte $80 ;submenu option
1600 .word donemenu ;submenu defination
1610 .word make
1620 .byte 0 ;flash & do option
1630 .word domake
1640 .word help
1650 .byte 0
1660 .word dohelp
1670 done .asc "[196]one" : .byte 0
1680 make .asc "[205]ake" : .byte 0
1690 help .asc "[200]elp" : .byte 0
1700 ;
1710 donemenu .byte 14 ;start below main
1720 .byte 14+14 ;still 14 pixels high
1730 .word 0 ;left edge
1740 .word 29 ;right edge
1750 .byte $80+1 ;one vertical entry
1760 .word quit
1770 .byte 0 ;flash & do
1780 .word doquit
1790 quit .asc "[209]uit" : .byte 0
1800 ;
1810 title .byte $05,28 ;fill pattern
1820 .byte $01,0,0,0 ;top/left corner
1830 .byte $03:.word 320:.byte 199 ;fill whole screen
1840 .byte $05,9 ;new fill pattern
1850 .byte $03:.word 320:.byte 20 ;fill top title line
1860 .byte $06:.word 8:.byte 190 ;output title
1870 .byte $18,$20,$1a ; bold+outlined
1880 .asc "[204]oader[205]aker"
1890 .byte $1b,$18 ; just bold
1900 .asc " [214]1.0 [205]achine [204]anguage [204]oader [205]aker "
1910 .byte $16,8,0,142 ; new position for text
1920 .asc " [206]icholas [202]. [214]rtis "
1930 .byte $16,200,0,142
1940 .asc " [195]opyright 1988 "
1950 .byte $16,8,0,158
1960 .asc " 5863 [208]inetree [211].[197]. "
1970 .byte $16,8,0,174
1980 .asc " [203]entwood, [205][201] 49508 "
1990 .byte $1b,0 ;back to plaintext at end
2000 ;
2010 helpw .byte $01 ;non-standard sized window here
2020 .byte 22,178 ;top/bottom pixels
2030 .word 4 ;left edge
2040 .word 305 ;right edge
2050 .byte $0b,2,15
2060 .word helpmsg
2070 .byte $01,31,135,0 ;-cancel- box
2080 helpmsg .byte $18
2090 .asc "[212]his program is used to create a [199][197][207][211] program which"
2100 .byte $16,6,0,47 ;change here is window size adjusted
2110 .asc "can be run from the [196]esk[212]op. [212]he [199][197][207][211] program will"
2120 .byte $16,6,0,57
2130 .asc "then load and run an assembler program created as a"
2140 .byte $16,6,0,67
2150 .asc "'normal' [195]ommodore program. [212]his avoids having to"
2160 .byte $16,6,0,77
2170 .asc "run a seperate program to 'convert' your assembler"
2180 .byte $16,6,0,87
2190 .asc "program each time you reassemble it. [193] 'normal'"
2200 .byte $16,6,0,97
2210 .asc "[195]ommodore program has the load address as the first"
2220 .byte $16,6,0,107
2230 .asc "two data bytes of the file, and starts execution at"
2240 .byte $16,6,0,117
2250 .asc "that address after being loaded."
2260 .byte $1b,0
2270 ;
2280 ldrnw .byte $81 ;standard size window
2290 .byte $0b,10,30
2300 .word lnmsg
2310 .byte $0b,10,40 ;two lines of text in this window
2320 .word lnmsg2
2330 .byte $0d,10,60 ;get input in window
2340 .byte <r10,16 ;r10 is buffer pointer/max 16 characters input
2350 .byte $02,17,78 ;-cancel- box
2360 .byte 0
2370 lnmsg .byte $18
2380 .asc "[197]nter name for [206][197][215] loader"
2390 .byte 0
2400 lnmsg2 .asc "program to be created."
2410 .byte $1b,0
2420 ;
2430 loadnw .byte $81 ;again a standard sized window
2440 .byte $0b,10,30
2450 .word plmsg
2460 .byte $0d,10,60
2470 .byte <r10,16
2480 .byte $02,17,78 ;cancel box
2490 .byte 0
2500 plmsg .byte $18
2510 .asc "[197]nter name of [208][210][207][199][210][193][205] to load."
2520 .byte $1b,0
2530 ;
2540 erafnw .byte $81
2550 .byte $0b,10,30
2560 .word errmsg
2570 .byte $0b,10,40
2580 .word errmsg2
2590 .byte $03,17,60 ;-yes- box
2600 .byte $04,17,78 ;-no- box
2610 .byte 0
2620 errmsg .byte $18
2630 .asc "[212]hat file already exists."
2640 .byte 0
2650 errmsg2 .asc "[207][203] to overlay ?"
2660 .byte $1b,0
2670 ;
2680 ldrinfo .word ldrname
2690 .byte $03,$15,$bf
2700 .byte $ff,$ff,$ff,$80,$00,$01,$aa,$a0
2710 .byte $01,$a0,$55,$81,$90,$00,$01,$88
2720 .byte $01,$81,$80,$f8,$01,$89,$fc,$01
2730 .byte $83,$00,$01,$8a,$7f,$81,$82,$00
2740 .byte $01,$8a,$7f,$81,$83,$00,$09,$89
2750 .byte $fc,$a5,$80,$f8,$03,$88,$00,$01
2760 .byte $80,$54,$03,$88,$05,$05,$8d,$40
2770 .byte $a9,$80,$00,$01,$ff,$ff,$ff
2780 .byte $83,$06,$00
2790 .word moveto ;begin address of save
2800 savend *=*+2 ;end address for save
2810 .word moveto+17 ;execution start address
2820 .asc "[204]oader[205]aker[214]1.0"
2830 .byte 0,0,0,0,0
2840 .asc "[206]ick [214]rtis -- 1988"
2850 .byte 0,0
2860 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
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
2880 .asc "[204]oad and [210]un a [199][197][207][211] program created by a non-[199][197][207][211] assembler. "
2890 .asc "[212]his program loads "
2900 ;
2910 ldrname .byte 0
2920 *=*+16 ;allow for full name + trailing null
2930 ;
2940 ldrcode = * ;loader code starts here
2950 pgmname .byte 0
2960 *=*+16
2970 ;
2980 loadml lda #<moveto ;address of name of program to load
2990 sta r6
3000 lda #>moveto
3010 sta r6+1
3020 jsr lookup
3030 txa ;check return
3040 beq diskok ;..found it ok
3050 jmp restrt ;else abandon the load & (NULL) back to desktop
3060 ;
3070 diskok lda dentry+2 ;sector of file beginning
3080 sta r1+1
3090 lda dentry+1 ;track of file beginning
3100 sta r1
3110 lda #<buf0 ;set pointer to buffer for read
3120 sta r4
3130 lda #>buf0
3140 sta r4+1
3150 jsr read ;read 1st buffer
3160 lda buf0+2 ;get program load adress
3170 sta a0
3180 sta a1 ;also store as starting address
3190 lda buf0+3
3200 sta a0+1
3210 sta a1+1
3220 ldx #3 ;skip t/s & address
3230 bne skipread ;..unconditional-skip 1st read
3240 readpgm lda buf0 ;get track/sector of next block
3250 sta r1
3260 lda buf0+1
3270 sta r1+1
3280 jsr read
3290 ldx #1 ;skip t/s pointer for all other blocks
3300 skipread ldy #$ff ;assume a full sector
3310 lda buf0 ;check next track pointer
3320 bne (NULL)odnxtt ;..(NULL)od next track
3330 ldy buf0+1 ;else this is last sector/pick up # valid bytes
3340 (NULL)odnxtt sty r0 ;save # valid bytes (255 for full sector)
3350 ldy #0
3360 moveloop inx
3370 lda buf0,x ;get input byte
3380 sta (a0),y ;store it
3390 inc a0 ;bump pointer
3400 bne a0ok
3410 inc a0+1
3420 a0ok cpx r0 ;check if to end of buffer
3430 bne moveloop ;..not yet/more to do
3440 lda buf0 ;check if more sectors to (NULL)
3450 bne readpgm ;..yes (next track pointer is non-zero)
3460 jmp (a1) ;now (NULL) start program
3470 ;
3480 ldrend = * ;end of loader code to move
3490 ;
3500 buf0 = $8000 ;geos buffer 0
3510 dentry = $8400 ;directory entry from lookup
3520 drvsrch = $886e ;drive search flag
3530 ;
3540 grphic = $c136 ;graphic table processor
3550 menu = $c151 ;menu processor
3560 drwmnu = $c193 ;redraw the menu
3570 cmenus = $c1bd ;close all menus
3580 read = $c1e4 ;read a sector
3590 save = $c1ed ;save a geos file
3600 lookup = $c20b ;lookup file in directory
3610 restrt = $c22c ;reload desktop & restart geos
3620 delete = $c238 ;delete geos file
3630 window = $c256 ;window processor routine
3640 ;
3650 .end