1
0
mirror of https://github.com/pfusik/xasm.git synced 2024-12-22 00:29:15 +00:00

X-BOOT 3.1 - converts Atari 8-bit executables to bootable disk images.

This commit is contained in:
Piotr Fusik 1998-08-13 13:37:32 +02:00
parent e496cc76f5
commit 35bf3f192d
4 changed files with 364 additions and 0 deletions

195
xboot.asm Normal file
View File

@ -0,0 +1,195 @@
; ><-B00T III b. Fox
IDEAL
P386
MODEL TINY
CODESEG
ORG 100h
include 'fox.mak'
blen = 60*1024
start:
db 1024 dup(0) ;for COMpack
print hello
mov di, 81h
movzx cx, [di-1]
jcxz usg
mov al, '?'
repne scasb
jne nousg
usg: mov dx, offset usgtxt
panic: print
dos 4c01h
getfil: mov ch, -1
mov al, ' '
repe scasb
mov dx, offset fname
lea si, [di-1]
cmp [byte si], 0dh
je usg
mov di, dx
movfn1: movsb
cmp [si], al
ja movfn1
mov bx, di
srchex: dec bx
cmp [byte bx], '\'
je addext
cmp [byte bx], '.'
je extexs
cmp bx, dx
ja srchex
addext: xchg eax, ebp
stosd
extexs: mov [byte di], 0
rts: ret
smartdisk
badf: mov dx, offset badtxt
jmp panic
nousg: mov ch, -1
mov di, 81h
mov al, ' '
repe scasb
mov ax, [di-1]
inc di
or ah, 20h
cmp ax, 'p/'
je romsw
dec [romfl]
mov di, 81h
romsw: mov ebp, 'moc.'
call getfil
push si
fopen
mov cx, blen
fread bufr
mov dx, offset lontxt
cmp ax, blen
jnb panic
mov [len], ax
fclose
mov si, offset bufr
mov di, si
lodsw
cmp ax, -1
jne badf
mov ax, [si]
mov [l1runl], al
mov [l2runl], al
mov [l1runh], ah
mov [l2runh], ah
cutf1: lodsw
cmp ax, -1
je cutf1
stosw
sta bx
lodsw
stosw
sub ax, bx
jb badf
inc ax
sta cx
rep movsb
cutfn: mov ax, si
sub ax, offset bufr
cmp ax, [len]
jb cutf1
mov si, offset endseq1
cmp [romfl], 0
jz stdld
push di
mov si, offset romlod
mov di, offset sect
mov cx, 64
rep movsw
pop di
mov si, offset endseq2
stdld: mov cx, endlen
rep movsb
mov cx, offset sect
sub cx, di
and cx, 7fh
xor al, al
rep stosb
sub di, offset begin
mov [len], di
shr di, 4
dec di
mov [paras], di
pop di
mov ebp, 'rta.'
call getfil
fcreate
mov cx, [len]
mov dx, offset begin
fwrite
fclose
print oktxt
dos 4c00h
; Poetry
hello db 'X-BOOT 3.1 by Fox/Taquart',eot
usgtxt db 'Converts Atari 8-bit executable into .ATR disk image.',eol
db 'Usage: XBOOT [/p] comfile atrfile',eol
db 'Use /p switch to write professional loader rather than standard.',eot
oktxt db 'O.K.',eot
badtxt db 'Bad format of file!',eot
lontxt db 'File too long',eot
smarterr
romfl db 1
; Ending Header for loader #1
endseq1 db 233,7,235,7,108,224,2
; Ending Header for loader #2
endseq2 db 244,4,246,4,108,224,2
endlen = $-endseq2
; Loader #2 (rom)
romlod: db 96,1,128,4,119,228,169,0,141,47,2
db 169,82,141,200,2,165,20,197,20,240,252,169
l2runl db 128,141,224,2,169
l2runh db 4,141,225,2,160,254,169,128,141,226,2,169,4,141,227,2,162,251,149
db 72,232,134,67,76,188,4,230,68,208,2,230,69,200,16,32,238,10
db 3,208,3,238,11,3,169,255,141,1,211,78,14,212,88,32,83,228
db 56,48,170,160,0,120,140,14,212,206,1,211,185,0,4,166,67,208
db 200,129,68,165,68,197,70,208,200,165,69,197,71,208,194,152,72,32
db 253,4,104,168,16,165,108,226,2
; ATR Header
begin dw 296h
paras dw 0
dw 80h,5 dup(0)
; Atari Boot Sector(s)
sect:
; Loader #1 (std)
db 96,1,128,7,119,228,160,215,185,30,7
db 145,88,200,192,226,144,246,169
l1runl db 128,141,224,2,169
l1runh db 7,141,225,2,169
db 7,141,5,3,160,255,140,1,211,136,169,128,141,226,2,169,7,141
db 227,2,162,251,149,72,232,134,67,76,193,7,230,68,208,2,230,69
db 200,16,16,238,10,3,208,3,238,11,3,32,83,228,56,48,174,160
db 0,185,0,7,166,67,208,216,129,68,165,68,197,70,208,216,165,69
db 197,71,208,210,152,72,32,242,7,104,168,16,181,108,226,2,44,111
db 97,100,105,110,103,14,14,14,0
beglen = $-begin
bufr db blen dup(?)
len dw ?
fname db 128 dup(?)
ENDS
END start

12
xboot.txt Normal file
View File

@ -0,0 +1,12 @@
X-Boot 3.1 by Fox/Taquart
Some (un)important notes
-------------------------
This tool converts Atari executable (.COM) into Atari disk image (.ATR).
Produced ATR is single density and as short as possible. It has a loader
in one boot sector. You can choose one of two built-in loaders:
standard and professional. Professional loader allows you to load code/data
under ROM and disables ROM and interrupts while starting program.
Both loaders disable Atari Basic. For details, view sources of loaders.
X-Boot does not write your program in ATR as Atari file, you can only run it
by booting.
---

79
xbootpro.asx Normal file
View File

@ -0,0 +1,79 @@
* Boot executable file loader coded by Fox/Taquart
* Version for professionals - can load file under ROM.
* Note interrupts and ROM are disabled when running loaded program.
org $480
bufr equ $400
tp equ $43
vc equ $44
* Boot header
boot equ *
rts rts
dta b(1),a(boot,$e477)
* Nice blank screen
lda #0
sta $22f
lda #$52
sta $2c8
lda 20
cmp 20
beq *-2
* Init run vector
lda <rts
sta $2e0
lda >rts
sta $2e1
ldy #$fe
* Load header
lhead lda <rts
sta $2e2
lda >rts
sta $2e3
ldx <-5
* Store byte of header
hput sta vc+4,x
inx
stx tp
jmp get
next inw vc
get iny
bpl getx
inw $30a
lda #$ff
sta ^31
lsr ^4e
cli
jsr $e453
sec
bmi rts
ldy #0
sei
sty ^4e
dec ^31
getx lda bufr,y
ldx tp
bne hput
sta (vc,x)
lda vc
cmp vc+2
bne next
lda vc+1
cmp vc+3
bne next
endseq tya
pha
jsr init
pla
tay
bpl lhead !
init jmp ($2e2)
* This will be added at the end of loaded file
org endseq
jmp ($2e0)
end

78
xbootstd.asx Normal file
View File

@ -0,0 +1,78 @@
* Boot executable file loader coded by Fox/Taquart
* Standard loader - ROM and interrupts enabled.
org $780
bufr equ $700
tp equ $43
vc equ $44
* Boot header
boot equ *
rts rts
dta b(1),a(boot,$e477)
* Print text
txtpos equ 215
ldy #txtpos
print lda text-txtpos,y
sta ($58),y
iny
cpy #txtpos+txtlen
bcc print
* Init run vector
lda <rts
sta $2e0
lda >rts
sta $2e1
lda >bufr
sta $305
ldy #$ff
sty ^31
dey #$fe
* Load header
lhead lda <rts
sta $2e2
lda >rts
sta $2e3
ldx <-5
* Store byte of header
hput sta vc+4,x
inx
stx tp
jmp get
next inw vc
get iny
bpl getx
inw $30a
jsr $e453
sec
bmi rts
ldy #0
getx lda bufr,y
ldx tp
bne hput
sta (vc,x)
lda vc
cmp vc+2
bne next
lda vc+1
cmp vc+3
bne next
endseq tya
pha
jsr init
pla
tay
bpl lhead !
init jmp ($2e2)
text dta d'Loading... '
txtlen equ *-text
* This will be added at the end of loaded file
org endseq
jmp ($2e0)
end