1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00
cc65/libsrc/atari7800/crt0.s

72 lines
2.0 KiB
ArmAsm
Raw Normal View History

2022-04-16 16:16:14 +00:00
.export _zonecounter
.export __STARTUP__ : absolute = 1
.export _exit
.import __ROM_START__
.import __RAM3_START__, __RAM3_SIZE__
.import initlib, donelib
.import zerobss, copydata
.import IRQStub
.import push0, _main
.include "atari7800.inc"
.include "zeropage.inc"
2022-03-01 05:37:07 +00:00
INPTCTRL = $01
.segment "STARTUP"
start:
; Startup sequence recommended by Atari.
; See the 7800 standards document.
sei ; Initialize 6502
cld
lda #$07 ; Lock machine in 7800 mode
2022-04-17 14:06:22 +00:00
sta INPTCTRL
2022-03-01 05:37:07 +00:00
lda #$7f ; DMA off
sta CTRL
ldx #0 ; OFFSET must always be 0
stx OFFSET
stx INPTCTRL ; Make sure joysticks don't freeze
dex ; Stack pointer = $ff
txs
2022-04-17 14:06:22 +00:00
; Set up parameter stack
2022-03-01 05:37:07 +00:00
lda #<(__RAM3_START__ + __RAM3_SIZE__)
sta sp
lda #>(__RAM3_START__ + __RAM3_SIZE__)
sta sp+1
jsr copydata
jsr zerobss
jsr initlib
; Call main program (pass empty command line)
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main
_exit:
jsr donelib
jmp start
2022-04-17 14:06:22 +00:00
NMIHandler:
2022-03-01 05:37:07 +00:00
inc _zonecounter
2022-04-16 16:16:14 +00:00
jmp IRQStub
2022-03-01 05:37:07 +00:00
IRQHandler:
rti
.segment "DATA"
_zonecounter:
.byte 0
.segment "ENCRYPTION"
.res 126, $ff ; Reserved for encryption
Lfff8: .byte $ff ; Region verification (always $ff)
Lfff9: .byte $f7 ; Use last 4096 bytes only for encryption
;;;Lfff9: .byte <(((__ROM_START__/4096)<<4) | 7)
.segment "VECTORS"
.word NMIHandler
.word start
.word IRQHandler