diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2018-08-28 13:39:33 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2018-08-28 13:39:33 +0300 |
commit | 49ea09ce059c75d79e886b45e979be8d49be09d4 (patch) | |
tree | 2c9b64bf6e246c477d99ac618bfcd88237908455 /misc.asm |
First commit
Diffstat (limited to 'misc.asm')
-rw-r--r-- | misc.asm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/misc.asm b/misc.asm new file mode 100644 index 0000000..8a5435e --- /dev/null +++ b/misc.asm @@ -0,0 +1,65 @@ +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
+ ; Определяем тип консоли
+.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:
+ sta <CONSOLE_TYPE
+ rts
|