mirror of
https://github.com/bobbimanners/Applecorn.git
synced 2025-01-19 05:30:35 +00:00
Merge JGH's PR 126 'Added ROM select'
This commit is contained in:
parent
8d020183f5
commit
725fc3b76e
BIN
applecorn.po
BIN
applecorn.po
Binary file not shown.
@ -7,6 +7,8 @@
|
||||
* BBC Micro 'virtual machine' in Apple //e aux memory
|
||||
***********************************************************
|
||||
|
||||
MAXROM EQU $00 ; Only one sideways ROM
|
||||
|
||||
ZP1 EQU $90 ; $90-$9f are spare Econet space
|
||||
; so safe to use
|
||||
ZP2 EQU $92
|
||||
@ -129,12 +131,15 @@ MOSHIGH SEI
|
||||
LDA #7
|
||||
JSR OSWRCH
|
||||
JSR OSNEWL
|
||||
LDX #MAXROM ; TEMP X=language to enter
|
||||
CLC
|
||||
* JMP BYTE8E
|
||||
|
||||
* OSBYTE $8E - Enter language ROM
|
||||
* X=ROM number to select
|
||||
*
|
||||
BYTE8E PHP ; Save CLC=RESET, SEC=Not RESET
|
||||
JSR ROMSELECT ; Bring ROM X into memory
|
||||
STX BYTEVARBASE+$FC ; Set current language ROM
|
||||
LDA #$00
|
||||
STA FAULT+0
|
||||
LDA #$80
|
||||
@ -151,16 +156,28 @@ BYTE8E PHP ; Save CLC=RESET, SEC=Not RESET
|
||||
* OSBYTE $8F - Issue service call
|
||||
* X=service call, Y=parameter
|
||||
*
|
||||
SERVICE TAX ; Enter here with A=Service Num
|
||||
BYTE8F
|
||||
SERVICEX TXA
|
||||
SERVICE LDX #$0F
|
||||
SERVICEX LDA $F4
|
||||
PHA ; Save current ROM
|
||||
TXA
|
||||
LDX #MAXROM ; Start at highest ROM
|
||||
:SERVLP JSR ROMSELECT ; Bring it into memory
|
||||
BIT $8006
|
||||
BPL :SERVSKIP ; No service entry
|
||||
JSR $8003 ; Call service entry
|
||||
BPL :SERVSKIP ; No service entry
|
||||
JSR $8003 ; Call service entry
|
||||
TAX
|
||||
BEQ :SERVDONE
|
||||
:SERVSKIP LDX #$FF
|
||||
:SERVDONE RTS
|
||||
:SERVSKIP LDX $F4 ; Restore X=current ROM
|
||||
DEX ; Step down to next
|
||||
BPL :SERVLP ; Loop until ROM 0 done
|
||||
:SERVDONE PLA ; Get caller's ROM back
|
||||
PHX ; Save return from service call
|
||||
TAX
|
||||
JSR ROMSELECT ; Restore caller's ROM
|
||||
PLX ; Get return value back
|
||||
TXA ; Return in A and X and set EQ/NE
|
||||
RTS
|
||||
|
||||
|
||||
PRHELLO LDA #<HELLO
|
||||
@ -174,10 +191,7 @@ BYTE00 BEQ BYTE00A ; OSBYTE 0,0 - generate error
|
||||
RTS ; %000x1xxx host type, 'A'pple
|
||||
BYTE00A BRK
|
||||
DB $F7
|
||||
HELLO ASC 'Applecorn MOS 2021-10-18'
|
||||
HELLO ASC 'Applecorn MOS 2021-10-23'
|
||||
DB $00 ; Unify MOS messages
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
179
auxmem.misc.s
179
auxmem.misc.s
@ -76,6 +76,7 @@ BEEP PHA
|
||||
PLA
|
||||
RTS
|
||||
|
||||
|
||||
* Print string pointed to by X,Y to the screen
|
||||
OUTSTR TXA
|
||||
|
||||
@ -128,99 +129,55 @@ PRNIB CMP #$0A
|
||||
* Print 16-bit value in XY in decimal
|
||||
OSNUM EQU OSTEXT+0
|
||||
OSPAD EQU OSTEXT+4
|
||||
PRDECXY
|
||||
PRDECPAD STX OSNUM+0
|
||||
STY OSNUM+1
|
||||
STZ OSNUM+2
|
||||
STZ OSNUM+3
|
||||
:PRDEC16 LDY #$05 ; 5 digits
|
||||
LDX #OSNUM ; number stored in OSNUM
|
||||
*PRDECXY
|
||||
*PRDECPAD STX OSNUM+0
|
||||
* STY OSNUM+1
|
||||
* STZ OSNUM+2
|
||||
* STZ OSNUM+3
|
||||
*:PRDEC16 LDY #$05 ; 5 digits
|
||||
* LDX #OSNUM ; number stored in OSNUM
|
||||
|
||||
* Print up to 32-bit decimal number
|
||||
* See forum.6502.org/viewtopic.php?f=2&t=4894
|
||||
* X=>four byte zero page locations
|
||||
* Y= number of digits, 0 for no padding
|
||||
* and groups.google.com/g/comp.sys.apple2/c/_y27d_TxDHA
|
||||
*
|
||||
PRINTDEC sty OSPAD ; Number of padding+digits
|
||||
ldy #0 ; Digit counter
|
||||
PRDECDIGIT lda #32 ; 32-bit divide
|
||||
* X=>four byte zero page locations
|
||||
* Y= number of digits to pad to, 0 for no padding
|
||||
*
|
||||
PRINTDEC sty OSPAD ; Number of padding+digits
|
||||
ldy #0 ; Digit counter
|
||||
PRDECDIGIT lda #32 ; 32-bit divide
|
||||
sta OSTEMP
|
||||
lda #0 ; Remainder=0
|
||||
clv ; V=0 means div result = 0
|
||||
PRDECDIV10 cmp #10/2 ; Calculate OSNUM/10
|
||||
lda #0 ; Remainder=0
|
||||
clv ; V=0 means div result = 0
|
||||
PRDECDIV10 cmp #10/2 ; Calculate OSNUM/10
|
||||
bcc PRDEC10
|
||||
sbc #10/2+$80 ; Remove digit & set V=1 to show div result > 0
|
||||
sec ; Shift 1 into div result
|
||||
PRDEC10 rol 0,x ; Shift /10 result into OSNUM
|
||||
sbc #10/2+$80 ; Remove digit & set V=1 to show div result > 0
|
||||
sec ; Shift 1 into div result
|
||||
PRDEC10 rol 0,x ; Shift /10 result into OSNUM
|
||||
rol 1,x
|
||||
rol 2,x
|
||||
rol 3,x
|
||||
rol a ; Shift bits of input into acc (input mod 10)
|
||||
rol a ; Shift bits of input into acc (input mod 10)
|
||||
dec OSTEMP
|
||||
bne PRDECDIV10 ; Continue 32-bit divide
|
||||
bne PRDECDIV10 ; Continue 32-bit divide
|
||||
ora #48
|
||||
pha ; Push low digit 0-9 to print
|
||||
pha ; Push low digit 0-9 to print
|
||||
iny
|
||||
bvs PRDECDIGIT ; If V=1, result of /10 was > 0 & do next digit
|
||||
bvs PRDECDIGIT ; If V=1, result of /10 was > 0 & do next digit
|
||||
lda #32
|
||||
PRDECLP1 cpy OSPAD
|
||||
bcs PRDECLP2 ; Enough padding pushed
|
||||
pha ; Push leading space characters
|
||||
bcs PRDECLP2 ; Enough padding pushed
|
||||
pha ; Push leading space characters
|
||||
iny
|
||||
bne PRDECLP1
|
||||
PRDECLP2 pla ; Pop character left to right
|
||||
jsr OSWRCH ; Print it
|
||||
PRDECLP2 pla ; Pop character left to right
|
||||
jsr OSWRCH ; Print it
|
||||
dey
|
||||
bne PRDECLP2
|
||||
rts
|
||||
|
||||
|
||||
** Print 16-bit value in XY in decimal
|
||||
** beebwiki.mdfs.net/Number_output_in_6502_machine_code
|
||||
*OSNUM EQU OSTEXT+0
|
||||
*OSPAD EQU OSTEXT+4
|
||||
*
|
||||
*PRDECXY LDA #' '
|
||||
*PRDECPAD STA OSPAD
|
||||
* STX OSNUM+0
|
||||
* STY OSNUM+1
|
||||
*:PRDEC16 LDY #$08 ; Five digits (5-1)*2
|
||||
*:LP1 LDX #$FF
|
||||
* SEC
|
||||
*:LP2 LDA OSNUM+0
|
||||
* SBC :TENS+0,Y
|
||||
* STA OSNUM+0
|
||||
* LDA OSNUM+1
|
||||
* SBC :TENS+1,Y
|
||||
* STA OSNUM+1
|
||||
* INX
|
||||
* BCS :LP2
|
||||
* LDA OSNUM+0
|
||||
* ADC :TENS+0,Y
|
||||
* STA OSNUM+0
|
||||
* LDA OSNUM+1
|
||||
* ADC :TENS+1,Y
|
||||
* STA OSNUM+1
|
||||
* TXA
|
||||
* BNE :DIGIT
|
||||
* LDA OSPAD
|
||||
* BNE :PRINT
|
||||
* BEQ :NEXT
|
||||
*:DIGIT LDX #'0'
|
||||
* STX OSPAD
|
||||
* ORA #'0'
|
||||
*:PRINT JSR OSWRCH
|
||||
*:NEXT DEY
|
||||
* DEY
|
||||
* BPL :LP1
|
||||
* RTS
|
||||
*:TENS DW 1
|
||||
* DW 10
|
||||
* DW 100
|
||||
* DW 1000
|
||||
* DW 10000
|
||||
|
||||
|
||||
* GSINIT - Initialise for GSTRANS string parsing
|
||||
************************************************
|
||||
* On entry,
|
||||
@ -357,9 +314,26 @@ GSREADOK INY ; Step to next character
|
||||
|
||||
|
||||
* Read a byte from sideways ROM
|
||||
RDROM LDX #$0F ; Returns X=current ROM, Y=0, A=byte
|
||||
LDY #$00 ; We haven't really got any ROMs
|
||||
LDA ($F6),Y ; so just read directly
|
||||
* On entry, X=ROM to read from
|
||||
* On exit, A=byte read, X=current ROM, Y=$00
|
||||
RDROM LDA $F4
|
||||
PHA
|
||||
JSR ROMSELECT ; Page in the required ROM
|
||||
LDY #$00
|
||||
LDA ($F6),Y ; Read the byte
|
||||
PLX
|
||||
|
||||
* Select a sideways ROM
|
||||
* X=ROM to select
|
||||
* All registers must be preserved
|
||||
ROMSELECT CPX $F4
|
||||
BNE :ROMSELOK ; Already selected
|
||||
|
||||
* Insert code here for faking sideways ROMs by loading or otherwise
|
||||
* fetching code to $8000. All registers must be preserved.
|
||||
|
||||
STX $F4 ; Set Current ROM number
|
||||
:ROMSELOK
|
||||
EVENT RTS
|
||||
|
||||
*EVENT LDA #<OSEVENM
|
||||
@ -382,30 +356,33 @@ GSBRKAUX >>> IENTAUX ; IENTAUX does not do CLI
|
||||
IRQBRKHDLR PHA
|
||||
* Mustn't enable IRQs within the IRQ handler
|
||||
* Do not use WRTMAIN/WRTAUX macros
|
||||
BIT $C014
|
||||
STA $C004 ; Write to main memory
|
||||
STA $45 ; $45=A for ProDOS IRQ handlers
|
||||
BPL :NOTAUX
|
||||
STA $C005 ; Write to aux memory
|
||||
:NOTAUX TXA
|
||||
|
||||
TXA
|
||||
PHA
|
||||
CLD
|
||||
TSX
|
||||
INX ; Safe way to do LDA $103,X
|
||||
INX
|
||||
INX
|
||||
LDA $0100,X ; Get PSW from stack
|
||||
LDA $103,X ; Get PSW from stack
|
||||
AND #$10
|
||||
BEQ :IRQ ; IRQ
|
||||
SEC
|
||||
INX
|
||||
LDA $0100,X
|
||||
LDA $0104,X
|
||||
SBC #$01
|
||||
STA FAULT
|
||||
INX
|
||||
LDA $0100,X
|
||||
STA FAULT+0 ; FAULT=>error block after BRK
|
||||
LDA $0105,X
|
||||
SBC #$00
|
||||
STA FAULT+1
|
||||
|
||||
LDA $F4 ; Get current ROM
|
||||
STA BYTEVARBASE+$BA ; Set ROM at last BRK
|
||||
STX OSXREG ; Pass stack pointer
|
||||
LDA #$06 ; Service Call 6 = BRK occured
|
||||
JSR SERVICE
|
||||
LDX BYTEVARBASE+$FC ; Get current language
|
||||
JSR ROMSELECT ; Bring it into memory
|
||||
|
||||
PLA
|
||||
TAX
|
||||
PLA
|
||||
@ -415,7 +392,7 @@ IRQBRKHDLR PHA
|
||||
:IRQ >>> XF2MAIN,A2IRQ ; Bounce to Apple IRQ handler
|
||||
IRQBRKRET
|
||||
>>> IENTAUX ; IENTAUX does not do CLI
|
||||
PLA ; TO DO: Pass on to IRQ1V
|
||||
PLA ; TODO: Pass on to IRQ1V
|
||||
TAX
|
||||
PLA
|
||||
NULLRTI RTI
|
||||
@ -438,7 +415,7 @@ MOSBRKHDLR LDA #<MSGBRK
|
||||
STOP JMP STOP ; Cannot return from a BRK
|
||||
|
||||
MSGBRK DB $0D
|
||||
ASC "ERROR: "
|
||||
ASC 'ERROR: '
|
||||
DB $00
|
||||
|
||||
|
||||
@ -538,27 +515,3 @@ MOSVEND
|
||||
AUXBLK ASC '**ENDOFCODE**'
|
||||
DS $200-13
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user