1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00

Access routines for different eeprom types. By Karri Kaksonen.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4994 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-04-25 18:42:50 +00:00
parent 5e37ed1a16
commit cc3424a545
5 changed files with 709 additions and 0 deletions

View File

@ -120,6 +120,12 @@ unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
void __fastcall__ lynx_eeprom_erase (unsigned char cell);
/* Clear the word at the given address */
unsigned __fastcall__ lynx_eeread (unsigned cell);
/* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/
unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val);
/* Write the word at the given address 93C46 93C66 or 93C86*/
/*****************************************************************************/
@ -138,6 +144,39 @@ void __fastcall__ lynx_eeprom_erase (unsigned char cell);
/*****************************************************************************/
/* Sprites */
/*****************************************************************************/
#define SPRCTL0_1_bit_per_pixel 0
#define SPRCTL0_2_bits_per_pixel 0x40
#define SPRCTL0_3_bits_per_pixel 0x80
#define SPRCTL0_4_bits_per_pixel 0xc0
#define SPRCTL0_h_flip 0x20
#define SPRCTL0_v_flip 0x10
#define SPRCTL0_shadow 7
#define SPRCTL0_xor_shadow 6
#define SPRCTL0_non_collide 5
#define SPRCTL0_normal 4
#define SPRCTL0_boundary 3
#define SPRCTL0_boundary_shadow 2
#define SPRCTL0_background_no_coll 1
#define SPRCTL0_background_shadow 0
#define SPRCTL1_literal 0x80
#define SPRCTL1_hsize_vsize_strech_tilt 0x30
#define SPRCTL1_hsize_vsize_strech 0x20
#define SPRCTL1_hsize_vsize 0x10
#define SPRCTL1_no_palette 0x08
#define SPRCTL1_skip_sprite 0x04
#define SPRCTL1_start_drawing_up 0x02
#define SPRCTL1_start_drawing_left 0x01
#define SPRCOLL_dont_collide 0x20
#define SPRCOLL_number_0_3 0x00
/* End of lynx.h */
#endif

View File

@ -51,6 +51,9 @@ OBJS = bllhdr.o \
ctype.o \
defdir.o \
eeprom.o \
eeprom46.o \
eeprom66.o \
eeprom86.o \
exec.o \
exehdr.o \
extzp.o \

204
libsrc/lynx/eeprom46.s Normal file
View File

@ -0,0 +1,204 @@
;***************
; EEPROM-routines
; for 93C46 (128 bytes as 64 16-bit words)
;
; created : 11.05.95
; last modified :
;
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
;
;
; (c) 1995..97 Bastian Schick
; CS = A7 (18)
; CLK = A1 (11)
; DI/DO = AUDIN (32)
;
;And now how to contact the EEPROM :
;
;CARD
;PORT ----\/---- 93C46(SMD too)
;(18) A7 --------| CS |- +5V
;(11) A1 --------| CLK |- NC
; +---| DI |- NC
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c46
.export _lynx_eewrite_93c46
.import popax
.importzp ptr1
.include "lynx.inc"
; -------------------
; EEPROM command list
EE_C_WRITE = $40
EE_C_READ = $80
EE_C_ERASE = $C0
EE_C_EWEN = $30
EE_C_EWDS = $00
; ------------------------------------------------------------------------
; unsigned __fastcall__ lynx_eeread_93c46(unsigned char cell);
; /* Read a 16 bit word from the given address */
;
_lynx_eeread_93c46:
and #$3f
ora #EE_C_READ
jsr EE_Send9Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c46(unsigned int addr, unsigned int val);
_lynx_eewrite_93c46:
sta ptr1
stx ptr1+1
lda #EE_C_EWEN
jsr EE_Send9Bit
jsr popax
and #$3f
ora #EE_C_WRITE
jsr EE_Send9Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
lda #EE_C_EWDS
; bra EE_Send9Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
;***************
EE_Send9Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
ldy #8
sec ; start bit
ror A
ror A
ror A
ror A ; bit 8 at pos. 4
EEloop3:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts

227
libsrc/lynx/eeprom66.s Normal file
View File

@ -0,0 +1,227 @@
;***************
; EEPROM-routines
; for 93C66 (512 bytes as 256 16-bit words)
;
; created : 11.05.95
; last modified :
;
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
; 2010 93c66 support B. Spruck
; 2011 modified to suit cc65 environment Karri Kaksonen
;
; (c) 1995..97 Bastian Schick
; CS = A7 (18)
; CLK = A1 (11)
; DI/DO = AUDIN (32)
;
;And now how to contact the EEPROM :
;
;CARD
;PORT ----\/---- 93C66(SMD too)
;(18) A7 --------| CS |- +5V
;(11) A1 --------| CLK |- NC
; +---| DI |- NC
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c66
.export _lynx_eewrite_93c66
.import popax
.importzp ptr1
.include "lynx.inc"
; -------------------
; EEPROM command list
EE_C_WRITE = $14
EE_C_READ = $18
EE_C_ERASE = $1C
EE_C_EWEN = $13
EE_C_EWEN2 = $FF ;; C0 schould be enough
EE_C_EWDS = $10
EE_C_EWDS2 = $00
;**************
; Only lower byte in A is used for address
; unsigned int __fastcall__ lynx_eeread_93c66(unsigned int addr);
_lynx_eeread_93c66:
ldx #EE_C_READ
jsr EE_Send11Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c66(unsigned int addr, unsigned int val);
_lynx_eewrite_93c66:
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send11Bit
jsr popax
ldx #EE_C_WRITE
jsr EE_Send11Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send11Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
EE_Send11Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #2 ; 3 times
EEloop3:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ror A
ror A
ror A ; bit 7 at pos. 4
EEloop4:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts

236
libsrc/lynx/eeprom86.s Normal file
View File

@ -0,0 +1,236 @@
;***************
; EEPROM-routs
; for 93C86 (2048 bytes as 1024 16-bit words)
;
; created : 11.05.95
; last modified :
;
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
; 2010 93c66 support B. Spruck
; 2010 93c86 support B. Spruck
; 2011 modified to suit cc65 environment Karri Kaksonen
;
; (c) 1995..97 Bastian Schick
; CS = A7 (18)
; CLK = A1 (11)
; DI/DO = AUDIN (32)
;
;And now how to contact the EEPROM :
;
;CARD
;PORT ----\/---- 93C86(SMD too)
;(18) A7 --------| CS |- +5V
;(11) A1 --------| CLK |- NC
; +---| DI |- NC
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c86
.export _lynx_eewrite_93c86
.import popax
.importzp ptr1
.include "lynx.inc"
; -------------------
; EEPROM command list
EE_C_WRITE = $14
EE_C_READ = $18
EE_C_ERASE = $1C
EE_C_EWEN = $13
EE_C_EWEN2 = $FF ;; C0 schould be enough
EE_C_EWDS = $10
EE_C_EWDS2 = $00
;**************
; Only lower byte in A is used for address
; unsigned int __fastcall__ lynx_eeread_93c86(unsigned int addr);
_lynx_eeread_93c86:
pha
txa
ora #EE_C_READ
tax
pla
jsr EE_Send13Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c86(unsigned int addr, unsigned int val);
_lynx_eewrite_93c86:
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send13Bit
jsr popax
pha
txa
ora #EE_C_WRITE
tax
pla
jsr EE_Send13Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send13Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
EE_Send13Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #4 ; 5 times
EEloop3:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ror A
ror A
ror A ; bit 7 at pos. 4
EEloop4:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts