Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/coolgirl-multicart/coolgirl-multirom-builder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-09-21 00:12:41 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-09-21 00:12:41 +0300
commit6d1a15a8ad99725f5e3f9d95b30df53d6a434062 (patch)
tree69c9ad7bbd5761315ec23339cf5facedc300a60f /video.asm
parent65f7185ad6e99eab403e9111b12e4c34db54136b (diff)
More build info
Diffstat (limited to 'video.asm')
-rw-r--r--video.asm76
1 files changed, 76 insertions, 0 deletions
diff --git a/video.asm b/video.asm
index 5abb915..6d524a1 100644
--- a/video.asm
+++ b/video.asm
@@ -13,6 +13,8 @@ LAST_LINE_GAME .rs 2
SCROLL_FINE .rs 1 ; fine scroll position
SCROLL_LINES_TARGET .rs 2 ; scrolling target
STAR_SPAWN_TIMER .rs 1 ; stars spawn timer
+ ; for build info
+CHR_RAM_SIZE .rs 1 ; CHR RAM size 8*2^xKB
; constants
CHARS_PER_LINE .equ 32
@@ -913,3 +915,77 @@ saving_warning_hide:
jsr waitblank_simple
jsr clear_screen
rts
+
+detect_chr_ram_size:
+ ; disable PPU
+ lda #%00000000
+ sta $2000
+ sta $2001
+ jsr waitblank_simple
+ jsr enable_chr_write
+ lda #$00
+ sta $2006
+ sta $2006
+ ; store $AA to zero bank
+ sta <CHR_RAM_SIZE
+ lda #$AA
+ sta $2007
+ ; calculate bank number
+.next_size:
+ lda #1
+ ldx CHR_RAM_SIZE
+ ; shift 1 to the left CHR_RAM_SIZE times
+.shift_loop:
+ dex
+ bmi .shift_done
+ asl A
+ beq .end ; overflow check
+ jmp .shift_loop
+.shift_done:
+ ; select this bank
+ jsr select_chr_bank
+ ; store $AA
+ ldx #$00
+ stx $2006
+ stx $2006
+ lda #$AA
+ sta $2007
+ ; check for $AA
+ stx $2006
+ stx $2006
+ ldy $2007 ; dump read
+ cmp $2007
+ bne .end ; check failed
+ ; store $55
+ stx $2006
+ stx $2006
+ lda #$55
+ ; check for $55
+ sta $2007
+ stx $2006
+ stx $2006
+ ldy $2007 ; dump read
+ cmp $2007
+ bne .end ; check failed
+ ; select zero bank
+ lda #0
+ jsr select_chr_bank
+ ; check that $AA is not overwrited
+ stx $2006
+ stx $2006
+ lda #$AA
+ ldy $2007 ; dump read
+ cmp $2007
+ bne .end ; check failed
+ ; OK! Let's check next bank
+ inc <CHR_RAM_SIZE
+ jmp .next_size
+.end:
+ lda #0
+ jsr select_chr_bank
+ lda #0
+ sta $2006
+ sta $2006
+ sta $2007
+ jsr disable_chr_write
+ rts