X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Flynx%2Fcrt0.s;h=397d85bb35ec1ce739e7fb562d012166b1091110;hb=5f006333bf97d98099a4702320f60c3551a5bbe5;hp=1d8e19de3f131bd5cafb6e7246b058bcf4dbe679;hpb=4c06d021c6fa6303c96486130497eb45f3991d68;p=cc65 diff --git a/libsrc/lynx/crt0.s b/libsrc/lynx/crt0.s index 1d8e19de3..397d85bb3 100644 --- a/libsrc/lynx/crt0.s +++ b/libsrc/lynx/crt0.s @@ -13,22 +13,22 @@ ; code structure. The C stack is located at the end of the RAM memory ; segment and grows downward. Bastian Schick's executable header is put ; on the front of the fully linked binary (see EXEHDR segment.) -; -; This must be the *first* file on the linker command line ; .include "lynx.inc" .export _exit - .exportzp __iodat,__iodir,__viddma,__sprsys + .export __STARTUP__ : absolute = 1 ; Mark as startup - .import initlib, donelib + .import callirq, initlib, donelib .import zerobss .import callmain .import _main - .import __CODE_LOAD__, __BSS_LOAD__ - .import __RAM_START__, __RAM_SIZE__ + .import __BSS_LOAD__ + .import __INTERRUPTOR_COUNT__ + .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__ .include "zeropage.inc" + .include "extzp.inc" ; ------------------------------------------------------------------------ @@ -36,8 +36,8 @@ .segment "EXEHDR" .word $0880 - .byte >__CODE_LOAD__, <__CODE_LOAD__ - .byte >__BSS_LOAD__, <(__BSS_LOAD__ - 1) + .dbyt __RAM_START__ + .dbyt __BSS_LOAD__ - __RAM_START__ + 10 .byte $42,$53 .byte $39,$33 @@ -54,17 +54,6 @@ MikeyInitReg: .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$9 MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29 -; ------------------------------------------------------------------------ -; mikey and suzy shadow registers - - .segment "EXTZP" : zeropage - -__iodat: .res 1 -__iodir: .res 1 -__viddma: .res 1 -__sprsys: .res 1 - - ; ------------------------------------------------------------------------ ; Actual code @@ -105,9 +94,9 @@ __sprsys: .res 1 ; setup the stack - lda #<(__RAM_START__ + __RAM_SIZE__) + lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__) + lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__) sta sp+1 ; Init Mickey @@ -144,9 +133,21 @@ sloop: ldy SuzyInitReg,x jsr zerobss +; If we have IRQ functions, set the IRQ vector +; as Lynx is a console there is not much point in releasing the IRQ + + lda #<__INTERRUPTOR_COUNT__ + beq NoIRQ1 + lda #IRQStub + sei + sta INTVECTL + stx INTVECTH + cli + ; Call module constructors - jsr initlib +NoIRQ1: jsr initlib ; Push arguments and call main @@ -161,3 +162,17 @@ _exit: jsr donelib ; Run module destructors noret: bra noret + .segment "CODE" +IRQStub: + phy + phx + pha + cld + jsr callirq + lda INTSET + sta INTRST + pla + plx + ply + rti +