-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsyspage.inc
114 lines (83 loc) · 2.41 KB
/
syspage.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
;
; syspage.inc
;
; By Alex Herbert, 2004
;
;
; Call eeprom_readsys at program start to load the
; TV settings from EEPROM into the variable tv_mode.
;
; Call eeprom_writesys to save tv_mode to EEPROM
; after switching modes.
;
; tv_mode:
; bit 7 - 0=NTSC, 1=PAL
; bit 6 - 0=60Hz, 1=50Hz
; bit 5 - Always 0
; bit 4 - Always 0
; bit 3 - Always 0
; bit 2 - Always 0
; bit 1 - Always 0
; bit 0 - Always 0
;
; It is not necessary that your application supports
; all mode combinations.
;
eeprom_readsys
lda #$00 ; Default TV mode = NTSC
sta tv_mode
; Fisrt we set the EEPROM's memory pointer
; to $0000.
jsr i2c_startwrite
bcs eeprom_sysfail ; Device not attached?
lda #$00
jsr i2c_txbyte
lda #$00
jsr i2c_txbyte
jsr i2c_stopwrite
; Now we check for the "ATARIVOX" signature in
; the first 8 bytes.
jsr i2c_startread
ldx #$00
eereadsys_loop
jsr i2c_rxbyte
cmp avoxsys_filename,x
bne eereadsys_notvalid ; Mismatch?
inx
cpx #$08
bne eereadsys_loop
; Signature found, so the next byte holds the
; TV mode.
jsr i2c_rxbyte
and #$c0
sta tv_mode
jmp i2c_stopread ; Done!
eereadsys_notvalid
; If the signature was not found then we want
; to create a signature and set the default
; TV mode
jsr i2c_stopread ; End the read started above
eeprom_writesys
; Set EEPROM addres to $0000.
jsr i2c_startwrite
bcs eeprom_sysfail ; Device not attached?
lda #$00
jsr i2c_txbyte
lda #$00
jsr i2c_txbyte
; Write "ATARIVOX" signature to first 8 bytes.
ldx #$00
eewritesys_loop
lda avoxsys_filename,x
jsr i2c_txbyte
inx
cpx #$08
bne eewritesys_loop
; Write TV mode
lda tv_mode
and #$c0
jsr i2c_txbyte
eeprom_sysfail
jmp i2c_stopwrite ; Done!
avoxsys_filename
dc.b "ATARIVOX"