 .OPT NO LIST›;  SAVE #D1:INIT.M65›;›;›;  LOAD #D1:DISKOPS.M65›;›; *= $C290›  LIST  › .PAGE "Initiation"›;›RESET› SEI         Perform warm› LDA TRIG3   start unless› CMP GINTLK  cart pulled or› BNE POWRUP  inserted› ROR A› BCC ?NOCART› JSR ?CARTCSUM Check cart› BNE POWRUP  boot if invalid›;›?NOCART› LDA COLDST  Boot if› BNE POWRUP  flag non-0› LDA #$FF    value for warmst› BNE ?SETRAM Go always›;›RESET1› SEI         exec reset key› LDX #$8C    or vector›;›?DELAY› DEY         Nested delay› BNE ?DELAY  loops› DEX › BNE ?DELAY› LDA PUPBT1  Check ram› CMP #$5C    integrity› BNE POWRUP› LDA PUPBT2› CMP #$93› BNE POWRUP› LDA PUPBT3› CMP #$25› BEQ RESET   Select warm/cold›;›POWRUP› LDA #0      Exec cold start›;›?SETRAM› STA WARMST  Preset ram› SEI         for cold or› CLD         warm start› LDX #$FF    continuation› TXS › JSR ?ANYCART Init cart or› LDA #1      basic or kill› STA NGFLAG  basic› LDA WARMST› BNE ?CLRLORAM Skip on reset› LDA #0      Test and clear› LDY #8      all ram except  *› STA RAMLO   first 8 bytes› STA RAMHI›;›?TESTRAM› LDA #$FF› STA (RAMLO),Y› CMP (RAMLO),Y› BEQ ?CLRRAM› LSR NGFLAG›;›?CLRRAM› LDA #0› STA (RAMLO),Y› CMP (RAMLO),Y› BEQ ?NXTBYT› LSR NGFLAG›;›?NXTBYT› INY › BNE ?TESTRAM› INC RAMHI› LDX RAMHI› CPX TRAMSZ› BNE ?TESTRAM› LDA # <BYE  Default› STA DOSVEC  dosvec› LDA # >BYE› STA DOSVEC+1› LDA PORTB› AND #$7F    Enable self› STA PORTB   test rom› JSR VFR     Check first 8k› BCS ?ROMERR of rom› JSR VSR     and 2nd› BCC ?ROMTESTDONE›;›?ROMERR› LSR NGFLAG  Flag err›;›?ROMTESTDONE› LDA PORTB› ORA #$80    Kill self› STA PORTB   test rom› LDA #$FF› STA COLDST› BNE ?SETBFLG Go always›;›?CLRLORAM› LDX #0› LDA DERRF   E: opened ok?› BEQ ?CLRP23›  ASTX  APPMHI No, show no *›  ASTX  APPMHI+1 memory    *› TXA ›;›?CLRP23› STA VDSLST,X Clear all› CPX #$ED    of page 2 and› BCS ?SKIPFLGS page 3 except› STA DDEVIC,X basicf, etc.›;›?SKIPFLGS› DEX › BNE ?CLRP23› LDX #16     Clear $11-$7F **›;›?CLRZ› STA LNFLG,X› INX › BPL ?CLRZ›;›?SETBFLG› LDX #0› LDA PORTB› AND #2      Check bit 1› BEQ ?SETBFLG2 Go if Basic on› INX         else flag it off›;›?SETBFLG2› STX BASICF› LDA #$5C    Set check values› STA PUPBT1› LDA #$93› STA PUPBT2› LDA #$25› STA PUPBT3› LDA #2      Margins› STA LMARGN› LDA #39› STA RMARGN› LDA PAL     Keyboard for› AND #$0E    pal or ntsc?› BNE ?SETNTSC› LDA #5      Set for pal› LDX #1› LDY #40› BNE ?SETKBD Go always›;›?SETNTSC› LDA #6      Set for ntsc› LDX #0› LDY #48›;›?SETKBD› STA KEYREP› STX PALNTS› STY KRPDEL› LDX #37›;›?VLOOP7› LDA ?INTVECS,X Copy› STA VDSLST,X vectors› DEX › BPL ?VLOOP7› LDX #14›;›?HTLOOP› LDA ?DEVTABLE,X copy› STA HATABS,X hatabs› DEX › BPL ?HTLOOP› JSR ?INITRAM Init devices› CLI › LDA NGFLAG  Bad ram?› BNE ?RAMOK  Go if not› LDA PORTB   Enable self› AND #$7F    test rOM› STA PORTB› LDA #2      normal chars› STA CHACT   and cursor› LDA # >CHARSET1› STA CHBAS› JMP XRAMERR To selftest›;›?RAMOK› LDX #0› STX TRAMSZ› LDX RAMSIZ  Look for cart› CPX #$B0› BCS ?OPNEDITOR› LDX CARTFLG› BNE ?OPNEDITOR› INC TRAMSZ  Got one, calc› JSR ?CARTCSUM csum and› JSR ?INITCART init it›;›?OPNEDITOR› LDA #3    Open E:› LDX #0› STA ICCOM,X› LDA # <ENAME› STA ICBAL,X› LDA # >ENAME› STA ICBAH,X› LDA #12› STA ICAX1,X› JSR CIOV› BPL ?EWAIT› JMP RESET1  Cio error›;›?EWAIT› INX         Nested delay› BNE ?EWAIT  loops› INY › BPL ?EWAIT› JSR BOOTTAPE Try tape/disk boot› LDA TRAMSZ› BEQ ?NOCARTRIDGE› LDA CARTOPT Option byte b0› ROR A       clear if no disk› BCC ?NODSKWITHCART boot›; jsr boot or jsr (dosini)›;›?NOCARTRIDGE› JSR INITDOS› JSR PHR     Init pd handler›;›?NODSKWITHCART› LDA #0› STA COLDST› LDA TRAMSZ› BEQ ?GOFMS› LDA CARTOPT› AND #4› BEQ ?GOFMS› JMP (CARTRUN)›;›?GOFMS› JMP (DOSVEC)›;›;›?INITCART› JMP (CARTINI)›;› CLC         Not referenced› RTS ›;›?DEVTABLE› .BYTE 'P› .WORD PRINTV› .BYTE 'C    ;*› .WORD CASETV ;*› .BYTE 'E› .WORD EDITRV› .BYTE 'S› .WORD SCRENV› .BYTE 'K› .WORD KEYBDV›;›MSGBERR› .BYTE "BOOT ERROR",155›;›ENAME› .BYTE "E:",155›;›?INTVECS› .WORD RTI   Vdslst› .WORD ?PLARTI Vprced› .WORD ?PLARTI Vinter› .WORD ?PLARTI vbreak› .WORD KIR   Vkeybd› .WORD XSERIN Vserin› .WORD XSEROUT Vseror› .WORD XSEROC Vseroc› .WORD ?PLARTI Vtimr1› .WORD ?PLARTI Vtimr2› .WORD ?PLARTI Vtimr4› .WORD ?REGIRQ Vimirq› .WORD 0     Cdtmv1› .WORD 0     Cdtmv2› .WORD 0     Cdtmv3› .WORD 0     Cdtmv4› .WORD 0     Cdtmv5› .WORD DOSYSBV Vvblki› .WORD DOXITBV Vvblkd›;›?ANYCART› LDA TRIG3› ROR A› BCC ?BASICOFF› LDA CARTFLG› BNE ?BASICOFF› LDA CARTOPT If -ve cart is› BPL ?BASICOFF diagnostic› JMP (CARTINI)›;›?BASICOFF› JSR ?INIHDWARE› LDA PORTB   Kill basic rom› ORA #2› STA PORTB› LDA WARMST  If cold start› BEQ ?OPTION? go check option› LDA BASICF  If on reset see› BNE ?RAMTOP? if it should be› BEQ ?ENABLEBASIC on›;›?OPTION?› LDA CONSOL  ;*› AND #4› BEQ ?RAMTOP?›;›?ENABLEBASIC› LDA PORTB› AND #$FD› STA PORTB›;›?RAMTOP?› LDA #0      Find top of› TAY         ram› STA RAMHI› LDA #$28› STA RAMHI+1 ramhi aka tramsz›;›?NEXTPG› LDA (RAMHI),Y Read 1st› EOR #$FF    byte. Toggle› STA (RAMHI),Y and compare› CMP (RAMHI),Y› BNE ?TOPFOUND› EOR #$FF    Restore byte› STA (RAMHI),Y Compare again› CMP (RAMHI),Y› BNE ?TOPFOUND› INC RAMHI+1› BNE ?NEXTPG›;›?TOPFOUND› RTS ›;›;›?CARTCSUM› LDA #0     Calculate› TAX         cartridge C/sum› CLC         and exit with›;›?CSLOOP› ADC $BFF0,X ; s valid› INX › BNE ?CSLOOP› CMP CARTCK› STA CARTCK› RTS ›;›?INIHDWARE› LDA #0    Hardware› TAX         init routines› STA PBCTL›;›?HZLOOP› STA HPOSP0,X Write 0› STA DMACTL,X to all regs in› STA AUDF1,X gtia pokey and› CPX #1      antic but skip› BEQ ?SKIPPIA portb› STA PORTA,X›;›?SKIPPIA› INX › BNE ?HZLOOP› LDA #$3C› STA PBCTL   Set portB› LDA #$FF    all pins to› STA PORTB   output› LDA #$38    Set ports for› STA PACTL   direction› STA PBCTL   control (b3=1)› LDA #0› STA PORTA   All input› LDA #$FF› STA PORTB   All output› LDA #$3C    Ports as regs› STA PACTL   Motor off› STA PBCTL   Periph ctl id› LDA PORTB   Clear any ints› LDA PORTA› LDA #$22    Set Pokey for› STA SKCTL   kbd & clock out› LDA #$A0    Set channels› STA AUDC3   3&4 to pure tone› STA AUDC4› LDA #$28    Join ch 3/4› STA AUDCTL  at 1.79mhz› LDA #$FF    Clear serout› STA SEROUT› RTS ›;›?INITRAM› DEC BRKKEY  Software› LDA # <?XBRKKY and ram› STA BRKKY   init› LDA # >?XBRKKY› STA BRKKY+1› LDA TRAMSZ› STA RAMSIZ› STA MEMTOP+1› LDA #0› STA MEMTOP› LDA # <$0700› STA MEMLO› LDA # >$0700› STA MEMLO+1› JSR EDITRV+12 Init devices› JSR SCRENV+12› JSR KEYBDV+12› JSR PRINTV+12› JSR CASETV+12 ;*› JSR CIOINV  Init i/o› JSR SIOINV  handlers› JSR INTINV› JSR DISKIV› LDA # <PDEVID point vpirq to› STA VPIRQ   pll device id› LDA # >PDEVID routine› STA VPIRQ+1› JSR GPDVV+12 Init any found› LDA CONSOL  Check start key *› AND #1      and set flag for› EOR #1      cassette boot.› STA CKEY    Is 1 for tape› RTS ›