mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
114 lines
2.3 KiB
Plaintext
114 lines
2.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* K.LoadBinYA
|
||
* in :
|
||
* A = hMem of FilePath (PSTRING)
|
||
* out :
|
||
* Y,A = MEMPTR
|
||
* X = hMem of Code Segment
|
||
*--------------------------------------
|
||
K.LoadBinYA >STYA K.LoadBin.Filename
|
||
jsr K.PStrUprYA
|
||
|
||
>LDYA K.LoadBin.Filename
|
||
jsr K.GetMemByNameYA
|
||
bcs .3 not already loaded
|
||
|
||
>STYA ZPQuickPtr1 Save base address
|
||
ldy #S.MEM.REFCNT
|
||
lda (ZPQuickPtr1),y
|
||
inc
|
||
sta (ZPQuickPtr1),y
|
||
|
||
ldy #S.MEM.PTR
|
||
lda (ZPQuickPtr1),y
|
||
pha Y,A = MEM PTR...
|
||
iny
|
||
lda (ZPQuickPtr1),y
|
||
ply X=hMem from K.GetMemByNameA
|
||
clc
|
||
rts
|
||
|
||
.3 >PUSHWI $2000 Aux type
|
||
>PUSHBI 6 S.FILEINFO.TYPE.BIN
|
||
>PUSHBI SYS.FOPEN.R
|
||
>PUSHW K.LoadBin.Filename
|
||
jsr K.LoadFile
|
||
bcs .99 Error Loading file
|
||
|
||
>STYA K.LoadBin.SegLen
|
||
stx K.LoadBin.hMem save hMem
|
||
txa
|
||
jsr K.GetMemPtrA
|
||
>STYA K.LoadBin.NewBase
|
||
|
||
>LDYA K.LoadBin.Filename
|
||
jsr K.MLIGetFileInfoYA Get File Info for AUXTYPE
|
||
bcs .98
|
||
|
||
>STYA ZPQuickPtr1
|
||
|
||
ldy #2 get AUXTYPE
|
||
lda (ZPQuickPtr1),y
|
||
sta K.LoadBin.OldBase
|
||
iny
|
||
lda (ZPQuickPtr1),y
|
||
sta K.LoadBin.OldBase+1
|
||
|
||
bit RRAMWRAMBNK2
|
||
bit RRAMWRAMBNK2
|
||
|
||
jsr K.InsBin
|
||
|
||
bit RRAMWRAMBNK1
|
||
bit RRAMWRAMBNK1
|
||
|
||
bcs .98 relocation error, dicard Code segment
|
||
|
||
>LDYA K.LoadBin.Filename get back bin path
|
||
jsr K.NewPStrYA make a copy of this string
|
||
bcs .98
|
||
phx save copy
|
||
|
||
lda K.LoadBin.hMem
|
||
jsr K.GetMemByIDA
|
||
>STYA ZPQuickPtr1
|
||
|
||
lda (ZPQuickPtr1)
|
||
ora #S.MEM.F.CODE This is a code segment
|
||
sta (ZPQuickPtr1)
|
||
|
||
pla
|
||
ldy #S.MEM.BIN
|
||
sta (ZPQuickPtr1),y
|
||
|
||
lda K.LoadBin.hMem
|
||
tax return hMEM to Caller...
|
||
jsr K.GetMemPtrA
|
||
clc ...and Y,A=PTR to CS
|
||
rts
|
||
|
||
.98 pha
|
||
lda K.LoadBin.hMem
|
||
jsr K.FreeMemA Discard Loaded Code
|
||
pla
|
||
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
K.LoadBin.Filename .BS 2
|
||
K.LoadBin.hMem .BS 1
|
||
K.LoadBin.OldBase .BS 2
|
||
K.LoadBin.NewBase .BS 2
|
||
K.LoadBin.SegLen .BS 2
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.BIN
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|