4cade/src/hw.memcheck.a

80 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 clear if 64K detected
; C set if 64K not detected
2018-08-30 17:07:21 +00:00
; all other flags and registers clobbered
; ROM in memory (not LC RAM bank)
;------------------------------------------------------------------------------
Has64K
+READ_RAM1_WRITE_RAM1
2018-08-30 17:07:21 +00:00
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
+READ_ROM_NO_WRITE
2018-08-30 17:07:21 +00:00
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
2019-10-09 02:15:23 +00:00
; zp $80-$9F clobbered
2018-08-29 19:27:30 +00:00
; 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
+READ_ROM_NO_WRITE
sta STOREOFF
2019-06-27 14:55:07 +00:00
lda ROM_MACHINEID
2020-08-05 23:01:22 +00:00
cmp #$A0
beq + ; Spectrum ED
2018-08-29 19:27:30 +00:00
cmp #6
bne @no ; earlier than //e -> no 128K
2020-08-05 23:01:22 +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
2019-10-09 02:15:23 +00:00
sta $0C00
2018-08-29 19:27:30 +00:00
sta $0800
2019-10-09 02:15:23 +00:00
lda $0C00
2018-08-27 19:39:08 +00:00
cmp #$EE
2018-08-29 19:27:30 +00:00
bne @no
2019-10-09 02:15:23 +00:00
asl $0C00
2018-08-29 19:27:30 +00:00
asl
2019-10-09 02:15:23 +00:00
cmp $0C00
2018-08-29 19:27:30 +00:00
bne @no
cmp $0800
2019-10-09 02:15:23 +00:00
bne @yes
2019-10-08 02:34:52 +00:00
@no clc
2019-10-09 02:15:23 +00:00
+HIDE_NEXT_BYTE
@yes sec
2018-08-29 19:27:30 +00:00
@finish sta WRITEMAINMEM
2018-08-27 19:39:08 +00:00
sta READMAINMEM
2018-08-29 19:27:30 +00:00
rts
@checklen=*-@checker