4cade/src/memcheck.a

78 lines
2.3 KiB
Plaintext
Raw Normal View History

2018-08-30 17:07:21 +00:00
;------------------------------------------------------------------------------
; Has64K
; Checks whether computer has functioning language card (64K)
;
; in: none
; out: C set if 64K detected
; C clear if 64K not detected
; all other flags and registers clobbered
; ROM in memory (not LC RAM bank)
;------------------------------------------------------------------------------
Has64K
lda LCBANK1 ; read/write LC RAM bank 1
lda LCBANK1
lda #$AA ; test #1 for $D0 page
sta $D000
eor $D000
bne @no
lsr $D000 ; test #2 for $D0 page
lda #$55
eor $D000
bne @no
clc
+HIDE_NEXT_BYTE
@no sec
sta ROMONLY
rts
2018-08-27 19:39:08 +00:00
;------------------------------------------------------------------------------
; Has128K
2018-08-29 19:27:30 +00:00
; Checks whether computer has functioning auxiliary memory (128K)
2018-08-27 19:39:08 +00:00
;
2018-08-29 19:27:30 +00:00
; in: none
; out: C set if 128K detected
; C clear if 128K not detected
; all other flags and registers clobbered
; zp $80-$9F clobbered
; ROM in memory (not LC RAM bank)
2018-08-27 19:39:08 +00:00
;
2018-08-29 19:27:30 +00:00
; adapted from "Prince of Persia" by Jordan Mechner
; (c) 1989 Broderbund Software
; https://github.com/jmechner/Prince-of-Persia-Apple-II/blob/master/01%20POP%20Source/Source/BOOT.S#L119
2018-08-27 19:39:08 +00:00
;------------------------------------------------------------------------------
Has128K
2018-08-29 19:27:30 +00:00
sta ROMONLY ; need ROM for machine ID byte
2018-08-27 19:39:08 +00:00
lda MACHINEID
2018-08-29 19:27:30 +00:00
cmp #6
bne @no ; earlier than //e -> no 128K
2018-08-27 19:39:08 +00:00
lda SLOT3STATUS
2018-08-29 19:27:30 +00:00
bmi @no ; no 80-column card -> no 128K
ldx #@checklen
- lda @checker,x
sta $80,x
dex
2018-08-27 19:39:08 +00:00
bpl -
2018-08-29 19:27:30 +00:00
jmp $80 ; check if auxmem actually works
2018-08-27 19:39:08 +00:00
@checker
lda #$EE
sta WRITEAUXMEM
sta READAUXMEM
2018-08-29 19:27:30 +00:00
sta $0C00
sta $0800
lda $0C00
2018-08-27 19:39:08 +00:00
cmp #$EE
2018-08-29 19:27:30 +00:00
bne @no
asl $0C00
asl
cmp $0C00
bne @no
cmp $0800
bne @yes
@no clc
2018-08-27 19:39:08 +00:00
+HIDE_NEXT_BYTE
2018-08-29 19:27:30 +00:00
@yes sec
@finish sta WRITEMAINMEM
2018-08-27 19:39:08 +00:00
sta READMAINMEM
2018-08-29 19:27:30 +00:00
rts
@checklen=*-@checker