aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-07 03:57:59 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-07 03:57:59 -0500
commit3ea71335da53364aa228a2066da31f8a14cfebe5 (patch)
treeb3bcd98ab1f44f725320785906b4913db7d0ea28
parent0f4d1ae5280df7ab7603c0c12f94b4d54e74031b (diff)
downloadtaipan-3ea71335da53364aa228a2066da31f8a14cfebe5.tar.gz
take 2 on checkmem
-rw-r--r--Makefile10
-rw-r--r--checkmem.s116
2 files changed, 80 insertions, 46 deletions
diff --git a/Makefile b/Makefile
index 04a5254..43954c4 100644
--- a/Makefile
+++ b/Makefile
@@ -131,16 +131,10 @@ taipan.atr: all
# The game binary is a multi-part binary load file. This rule
# depends on all the pieces, and just concatenates them.
-$(XEX): taimain.xex taifont.xex newtitle.xex comptitle.xex
- perl multixex.pl comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
+$(XEX): checkmem.xex taimain.xex taifont.xex newtitle.xex comptitle.xex
+ perl multixex.pl checkmem.xex comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
perl size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
-# checkmem.xex causes more problems than it solves, leave it
-# disabled until it can be fixed.
-#$(XEX): checkmem.xex taimain.xex taifont.xex newtitle.xex comptitle.xex
-# perl multixex.pl checkmem.xex comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
-# perl size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
-
# Bitmap data for the title screen, 256x184 = 47104 pixels, 8 bits
# per pixel, or 5888 bytes. Displayed in ANTIC mode F (aka GR.8),
# using GTIA narrow playfield. The original title screen for the Apple
diff --git a/checkmem.s b/checkmem.s
index a87bbd2..a88b462 100644
--- a/checkmem.s
+++ b/checkmem.s
@@ -1,10 +1,23 @@
-; initial load segment for taipan. intended to be a tiny (1-sector)
-; routine that checks for the presence of BASIC or a cartridge, and aborts
-; the load if found. Also, it resets RAMTOP to RAMSIZ and does a GRAPHICS
-; 0, to avoid problems with funky loaders leaving the graphics screen
-; in the wrong place (Atarimax flash cart leaves it at $9cxx) or in the
-; wrong graphics mode (Fenders 3-sector loader doesn't set up GR.0).
+; Memcheck needs to do this:
+
+;1. If RAMTOP is >=$C0, go to step 6.
+;2. Attempt to disable BASIC.
+;3. Write some data to $A000, read it back (do twice with 2 different values)
+;4. If we couldn't read back what we wrote, that means there really is a
+; cartridge plugged in. Go to step 8.
+;5. Set RAMTOP to $C0.
+;6. Do a GRAPHICS 0.
+;7. Exit via RTS, so the rest of the game will load.
+;8. Do a GRAPHICS 0.
+;9. Print a "remove cartridge" message
+;10. Wait for a keypress
+;11. Exit to DOS (without loading the rest of the file)
+
+;At no point do we look at RAMSIZ, since it can't be trusted under SDX.
+
+;Note that when we reach step 6, RAMTOP is always $C0 (either it was,
+;or we set it to that).
; cl65 -o checkmem.xex -t none checkmem.s
@@ -12,6 +25,7 @@
start = $0600 ; use page 6 for now
+; homebrew XEX header
.word $ffff
.word start
.word end-1
@@ -27,40 +41,46 @@ msg:
msglen = * - msg - 1
S: .byte "S:",0
+
init:
- lda RAMSIZ
+;1. If RAMTOP is >=$C0, go to step 6.
+ lda RAMTOP
cmp #$c0
- php
+ bcs ramtop_ok
+
+;2. Attempt to disable BASIC.
+; set bit 1 of PORTB. No effect on 400/800/1200XL. Don't
+; touch any other bits in PORTB!
+ lda PORTB
+ ora #$02
+ sta PORTB
+
+;3. Write some data to $A000, read it back (do twice with 2 different values)
+;4. If we couldn't read back what we wrote, that means there really is a
+; cartridge plugged in. Go to step 8.
+ lda #$AA
+ sta $A000
+ cmp $A000
+ bne rom_present
+ lsr
+ sta $A000
+ cmp $A000
+ bne rom_present
+
+;5. Set RAMTOP to $C0.
+ lda #$c0
sta RAMTOP
- ldx #6*$10 ; CLOSE #6
- lda #CLOSE
- sta ICCOM,x
- jsr CIOV
-
- ; GRAPHICS 0
- ldx #6*$10 ; IOCB #6
- lda #OPEN
- sta ICCOM,x
- lda #$1c ; $c = read/write
- sta ICAX1,x
- lda #0 ; aux2 byte zero
- sta ICAX2,x
- lda #<S
- sta ICBAL,x
- lda #>S
- sta ICBAH,x
- jsr CIOV
-
- plp
- bcc have_cart
+;6. Do a GRAPHICS 0.
+;7. Exit via RTS, so the rest of the game will load.
+ramtop_ok:
+ jmp gr_0
- ; if RAM size is $c000 or higher, we're OK, just exit.
- rts
+;8. Do a GRAPHICS 0.
+ jsr gr_0
-have_cart:
- ; if RAM size is below $c000, we have a cartridge (or XL BASIC).
- ; print the "remove cart" message...
+;9. Print a "remove cartridge" message
+rom_present:
lda #<msg
sta FR0
lda #>msg
@@ -73,18 +93,38 @@ msgloop:
dey
bpl msgloop
+;10. Wait for a keypress
sty CH ; y == $ff at this point, clear keyboard
; ...wait for a keystroke...
wait4key:
cpy CH
beq wait4key
+ sty CH ; clear the key so DOS menu won't see it.
- ; ...and do a warmstart.
- jmp WARMSV
+;11. Exit to DOS (without loading the rest of the file)
+ jmp (DOSVEC)
+
+gr_0:
+ ldx #6*$10 ; CLOSE #6
+ lda #CLOSE
+ sta ICCOM,x
+ jsr CIOV
+
+ ; GRAPHICS 0
+ ldx #6*$10 ; IOCB #6
+ lda #OPEN
+ sta ICCOM,x
+ lda #$1c ; $c = read/write
+ sta ICAX1,x
+ lda #0 ; aux2 byte zero
+ sta ICAX2,x
+ lda #<S
+ sta ICBAL,x
+ lda #>S
+ sta ICBAH,x
+ jmp CIOV
end:
.word INITAD
.word INITAD+1
.word init
-
-