;license:MIT ;(c) 2020 by 4am ; ; initialize program, generate lookup tables and dynamically generated code ; +READ_ROM_NO_WRITE sta PRIMARYCHARSET sta CLR80VID sta STOREOFF sta READMAINMEM sta WRITEMAINMEM jsr ROM_TEXT jsr ROM_HOME jsr ROM_NORMAL jsr ROM_IN0 jsr ROM_PR0 +BUILD_HGR_LOOKUP_TABLES HGRLO, HGRHI jsr InitScrollUp jsr InitScrollDown jsr BuildAcceleratorFunction +ST16 @accelSrc dex - @accelSrc=*+1 lda $FDFD, x sta DisableAccelerator, x dex bpl - - inc FM+2 ; relocate program code to $4000 inc FMDEST+2 lda FM+2 cmp #>LastMover bcc - ldx #$00 FM lda FirstMover, x FMDEST sta $4000, x inx bne FM dec FM+2 dec FMDEST+2 lda FMDEST+2 cmp #$40 bcs FM jsr DisableAccelerator jsr GetMockingboardSlot ;ldx #0 ; [DEBUG] uncomment to disable Mockingboard support cpx #0 beq + ; set up MockingDuet routine with the Mockingboard slot number ; so it works in any slot and not just slot 4 stx MBSLOT01+2 stx MBSLOT02+2 stx MBSLOT03+2 stx MBSLOT04+2 stx MBSLOT05+2 stx MBSLOT06+2 stx MBSLOT07+2 stx MBSLOT08+2 stx MBSLOT09+2 stx MBSLOT10+2 stx MBSLOT11+2 stx MBSLOT12+2 stx MBSLOT13+2 stx MBSLOT14+2 stx MBSLOT15+2 stx MBSLOT16+2 stx MBSLOT17+2 stx MBSLOT18+2 stx MBSLOT19+2 stx MBSLOT20+2 stx MBSLOT21+2 stx MBSLOT22+2 stx MBSLOT23+2 stx MBSLOT24+2 stx MBSLOT25+2 stx MBSLOT26+2 stx MBSLOT27+2 stx MBSLOT28+2 stx MBSLOT29+2 stx MBSLOT30+2 stx MBSLOT31+2 stx MBSLOT32+2 stx MBSLOT33+2 stx MBSLOT34+2 stx MBSLOT35+2 stx MBSLOT36+2 + jmp Start InitScrollUp lda #GENSCROLLUP sta $FF ldy #$00 ldx #$00 @loadleft inx cpx #$55 bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FE jsr StoreAndInc jmp @storeleft + cpx #$6B bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FC jsr StoreAndInc jmp @storeleft + lda #$B9 ; LDA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @storeleft dex cpx #$55 bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FE jsr StoreAndInc jmp @loadright + cpx #$6B bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FC jsr StoreAndInc jmp @loadright + lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @loadright inx cpx #$55 bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FF jsr StoreAndInc jmp @storeright + cpx #$6B bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FD jsr StoreAndInc jmp @storeright + lda #$B9 ; LDA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @storeright dex cpx #$55 bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FF jsr StoreAndInc jmp @next + cpx #$6B bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FD jsr StoreAndInc jmp @next + lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @next inx cpx #$BF +LBNE @loadleft lda #$A9 ; LDA #$00 jsr StoreAndInc lda #$00 jsr StoreAndInc lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc lda #$CA ; DEX jsr StoreAndInc lda #$F0 ; BEQ jsr StoreAndInc lda #$03 jsr StoreAndInc lda #$4C ; JMP jsr StoreAndInc lda #GENSCROLLUP jsr StoreAndInc lda #$60 ; RTS ; /!\ execution falls through here StoreAndInc sta ($FE), y iny bne + inc $FF + rts InitScrollDown lda #GENSCROLLDOWN sta $FF ldy #$00 ldx #$BF @loadleft dex cpx #$55 bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FE jsr StoreAndInc jmp @storeleft + cpx #$6B bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FC jsr StoreAndInc jmp @storeleft + lda #$B9 ; LDA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @storeleft inx cpx #$55 bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FE jsr StoreAndInc jmp @loadright + cpx #$6B bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FC jsr StoreAndInc jmp @loadright + lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @loadright dex cpx #$55 bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FF jsr StoreAndInc jmp @storeright + cpx #$6B bne + lda #$A5 ; LDA/zp jsr StoreAndInc lda #$FD jsr StoreAndInc jmp @storeright + lda #$B9 ; LDA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @storeright inx cpx #$55 bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FF jsr StoreAndInc jmp @next + cpx #$6B bne + lda #$85 ; STA/zp jsr StoreAndInc lda #$FD jsr StoreAndInc jmp @next + lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc @next dex +LBNE @loadleft lda #$A9 ; LDA #$00 jsr StoreAndInc lda #$00 jsr StoreAndInc lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x jsr StoreAndInc lda HGRHI, x jsr StoreAndInc lda #$99 ; STA addr,Y jsr StoreAndInc lda HGRLO, x clc adc #1 jsr StoreAndInc lda HGRHI, x jsr StoreAndInc lda #$CA ; DEX jsr StoreAndInc lda #$F0 ; BEQ jsr StoreAndInc lda #$03 jsr StoreAndInc lda #$4C ; JMP jsr StoreAndInc lda #GENSCROLLDOWN jsr StoreAndInc lda #$60 ; RTS jmp StoreAndInc