!src "../include/gmod3.inc" !src "common.inc" * = $0801 !word nextline !word 2016 !byte $9e !byte $32, $30, $36, $31 nextline: !byte 0,0,0 jmp start !src "../lib/gmod3.asm" temppage=$0400+(5*40) bptr1 = $20 part1banks = payloadbanks + 1 ; pages used for test.prg + testcode.bin part1pages = part1banks * $20 ; num banks used by test program * $20 ;------------------------------------------------------------------------------- start: sei lda #$36 sta $01 ; clear screen ldx #0 - lda #$20 sta $0400,x sta $0500,x sta $0600,x sta $0700,x lda #$01 sta $d800,x sta $d900,x sta $da00,x sta $db00,x inx bne - ; erase one 64k page lda #$00 jsr flash_erase ; ldy #0 ;-- ldx #0 - ; tya ; pha txa pha inc $0405 ; to indicate progress ; set byte program command and flash address pla pha tax lda #0 sta addr2 ;ldx #0 stx addr1 ;lda #0 ;sta addr0 inc $0406 ; to indicate progress lda #cart_file_start ; program one 256byte page jsr flash_writepage jsr showpage pla tax ; pla ; tay inc cadd+1 inx cpx #part1pages ; number of pages bne - ; - inc $d020 ; jmp - ; flash test pattern ldy #0 -- ; tya ; pha - tya pha txa pha inc $0406 ; to indicate progress ; set byte program command and flash address ; pla ; pha ; tax ; lda #0 ; sta addr2 sty addr2 ;ldx #0 stx addr1 ;lda #0 ;sta addr0 inc $0407 ; to indicate progress lda #onetimepad jsr preparepage ; program one 256byte page lda #temppage jsr flash_writepage jsr showpage inc cadd2+1 lda cadd2+1 cmp #>(onetimepad + $2000) bne + lda #>(onetimepad) sta cadd2+1 inc banklo bne + inc bankhi + lda bankhi cmp #1 ; 1:2mb 2:4mb 4:8mb 8:16mb beq flashend pla tax pla tay inx ; cpx #$40 ; number of pages bne - ; pla ; tay ; - inc $d020 ; jmp - !if UPDATEONLY=1 { jmp flashend } iny ; erase one 64k page tya jsr flash_erase jmp -- flashend: - inc $d020 dec $d020 jmp - ;------------------------------------------------------------------------------- failure: lda #2 sta $d020 jmp * preparepage: sta bptr1 stx bptr1+1 ldy #0 - lda (bptr1),y ; otp bankhi=*+1 eor #0 sta temppage,y iny lda (bptr1),y ; otp banklo=*+1 eor #firstrandombank sta temppage,y iny bne - rts showpage: lda addr2 pha lsr lsr lsr lsr tay lda hexdigits,y sta $0400+0 pla and #$0f tay lda hexdigits,y sta $0401+0 lda addr1 pha lsr lsr lsr lsr tay lda hexdigits,y sta $0400+2 pla and #$0f tay lda hexdigits,y sta $0401+2 rts hexdigits: !scr "0123456789abcdef" ;------------------------------------------------------------------------------- ; align to page boundary so we only have to compare the highbyte of the ; source address in the above loop !align 255,0 cart_file_start: !binary "testcart.bin" * = cart_file_start + (romcodebank * $2000) !binary "testcode.bin" !align 255,0 onetimepad: !binary "random.bin"