finished works on software for 1 MB (two 512kB flashes) cartridge

This commit is contained in:
Jakub Husak
2020-11-05 00:46:23 +01:00
parent b9d39da9a7
commit 7fe42388d4
4 changed files with 55 additions and 37 deletions
+50 -37
View File
@@ -1,55 +1,66 @@
; flash eeprom library ; flash eeprom library
; by JHusak , 04.01.2020 ; by JHusak , 04.01.2020
; free to use. ; free to use.
lstore_x dta 0
; x - bank to select on exit ; x - 0x0 or 0x40 - chip select
; c - 1 - format, 0 - write ; c - 1 - format, 0 - write
;.print flashcnt ;.print flashcnt
flashoppreamble flashoppreamble
pha
txa
pha
; when write byte x must be set to either 0 or 40 temporarily
and #$40
tax
; $5555<$aa ; $5555<$aa
sty $d502 @ sta $d502,x
ldy #$aa lda #$aa
sty $b555 sta $b555
; $2aaa<$55 ; $2aaa<$55
sty $d501 sta $d501,x
ldy #$55 lda #$55
sty $aaaa sta $aaaa
; $5555<$80 ; $5555<$80
sty $d502 sta $d502,x
; sector format: carry set ; sector format: carry set
scc scc
ldy #$80 ; sector erase lda #$80 ; sector erase
scs scs
ldy #$a0 ; byte programm lda #$a0 ; byte programm
sty $b555 sta $b555
bcc @+ bcc @+
; $5555<$aa ; $5555<$aa
sty $d502 sta $d502,x
ldy #$aa lda #$aa
sty $b555 sta $b555
; $2aaa<$55 ; $2aaa<$55
sty $d501 sta $d501,x
ldy #$55 lda #$55
sty $aaaa sta $aaaa
; PREPARE FOR SECTOR TO ERASE ; PREPARE FOR SECTOR TO ERASE
; set upper bank bits ; set upper bank bits
@ pla
@ rts tax
pla
rts
; -------------------------- ; --------------------------
; PROCEDURE ; PROCEDURE
; x = 0 or 0x40 - flash chip address.
store_x dta 0
flashformatchip2 flashformatchip2
ldx #$40 ldx #$40
dta { bit.w } dta { bit.w }
flashformatchip flashformatchip
ldx #0
sei sei
stx store_x
sec ; format preamble sec ; format preamble
jsr flashoppreamble ; does not touch A jsr flashoppreamble ; does not touch A
sta $d502 sta $d502,x
lda #$10 lda #$10
sta $b555 sta $b555
lda #$ff lda #$ff
@@ -59,17 +70,19 @@ flashformatchip
; cart is off and cli ; cart is off and cli
; sec ; error ; sec ; error
; rts ; rts
@ lda #$1f @ lda #$3f
sta flashformatcounter sta flashformatcounter
@ sei @ sei
ldx store_x
flashformatcounter equ*+1 flashformatcounter equ*+1
sta $d51f sta $d5FF,x ; set chip (x) and bank
ldx #0 ; set pages count
ldy #$20 ldy #$20
; reset address
lda #$a0 lda #$a0
sta flashformataddrcheck + 2 sta flashformataddrcheck + 2
lda #$ff ; check whole sector against 0xff
jsr flashformataddrcheck jsr flashchecksectorformatted_bare ; destroys x
bcs @+ ; format error bcs @+ ; format error
dec flashformatcounter dec flashformatcounter
bpl @- bpl @-
@@ -79,7 +92,7 @@ flashformatcounter equ*+1
; -------------------------- ; --------------------------
; PROCEDURE ; PROCEDURE
flashformatsector flashformatsector
; x - even sector 00 - 1f ; x - even sector 00 - 7f
; a - erase 4KB from $B000 if A=$B0, FROM $A000 IF A=$A0 ; a - erase 4KB from $B000 if A=$B0, FROM $A000 IF A=$A0
; format 4kb evensector ; format 4kb evensector
; strange form - easily maps to cartridge banks ; strange form - easily maps to cartridge banks
@@ -93,10 +106,6 @@ flashformatsector
sta flashformataddrcheck + 2 sta flashformataddrcheck + 2
jsr flashchecksectorformatted jsr flashchecksectorformatted
bcc flashsectorformatgood bcc flashsectorformatgood
;php
;lda #'F'
;jsr PRINTWHAT
;plp
sei sei
flashformatstorex equ * + 1 flashformatstorex equ * + 1
ldx #0 ; filled before ldx #0 ; filled before
@@ -125,9 +134,10 @@ flashtmpaddr equ *+1
; check if all data in sector is $ff ; check if all data in sector is $ff
flashchecksectorformatted flashchecksectorformatted
ldx #0
ldy #$10 ldy #$10
flashchecksectorformatted_bare
lda #$ff lda #$ff
ldx #0
flashformataddrcheck flashformataddrcheck
cmp $a000,x cmp $a000,x
bne flashsectorformaterror bne flashsectorformaterror
@@ -147,20 +157,23 @@ flashsectorformaterror
sec sec
rts rts
; --------------------- ; ---------------------
; PROCEDURE ; PROCEDURE
flashwritebyte flashwritebyte
; a - byte to write ; a - byte to write
; x - 8kb bank to switch ; x - 8kb bank to switch, $00 to $7f, also chip select
; flashaddr - addres in flash - must be a000-offset ; flashaddr - addres in flash - must be a000-offset
; do not programm byte if already good ; do not programm byte if already good
sei sei
sta $D500,x sta $D500,x ; select bank, chip
ldy #{ cmp.w } ldy #{ cmp.w }
jsr flashprocessbyte jsr flashprocessbyte
bne @+ bne @+
;clc
;jmp flashcartoff
sta $D580 sta $D580
cli cli
clc clc
@@ -169,12 +182,12 @@ flashwritebyte
sei sei
clc ; write byte preamble clc ; write byte preamble
jsr flashoppreamble ; preserves A,X jsr flashoppreamble ; preserves A,X
sta $D500,x sta $D500,x
ldy #{ sta.w } ldy #{ sta.w }
; WRITE BYTE !
jsr flashprocessbyte jsr flashprocessbyte
flashcheckresult ; sei mode flashcheckresult ; sei mode
@@ -220,7 +233,7 @@ flashcmp equ *+1
rts rts
flashcnt flashcnt
brk dta 0
; ---------------------- ; ----------------------
; PROCEDURE ; PROCEDURE
@@ -0,0 +1,2 @@
mads flashwrite.asx -o:spaceharrierflashwrite.xex
@@ -0,0 +1,3 @@
This is for new 1 MB cartridge.
http://atarionline.pl/arch/S/Space%20Harrier/Space%20Harrier%20%282011-07-05%29%28Hutt%2C%20Chris%29%28GB%29%5Bf%20for%20older%20cartridges%20Tucker%2C%20Steve%202011-07-23%5D%5B%21%5D.bin