mirror of
https://github.com/cc65/cc65.git
synced 2024-07-05 06:28:57 +00:00
Allow to run programs as ProDOS SYS files (beside BIN files). To do so detect at runtime if BASIC.SYSTEM is present by checking the "signature" of the last system bitmap byte.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4146 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
d9cdca75b6
commit
aeccd3a776
@ -99,14 +99,14 @@ _exit: ldx #<exit
|
|||||||
jsr donelib
|
jsr donelib
|
||||||
|
|
||||||
; Check for valid interrupt vector table entry number
|
; Check for valid interrupt vector table entry number
|
||||||
lda intnum
|
lda int_num
|
||||||
beq exit
|
beq exit
|
||||||
|
|
||||||
; Deallocate interrupt vector table entry
|
; Deallocate interrupt vector table entry
|
||||||
dec params ; Adjust parameter count
|
dec i_param ; Adjust parameter count
|
||||||
jsr $BF00 ; MLI call entry point
|
jsr $BF00 ; MLI call entry point
|
||||||
.byte $41 ; Dealloc interrupt
|
.byte $41 ; Dealloc interrupt
|
||||||
.addr params
|
.addr i_param
|
||||||
|
|
||||||
; Restore the original RESET vector
|
; Restore the original RESET vector
|
||||||
exit: ldx #$02
|
exit: ldx #$02
|
||||||
@ -128,8 +128,8 @@ exit: ldx #$02
|
|||||||
ldx #$FF
|
ldx #$FF
|
||||||
txs ; Re-init stack pointer
|
txs ; Re-init stack pointer
|
||||||
|
|
||||||
; Back to DOS
|
; We're done
|
||||||
jmp DOSWARM
|
jmp (done)
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -159,25 +159,47 @@ init: ldx #zpspace-1
|
|||||||
lda #>_exit
|
lda #>_exit
|
||||||
jsr reset ; Setup RESET vector
|
jsr reset ; Setup RESET vector
|
||||||
|
|
||||||
; Setup the stack
|
; Check for ProDOS
|
||||||
lda HIMEM
|
ldy $BF00 ; MLI call entry point
|
||||||
sta sp
|
cpy #$4C ; Is MLI present? (JMP opcode)
|
||||||
lda HIMEM+1
|
bne basic
|
||||||
sta sp+1 ; Set argument stack ptr
|
|
||||||
|
; Check ProDOS system bit map
|
||||||
|
lda $BF6F ; protection for pages $B8 - $BF
|
||||||
|
cmp #%00000001 ; exactly page $BF is protected
|
||||||
|
bne basic
|
||||||
|
|
||||||
|
; No BASIC.SYSTEM so quit to ProDOS dispatcher instead
|
||||||
|
lda #<quit
|
||||||
|
ldx #>quit
|
||||||
|
sta done
|
||||||
|
stx done+1
|
||||||
|
|
||||||
|
; No BASIC.SYSTEM so use addr of ProDOS system global page
|
||||||
|
lda #<$BF00
|
||||||
|
ldx #>$BF00
|
||||||
|
bne :+ ; Branch always
|
||||||
|
|
||||||
|
; Get highest available mem addr from BASIC interpreter
|
||||||
|
basic: lda HIMEM
|
||||||
|
ldx HIMEM+1
|
||||||
|
|
||||||
|
; Setup the C stack
|
||||||
|
: sta sp
|
||||||
|
stx sp+1
|
||||||
|
|
||||||
; Check for interruptors
|
; Check for interruptors
|
||||||
lda #<__INTERRUPTOR_COUNT__
|
lda #<__INTERRUPTOR_COUNT__
|
||||||
beq :+
|
beq :+
|
||||||
|
|
||||||
; Check for ProDOS
|
; Check for ProDOS
|
||||||
lda $BF00 ; MLI call entry point
|
cpy #$4C ; Is MLI present? (JMP opcode)
|
||||||
cmp #$4C ; Is MLI present? (JMP opcode)
|
|
||||||
bne prterr
|
bne prterr
|
||||||
|
|
||||||
; Allocate interrupt vector table entry
|
; Allocate interrupt vector table entry
|
||||||
jsr $BF00 ; MLI call entry point
|
jsr $BF00 ; MLI call entry point
|
||||||
.byte $40 ; Alloc interrupt
|
.byte $40 ; Alloc interrupt
|
||||||
.addr params
|
.addr i_param
|
||||||
bcs prterr
|
bcs prterr
|
||||||
|
|
||||||
; Enable interrupts as old ProDOS versions (i.e. 1.1.1)
|
; Enable interrupts as old ProDOS versions (i.e. 1.1.1)
|
||||||
@ -223,7 +245,7 @@ msglen = * - errmsg
|
|||||||
|
|
||||||
; ProDOS TechRefMan, chapter 6.2:
|
; ProDOS TechRefMan, chapter 6.2:
|
||||||
; "Each installed routine must begin with a CLD instruction."
|
; "Each installed routine must begin with a CLD instruction."
|
||||||
intrpt: cld
|
intptr: cld
|
||||||
|
|
||||||
; Call interruptors and check for success
|
; Call interruptors and check for success
|
||||||
jsr callirq
|
jsr callirq
|
||||||
@ -248,13 +270,33 @@ reset: stx SOFTEV
|
|||||||
sta PWREDUP
|
sta PWREDUP
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; Quit to ProDOS dispatcher
|
||||||
|
quit: jsr $BF00 ; MLI call entry point
|
||||||
|
.byte $65 ; Quit
|
||||||
|
.word q_param
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.rodata
|
||||||
|
|
||||||
|
; MLI parameter list for quit
|
||||||
|
q_param:.byte $04 ; param_count
|
||||||
|
.byte $00 ; quit_type
|
||||||
|
.word $0000 ; reserved
|
||||||
|
.byte $00 ; reserved
|
||||||
|
.word $0000 ; reserved
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
params: .byte $02 ; Parameter count
|
; MLI parameter list for (de)alloc interrupt
|
||||||
intnum: .byte $00 ; Interrupt number
|
i_param:.byte $02 ; param_count
|
||||||
.addr intrpt ; Interrupt handler
|
int_num:.byte $00 ; int_num
|
||||||
|
.addr intptr ; int_code
|
||||||
|
|
||||||
|
; Location to jump to when we're done
|
||||||
|
done: .addr DOSWARM
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user