mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Add irq handling, PAL/NTSC detection and clock()
This commit is contained in:
parent
76fae9da82
commit
7c12916718
@ -1,16 +1,17 @@
|
||||
.export _zonecounter
|
||||
.export _paldetected
|
||||
.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"
|
||||
|
||||
INPTCTRL = $01
|
||||
OFFSET = $38
|
||||
CTRL = $3c
|
||||
|
||||
.segment "STARTUP"
|
||||
start:
|
||||
@ -38,6 +39,29 @@ start:
|
||||
jsr zerobss
|
||||
jsr initlib
|
||||
|
||||
; Examine machine type as we need the info early
|
||||
vboff: lda MSTAT
|
||||
bmi vboff
|
||||
vbon: lda MSTAT
|
||||
bpl vbon
|
||||
vboff2: lda MSTAT
|
||||
bmi vboff2
|
||||
lda #$00
|
||||
sta _paldetected
|
||||
jmp mtsta
|
||||
count: sta WSYNC
|
||||
sta WSYNC
|
||||
dec _paldetected
|
||||
mtsta: lda MSTAT
|
||||
bpl count
|
||||
lda _paldetected
|
||||
cmp #$78
|
||||
bcc mtntsc
|
||||
lda #$01
|
||||
jmp mtpal
|
||||
mtntsc: lda #$00
|
||||
mtpal: sta _paldetected
|
||||
|
||||
; Call main program (pass empty command line)
|
||||
jsr push0 ; argc
|
||||
jsr push0 ; argv
|
||||
@ -50,7 +74,7 @@ _exit:
|
||||
|
||||
NMIHandler:
|
||||
inc _zonecounter
|
||||
rti
|
||||
jmp IRQStub
|
||||
|
||||
IRQHandler:
|
||||
rti
|
||||
@ -58,6 +82,9 @@ IRQHandler:
|
||||
.segment "DATA"
|
||||
_zonecounter:
|
||||
.byte 0
|
||||
_paldetected:
|
||||
.byte 0 ; 0 = NTSC, 1 = PAL
|
||||
|
||||
|
||||
.segment "ENCRYPTION"
|
||||
.res 126, $ff ; Reserved for encryption
|
||||
|
Loading…
x
Reference in New Issue
Block a user