Applecorn/applecorn.s

246 lines
5.9 KiB
ArmAsm
Raw Normal View History

* APPLECORN.S
* (c) Bobbi 2021 GPLv3
*
* Load an Acorn BBC Micro ROM in aux memory and
2021-07-15 22:16:22 -04:00
* Provide an environment where it can run
*
* Assembled with the Merlin 8 v2.58 assembler on Apple II.
2021-07-15 22:16:22 -04:00
* 14-Oct-2021 XF2MAIN, ENTAUX no longer save/restore STRTL/STRTH.
XC ; 65c02
2021-09-17 21:06:24 -04:00
ORG $4000 ; Load addr of loader in main memory
; Clear of first HGR frame buffer
2021-07-15 22:16:22 -04:00
* Monitor routines
BELL EQU $FBDD
PRBYTE EQU $FDDA
COUT1 EQU $FDED
CROUT EQU $FD8E
HOME EQU $FC58
2021-07-15 22:16:22 -04:00
AUXMOVE EQU $C311
XFER EQU $C314
* Monitor ZP locations
A1L EQU $3C
A1H EQU $3D
A2L EQU $3E
A2H EQU $3F
A4L EQU $42
A4H EQU $43
* Used by XFER
STRTL EQU $3ED
STRTH EQU $3EE
* Reset vector (2 bytes + 1 byte checksum)
RSTV EQU $3F2
* IRQ vector
A2IRQV EQU $3FE
2021-07-15 22:16:22 -04:00
* MLI entry point
MLI EQU $BF00
* IO Buffer for reading file (1024 bytes)
IOBUF0 EQU $0C00 ; For loading/saving, OSFILE, *.
IOBUF1 EQU $1000 ; Four open files for langs
IOBUF2 EQU $1400
IOBUF3 EQU $1800
IOBUF4 EQU $1C00
2021-07-15 22:16:22 -04:00
2021-07-28 20:47:26 -04:00
* 512 byte buffer sufficient for one disk block
2021-09-17 21:06:24 -04:00
BLKBUF EQU $9000 ; Can't use $400 as ProDOS uses
BLKBUFEND EQU $9200 ; 'hidden' bytes within screen
2021-07-15 22:16:22 -04:00
* 512 byte buffer for file copy (*COPY)
2021-09-17 21:06:24 -04:00
COPYBUF EQU $9200 ; File copy needs separate buffer
*COPYBUFEND EQU $9400
2021-09-21 22:05:42 -04:00
* Location of FDraw library in main memory
FDRAWADDR EQU $9400
* Location of FDraw library in main memory
FONTADDR EQU $A900
2021-07-15 22:16:22 -04:00
* Address in aux memory where ROM will be loaded
AUXADDR EQU $8000
* Address in aux memory where the MOS shim is located
AUXMOS1 EQU $2000 ; Temp staging area in Aux
EAUXMOS1 EQU $5000 ; End of staging area
AUXMOS EQU $D000 ; Final location in aux LC
2021-07-15 22:16:22 -04:00
2021-07-31 20:37:18 -04:00
* Called by code running in main mem to invoke a
* routine in aux memory
XF2AUX MAC
SEI ; Disable IRQ before XFER
2021-08-14 01:18:35 -04:00
LDX $C08B ; R/W LC RAM, bank 1
LDX $C08B
LDX #<]1
STX STRTL
LDX #>]1
STX STRTH
2021-07-31 20:37:18 -04:00
SEC ; Use aux memory
BIT RTSINSTR ; Set V: use alt ZP and LC
2021-07-31 20:37:18 -04:00
JMP XFER
2021-07-30 16:49:34 -04:00
EOM
2021-07-31 21:39:05 -04:00
* Called by code running in aux mem to invoke a
* routine in main memory
XF2MAIN MAC
* LDX STRTL ; No longer needed
* STX STRTBCKL ; $03E0-$03FF reserved for memory
* LDX STRTH ; switching
* STX STRTBCKH
2021-08-14 01:18:35 -04:00
LDX #<]1
STX STRTL
LDX #>]1
STX STRTH
SEI ; Disable IRQ before XFER
2021-07-31 20:19:15 -04:00
TSX
STX $0101 ; Save alt SP
LDX $0100 ; Load main SP into X
2021-07-31 21:39:05 -04:00
CLC ; Use main mem
CLV ; Use main ZP and LC
JMP XFER
2021-07-30 17:33:50 -04:00
EOM
2021-07-31 18:58:59 -04:00
* Macro called on re-entry to aux memory
* Careful: This enables IRQ - not for use in ISR
2021-07-31 18:58:59 -04:00
ENTAUX MAC
LDX $0101 ; Recover alt SP
TXS
CLI ; Re-enable IRQ after XFER
* LDX STRTBCKL ; No longer needed
* STX STRTL ; $03e0-$03FF reserved for memory
* LDX STRTBCKH ; switching
* STX STRTH
2021-07-30 17:33:50 -04:00
EOM
2021-07-31 18:58:59 -04:00
* Macro called on re-entry to main memory
* Careful: This enables IRQ - not for use in ISR
2021-07-31 17:33:08 -04:00
ENTMAIN MAC
TXS ; Main SP already in X
2021-08-14 01:18:35 -04:00
LDX $C081 ; Bank in ROM
LDX $C081
CLI ; Re-enable IRQ after XFER
2021-07-31 17:33:08 -04:00
EOM
* Macro called on re-entry to aux memory
* For use in interrupt handlers (no CLI!)
IENTAUX MAC
LDX $0101 ; Recover alt SP
TXS
LDX STRTBCKL
STX STRTL
LDX STRTBCKH
STX STRTH
EOM
* Macro called on re-entry to main memory
* For use in interrupt handlers (no CLI!)
IENTMAIN MAC
TXS ; Main SP already in X
LDX $C081 ; Bank in ROM
LDX $C081
EOM
* Enable writing to main memory (for code running in aux)
WRTMAIN MAC
SEI ; Keeps IRQ handler easy
STA $C004 ; Write to main memory
EOM
* Go back to writing to aux (for code running in aux)
WRTAUX MAC
STA $C005 ; Write to aux memory
CLI ; Normal service resumed
EOM
* Manually enable AltZP (for code running in main)
ALTZP MAC
PHP
SEI ; Disable IRQ when AltZP on
LDA $C08B ; R/W LC bank 1
LDA $C08B
STA $C009 ; Alt ZP and LC
EOM
* Manually disable AltZP (for code running in main)
MAINZP MAC
STA $C008 ; Main ZP and LC
LDA $C081 ; Bank ROM back in
LDA $C081
PLP ; Turn IRQ back on
EOM
2021-07-30 16:49:34 -04:00
* Code is all included from PUT files below ...
* ... order matters!
2021-09-06 21:39:36 -04:00
PUT MAINMEM.LDR
2021-09-06 21:38:20 -04:00
PUT MAINMEM.MENU
PUT MAINMEM.FSEQU
PUT MAINMEM.INIT
PUT MAINMEM.SVC
2021-09-23 16:19:35 -04:00
PUT MAINMEM.GFX
PUT MAINMEM.PATH
PUT MAINMEM.WILD
PUT MAINMEM.LISTS
PUT MAINMEM.MISC
PUT AUXMEM.MOSEQU
PUT AUXMEM.INIT
PUT AUXMEM.VDU
PUT AUXMEM.GFX
PUT AUXMEM.HOSTFS
2021-08-14 23:42:06 -04:00
PUT AUXMEM.OSCLI
PUT AUXMEM.BYTWRD
PUT AUXMEM.CHARIO
PUT AUXMEM.MISC
* Automatically save the object file:
2021-08-27 22:47:31 -04:00
SAV APPLECORN
2021-09-06 23:43:42 -04:00
2021-09-10 14:53:24 -04:00
2021-09-10 16:11:57 -04:00
2021-09-16 23:16:05 -04:00
2021-09-17 17:51:11 -04:00
2021-09-21 22:59:11 -04:00
2021-09-30 16:40:32 -04:00
2021-10-13 20:57:16 -04:00
2021-10-14 19:24:26 -04:00
2021-11-13 14:57:05 -05:00
2021-09-22 18:36:05 -04:00
2021-09-21 22:59:11 -04:00