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-17 01:13:18 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-09-17 01:13:18 +0300
commita95ef293d4c49ac8cc15f1e52000d6548c794990 (patch)
treef9e5c15cb83101c01a58b000e235ae561692771e /misc.asm
parentc1a0b52bc997859f7ba7f0fba0b76c9226ea1e95 (diff)
Refactoring
Diffstat (limited to 'misc.asm')
-rw-r--r--misc.asm69
1 files changed, 69 insertions, 0 deletions
diff --git a/misc.asm b/misc.asm
new file mode 100644
index 0000000..1666f96
--- /dev/null
+++ b/misc.asm
@@ -0,0 +1,69 @@
+RANDOM .rs 2 ; random numbers
+RANDOM_TEMP .rs 1 ; temporary variable for random
+CONSOLE_TYPE .rs 1 ; console type
+
+random_init:
+ lda #$5A
+ sta <RANDOM_TEMP
+ lda %10011101
+ sta <RANDOM
+ lda %01011011
+ sta <RANDOM+1
+ rts
+
+random:
+ lda <RANDOM+1
+ sta <RANDOM_TEMP
+ lda <RANDOM
+ asl a
+ rol <RANDOM_TEMP
+ asl a
+ rol <RANDOM_TEMP
+ clc
+ adc <RANDOM
+ pha
+ lda <RANDOM_TEMP
+ adc <RANDOM+1
+ sta <RANDOM+1
+ pla
+ adc #$11
+ sta <RANDOM
+ lda <RANDOM+1
+ adc #$36
+ sta <RANDOM+1
+ rts
+
+console_detect:
+ ldx #0
+ ldy #0
+ ; Console type detect
+.detect_l:
+ inx
+ bne .detect_s
+ iny
+.detect_s:
+ lda $2002
+ bpl .detect_l
+ lda #$00
+ cpy #$08
+ bne .not_ntsc1
+ ora #$01
+.not_ntsc1:
+ cpy #$09
+ bne .not_ntsc2
+ ora #$01
+.not_ntsc2:
+ cpy #$0A
+ bne .not_pal
+ ora #$02
+.not_pal:
+ cpy #$0B
+ bne .not_dendy
+ ora #$04
+.not_dendy:
+ ldx $5000
+ beq console_detect_not_new_dendy
+ ora #$08
+console_detect_not_new_dendy:
+ sta <CONSOLE_TYPE
+ rts