Now can actually make use of the RAM freed by moving ProDOS.

This commit is contained in:
Martin Haye 2015-06-04 10:11:38 -07:00
parent 53b956eccc
commit a8e501c51b
4 changed files with 33 additions and 33 deletions

View File

@ -468,8 +468,10 @@ init: !zone
; 3: aux $C000 -> 0, active + locked ; 3: aux $C000 -> 0, active + locked
; 4: main $0xxx -> 5, inactive (xxx = end of mem mgr tables) ; 4: main $0xxx -> 5, inactive (xxx = end of mem mgr tables)
; 5: main $2000 -> 6, active + locked ; 5: main $2000 -> 6, active + locked
; 6: main $6000 -> 3, inactive ; 6: main $6000 -> 7, inactive
; 7: main $BF00 -> 0, active + locked ; 7: main $BF00 -> 8, active + locked
; 8: main $E000 -> 9, inactive
; 9: main $F800 -> 0, active + locked
; First, the flags ; First, the flags
lda #$C0 ; flags for active + locked (with no resource) lda #$C0 ; flags for active + locked (with no resource)
sta tSegType+0 sta tSegType+0
@ -477,6 +479,7 @@ init: !zone
sta tSegType+3 sta tSegType+3
sta tSegType+5 sta tSegType+5
sta tSegType+7 sta tSegType+7
sta tSegType+9
; Next the links ; Next the links
ldx #2 ldx #2
stx tSegLink+1 stx tSegLink+1
@ -490,6 +493,10 @@ init: !zone
stx tSegLink+5 stx tSegLink+5
inx inx
stx tSegLink+6 stx tSegLink+6
inx
stx tSegLink+7
inx
stx tSegLink+8
; Then the addresses ; Then the addresses
lda #2 lda #2
sta tSegAdrHi+2 sta tSegAdrHi+2
@ -505,10 +512,14 @@ init: !zone
sta tSegAdrHi+5 sta tSegAdrHi+5
lda #$60 lda #$60
sta tSegAdrHi+6 sta tSegAdrHi+6
lda #$E0
sta tSegAdrHi+8
lda #$F8
sta tSegAdrHi+9
; Finally, form a long list of the remaining unused segments. ; Finally, form a long list of the remaining unused segments.
ldx #8 ldx #10
stx unusedSeg ; that's the first unused seg stx unusedSeg ; that's the first unused seg
ldy #9 ldy #11
.loop: tya .loop: tya
sta tSegLink,x sta tSegLink,x
inx inx
@ -573,8 +584,8 @@ moveProDOS: !zone
; copy the ProDOS code from main memory to aux ; copy the ProDOS code from main memory to aux
ldy #0 ldy #0
ldx #$D0 ldx #$D0
bit $C08B ; turn on language card bit setLcRW+lcBank1 ; turn on language card
bit $C08B ; for writing bit setLcRW+lcBank1 ; for writing
.pglup stx .ld+2 .pglup stx .ld+2
stx .st+2 stx .st+2
.bylup sta clrAuxZP .bylup sta clrAuxZP
@ -586,7 +597,6 @@ moveProDOS: !zone
inx inx
bne .pglup bne .pglup
sta clrAuxZP sta clrAuxZP
bit $C081
; patch into the main ProDOS MLI entry point ; patch into the main ProDOS MLI entry point
lda #$4C ; jmp lda #$4C ; jmp
sta $BFBB sta $BFBB
@ -609,8 +619,8 @@ moveProDOS: !zone
lda #>exitProDOS lda #>exitProDOS
sta $BFA2 sta $BFA2
; now blow away the main LC area as a check ; now blow away the main LC area as a check
bit $C089 bit setLcWr+lcBank1 ; only clear bank 1, because bank 2 is PLASMA runtime
bit $C089 bit setLcWr+lcBank1 ; write to it
ldx #$D0 ldx #$D0
lda #0 lda #0
tay tay
@ -671,25 +681,23 @@ enterProDOS2: !zone
; Shared exit point for ProDOS MLI and IRQ handlers. This patches the code ; Shared exit point for ProDOS MLI and IRQ handlers. This patches the code
; at $BFA0. ; at $BFA0.
exitProDOS: !zone exitProDOS: !zone
sta .ld4+1 ; preserve A reg pla ; saved A reg
pla ; saved A reg
sta .ld3+1 sta .ld3+1
pla ; lo byte of ret addr pla ; P-reg for RTI
sta .ld2+1 sta .ld2+1
pla ; hi byte of ret addr pla ; hi byte of ret addr
sta .ld1+1 sta .ld1+1
pla ; saved P reg pla ; lo byte of ret addr
sta clrAuxZP ; back to main stack/ZP/LC sta clrAuxZP ; back to main stack/ZP/LC
pha bit setLcRW+lcBank2 ; switch in PLASMA
.ld1 lda #11 ; self-modified earlier bit setLcRW+lcBank2 ; for write as well as read
pha pha ; lo byte of ret addr
.ld2 lda #11 ; ditto .ld1 lda #11 ; self-modified earlier
pha pha ; hi byte of ret addr
.ld3 lda #11 ; ditto .ld2 lda #11 ; ditto
pha pha ; P-reg for RTI
.ld4 lda #11 ; ditto .ld3 lda #11 ; self-modified earlier (the saved A reg)
eor $E000 ; this is what the original code at $BFA0 did rti ; RTI pops P-reg and *exact* return addr (not adding 1)
jmp $BFA3 ; back to where ProDOS left off
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
!if DEBUG { !if DEBUG {
@ -2074,7 +2082,6 @@ doAllFixups: !zone
; 8. Store A=lo/Y=hi into PLASMA return value ; 8. Store A=lo/Y=hi into PLASMA return value
; 9. Return to PLASMA ; 9. Return to PLASMA
__asmPlasm: !zone __asmPlasm: !zone
bit setROM ; switch to ROM
pla ; save address of calling routine, so we can call it pla ; save address of calling routine, so we can call it
clc clc
adc #1 adc #1
@ -2095,7 +2102,6 @@ __asmPlasm: !zone
lda evalStkL,x ; get last param to A=lo lda evalStkL,x ; get last param to A=lo
ldy evalStkH,x ; ...Y=hi ldy evalStkH,x ; ...Y=hi
.jsr jsr $1111 ; call the routine to do work .jsr jsr $1111 ; call the routine to do work
bit setLcRW+lcBank2 ; read from language card (where PLASMA runtime lives)
sta tmp ; stash return value lo sta tmp ; stash return value lo
pla pla
tax ; restore adjusted PLASMA stack pointer tax ; restore adjusted PLASMA stack pointer

View File

@ -479,7 +479,6 @@ end
// Jump straight to the system monitor // Jump straight to the system monitor
// Params: None // Params: None
asm goMon asm goMon
bit setROM
jmp $FF69 jmp $FF69
end end
@ -487,7 +486,6 @@ end
// Execute a monitor breakpoint // Execute a monitor breakpoint
// Params: None // Params: None
asm brk asm brk
bit setROM
bit setText bit setText
bit page1 bit page1
brk brk

View File

@ -1617,9 +1617,7 @@ loadTextures: !zone
; finally, init the scripts. ; finally, init the scripts.
!if DEBUG { +prStr : !text "Calling script init ",0 : +prWord .scInit+1 : +crout } !if DEBUG { +prStr : !text "Calling script init ",0 : +prWord .scInit+1 : +crout }
ldx plasmaStk ldx plasmaStk
bit setLcRW+lcBank2 ; switch PLASMA runtime back in
.scInit jsr $1111 ; self-modified earlier .scInit jsr $1111 ; self-modified earlier
bit setROM ; back to ROM so we can work normally
!if DEBUG { +prStr : !text "Back from script init. ",0 } !if DEBUG { +prStr : !text "Back from script init. ",0 }
rts rts
.get: lda $1111 .get: lda $1111

View File

@ -321,9 +321,7 @@ LOAD_SCRIPTS_NO_CALC:
+finishLoad 0 ; all done +finishLoad 0 ; all done
!if DEBUG { +prStr : !text "Calling init script.",0 } !if DEBUG { +prStr : !text "Calling init script.",0 }
LDX PLASMA_X LDX PLASMA_X
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
JSR .callit ; perform script init JSR .callit ; perform script init
BIT setROM ; switch out PLASMA so we're ready to render
!if DEBUG { +prStr : !text "Back from init script.",0 } !if DEBUG { +prStr : !text "Back from init script.",0 }
RTS RTS
.callit JMP (SCRIPTS_LOC) ; the init function is always first in the script module .callit JMP (SCRIPTS_LOC) ; the init function is always first in the script module