Detect CBM
Suche
Index
FAQ
Kontakt
Zurück
;---------------------------------------------------------
!to "detectcbm.prg",cbm
; Basicstart
*= $0400
!byte $00,$0c,$08,$0a,$00,$9e,$31,$30,$33,$39,$00,$00,$00,$00
; main
*=$040f

;--------------------------------------------------
    chrout = $ffd2  ;  print a char on screen
;--------------------------------------------------
    bas1 = $e180    ;  "***" in power on message (Basic 1) 
    bas2 = $e1c4    ;  "###" in power on message (Basic 2)
;--------------------------------------------------

menu:            
                 lda #$93              ; clear screen
                 jsr chrout
                 lda #$0e              ; set charmode
                 sta $e84c
                 jsr detect            ; resistance is futile .. We will add your           
                 rts                   ; technological distinctiveness to our own ;) 
;--------------------------------------------------    
; Try to detect Basic
;--------------------------------------------------    
detect:
                 ldx #00
-                lda $dea4,x           ; Basic 4 detect
                 cmp basic4,x          ; test for "*** Commodore Basic 4.0 ***" 
                 bne +
                 inx
                 cpx #27
                 bne -  
                 jsr bas4found 
                 rts 
+                ldx #$00              ; Basic 1 detect
-                lda bas1,x            ; test for "***" in $e180 : "*** Commodore Basic ***"
                 cmp #$2a 
                 bne +
                 inx
                 cpx #2
                 bne -  
                 rts 
+                ldx #$00              ; Basic 2 detect
-                lda bas2,x            ; test for "###" in $e1c4 : "### Commodore Basic ###" 
                 cmp #$23 
                 beq bas2found 
                 bne +
                 inx
                 cpx #2
                 bne -  
                 jsr bas2found 
                 jmp menu  
+                ldy #$00              
-                lda unkroms,y         ; point text
                 sta $8000,y           ; drop some text on the screen 
                 iny 
                 cpy #39          
                 bne -
                 rts
               
;--------------------------------------------------    
; Check for memory
;--------------------------------------------------    


bas1found:       lda #'1'
                 sta pettext+6         ; insert "1" in text
                 lda 133               ; old pet mem test
checkmem         cmp #32               ; check for 8K
                 bne +    
                 lda #'8'
                 sta pettext+30        ; "8"
                 jmp txtout
+                cmp #64               ; check for 16K
                 bne ++
                 lda #'1'
                 sta pettext+29        ; "1"
                 lda #'6' 
                 sta pettext+30        ; "6"
                 jmp txtout
++               cmp #128              ; check for 16K
                 bne unkmem
                 lda #'3'
                 sta pettext+29        ; "3" 
                 lda #'2'
                 sta pettext+30        ; "2"
                 jmp txtout
unkmem           lda #'?'              ; unknown size 
                 sta pettext+29        ; "?" 
                 sta pettext+30        ; "?"                 

txtout:          ldy #$00              
-                lda pettext,y         ; point text
                 sta $8000,y           ; drop some text on the screen 
                 iny 
                 cpy #39          
                 bne -
                 rts 

bas2found:       lda #'2'
                 sta pettext+6         ; insert "2" in text
                 lda 51
                 jsr checkmem 
                 rts 

bas4found:       lda #'4'
                 sta pettext+6         ; insert "4" in text
                 lda 51
                 cmp #31               ; check for 8K
                 bne +    
                 lda #'8'
                 sta pettext+30        ; "8"
                 jmp txtout         
+                cmp #63               ; check for 16K
                 bne ++
                 lda #'1'
                 sta pettext+29        ; "1"
                 lda #'6' 
                 sta pettext+30        ; "6"
                 jmp txtout
++               cmp #127              ; check for 16K
                 bne unkmem
                 lda #'3'
                 sta pettext+29        ; "3" 
                 lda #'2'
                 sta pettext+30        ; "2"
                 ldx #00               ; crtc check
-                lda crtc,x            ; check a few editor-rom bytes
                 cmp $e000,x
                 bne +
                 inx
                 cpx #8
                 bne -
                 lda #'8' 
                 sta pettext+18       ; "8"0 column
                 bne ++
+                jsr txtout
                 rts
++               lda #%11111000        ; cbm 8x96 check 
                 sta $fff0
                 sei
                 ldx #$00
-                lda testbytes,x
                 sta $c000,x
                 inx
                 cpx #20
                 bne -  
                 ldx #$00
-                lda $c000,x
                 cmp testbytes,x
                 bne +
                 inx
                 cpx #20
                 bne -
                 cli  
                 lda #$00
                 sta $fff0
                 ldy #$00              
-                lda cbm8296,y         
                 sta $8372,y           ; drop some text on the screen 
                 iny 
                 cpy #$10          
                 bne -
                 lda #$04
                 sta machine           ; set machine: Basic4/8296 
+                jsr txtout 
                 rts

machine !by $00

;-------------------------------------------------- 
; Basic 4 and CRTC bytes for comparing
;--------------------------------------------------
basic4  !byte $2A,$2A,$2A,$20,$43,$4f,$4D,$4D ;*** comm ; $dea4
        !byte $4F,$44,$4F,$52,$45,$20,$42,$41 ;odore ba 
        !byte $53,$49,$43,$20,$34,$2E,$30,$20 ;sic 4.0 
        !byte $2A,$2A,$2A,$0D,$0D,$00         ;***... 
crtc    !byte $4C,$4B,$E0,$4C,$A7,$E0,$4C,$16,$E1  ; editor rom $e000 (cbm 8000)

testbytes !PET "may there any ram ? "
cbm8296 !PET "cbm 8x96"
pettext !PET "basic   detected (40 column)    k        "
unkroms !PET "basic not detected !                     "

 

Letzte Änderung: 2019-01-04 09:54:08
  Rubrik:  CBM PET
Rubriken-Übersicht
 9 Besucher online 

Valid XHTML 1.0 Transitional Valid CSS!