You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
4.9KB

  1. .PAGE 'INITIALIZATION'
  2. ; START - SYSTEM RESET
  3. ; WILL GOTO ROM AT $8000...
  4. ; IF LOCS $8004-$8008
  5. ; = 'CBM80'
  6. ; ^^^ > THESE HAVE MSB SET
  7. ; KERNAL EXPECTS...
  8. ; $8000- .WORD INITILIZE (HARD START)
  9. ; $8002- .WORD PANIC (WARM START)
  10. ; ... ELSE BASIC SYSTEM USED
  11. ; ******************TESTING ONLY***************
  12. ; USE AUTO DISK/CASSETTE LOAD WHEN DEVELOPED...
  13. ;
  14. START LDX #$FF
  15. SEI
  16. TXS
  17. CLD
  18. JSR A0INT ;TEST FOR $A0 ROM IN
  19. BNE START1
  20. JMP ($8000) ; GO INIT AS $A000 ROM WANTS
  21. START1 STX VICREG+22 ;SET UP REFRESH (.X=<5)
  22. JSR IOINIT ;GO INITILIZE I/O DEVICES
  23. JSR RAMTAS ;GO RAM TEST AND SET
  24. JSR RESTOR ;GO SET UP OS VECTORS
  25. ;
  26. JSR PCINT ;GO INITILIZE SCREEN NEWXXX
  27. CLI ;INTERRUPTS OKAY NOW
  28. JMP ($A000) ;GO TO BASIC SYSTEM
  29. .SKI 4
  30. ; A0INT - TEST FOR AN $8000 ROM
  31. ; RETURNS Z - $8000 IN
  32. ;
  33. A0INT LDX #TBLA0E-TBLA0R ;CHECK FOR $8000
  34. A0IN1 LDA TBLA0R-1,X
  35. CMP $8004-1,X
  36. BNE A0IN2
  37. DEX
  38. BNE A0IN1
  39. A0IN2 RTS
  40. ;
  41. TBLA0R .BYT $C3,$C2,$CD,'80' ;..CBM80..
  42. TBLA0E
  43. .SKI 4
  44. ; RESTOR - SET KERNAL INDIRECTS AND VECTORS (SYSTEM)
  45. ;
  46. RESTOR LDX #<VECTSS
  47. LDY #>VECTSS
  48. CLC
  49. ;
  50. ; VECTOR - SET KERNAL INDIRECT AND VECTORS (USER)
  51. ;
  52. VECTOR STX TMP2
  53. STY TMP2+1
  54. LDY #VECTSE-VECTSS-1
  55. MOVOS1 LDA CINV,Y ;GET FROM STORAGE
  56. BCS MOVOS2 ;C...WANT STORAGE TO USER
  57. LDA (TMP2)Y ;...WANT USER TO STORAGE
  58. MOVOS2 STA (TMP2)Y ;PUT IN USER
  59. STA CINV,Y ;PUT IN STORAGE
  60. DEY
  61. BPL MOVOS1
  62. RTS
  63. ;
  64. VECTSS .WOR KEY,TIMB,NNMI
  65. .WOR NOPEN,NCLOSE,NCHKIN
  66. .WOR NCKOUT,NCLRCH,NBASIN
  67. .WOR NBSOUT,NSTOP,NGETIN
  68. .WOR NCLALL,TIMB ;GOTO BREAK ON A USRCMD JMP
  69. .WOR NLOAD,NSAVE
  70. VECTSE
  71. .PAGE 'INITILIZE CODE'
  72. ; RAMTAS - MEMORY SIZE CHECK AND SET
  73. ;
  74. RAMTAS LDA #0 ;ZERO LOW MEMORY
  75. TAY ;START AT 0002
  76. RAMTZ0 STA $0002,Y ;ZERO PAGE
  77. STA $0200,Y ;USER BUFFERS AND VARS
  78. STA $0300,Y ;SYSTEM SPACE AND USER SPACE
  79. INY
  80. BNE RAMTZ0
  81. ;
  82. ;ALLOCATE TAPE BUFFERS
  83. ;
  84. LDX #<TBUFFR
  85. LDY #>TBUFFR
  86. STX TAPE1
  87. STY TAPE1+1
  88. ;
  89. ; SET TOP OF MEMORY
  90. ;
  91. RAMTBT
  92. TAY ;MOVE $00 TO .Y
  93. LDA #3 ;SET HIGH INITAL INDEX
  94. STA TMP0+1
  95. ;
  96. RAMTZ1 INC TMP0+1 ;MOVE INDEX THRU MEMORY
  97. RAMTZ2 LDA (TMP0)Y ;GET PRESENT DATA
  98. TAX ;SAVE IN .X
  99. LDA #$55 ;DO A $55,$AA TEST
  100. STA (TMP0)Y
  101. CMP (TMP0)Y
  102. BNE SIZE
  103. ROL A
  104. STA (TMP0)Y
  105. CMP (TMP0)Y
  106. BNE SIZE
  107. TXA ;RESTORE OLD DATA
  108. STA (TMP0)Y
  109. INY
  110. BNE RAMTZ2
  111. BEQ RAMTZ1
  112. ;
  113. SIZE TYA ;SET TOP OF MEMORY
  114. TAX
  115. LDY TMP0+1
  116. CLC
  117. JSR SETTOP
  118. LDA #$08 ;SET BOTTOM OF MEMORY
  119. STA MEMSTR+1 ;ALWAYS AT $0800
  120. LDA #$04 ;SCREEN ALWAYS AT $400
  121. STA HIBASE ;SET BASE OF SCREEN
  122. RTS
  123. .SKI 3
  124. BSIT .WOR WRTZ,WRTN,KEY,READ ;TABLE OF INDIRECTS FOR CASSETTE IRQ'S
  125. .PAG 'INITILIZE CODE'
  126. ; IOINIT - INITILIZE IO DEVICES
  127. ;
  128. IOINIT LDA #$7F ;KILL INTERRUPTS
  129. STA D1ICR
  130. STA D2ICR
  131. STA D1PRA ;TURN ON STOP KEY
  132. LDA #%00001000 ;SHUT OFF TIMERS
  133. STA D1CRA
  134. STA D2CRA
  135. STA D1CRB
  136. STA D2CRB
  137. ; CONFIGURE PORTS
  138. LDX #$00 ;SET UP KEYBOARD INPUTS
  139. STX D1DDRB ;KEYBOARD INPUTS
  140. STX D2DDRB ;USER PORT (NO RS-232)
  141. STX SIDREG+24 ;TURN OFF SID
  142. DEX
  143. STX D1DDRA ;KEYBOARD OUTPUTS
  144. LDA #%00000111 ;SET SERIAL/VA14/15 (CLKHI)
  145. STA D2PRA
  146. LDA #%00111111 ;SET SERIAL IN/OUT, VA14/15OUT
  147. STA D2DDRA
  148. ;
  149. ; SET UP THE 6510 LINES
  150. ;
  151. LDA #%11100111 ;MOTOR ON, HIRAM LOWRAM CHAREN HIGH
  152. STA R6510
  153. LDA #%00101111 ;MTR OUT,SW IN,WR OUT,CONTROL OUT
  154. STA D6510
  155. ;
  156. ;JSR CLKHI ;CLKHI TO RELEASE SERIAL DEVICES ^
  157. ;
  158. IOKEYS LDA PALNTS ;PAL OR NTSC
  159. BEQ I0010 ;NTSC
  160. LDA #<SIXTYP
  161. STA D1T1L
  162. LDA #>SIXTYP
  163. JMP I0020
  164. I0010 LDA #<SIXTY ;KEYBOARD SCAN IRQ'S
  165. STA D1T1L
  166. LDA #>SIXTY
  167. I0020 STA D1T1H
  168. JMP PIOKEY
  169. ; LDA #$81 ;ENABLE T1 IRQ'S
  170. ; STA D1ICR
  171. ; LDA D1CRA
  172. ; AND #$80 ;SAVE ONLY TOD BIT
  173. ; ORA #%00010001 ;ENABLE TIMER1
  174. ; STA D1CRA
  175. ; JMP CLKLO ;RELEASE THE CLOCK LINE
  176. ;
  177. ; SIXTY HERTZ VALUE
  178. ;
  179. SIXTY = 17045 ; NTSC
  180. SIXTYP = 16421 ; PAL
  181. .PAGE 'INIT - SYS SUBS'
  182. SETNAM STA FNLEN
  183. STX FNADR
  184. STY FNADR+1
  185. RTS
  186. .SKI 5
  187. SETLFS STA LA
  188. STX FA
  189. STY SA
  190. RTS
  191. .SKI 5
  192. READSS LDA FA ;SEE WHICH DEVICES' TO READ
  193. CMP #2 ;IS IT RS-232?
  194. BNE READST ;NO...READ SERIAL/CASS
  195. LDA RSSTAT ;YES...GET RS-232 UP
  196. PHA
  197. LDA #00 ;CLEAR RS232 STATUS WHEN READ
  198. STA RSSTAT
  199. PLA
  200. RTS
  201. SETMSG STA MSGFLG
  202. READST LDA STATUS
  203. UDST ORA STATUS
  204. STA STATUS
  205. RTS
  206. .SKI 5
  207. SETTMO STA TIMOUT
  208. RTS
  209. .SKI 5
  210. MEMTOP BCC SETTOP
  211. ;
  212. ;CARRY SET--READ TOP OF MEMORY
  213. ;
  214. GETTOP LDX MEMSIZ
  215. LDY MEMSIZ+1
  216. ;
  217. ;CARRY CLEAR--SET TOP OF MEMORY
  218. ;
  219. SETTOP STX MEMSIZ
  220. STY MEMSIZ+1
  221. RTS
  222. .SKI 5
  223. ;MANAGE BOTTOM OF MEMORY
  224. ;
  225. MEMBOT BCC SETBOT
  226. ;
  227. ;CARRY SET--READ BOTTOM OF MEMORY
  228. ;
  229. LDX MEMSTR
  230. LDY MEMSTR+1
  231. ;
  232. ;CARRY CLEAR--SET BOTTOM OF MEMORY
  233. ;
  234. SETBOT STX MEMSTR
  235. STY MEMSTR+1
  236. RTS
  237. .END
  238. ; RSR 8/5/80 CHANGE IO STRUCTURE
  239. ; RSR 8/15/80 ADD MEMORY TEST
  240. ; RSR 8/21/80 CHANGE I/O FOR MOD
  241. ; RSR 8/25/80 CHANGE I/O FOR MOD2
  242. ; RSR 8/29/80 CHANGE RAMTEST FOR HARDWARE MISTAKE
  243. ; RSR 9/22/80 CHANGE SO RAM HANG RS232 STATUS READ
  244. ; RSR 5/12/82 CHANGE START1 ORDER TO REMOVE DISK PROBLEM