aboutsummaryrefslogtreecommitdiff
path: root/bank7.s
diff options
context:
space:
mode:
Diffstat (limited to 'bank7.s')
-rw-r--r--bank7.s88
1 files changed, 70 insertions, 18 deletions
diff --git a/bank7.s b/bank7.s
index 3459aa0..1ddb55a 100644
--- a/bank7.s
+++ b/bank7.s
@@ -1,31 +1,57 @@
+; bank 7 of the cartridge image, to be built with -t none.
+; this bank is the fixed bank, always mapped at $a000-$bfff, in
+; the "left cartridge" area.
+
+ .macpack atari ; for scrcode (screen code) macro
+
.include "atari.inc"
-font = $9c00
-CCNTL = $d500
+; zero page temporaries
destptr = FR0
srcptr = FR1
+
+; where the romable_taimain code was org'ed.
codedest = $0400
+; address of the font, which lives in bank 3 of the cart.
+font = $9c00
+
+; cc65's atari.inc fails to define this standard Atari label.
+CCNTL = $d500
+
+; cart_trailer is my name for what the OS calls CARTLOC.
+; cc65's atari.inc doesn't define it either.
cart_trailer = $bffa
+
.org $a000 ; left cartridge
screendata:
+ ; uncompressed title screen bitmap, $1700 bytes
.incbin "titledata.dat"
.res $44, $ff ; fudge factor, keep the DL from crossing a 1K boundary
+
+ ; newtitle.s is the display list and menu code. CART_TARGET is used
+ ; for conditional assembly (to make it work from ROM).
CART_TARGET = 1
.include "newtitle.s"
-; copy 7680 bytes from $8000-$9dff to (destptr).
-; on exit, destptr points to the next 7680 byte chunk.
-copy_30_pages:
+; copy_31_pages:
+; copy 7936 bytes from $8000-$9dff to (destptr).
+; on exit, destptr points to the next 7936 byte chunk.
+
+; copy_x_pages:
+; as above, but accepts number of pages to copy in X register.
+
+copy_31_pages:
+ ldx #$1f
+copy_x_pages:
lda #$0
tay
sta srcptr
lda #$80
sta srcptr+1
- ldx #$1e
@copypage:
lda (srcptr),y
sta (destptr),y
@@ -38,7 +64,27 @@ copy_30_pages:
init:
rts
+mem_msg:
+ scrcode "Sorry, this game requires at least 32K"
+mem_msg_len = * - mem_msg - 1
+
+memory_error:
+ lda #$20 ; red BG
+ sta COLOR2
+ ldy #mem_msg_len
+@mloop:
+ lda mem_msg,y
+ sta (SAVMSC),y
+ dey
+ bpl @mloop
+@hang:
+ bmi @hang
+
cartstart:
+ lda RAMTOP
+ cmp #$80
+ bne memory_error
+
; turn off ANTIC DMA to speed up copying to RAM
lda #0
sta SDMCTL
@@ -51,35 +97,41 @@ cartstart:
sta destptr+1
lda #0 ; bank 0...
sta CCNTL ; ...select it
- jsr copy_30_pages
+ jsr copy_31_pages
lda #1 ; bank 1...
sta CCNTL ; ...select it
- jsr copy_30_pages
+ jsr copy_31_pages
lda #2 ; bank 2...
sta CCNTL ; ...select it
- jsr copy_30_pages
+ jsr copy_31_pages
lda #3 ; bank 3...
sta CCNTL ; ...select it
- jsr copy_30_pages
+ ldx #(>BANK3SIZE)+1 ; BANK3SIZE defined on the command line
+ jsr copy_x_pages
+
+ .out .sprintf("BANK3SIZE %x (%x pages)", BANK3SIZE, (>BANK3SIZE)+1)
; leave bank 3 enabled, as it has our custom font in it
-; set up display list
- ;lda #34
- ;sta SDMCTL
- ;lda #>font
- ;sta CHBAS
lda #1
- sta COLDST ; System Reset = reboot
- jsr start ; from newtitle.s
- jsr $0400 ; run the game (romable_taimain)
+ sta COLDST ; System Reset = reboot
+ jsr start ; 'start' is from newtitle.s
+ jsr codedest ; run the game (romable_taimain)
jmp cartstart ; redisplay title screen if "play again? N"
.if * > cart_trailer
.fatal "bank7 code too large"
+ .else
+ .out .sprintf("=> %d bytes free in bank 7", cart_trailer - *)
.endif
+ ; fill with 1 bits until the cart trailer
.res cart_trailer - *, $ff
+
+ ; trailer (some docs called it a 'header' but, eh, it doesn't come at
+ ; the head of the cart...)
+ ; see Mapping the Atari's entry for 'Cartridge B' or the Tech Ref Manual
+ ; for a description of this.
.word cartstart ; entry point
.byte 0 ; 0 = cartridge present
.byte 4 ; init and run the cart, don't boot the disk, non-diagnostic